babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. 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>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. 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;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. 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;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. 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;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * 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".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * 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"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * 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"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignored for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @returns the current unchanged quaternion
  3895. */
  3896. toEulerAnglesToRef(result: Vector3): Quaternion;
  3897. /**
  3898. * Updates the given rotation matrix with the current quaternion values
  3899. * @param result defines the target matrix
  3900. * @returns the current unchanged quaternion
  3901. */
  3902. toRotationMatrix(result: Matrix): Quaternion;
  3903. /**
  3904. * Updates the current quaternion from the given rotation matrix values
  3905. * @param matrix defines the source matrix
  3906. * @returns the current updated quaternion
  3907. */
  3908. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from a rotation matrix
  3911. * @param matrix defines the source matrix
  3912. * @returns a new quaternion created from the given rotation matrix values
  3913. */
  3914. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3915. /**
  3916. * Updates the given quaternion with the given rotation matrix values
  3917. * @param matrix defines the source matrix
  3918. * @param result defines the target quaternion
  3919. */
  3920. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3921. /**
  3922. * Returns the dot product (float) between the quaternions "left" and "right"
  3923. * @param left defines the left operand
  3924. * @param right defines the right operand
  3925. * @returns the dot product
  3926. */
  3927. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3928. /**
  3929. * Checks if the two quaternions are close to each other
  3930. * @param quat0 defines the first quaternion to check
  3931. * @param quat1 defines the second quaternion to check
  3932. * @returns true if the two quaternions are close to each other
  3933. */
  3934. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3935. /**
  3936. * Creates an empty quaternion
  3937. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3938. */
  3939. static Zero(): Quaternion;
  3940. /**
  3941. * Inverse a given quaternion
  3942. * @param q defines the source quaternion
  3943. * @returns a new quaternion as the inverted current quaternion
  3944. */
  3945. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3946. /**
  3947. * Inverse a given quaternion
  3948. * @param q defines the source quaternion
  3949. * @param result the quaternion the result will be stored in
  3950. * @returns the result quaternion
  3951. */
  3952. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates an identity quaternion
  3955. * @returns the identity quaternion
  3956. */
  3957. static Identity(): Quaternion;
  3958. /**
  3959. * Gets a boolean indicating if the given quaternion is identity
  3960. * @param quaternion defines the quaternion to check
  3961. * @returns true if the quaternion is identity
  3962. */
  3963. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3964. /**
  3965. * Creates a quaternion from a rotation around an axis
  3966. * @param axis defines the axis to use
  3967. * @param angle defines the angle to use
  3968. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3969. */
  3970. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3971. /**
  3972. * Creates a rotation around an axis and stores it into the given quaternion
  3973. * @param axis defines the axis to use
  3974. * @param angle defines the angle to use
  3975. * @param result defines the target quaternion
  3976. * @returns the target quaternion
  3977. */
  3978. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3979. /**
  3980. * Creates a new quaternion from data stored into an array
  3981. * @param array defines the data source
  3982. * @param offset defines the offset in the source array where the data starts
  3983. * @returns a new quaternion
  3984. */
  3985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3986. /**
  3987. * Updates the given quaternion "result" from the starting index of the given array.
  3988. * @param array the array to pull values from
  3989. * @param offset the offset into the array to start at
  3990. * @param result the quaternion to store the result in
  3991. */
  3992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3993. /**
  3994. * Create a quaternion from Euler rotation angles
  3995. * @param x Pitch
  3996. * @param y Yaw
  3997. * @param z Roll
  3998. * @returns the new Quaternion
  3999. */
  4000. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4001. /**
  4002. * Updates a quaternion from Euler rotation angles
  4003. * @param x Pitch
  4004. * @param y Yaw
  4005. * @param z Roll
  4006. * @param result the quaternion to store the result
  4007. * @returns the updated quaternion
  4008. */
  4009. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4010. /**
  4011. * Create a quaternion from Euler rotation vector
  4012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4013. * @returns the new Quaternion
  4014. */
  4015. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4016. /**
  4017. * Updates a quaternion from Euler rotation vector
  4018. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4019. * @param result the quaternion to store the result
  4020. * @returns the updated quaternion
  4021. */
  4022. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4025. * @param yaw defines the rotation around Y axis
  4026. * @param pitch defines the rotation around X axis
  4027. * @param roll defines the rotation around Z axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4031. /**
  4032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4033. * @param yaw defines the rotation around Y axis
  4034. * @param pitch defines the rotation around X axis
  4035. * @param roll defines the rotation around Z axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4041. * @param alpha defines the rotation around first axis
  4042. * @param beta defines the rotation around second axis
  4043. * @param gamma defines the rotation around third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4049. * @param alpha defines the rotation around first axis
  4050. * @param beta defines the rotation around second axis
  4051. * @param gamma defines the rotation around third axis
  4052. * @param result defines the target quaternion
  4053. */
  4054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4055. /**
  4056. * 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)
  4057. * @param axis1 defines the first axis
  4058. * @param axis2 defines the second axis
  4059. * @param axis3 defines the third axis
  4060. * @returns the new quaternion
  4061. */
  4062. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4063. /**
  4064. * 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
  4065. * @param axis1 defines the first axis
  4066. * @param axis2 defines the second axis
  4067. * @param axis3 defines the third axis
  4068. * @param ref defines the target quaternion
  4069. */
  4070. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4071. /**
  4072. * Interpolates between two quaternions
  4073. * @param left defines first quaternion
  4074. * @param right defines second quaternion
  4075. * @param amount defines the gradient to use
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. /**
  4080. * Interpolates between two quaternions and stores it into a target quaternion
  4081. * @param left defines first quaternion
  4082. * @param right defines second quaternion
  4083. * @param amount defines the gradient to use
  4084. * @param result defines the target quaternion
  4085. */
  4086. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4087. /**
  4088. * Interpolate between two quaternions using Hermite interpolation
  4089. * @param value1 defines first quaternion
  4090. * @param tangent1 defines the incoming tangent
  4091. * @param value2 defines second quaternion
  4092. * @param tangent2 defines the outgoing tangent
  4093. * @param amount defines the target quaternion
  4094. * @returns the new interpolated quaternion
  4095. */
  4096. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4097. }
  4098. /**
  4099. * Class used to store matrix data (4x4)
  4100. */
  4101. export class Matrix {
  4102. /**
  4103. * Gets the precision of matrix computations
  4104. */
  4105. static get Use64Bits(): boolean;
  4106. private static _updateFlagSeed;
  4107. private static _identityReadOnly;
  4108. private _isIdentity;
  4109. private _isIdentityDirty;
  4110. private _isIdentity3x2;
  4111. private _isIdentity3x2Dirty;
  4112. /**
  4113. * Gets the update flag of the matrix which is an unique number for the matrix.
  4114. * It will be incremented every time the matrix data change.
  4115. * You can use it to speed the comparison between two versions of the same matrix.
  4116. */
  4117. updateFlag: number;
  4118. private readonly _m;
  4119. /**
  4120. * Gets the internal data of the matrix
  4121. */
  4122. get m(): DeepImmutable<Float32Array | Array<number>>;
  4123. /** @hidden */
  4124. _markAsUpdated(): void;
  4125. /** @hidden */
  4126. private _updateIdentityStatus;
  4127. /**
  4128. * Creates an empty matrix (filled with zeros)
  4129. */
  4130. constructor();
  4131. /**
  4132. * Check if the current matrix is identity
  4133. * @returns true is the matrix is the identity matrix
  4134. */
  4135. isIdentity(): boolean;
  4136. /**
  4137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4138. * @returns true is the matrix is the identity matrix
  4139. */
  4140. isIdentityAs3x2(): boolean;
  4141. /**
  4142. * Gets the determinant of the matrix
  4143. * @returns the matrix determinant
  4144. */
  4145. determinant(): number;
  4146. /**
  4147. * Returns the matrix as a Float32Array or Array<number>
  4148. * @returns the matrix underlying array
  4149. */
  4150. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4151. /**
  4152. * Returns the matrix as a Float32Array or Array<number>
  4153. * @returns the matrix underlying array.
  4154. */
  4155. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4156. /**
  4157. * Inverts the current matrix in place
  4158. * @returns the current inverted matrix
  4159. */
  4160. invert(): Matrix;
  4161. /**
  4162. * Sets all the matrix elements to zero
  4163. * @returns the current matrix
  4164. */
  4165. reset(): Matrix;
  4166. /**
  4167. * Adds the current matrix with a second one
  4168. * @param other defines the matrix to add
  4169. * @returns a new matrix as the addition of the current matrix and the given one
  4170. */
  4171. add(other: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4174. * @param other defines the matrix to add
  4175. * @param result defines the target matrix
  4176. * @returns the current matrix
  4177. */
  4178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4179. /**
  4180. * Adds in place the given matrix to the current matrix
  4181. * @param other defines the second operand
  4182. * @returns the current updated matrix
  4183. */
  4184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4185. /**
  4186. * Sets the given matrix to the current inverted Matrix
  4187. * @param other defines the target matrix
  4188. * @returns the unmodified current matrix
  4189. */
  4190. invertToRef(other: Matrix): Matrix;
  4191. /**
  4192. * add a value at the specified position in the current Matrix
  4193. * @param index the index of the value within the matrix. between 0 and 15.
  4194. * @param value the value to be added
  4195. * @returns the current updated matrix
  4196. */
  4197. addAtIndex(index: number, value: number): Matrix;
  4198. /**
  4199. * mutiply the specified position in the current Matrix by a value
  4200. * @param index the index of the value within the matrix. between 0 and 15.
  4201. * @param value the value to be added
  4202. * @returns the current updated matrix
  4203. */
  4204. multiplyAtIndex(index: number, value: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector (using 3 floats) in the current matrix
  4207. * @param x defines the 1st component of the translation
  4208. * @param y defines the 2nd component of the translation
  4209. * @param z defines the 3rd component of the translation
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4213. /**
  4214. * Adds the translation vector (using 3 floats) in the current matrix
  4215. * @param x defines the 1st component of the translation
  4216. * @param y defines the 2nd component of the translation
  4217. * @param z defines the 3rd component of the translation
  4218. * @returns the current updated matrix
  4219. */
  4220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4221. /**
  4222. * Inserts the translation vector in the current matrix
  4223. * @param vector3 defines the translation to insert
  4224. * @returns the current updated matrix
  4225. */
  4226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4227. /**
  4228. * Gets the translation value of the current matrix
  4229. * @returns a new Vector3 as the extracted translation from the matrix
  4230. */
  4231. getTranslation(): Vector3;
  4232. /**
  4233. * Fill a Vector3 with the extracted translation from the matrix
  4234. * @param result defines the Vector3 where to store the translation
  4235. * @returns the current matrix
  4236. */
  4237. getTranslationToRef(result: Vector3): Matrix;
  4238. /**
  4239. * Remove rotation and scaling part from the matrix
  4240. * @returns the updated matrix
  4241. */
  4242. removeRotationAndScaling(): Matrix;
  4243. /**
  4244. * Multiply two matrices
  4245. * @param other defines the second operand
  4246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4247. */
  4248. multiply(other: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Copy the current matrix from the given one
  4251. * @param other defines the source matrix
  4252. * @returns the current updated matrix
  4253. */
  4254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Populates the given array from the starting index with the current matrix values
  4257. * @param array defines the target array
  4258. * @param offset defines the offset in the target array where to start storing values
  4259. * @returns the current matrix
  4260. */
  4261. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4262. /**
  4263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4264. * @param other defines the second operand
  4265. * @param result defines the matrix where to store the multiplication
  4266. * @returns the current matrix
  4267. */
  4268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4269. /**
  4270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4271. * @param other defines the second operand
  4272. * @param result defines the array where to store the multiplication
  4273. * @param offset defines the offset in the target array where to start storing values
  4274. * @returns the current matrix
  4275. */
  4276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4277. /**
  4278. * Check equality between this matrix and a second one
  4279. * @param value defines the second matrix to compare
  4280. * @returns true is the current matrix and the given one values are strictly equal
  4281. */
  4282. equals(value: DeepImmutable<Matrix>): boolean;
  4283. /**
  4284. * Clone the current matrix
  4285. * @returns a new matrix from the current matrix
  4286. */
  4287. clone(): Matrix;
  4288. /**
  4289. * Returns the name of the current matrix class
  4290. * @returns the string "Matrix"
  4291. */
  4292. getClassName(): string;
  4293. /**
  4294. * Gets the hash code of the current matrix
  4295. * @returns the hash code
  4296. */
  4297. getHashCode(): number;
  4298. /**
  4299. * Decomposes the current Matrix into a translation, rotation and scaling components
  4300. * @param scale defines the scale vector3 given as a reference to update
  4301. * @param rotation defines the rotation quaternion given as a reference to update
  4302. * @param translation defines the translation vector3 given as a reference to update
  4303. * @returns true if operation was successful
  4304. */
  4305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4306. /**
  4307. * Gets specific row of the matrix
  4308. * @param index defines the number of the row to get
  4309. * @returns the index-th row of the current matrix as a new Vector4
  4310. */
  4311. getRow(index: number): Nullable<Vector4>;
  4312. /**
  4313. * Sets the index-th row of the current matrix to the vector4 values
  4314. * @param index defines the number of the row to set
  4315. * @param row defines the target vector4
  4316. * @returns the updated current matrix
  4317. */
  4318. setRow(index: number, row: Vector4): Matrix;
  4319. /**
  4320. * Compute the transpose of the matrix
  4321. * @returns the new transposed matrix
  4322. */
  4323. transpose(): Matrix;
  4324. /**
  4325. * Compute the transpose of the matrix and store it in a given matrix
  4326. * @param result defines the target matrix
  4327. * @returns the current matrix
  4328. */
  4329. transposeToRef(result: Matrix): Matrix;
  4330. /**
  4331. * Sets the index-th row of the current matrix with the given 4 x float values
  4332. * @param index defines the row index
  4333. * @param x defines the x component to set
  4334. * @param y defines the y component to set
  4335. * @param z defines the z component to set
  4336. * @param w defines the w component to set
  4337. * @returns the updated current matrix
  4338. */
  4339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4340. /**
  4341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4342. * @param scale defines the scale factor
  4343. * @returns a new matrix
  4344. */
  4345. scale(scale: number): Matrix;
  4346. /**
  4347. * Scale the current matrix values by a factor to a given result matrix
  4348. * @param scale defines the scale factor
  4349. * @param result defines the matrix to store the result
  4350. * @returns the current matrix
  4351. */
  4352. scaleToRef(scale: number, result: Matrix): Matrix;
  4353. /**
  4354. * Scale the current matrix values by a factor and add the result to a given matrix
  4355. * @param scale defines the scale factor
  4356. * @param result defines the Matrix to store the result
  4357. * @returns the current matrix
  4358. */
  4359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4360. /**
  4361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4362. * @param ref matrix to store the result
  4363. */
  4364. toNormalMatrix(ref: Matrix): void;
  4365. /**
  4366. * Gets only rotation part of the current matrix
  4367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4368. */
  4369. getRotationMatrix(): Matrix;
  4370. /**
  4371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4372. * @param result defines the target matrix to store data to
  4373. * @returns the current matrix
  4374. */
  4375. getRotationMatrixToRef(result: Matrix): Matrix;
  4376. /**
  4377. * Toggles model matrix from being right handed to left handed in place and vice versa
  4378. */
  4379. toggleModelMatrixHandInPlace(): void;
  4380. /**
  4381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleProjectionMatrixHandInPlace(): void;
  4384. /**
  4385. * Creates a matrix from an array
  4386. * @param array defines the source array
  4387. * @param offset defines an offset in the source array
  4388. * @returns a new Matrix set from the starting index of the given array
  4389. */
  4390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4391. /**
  4392. * Copy the content of an array into a given matrix
  4393. * @param array defines the source array
  4394. * @param offset defines an offset in the source array
  4395. * @param result defines the target matrix
  4396. */
  4397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4398. /**
  4399. * Stores an array into a matrix after having multiplied each component by a given factor
  4400. * @param array defines the source array
  4401. * @param offset defines the offset in the source array
  4402. * @param scale defines the scaling factor
  4403. * @param result defines the target matrix
  4404. */
  4405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4406. /**
  4407. * Gets an identity matrix that must not be updated
  4408. */
  4409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4410. /**
  4411. * Stores a list of values (16) inside a given matrix
  4412. * @param initialM11 defines 1st value of 1st row
  4413. * @param initialM12 defines 2nd value of 1st row
  4414. * @param initialM13 defines 3rd value of 1st row
  4415. * @param initialM14 defines 4th value of 1st row
  4416. * @param initialM21 defines 1st value of 2nd row
  4417. * @param initialM22 defines 2nd value of 2nd row
  4418. * @param initialM23 defines 3rd value of 2nd row
  4419. * @param initialM24 defines 4th value of 2nd row
  4420. * @param initialM31 defines 1st value of 3rd row
  4421. * @param initialM32 defines 2nd value of 3rd row
  4422. * @param initialM33 defines 3rd value of 3rd row
  4423. * @param initialM34 defines 4th value of 3rd row
  4424. * @param initialM41 defines 1st value of 4th row
  4425. * @param initialM42 defines 2nd value of 4th row
  4426. * @param initialM43 defines 3rd value of 4th row
  4427. * @param initialM44 defines 4th value of 4th row
  4428. * @param result defines the target matrix
  4429. */
  4430. 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;
  4431. /**
  4432. * Creates new matrix from a list of values (16)
  4433. * @param initialM11 defines 1st value of 1st row
  4434. * @param initialM12 defines 2nd value of 1st row
  4435. * @param initialM13 defines 3rd value of 1st row
  4436. * @param initialM14 defines 4th value of 1st row
  4437. * @param initialM21 defines 1st value of 2nd row
  4438. * @param initialM22 defines 2nd value of 2nd row
  4439. * @param initialM23 defines 3rd value of 2nd row
  4440. * @param initialM24 defines 4th value of 2nd row
  4441. * @param initialM31 defines 1st value of 3rd row
  4442. * @param initialM32 defines 2nd value of 3rd row
  4443. * @param initialM33 defines 3rd value of 3rd row
  4444. * @param initialM34 defines 4th value of 3rd row
  4445. * @param initialM41 defines 1st value of 4th row
  4446. * @param initialM42 defines 2nd value of 4th row
  4447. * @param initialM43 defines 3rd value of 4th row
  4448. * @param initialM44 defines 4th value of 4th row
  4449. * @returns the new matrix
  4450. */
  4451. 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;
  4452. /**
  4453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4454. * @param scale defines the scale vector3
  4455. * @param rotation defines the rotation quaternion
  4456. * @param translation defines the translation vector3
  4457. * @returns a new matrix
  4458. */
  4459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4460. /**
  4461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4462. * @param scale defines the scale vector3
  4463. * @param rotation defines the rotation quaternion
  4464. * @param translation defines the translation vector3
  4465. * @param result defines the target matrix
  4466. */
  4467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4468. /**
  4469. * Creates a new identity matrix
  4470. * @returns a new identity matrix
  4471. */
  4472. static Identity(): Matrix;
  4473. /**
  4474. * Creates a new identity matrix and stores the result in a given matrix
  4475. * @param result defines the target matrix
  4476. */
  4477. static IdentityToRef(result: Matrix): void;
  4478. /**
  4479. * Creates a new zero matrix
  4480. * @returns a new zero matrix
  4481. */
  4482. static Zero(): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the X axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationX(angle: number): Matrix;
  4489. /**
  4490. * Creates a new matrix as the invert of a given matrix
  4491. * @param source defines the source matrix
  4492. * @returns the new matrix
  4493. */
  4494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4497. * @param angle defines the angle (in radians) to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static RotationXToRef(angle: number, result: Matrix): void;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Y axis
  4503. * @param angle defines the angle (in radians) to use
  4504. * @return the new matrix
  4505. */
  4506. static RotationY(angle: number): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationYToRef(angle: number, result: Matrix): void;
  4513. /**
  4514. * Creates a new rotation matrix for "angle" radians around the Z axis
  4515. * @param angle defines the angle (in radians) to use
  4516. * @return the new matrix
  4517. */
  4518. static RotationZ(angle: number): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationZToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the given axis
  4527. * @param axis defines the axis to use
  4528. * @param angle defines the angle (in radians) to use
  4529. * @return the new matrix
  4530. */
  4531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4532. /**
  4533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4534. * @param axis defines the axis to use
  4535. * @param angle defines the angle (in radians) to use
  4536. * @param result defines the target matrix
  4537. */
  4538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4539. /**
  4540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4542. * @param from defines the vector to align
  4543. * @param to defines the vector to align to
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4547. /**
  4548. * Creates a rotation matrix
  4549. * @param yaw defines the yaw angle in radians (Y axis)
  4550. * @param pitch defines the pitch angle in radians (X axis)
  4551. * @param roll defines the roll angle in radians (Z axis)
  4552. * @returns the new rotation matrix
  4553. */
  4554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4555. /**
  4556. * Creates a rotation matrix and stores it in a given matrix
  4557. * @param yaw defines the yaw angle in radians (Y axis)
  4558. * @param pitch defines the pitch angle in radians (X axis)
  4559. * @param roll defines the roll angle in radians (Z axis)
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4563. /**
  4564. * Creates a scaling matrix
  4565. * @param x defines the scale factor on X axis
  4566. * @param y defines the scale factor on Y axis
  4567. * @param z defines the scale factor on Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Scaling(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a scaling matrix and stores it in a given matrix
  4573. * @param x defines the scale factor on X axis
  4574. * @param y defines the scale factor on Y axis
  4575. * @param z defines the scale factor on Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Creates a translation matrix
  4581. * @param x defines the translation on X axis
  4582. * @param y defines the translation on Y axis
  4583. * @param z defines the translationon Z axis
  4584. * @returns the new matrix
  4585. */
  4586. static Translation(x: number, y: number, z: number): Matrix;
  4587. /**
  4588. * Creates a translation matrix and stores it in a given matrix
  4589. * @param x defines the translation on X axis
  4590. * @param y defines the translation on Y axis
  4591. * @param z defines the translationon Z axis
  4592. * @param result defines the target matrix
  4593. */
  4594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4595. /**
  4596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4597. * @param startValue defines the start value
  4598. * @param endValue defines the end value
  4599. * @param gradient defines the gradient factor
  4600. * @returns the new matrix
  4601. */
  4602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4603. /**
  4604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4605. * @param startValue defines the start value
  4606. * @param endValue defines the end value
  4607. * @param gradient defines the gradient factor
  4608. * @param result defines the Matrix object where to store data
  4609. */
  4610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4611. /**
  4612. * Builds a new matrix whose values are computed by:
  4613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4616. * @param startValue defines the first matrix
  4617. * @param endValue defines the second matrix
  4618. * @param gradient defines the gradient between the two matrices
  4619. * @returns the new matrix
  4620. */
  4621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4622. /**
  4623. * Update a matrix to values which are computed by:
  4624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4627. * @param startValue defines the first matrix
  4628. * @param endValue defines the second matrix
  4629. * @param gradient defines the gradient between the two matrices
  4630. * @param result defines the target matrix
  4631. */
  4632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * 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"
  4653. * This function works in right handed mode
  4654. * @param eye defines the final position of the entity
  4655. * @param target defines where the entity should look at
  4656. * @param up defines the up vector for the entity
  4657. * @returns the new matrix
  4658. */
  4659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4660. /**
  4661. * 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".
  4662. * This function works in right handed mode
  4663. * @param eye defines the final position of the entity
  4664. * @param target defines where the entity should look at
  4665. * @param up defines the up vector for the entity
  4666. * @param result defines the target matrix
  4667. */
  4668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param width defines the viewport width
  4672. * @param height defines the viewport height
  4673. * @param znear defines the near clip plane
  4674. * @param zfar defines the far clip plane
  4675. * @returns a new matrix as a left-handed orthographic projection matrix
  4676. */
  4677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4678. /**
  4679. * Store a left-handed orthographic projection to a given matrix
  4680. * @param width defines the viewport width
  4681. * @param height defines the viewport height
  4682. * @param znear defines the near clip plane
  4683. * @param zfar defines the far clip plane
  4684. * @param result defines the target matrix
  4685. */
  4686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4687. /**
  4688. * Create a left-handed orthographic projection matrix
  4689. * @param left defines the viewport left coordinate
  4690. * @param right defines the viewport right coordinate
  4691. * @param bottom defines the viewport bottom coordinate
  4692. * @param top defines the viewport top coordinate
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Stores a left-handed orthographic projection into a given matrix
  4700. * @param left defines the viewport left coordinate
  4701. * @param right defines the viewport right coordinate
  4702. * @param bottom defines the viewport bottom coordinate
  4703. * @param top defines the viewport top coordinate
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Creates a right-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a right-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a left-handed perspective projection matrix
  4733. * @param width defines the viewport width
  4734. * @param height defines the viewport height
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a left-handed perspective projection matrix
  4738. */
  4739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Creates a left-handed perspective projection matrix
  4742. * @param fov defines the horizontal field of view
  4743. * @param aspect defines the aspect ratio
  4744. * @param znear defines the near clip plane
  4745. * @param zfar defines the far clip plane
  4746. * @returns a new matrix as a left-handed perspective projection matrix
  4747. */
  4748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4749. /**
  4750. * Stores a left-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar defines the far clip plane
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar not used as infinity is used as far clip
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Creates a right-handed perspective projection matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @returns a new matrix as a right-handed perspective projection matrix
  4776. */
  4777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4778. /**
  4779. * Stores a right-handed perspective projection into a given matrix
  4780. * @param fov defines the horizontal field of view
  4781. * @param aspect defines the aspect ratio
  4782. * @param znear defines the near clip plane
  4783. * @param zfar defines the far clip plane
  4784. * @param result defines the target matrix
  4785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4786. */
  4787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar not used as infinity is used as far clip
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a perspective projection for WebVR info a given matrix
  4800. * @param fov defines the field of view
  4801. * @param znear defines the near clip plane
  4802. * @param zfar defines the far clip plane
  4803. * @param result defines the target matrix
  4804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4805. */
  4806. static PerspectiveFovWebVRToRef(fov: {
  4807. upDegrees: number;
  4808. downDegrees: number;
  4809. leftDegrees: number;
  4810. rightDegrees: number;
  4811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4812. /**
  4813. * Computes a complete transformation matrix
  4814. * @param viewport defines the viewport to use
  4815. * @param world defines the world matrix
  4816. * @param view defines the view matrix
  4817. * @param projection defines the projection matrix
  4818. * @param zmin defines the near clip plane
  4819. * @param zmax defines the far clip plane
  4820. * @returns the transformation matrix
  4821. */
  4822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4823. /**
  4824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4825. * @param matrix defines the matrix to use
  4826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4827. */
  4828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4829. /**
  4830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4831. * @param matrix defines the matrix to use
  4832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4833. */
  4834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4835. /**
  4836. * Compute the transpose of a given matrix
  4837. * @param matrix defines the matrix to transpose
  4838. * @returns the new matrix
  4839. */
  4840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4841. /**
  4842. * Compute the transpose of a matrix and store it in a target matrix
  4843. * @param matrix defines the matrix to transpose
  4844. * @param result defines the target matrix
  4845. */
  4846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4847. /**
  4848. * Computes a reflection matrix from a plane
  4849. * @param plane defines the reflection plane
  4850. * @returns a new matrix
  4851. */
  4852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4853. /**
  4854. * Computes a reflection matrix from a plane
  4855. * @param plane defines the reflection plane
  4856. * @param result defines the target matrix
  4857. */
  4858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4859. /**
  4860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4861. * @param xaxis defines the value of the 1st axis
  4862. * @param yaxis defines the value of the 2nd axis
  4863. * @param zaxis defines the value of the 3rd axis
  4864. * @param result defines the target matrix
  4865. */
  4866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4867. /**
  4868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4869. * @param quat defines the quaternion to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4873. }
  4874. /**
  4875. * @hidden
  4876. */
  4877. export class TmpVectors {
  4878. static Vector2: Vector2[];
  4879. static Vector3: Vector3[];
  4880. static Vector4: Vector4[];
  4881. static Quaternion: Quaternion[];
  4882. static Matrix: Matrix[];
  4883. }
  4884. }
  4885. declare module "babylonjs/Maths/math.path" {
  4886. import { DeepImmutable, Nullable } from "babylonjs/types";
  4887. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4888. /**
  4889. * Defines potential orientation for back face culling
  4890. */
  4891. export enum Orientation {
  4892. /**
  4893. * Clockwise
  4894. */
  4895. CW = 0,
  4896. /** Counter clockwise */
  4897. CCW = 1
  4898. }
  4899. /** Class used to represent a Bezier curve */
  4900. export class BezierCurve {
  4901. /**
  4902. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4903. * @param t defines the time
  4904. * @param x1 defines the left coordinate on X axis
  4905. * @param y1 defines the left coordinate on Y axis
  4906. * @param x2 defines the right coordinate on X axis
  4907. * @param y2 defines the right coordinate on Y axis
  4908. * @returns the interpolated value
  4909. */
  4910. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4911. }
  4912. /**
  4913. * Defines angle representation
  4914. */
  4915. export class Angle {
  4916. private _radians;
  4917. /**
  4918. * Creates an Angle object of "radians" radians (float).
  4919. * @param radians the angle in radians
  4920. */
  4921. constructor(radians: number);
  4922. /**
  4923. * Get value in degrees
  4924. * @returns the Angle value in degrees (float)
  4925. */
  4926. degrees(): number;
  4927. /**
  4928. * Get value in radians
  4929. * @returns the Angle value in radians (float)
  4930. */
  4931. radians(): number;
  4932. /**
  4933. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4934. * @param a defines first point as the origin
  4935. * @param b defines point
  4936. * @returns a new Angle
  4937. */
  4938. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4939. /**
  4940. * Gets a new Angle object from the given float in radians
  4941. * @param radians defines the angle value in radians
  4942. * @returns a new Angle
  4943. */
  4944. static FromRadians(radians: number): Angle;
  4945. /**
  4946. * Gets a new Angle object from the given float in degrees
  4947. * @param degrees defines the angle value in degrees
  4948. * @returns a new Angle
  4949. */
  4950. static FromDegrees(degrees: number): Angle;
  4951. }
  4952. /**
  4953. * This represents an arc in a 2d space.
  4954. */
  4955. export class Arc2 {
  4956. /** Defines the start point of the arc */
  4957. startPoint: Vector2;
  4958. /** Defines the mid point of the arc */
  4959. midPoint: Vector2;
  4960. /** Defines the end point of the arc */
  4961. endPoint: Vector2;
  4962. /**
  4963. * Defines the center point of the arc.
  4964. */
  4965. centerPoint: Vector2;
  4966. /**
  4967. * Defines the radius of the arc.
  4968. */
  4969. radius: number;
  4970. /**
  4971. * Defines the angle of the arc (from mid point to end point).
  4972. */
  4973. angle: Angle;
  4974. /**
  4975. * Defines the start angle of the arc (from start point to middle point).
  4976. */
  4977. startAngle: Angle;
  4978. /**
  4979. * Defines the orientation of the arc (clock wise/counter clock wise).
  4980. */
  4981. orientation: Orientation;
  4982. /**
  4983. * Creates an Arc object from the three given points : start, middle and end.
  4984. * @param startPoint Defines the start point of the arc
  4985. * @param midPoint Defines the midlle point of the arc
  4986. * @param endPoint Defines the end point of the arc
  4987. */
  4988. constructor(
  4989. /** Defines the start point of the arc */
  4990. startPoint: Vector2,
  4991. /** Defines the mid point of the arc */
  4992. midPoint: Vector2,
  4993. /** Defines the end point of the arc */
  4994. endPoint: Vector2);
  4995. }
  4996. /**
  4997. * Represents a 2D path made up of multiple 2D points
  4998. */
  4999. export class Path2 {
  5000. private _points;
  5001. private _length;
  5002. /**
  5003. * If the path start and end point are the same
  5004. */
  5005. closed: boolean;
  5006. /**
  5007. * Creates a Path2 object from the starting 2D coordinates x and y.
  5008. * @param x the starting points x value
  5009. * @param y the starting points y value
  5010. */
  5011. constructor(x: number, y: number);
  5012. /**
  5013. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5014. * @param x the added points x value
  5015. * @param y the added points y value
  5016. * @returns the updated Path2.
  5017. */
  5018. addLineTo(x: number, y: number): Path2;
  5019. /**
  5020. * 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.
  5021. * @param midX middle point x value
  5022. * @param midY middle point y value
  5023. * @param endX end point x value
  5024. * @param endY end point y value
  5025. * @param numberOfSegments (default: 36)
  5026. * @returns the updated Path2.
  5027. */
  5028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5029. /**
  5030. * Closes the Path2.
  5031. * @returns the Path2.
  5032. */
  5033. close(): Path2;
  5034. /**
  5035. * Gets the sum of the distance between each sequential point in the path
  5036. * @returns the Path2 total length (float).
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Gets the points which construct the path
  5041. * @returns the Path2 internal array of points.
  5042. */
  5043. getPoints(): Vector2[];
  5044. /**
  5045. * Retreives the point at the distance aways from the starting point
  5046. * @param normalizedLengthPosition the length along the path to retreive the point from
  5047. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5048. */
  5049. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5050. /**
  5051. * Creates a new path starting from an x and y position
  5052. * @param x starting x value
  5053. * @param y starting y value
  5054. * @returns a new Path2 starting at the coordinates (x, y).
  5055. */
  5056. static StartingAt(x: number, y: number): Path2;
  5057. }
  5058. /**
  5059. * Represents a 3D path made up of multiple 3D points
  5060. */
  5061. export class Path3D {
  5062. /**
  5063. * an array of Vector3, the curve axis of the Path3D
  5064. */
  5065. path: Vector3[];
  5066. private _curve;
  5067. private _distances;
  5068. private _tangents;
  5069. private _normals;
  5070. private _binormals;
  5071. private _raw;
  5072. private _alignTangentsWithPath;
  5073. private readonly _pointAtData;
  5074. /**
  5075. * new Path3D(path, normal, raw)
  5076. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5077. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5078. * @param path an array of Vector3, the curve axis of the Path3D
  5079. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5080. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5081. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5082. */
  5083. constructor(
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5088. /**
  5089. * Returns the Path3D array of successive Vector3 designing its curve.
  5090. * @returns the Path3D array of successive Vector3 designing its curve.
  5091. */
  5092. getCurve(): Vector3[];
  5093. /**
  5094. * Returns the Path3D array of successive Vector3 designing its curve.
  5095. * @returns the Path3D array of successive Vector3 designing its curve.
  5096. */
  5097. getPoints(): Vector3[];
  5098. /**
  5099. * @returns the computed length (float) of the path.
  5100. */
  5101. length(): number;
  5102. /**
  5103. * Returns an array populated with tangent vectors on each Path3D curve point.
  5104. * @returns an array populated with tangent vectors on each Path3D curve point.
  5105. */
  5106. getTangents(): Vector3[];
  5107. /**
  5108. * Returns an array populated with normal vectors on each Path3D curve point.
  5109. * @returns an array populated with normal vectors on each Path3D curve point.
  5110. */
  5111. getNormals(): Vector3[];
  5112. /**
  5113. * Returns an array populated with binormal vectors on each Path3D curve point.
  5114. * @returns an array populated with binormal vectors on each Path3D curve point.
  5115. */
  5116. getBinormals(): Vector3[];
  5117. /**
  5118. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5119. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. */
  5121. getDistances(): number[];
  5122. /**
  5123. * Returns an interpolated point along this path
  5124. * @param position the position of the point along this path, from 0.0 to 1.0
  5125. * @returns a new Vector3 as the point
  5126. */
  5127. getPointAt(position: number): Vector3;
  5128. /**
  5129. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5130. * @param position the position of the point along this path, from 0.0 to 1.0
  5131. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5132. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5133. */
  5134. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5135. /**
  5136. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5137. * @param position the position of the point along this path, from 0.0 to 1.0
  5138. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5139. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5140. */
  5141. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5142. /**
  5143. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5146. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5147. */
  5148. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5149. /**
  5150. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5151. * @param position the position of the point along this path, from 0.0 to 1.0
  5152. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5153. */
  5154. getDistanceAt(position: number): number;
  5155. /**
  5156. * Returns the array index of the previous point of an interpolated point along this path
  5157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5158. * @returns the array index
  5159. */
  5160. getPreviousPointIndexAt(position: number): number;
  5161. /**
  5162. * 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)
  5163. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5164. * @returns the sub position
  5165. */
  5166. getSubPositionAt(position: number): number;
  5167. /**
  5168. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5169. * @param target the vector of which to get the closest position to
  5170. * @returns the position of the closest virtual point on this path to the target vector
  5171. */
  5172. getClosestPositionTo(target: Vector3): number;
  5173. /**
  5174. * Returns a sub path (slice) of this path
  5175. * @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
  5176. * @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
  5177. * @returns a sub path (slice) of this path
  5178. */
  5179. slice(start?: number, end?: number): Path3D;
  5180. /**
  5181. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5182. * @param path path which all values are copied into the curves points
  5183. * @param firstNormal which should be projected onto the curve
  5184. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5185. * @returns the same object updated.
  5186. */
  5187. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5188. private _compute;
  5189. private _getFirstNonNullVector;
  5190. private _getLastNonNullVector;
  5191. private _normalVector;
  5192. /**
  5193. * Updates the point at data for an interpolated point along this curve
  5194. * @param position the position of the point along this curve, from 0.0 to 1.0
  5195. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5196. * @returns the (updated) point at data
  5197. */
  5198. private _updatePointAtData;
  5199. /**
  5200. * Updates the point at data from the specified parameters
  5201. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5202. * @param point the interpolated point
  5203. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5204. */
  5205. private _setPointAtData;
  5206. /**
  5207. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5208. */
  5209. private _updateInterpolationMatrix;
  5210. }
  5211. /**
  5212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5213. * A Curve3 is designed from a series of successive Vector3.
  5214. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5215. */
  5216. export class Curve3 {
  5217. private _points;
  5218. private _length;
  5219. /**
  5220. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5221. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5222. * @param v1 (Vector3) the control point
  5223. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5224. * @param nbPoints (integer) the wanted number of points in the curve
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5228. /**
  5229. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5230. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5231. * @param v1 (Vector3) the first control point
  5232. * @param v2 (Vector3) the second control point
  5233. * @param v3 (Vector3) the end point of the Cubic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5240. * @param p1 (Vector3) the origin point of the Hermite Spline
  5241. * @param t1 (Vector3) the tangent vector at the origin point
  5242. * @param p2 (Vector3) the end point of the Hermite Spline
  5243. * @param t2 (Vector3) the tangent vector at the end point
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a CatmullRom Spline curve :
  5250. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5251. * @param nbPoints (integer) the wanted number of points between each curve control points
  5252. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5253. * @returns the created Curve3
  5254. */
  5255. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5256. /**
  5257. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5258. * A Curve3 is designed from a series of successive Vector3.
  5259. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5260. * @param points points which make up the curve
  5261. */
  5262. constructor(points: Vector3[]);
  5263. /**
  5264. * @returns the Curve3 stored array of successive Vector3
  5265. */
  5266. getPoints(): Vector3[];
  5267. /**
  5268. * @returns the computed length (float) of the curve.
  5269. */
  5270. length(): number;
  5271. /**
  5272. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5273. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5274. * curveA and curveB keep unchanged.
  5275. * @param curve the curve to continue from this curve
  5276. * @returns the newly constructed curve
  5277. */
  5278. continue(curve: DeepImmutable<Curve3>): Curve3;
  5279. private _computeLength;
  5280. }
  5281. }
  5282. declare module "babylonjs/Animations/easing" {
  5283. /**
  5284. * This represents the main contract an easing function should follow.
  5285. * Easing functions are used throughout the animation system.
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export interface IEasingFunction {
  5289. /**
  5290. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5291. * of the easing function.
  5292. * The link below provides some of the most common examples of easing functions.
  5293. * @see https://easings.net/
  5294. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5295. * @returns the corresponding value on the curve defined by the easing function
  5296. */
  5297. ease(gradient: number): number;
  5298. }
  5299. /**
  5300. * Base class used for every default easing function.
  5301. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5302. */
  5303. export class EasingFunction implements IEasingFunction {
  5304. /**
  5305. * Interpolation follows the mathematical formula associated with the easing function.
  5306. */
  5307. static readonly EASINGMODE_EASEIN: number;
  5308. /**
  5309. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEOUT: number;
  5312. /**
  5313. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5314. */
  5315. static readonly EASINGMODE_EASEINOUT: number;
  5316. private _easingMode;
  5317. /**
  5318. * Sets the easing mode of the current function.
  5319. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5320. */
  5321. setEasingMode(easingMode: number): void;
  5322. /**
  5323. * Gets the current easing mode.
  5324. * @returns the easing mode
  5325. */
  5326. getEasingMode(): number;
  5327. /**
  5328. * @hidden
  5329. */
  5330. easeInCore(gradient: number): number;
  5331. /**
  5332. * Given an input gradient between 0 and 1, this returns the corresponding value
  5333. * of the easing function.
  5334. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5335. * @returns the corresponding value on the curve defined by the easing function
  5336. */
  5337. ease(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a circle shape (see link below).
  5341. * @see https://easings.net/#easeInCirc
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class CircleEase extends EasingFunction implements IEasingFunction {
  5345. /** @hidden */
  5346. easeInCore(gradient: number): number;
  5347. }
  5348. /**
  5349. * Easing function with a ease back shape (see link below).
  5350. * @see https://easings.net/#easeInBack
  5351. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5352. */
  5353. export class BackEase extends EasingFunction implements IEasingFunction {
  5354. /** Defines the amplitude of the function */
  5355. amplitude: number;
  5356. /**
  5357. * Instantiates a back ease easing
  5358. * @see https://easings.net/#easeInBack
  5359. * @param amplitude Defines the amplitude of the function
  5360. */
  5361. constructor(
  5362. /** Defines the amplitude of the function */
  5363. amplitude?: number);
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a bouncing shape (see link below).
  5369. * @see https://easings.net/#easeInBounce
  5370. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class BounceEase extends EasingFunction implements IEasingFunction {
  5373. /** Defines the number of bounces */
  5374. bounces: number;
  5375. /** Defines the amplitude of the bounce */
  5376. bounciness: number;
  5377. /**
  5378. * Instantiates a bounce easing
  5379. * @see https://easings.net/#easeInBounce
  5380. * @param bounces Defines the number of bounces
  5381. * @param bounciness Defines the amplitude of the bounce
  5382. */
  5383. constructor(
  5384. /** Defines the number of bounces */
  5385. bounces?: number,
  5386. /** Defines the amplitude of the bounce */
  5387. bounciness?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a power of 3 shape (see link below).
  5393. * @see https://easings.net/#easeInCubic
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class CubicEase extends EasingFunction implements IEasingFunction {
  5397. /** @hidden */
  5398. easeInCore(gradient: number): number;
  5399. }
  5400. /**
  5401. * Easing function with an elastic shape (see link below).
  5402. * @see https://easings.net/#easeInElastic
  5403. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5404. */
  5405. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5406. /** Defines the number of oscillations*/
  5407. oscillations: number;
  5408. /** Defines the amplitude of the oscillations*/
  5409. springiness: number;
  5410. /**
  5411. * Instantiates an elastic easing function
  5412. * @see https://easings.net/#easeInElastic
  5413. * @param oscillations Defines the number of oscillations
  5414. * @param springiness Defines the amplitude of the oscillations
  5415. */
  5416. constructor(
  5417. /** Defines the number of oscillations*/
  5418. oscillations?: number,
  5419. /** Defines the amplitude of the oscillations*/
  5420. springiness?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an exponential shape (see link below).
  5426. * @see https://easings.net/#easeInExpo
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the exponent of the function */
  5431. exponent: number;
  5432. /**
  5433. * Instantiates an exponential easing function
  5434. * @see https://easings.net/#easeInExpo
  5435. * @param exponent Defines the exponent of the function
  5436. */
  5437. constructor(
  5438. /** Defines the exponent of the function */
  5439. exponent?: number);
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power shape (see link below).
  5445. * @see https://easings.net/#easeInQuad
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class PowerEase extends EasingFunction implements IEasingFunction {
  5449. /** Defines the power of the function */
  5450. power: number;
  5451. /**
  5452. * Instantiates an power base easing function
  5453. * @see https://easings.net/#easeInQuad
  5454. * @param power Defines the power of the function
  5455. */
  5456. constructor(
  5457. /** Defines the power of the function */
  5458. power?: number);
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 2 shape (see link below).
  5464. * @see https://easings.net/#easeInQuad
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a power of 4 shape (see link below).
  5473. * @see https://easings.net/#easeInQuart
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a power of 5 shape (see link below).
  5482. * @see https://easings.net/#easeInQuint
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5486. /** @hidden */
  5487. easeInCore(gradient: number): number;
  5488. }
  5489. /**
  5490. * Easing function with a sin shape (see link below).
  5491. * @see https://easings.net/#easeInSine
  5492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5493. */
  5494. export class SineEase extends EasingFunction implements IEasingFunction {
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. /**
  5499. * Easing function with a bezier shape (see link below).
  5500. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5501. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5502. */
  5503. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5504. /** Defines the x component of the start tangent in the bezier curve */
  5505. x1: number;
  5506. /** Defines the y component of the start tangent in the bezier curve */
  5507. y1: number;
  5508. /** Defines the x component of the end tangent in the bezier curve */
  5509. x2: number;
  5510. /** Defines the y component of the end tangent in the bezier curve */
  5511. y2: number;
  5512. /**
  5513. * Instantiates a bezier function
  5514. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5515. * @param x1 Defines the x component of the start tangent in the bezier curve
  5516. * @param y1 Defines the y component of the start tangent in the bezier curve
  5517. * @param x2 Defines the x component of the end tangent in the bezier curve
  5518. * @param y2 Defines the y component of the end tangent in the bezier curve
  5519. */
  5520. constructor(
  5521. /** Defines the x component of the start tangent in the bezier curve */
  5522. x1?: number,
  5523. /** Defines the y component of the start tangent in the bezier curve */
  5524. y1?: number,
  5525. /** Defines the x component of the end tangent in the bezier curve */
  5526. x2?: number,
  5527. /** Defines the y component of the end tangent in the bezier curve */
  5528. y2?: number);
  5529. /** @hidden */
  5530. easeInCore(gradient: number): number;
  5531. }
  5532. }
  5533. declare module "babylonjs/Maths/math.color" {
  5534. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5535. /**
  5536. * Class used to hold a RBG color
  5537. */
  5538. export class Color3 {
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r: number;
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g: number;
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b: number;
  5551. /**
  5552. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5553. * @param r defines the red component (between 0 and 1, default is 0)
  5554. * @param g defines the green component (between 0 and 1, default is 0)
  5555. * @param b defines the blue component (between 0 and 1, default is 0)
  5556. */
  5557. constructor(
  5558. /**
  5559. * Defines the red component (between 0 and 1, default is 0)
  5560. */
  5561. r?: number,
  5562. /**
  5563. * Defines the green component (between 0 and 1, default is 0)
  5564. */
  5565. g?: number,
  5566. /**
  5567. * Defines the blue component (between 0 and 1, default is 0)
  5568. */
  5569. b?: number);
  5570. /**
  5571. * Creates a string with the Color3 current values
  5572. * @returns the string representation of the Color3 object
  5573. */
  5574. toString(): string;
  5575. /**
  5576. * Returns the string "Color3"
  5577. * @returns "Color3"
  5578. */
  5579. getClassName(): string;
  5580. /**
  5581. * Compute the Color3 hash code
  5582. * @returns an unique number that can be used to hash Color3 objects
  5583. */
  5584. getHashCode(): number;
  5585. /**
  5586. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5587. * @param array defines the array where to store the r,g,b components
  5588. * @param index defines an optional index in the target array to define where to start storing values
  5589. * @returns the current Color3 object
  5590. */
  5591. toArray(array: FloatArray, index?: number): Color3;
  5592. /**
  5593. * Update the current color with values stored in an array from the starting index of the given array
  5594. * @param array defines the source array
  5595. * @param offset defines an offset in the source array
  5596. * @returns the current Color3 object
  5597. */
  5598. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5599. /**
  5600. * Returns a new Color4 object from the current Color3 and the given alpha
  5601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5602. * @returns a new Color4 object
  5603. */
  5604. toColor4(alpha?: number): Color4;
  5605. /**
  5606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5607. * @returns the new array
  5608. */
  5609. asArray(): number[];
  5610. /**
  5611. * Returns the luminance value
  5612. * @returns a float value
  5613. */
  5614. toLuminance(): number;
  5615. /**
  5616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5617. * @param otherColor defines the second operand
  5618. * @returns the new Color3 object
  5619. */
  5620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5621. /**
  5622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5623. * @param otherColor defines the second operand
  5624. * @param result defines the Color3 object where to store the result
  5625. * @returns the current Color3
  5626. */
  5627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5628. /**
  5629. * Determines equality between Color3 objects
  5630. * @param otherColor defines the second operand
  5631. * @returns true if the rgb values are equal to the given ones
  5632. */
  5633. equals(otherColor: DeepImmutable<Color3>): boolean;
  5634. /**
  5635. * Determines equality between the current Color3 object and a set of r,b,g values
  5636. * @param r defines the red component to check
  5637. * @param g defines the green component to check
  5638. * @param b defines the blue component to check
  5639. * @returns true if the rgb values are equal to the given ones
  5640. */
  5641. equalsFloats(r: number, g: number, b: number): boolean;
  5642. /**
  5643. * Multiplies in place each rgb value by scale
  5644. * @param scale defines the scaling factor
  5645. * @returns the updated Color3
  5646. */
  5647. scale(scale: number): Color3;
  5648. /**
  5649. * Multiplies the rgb values by scale and stores the result into "result"
  5650. * @param scale defines the scaling factor
  5651. * @param result defines the Color3 object where to store the result
  5652. * @returns the unmodified current Color3
  5653. */
  5654. scaleToRef(scale: number, result: Color3): Color3;
  5655. /**
  5656. * Scale the current Color3 values by a factor and add the result to a given Color3
  5657. * @param scale defines the scale factor
  5658. * @param result defines color to store the result into
  5659. * @returns the unmodified current Color3
  5660. */
  5661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5662. /**
  5663. * Clamps the rgb values by the min and max values and stores the result into "result"
  5664. * @param min defines minimum clamping value (default is 0)
  5665. * @param max defines maximum clamping value (default is 1)
  5666. * @param result defines color to store the result into
  5667. * @returns the original Color3
  5668. */
  5669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5670. /**
  5671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5672. * @param otherColor defines the second operand
  5673. * @returns the new Color3
  5674. */
  5675. add(otherColor: DeepImmutable<Color3>): Color3;
  5676. /**
  5677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5678. * @param otherColor defines the second operand
  5679. * @param result defines Color3 object to store the result into
  5680. * @returns the unmodified current Color3
  5681. */
  5682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5683. /**
  5684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5685. * @param otherColor defines the second operand
  5686. * @returns the new Color3
  5687. */
  5688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5691. * @param otherColor defines the second operand
  5692. * @param result defines Color3 object to store the result into
  5693. * @returns the unmodified current Color3
  5694. */
  5695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5696. /**
  5697. * Copy the current object
  5698. * @returns a new Color3 copied the current one
  5699. */
  5700. clone(): Color3;
  5701. /**
  5702. * Copies the rgb values from the source in the current Color3
  5703. * @param source defines the source Color3 object
  5704. * @returns the updated Color3 object
  5705. */
  5706. copyFrom(source: DeepImmutable<Color3>): Color3;
  5707. /**
  5708. * Updates the Color3 rgb values from the given floats
  5709. * @param r defines the red component to read from
  5710. * @param g defines the green component to read from
  5711. * @param b defines the blue component to read from
  5712. * @returns the current Color3 object
  5713. */
  5714. copyFromFloats(r: number, g: number, b: number): Color3;
  5715. /**
  5716. * Updates the Color3 rgb values from the given floats
  5717. * @param r defines the red component to read from
  5718. * @param g defines the green component to read from
  5719. * @param b defines the blue component to read from
  5720. * @returns the current Color3 object
  5721. */
  5722. set(r: number, g: number, b: number): Color3;
  5723. /**
  5724. * Compute the Color3 hexadecimal code as a string
  5725. * @returns a string containing the hexadecimal representation of the Color3 object
  5726. */
  5727. toHexString(): string;
  5728. /**
  5729. * Computes a new Color3 converted from the current one to linear space
  5730. * @returns a new Color3 object
  5731. */
  5732. toLinearSpace(): Color3;
  5733. /**
  5734. * Converts current color in rgb space to HSV values
  5735. * @returns a new color3 representing the HSV values
  5736. */
  5737. toHSV(): Color3;
  5738. /**
  5739. * Converts current color in rgb space to HSV values
  5740. * @param result defines the Color3 where to store the HSV values
  5741. */
  5742. toHSVToRef(result: Color3): void;
  5743. /**
  5744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5745. * @param convertedColor defines the Color3 object where to store the linear space version
  5746. * @returns the unmodified Color3
  5747. */
  5748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5749. /**
  5750. * Computes a new Color3 converted from the current one to gamma space
  5751. * @returns a new Color3 object
  5752. */
  5753. toGammaSpace(): Color3;
  5754. /**
  5755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5756. * @param convertedColor defines the Color3 object where to store the gamma space version
  5757. * @returns the unmodified Color3
  5758. */
  5759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5760. private static _BlackReadOnly;
  5761. /**
  5762. * Convert Hue, saturation and value to a Color3 (RGB)
  5763. * @param hue defines the hue
  5764. * @param saturation defines the saturation
  5765. * @param value defines the value
  5766. * @param result defines the Color3 where to store the RGB values
  5767. */
  5768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5769. /**
  5770. * Creates a new Color3 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color3 object
  5773. */
  5774. static FromHexString(hex: string): Color3;
  5775. /**
  5776. * Creates a new Color3 from the starting index of the given array
  5777. * @param array defines the source array
  5778. * @param offset defines an offset in the source array
  5779. * @returns a new Color3 object
  5780. */
  5781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5782. /**
  5783. * Creates a new Color3 from the starting index element of the given array
  5784. * @param array defines the source array to read from
  5785. * @param offset defines the offset in the source array
  5786. * @param result defines the target Color3 object
  5787. */
  5788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from integer values (< 256)
  5791. * @param r defines the red component to read from (value between 0 and 255)
  5792. * @param g defines the green component to read from (value between 0 and 255)
  5793. * @param b defines the blue component to read from (value between 0 and 255)
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromInts(r: number, g: number, b: number): Color3;
  5797. /**
  5798. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5799. * @param start defines the start Color3 value
  5800. * @param end defines the end Color3 value
  5801. * @param amount defines the gradient value between start and end
  5802. * @returns a new Color3 object
  5803. */
  5804. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5805. /**
  5806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5807. * @param left defines the start value
  5808. * @param right defines the end value
  5809. * @param amount defines the gradient factor
  5810. * @param result defines the Color3 object where to store the result
  5811. */
  5812. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5813. /**
  5814. * Returns a Color3 value containing a red color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Red(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a green color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Green(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a blue color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Blue(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a black color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Black(): Color3;
  5833. /**
  5834. * Gets a Color3 value containing a black color that must not be updated
  5835. */
  5836. static get BlackReadOnly(): DeepImmutable<Color3>;
  5837. /**
  5838. * Returns a Color3 value containing a white color
  5839. * @returns a new Color3 object
  5840. */
  5841. static White(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a purple color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Purple(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a magenta color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Magenta(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a yellow color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Yellow(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a gray color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Gray(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a teal color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Teal(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a random color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Random(): Color3;
  5872. }
  5873. /**
  5874. * Class used to hold a RBGA color
  5875. */
  5876. export class Color4 {
  5877. /**
  5878. * Defines the red component (between 0 and 1, default is 0)
  5879. */
  5880. r: number;
  5881. /**
  5882. * Defines the green component (between 0 and 1, default is 0)
  5883. */
  5884. g: number;
  5885. /**
  5886. * Defines the blue component (between 0 and 1, default is 0)
  5887. */
  5888. b: number;
  5889. /**
  5890. * Defines the alpha component (between 0 and 1, default is 1)
  5891. */
  5892. a: number;
  5893. /**
  5894. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5895. * @param r defines the red component (between 0 and 1, default is 0)
  5896. * @param g defines the green component (between 0 and 1, default is 0)
  5897. * @param b defines the blue component (between 0 and 1, default is 0)
  5898. * @param a defines the alpha component (between 0 and 1, default is 1)
  5899. */
  5900. constructor(
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r?: number,
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g?: number,
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b?: number,
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a?: number);
  5917. /**
  5918. * Adds in place the given Color4 values to the current Color4 object
  5919. * @param right defines the second operand
  5920. * @returns the current updated Color4 object
  5921. */
  5922. addInPlace(right: DeepImmutable<Color4>): Color4;
  5923. /**
  5924. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5925. * @returns the new array
  5926. */
  5927. asArray(): number[];
  5928. /**
  5929. * Stores from the starting index in the given array the Color4 successive values
  5930. * @param array defines the array where to store the r,g,b components
  5931. * @param index defines an optional index in the target array to define where to start storing values
  5932. * @returns the current Color4 object
  5933. */
  5934. toArray(array: number[], index?: number): Color4;
  5935. /**
  5936. * Update the current color with values stored in an array from the starting index of the given array
  5937. * @param array defines the source array
  5938. * @param offset defines an offset in the source array
  5939. * @returns the current Color4 object
  5940. */
  5941. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5942. /**
  5943. * Determines equality between Color4 objects
  5944. * @param otherColor defines the second operand
  5945. * @returns true if the rgba values are equal to the given ones
  5946. */
  5947. equals(otherColor: DeepImmutable<Color4>): boolean;
  5948. /**
  5949. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5950. * @param right defines the second operand
  5951. * @returns a new Color4 object
  5952. */
  5953. add(right: DeepImmutable<Color4>): Color4;
  5954. /**
  5955. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5956. * @param right defines the second operand
  5957. * @returns a new Color4 object
  5958. */
  5959. subtract(right: DeepImmutable<Color4>): Color4;
  5960. /**
  5961. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5962. * @param right defines the second operand
  5963. * @param result defines the Color4 object where to store the result
  5964. * @returns the current Color4 object
  5965. */
  5966. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5967. /**
  5968. * Creates a new Color4 with the current Color4 values multiplied by scale
  5969. * @param scale defines the scaling factor to apply
  5970. * @returns a new Color4 object
  5971. */
  5972. scale(scale: number): Color4;
  5973. /**
  5974. * Multiplies the current Color4 values by scale and stores the result in "result"
  5975. * @param scale defines the scaling factor to apply
  5976. * @param result defines the Color4 object where to store the result
  5977. * @returns the current unmodified Color4
  5978. */
  5979. scaleToRef(scale: number, result: Color4): Color4;
  5980. /**
  5981. * Scale the current Color4 values by a factor and add the result to a given Color4
  5982. * @param scale defines the scale factor
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the unmodified current Color4
  5985. */
  5986. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5987. /**
  5988. * Clamps the rgb values by the min and max values and stores the result into "result"
  5989. * @param min defines minimum clamping value (default is 0)
  5990. * @param max defines maximum clamping value (default is 1)
  5991. * @param result defines color to store the result into.
  5992. * @returns the cuurent Color4
  5993. */
  5994. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5995. /**
  5996. * Multipy an Color4 value by another and return a new Color4 object
  5997. * @param color defines the Color4 value to multiply by
  5998. * @returns a new Color4 object
  5999. */
  6000. multiply(color: Color4): Color4;
  6001. /**
  6002. * Multipy a Color4 value by another and push the result in a reference value
  6003. * @param color defines the Color4 value to multiply by
  6004. * @param result defines the Color4 to fill the result in
  6005. * @returns the result Color4
  6006. */
  6007. multiplyToRef(color: Color4, result: Color4): Color4;
  6008. /**
  6009. * Creates a string with the Color4 current values
  6010. * @returns the string representation of the Color4 object
  6011. */
  6012. toString(): string;
  6013. /**
  6014. * Returns the string "Color4"
  6015. * @returns "Color4"
  6016. */
  6017. getClassName(): string;
  6018. /**
  6019. * Compute the Color4 hash code
  6020. * @returns an unique number that can be used to hash Color4 objects
  6021. */
  6022. getHashCode(): number;
  6023. /**
  6024. * Creates a new Color4 copied from the current one
  6025. * @returns a new Color4 object
  6026. */
  6027. clone(): Color4;
  6028. /**
  6029. * Copies the given Color4 values into the current one
  6030. * @param source defines the source Color4 object
  6031. * @returns the current updated Color4 object
  6032. */
  6033. copyFrom(source: Color4): Color4;
  6034. /**
  6035. * Copies the given float values into the current one
  6036. * @param r defines the red component to read from
  6037. * @param g defines the green component to read from
  6038. * @param b defines the blue component to read from
  6039. * @param a defines the alpha component to read from
  6040. * @returns the current updated Color4 object
  6041. */
  6042. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6043. /**
  6044. * Copies the given float values into the current one
  6045. * @param r defines the red component to read from
  6046. * @param g defines the green component to read from
  6047. * @param b defines the blue component to read from
  6048. * @param a defines the alpha component to read from
  6049. * @returns the current updated Color4 object
  6050. */
  6051. set(r: number, g: number, b: number, a: number): Color4;
  6052. /**
  6053. * Compute the Color4 hexadecimal code as a string
  6054. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6055. * @returns a string containing the hexadecimal representation of the Color4 object
  6056. */
  6057. toHexString(returnAsColor3?: boolean): string;
  6058. /**
  6059. * Computes a new Color4 converted from the current one to linear space
  6060. * @returns a new Color4 object
  6061. */
  6062. toLinearSpace(): Color4;
  6063. /**
  6064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6065. * @param convertedColor defines the Color4 object where to store the linear space version
  6066. * @returns the unmodified Color4
  6067. */
  6068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6069. /**
  6070. * Computes a new Color4 converted from the current one to gamma space
  6071. * @returns a new Color4 object
  6072. */
  6073. toGammaSpace(): Color4;
  6074. /**
  6075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6076. * @param convertedColor defines the Color4 object where to store the gamma space version
  6077. * @returns the unmodified Color4
  6078. */
  6079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6080. /**
  6081. * Creates a new Color4 from the string containing valid hexadecimal values
  6082. * @param hex defines a string containing valid hexadecimal values
  6083. * @returns a new Color4 object
  6084. */
  6085. static FromHexString(hex: string): Color4;
  6086. /**
  6087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6088. * @param left defines the start value
  6089. * @param right defines the end value
  6090. * @param amount defines the gradient factor
  6091. * @returns a new Color4 object
  6092. */
  6093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6094. /**
  6095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6096. * @param left defines the start value
  6097. * @param right defines the end value
  6098. * @param amount defines the gradient factor
  6099. * @param result defines the Color4 object where to store data
  6100. */
  6101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6102. /**
  6103. * Creates a new Color4 from a Color3 and an alpha value
  6104. * @param color3 defines the source Color3 to read from
  6105. * @param alpha defines the alpha component (1.0 by default)
  6106. * @returns a new Color4 object
  6107. */
  6108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6109. /**
  6110. * Creates a new Color4 from the starting index element of the given array
  6111. * @param array defines the source array to read from
  6112. * @param offset defines the offset in the source array
  6113. * @returns a new Color4 object
  6114. */
  6115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6116. /**
  6117. * Creates a new Color4 from the starting index element of the given array
  6118. * @param array defines the source array to read from
  6119. * @param offset defines the offset in the source array
  6120. * @param result defines the target Color4 object
  6121. */
  6122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6123. /**
  6124. * Creates a new Color3 from integer values (< 256)
  6125. * @param r defines the red component to read from (value between 0 and 255)
  6126. * @param g defines the green component to read from (value between 0 and 255)
  6127. * @param b defines the blue component to read from (value between 0 and 255)
  6128. * @param a defines the alpha component to read from (value between 0 and 255)
  6129. * @returns a new Color3 object
  6130. */
  6131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6132. /**
  6133. * Check the content of a given array and convert it to an array containing RGBA data
  6134. * If the original array was already containing count * 4 values then it is returned directly
  6135. * @param colors defines the array to check
  6136. * @param count defines the number of RGBA data to expect
  6137. * @returns an array containing count * 4 values (RGBA)
  6138. */
  6139. static CheckColors4(colors: number[], count: number): number[];
  6140. }
  6141. /**
  6142. * @hidden
  6143. */
  6144. export class TmpColors {
  6145. static Color3: Color3[];
  6146. static Color4: Color4[];
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationKey" {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module "babylonjs/Animations/animationRange" {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module "babylonjs/Animations/animationEvent" {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module "babylonjs/Behaviors/behavior" {
  6249. import { Nullable } from "babylonjs/types";
  6250. /**
  6251. * Interface used to define a behavior
  6252. */
  6253. export interface Behavior<T> {
  6254. /** gets or sets behavior's name */
  6255. name: string;
  6256. /**
  6257. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6258. */
  6259. init(): void;
  6260. /**
  6261. * Called when the behavior is attached to a target
  6262. * @param target defines the target where the behavior is attached to
  6263. */
  6264. attach(target: T): void;
  6265. /**
  6266. * Called when the behavior is detached from its target
  6267. */
  6268. detach(): void;
  6269. }
  6270. /**
  6271. * Interface implemented by classes supporting behaviors
  6272. */
  6273. export interface IBehaviorAware<T> {
  6274. /**
  6275. * Attach a behavior
  6276. * @param behavior defines the behavior to attach
  6277. * @returns the current host
  6278. */
  6279. addBehavior(behavior: Behavior<T>): T;
  6280. /**
  6281. * Remove a behavior from the current object
  6282. * @param behavior defines the behavior to detach
  6283. * @returns the current host
  6284. */
  6285. removeBehavior(behavior: Behavior<T>): T;
  6286. /**
  6287. * Gets a behavior using its name to search
  6288. * @param name defines the name to search
  6289. * @returns the behavior or null if not found
  6290. */
  6291. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6292. }
  6293. }
  6294. declare module "babylonjs/Misc/smartArray" {
  6295. /**
  6296. * Defines an array and its length.
  6297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6298. */
  6299. export interface ISmartArrayLike<T> {
  6300. /**
  6301. * The data of the array.
  6302. */
  6303. data: Array<T>;
  6304. /**
  6305. * The active length of the array.
  6306. */
  6307. length: number;
  6308. }
  6309. /**
  6310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6311. */
  6312. export class SmartArray<T> implements ISmartArrayLike<T> {
  6313. /**
  6314. * The full set of data from the array.
  6315. */
  6316. data: Array<T>;
  6317. /**
  6318. * The active length of the array.
  6319. */
  6320. length: number;
  6321. protected _id: number;
  6322. /**
  6323. * Instantiates a Smart Array.
  6324. * @param capacity defines the default capacity of the array.
  6325. */
  6326. constructor(capacity: number);
  6327. /**
  6328. * Pushes a value at the end of the active data.
  6329. * @param value defines the object to push in the array.
  6330. */
  6331. push(value: T): void;
  6332. /**
  6333. * Iterates over the active data and apply the lambda to them.
  6334. * @param func defines the action to apply on each value.
  6335. */
  6336. forEach(func: (content: T) => void): void;
  6337. /**
  6338. * Sorts the full sets of data.
  6339. * @param compareFn defines the comparison function to apply.
  6340. */
  6341. sort(compareFn: (a: T, b: T) => number): void;
  6342. /**
  6343. * Resets the active data to an empty array.
  6344. */
  6345. reset(): void;
  6346. /**
  6347. * Releases all the data from the array as well as the array.
  6348. */
  6349. dispose(): void;
  6350. /**
  6351. * Concats the active data with a given array.
  6352. * @param array defines the data to concatenate with.
  6353. */
  6354. concat(array: any): void;
  6355. /**
  6356. * Returns the position of a value in the active data.
  6357. * @param value defines the value to find the index for
  6358. * @returns the index if found in the active data otherwise -1
  6359. */
  6360. indexOf(value: T): number;
  6361. /**
  6362. * Returns whether an element is part of the active data.
  6363. * @param value defines the value to look for
  6364. * @returns true if found in the active data otherwise false
  6365. */
  6366. contains(value: T): boolean;
  6367. private static _GlobalId;
  6368. }
  6369. /**
  6370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6371. * The data in this array can only be present once
  6372. */
  6373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6374. private _duplicateId;
  6375. /**
  6376. * Pushes a value at the end of the active data.
  6377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6378. * @param value defines the object to push in the array.
  6379. */
  6380. push(value: T): void;
  6381. /**
  6382. * Pushes a value at the end of the active data.
  6383. * If the data is already present, it won t be added again
  6384. * @param value defines the object to push in the array.
  6385. * @returns true if added false if it was already present
  6386. */
  6387. pushNoDuplicate(value: T): boolean;
  6388. /**
  6389. * Resets the active data to an empty array.
  6390. */
  6391. reset(): void;
  6392. /**
  6393. * Concats the active data with a given array.
  6394. * This ensures no dupplicate will be present in the result.
  6395. * @param array defines the data to concatenate with.
  6396. */
  6397. concatWithNoDuplicate(array: any): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Cameras/cameraInputsManager" {
  6401. import { Nullable } from "babylonjs/types";
  6402. import { Camera } from "babylonjs/Cameras/camera";
  6403. /**
  6404. * @ignore
  6405. * This is a list of all the different input types that are available in the application.
  6406. * Fo instance: ArcRotateCameraGamepadInput...
  6407. */
  6408. export var CameraInputTypes: {};
  6409. /**
  6410. * This is the contract to implement in order to create a new input class.
  6411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6412. */
  6413. export interface ICameraInput<TCamera extends Camera> {
  6414. /**
  6415. * Defines the camera the input is attached to.
  6416. */
  6417. camera: Nullable<TCamera>;
  6418. /**
  6419. * Gets the class name of the current intput.
  6420. * @returns the class name
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * Get the friendly name associated with the input class.
  6425. * @returns the input friendly name
  6426. */
  6427. getSimpleName(): string;
  6428. /**
  6429. * Attach the input controls to a specific dom element to get the input from.
  6430. * @param element Defines the element the controls should be listened from
  6431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6432. */
  6433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6434. /**
  6435. * Detach the current controls from the specified dom element.
  6436. * @param element Defines the element to stop listening the inputs from
  6437. */
  6438. detachControl(element: Nullable<HTMLElement>): void;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs?: () => void;
  6444. }
  6445. /**
  6446. * Represents a map of input types to input instance or input index to input instance.
  6447. */
  6448. export interface CameraInputsMap<TCamera extends Camera> {
  6449. /**
  6450. * Accessor to the input by input type.
  6451. */
  6452. [name: string]: ICameraInput<TCamera>;
  6453. /**
  6454. * Accessor to the input by input index.
  6455. */
  6456. [idx: number]: ICameraInput<TCamera>;
  6457. }
  6458. /**
  6459. * This represents the input manager used within a camera.
  6460. * It helps dealing with all the different kind of input attached to a camera.
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. */
  6463. export class CameraInputsManager<TCamera extends Camera> {
  6464. /**
  6465. * Defines the list of inputs attahed to the camera.
  6466. */
  6467. attached: CameraInputsMap<TCamera>;
  6468. /**
  6469. * Defines the dom element the camera is collecting inputs from.
  6470. * This is null if the controls have not been attached.
  6471. */
  6472. attachedElement: Nullable<HTMLElement>;
  6473. /**
  6474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6475. */
  6476. noPreventDefault: boolean;
  6477. /**
  6478. * Defined the camera the input manager belongs to.
  6479. */
  6480. camera: TCamera;
  6481. /**
  6482. * Update the current camera state depending on the inputs that have been used this frame.
  6483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6484. */
  6485. checkInputs: () => void;
  6486. /**
  6487. * Instantiate a new Camera Input Manager.
  6488. * @param camera Defines the camera the input manager blongs to
  6489. */
  6490. constructor(camera: TCamera);
  6491. /**
  6492. * Add an input method to a camera
  6493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6494. * @param input camera input method
  6495. */
  6496. add(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Remove a specific input method from a camera
  6499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6500. * @param inputToRemove camera input method
  6501. */
  6502. remove(inputToRemove: ICameraInput<TCamera>): void;
  6503. /**
  6504. * Remove a specific input type from a camera
  6505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6506. * @param inputType the type of the input to remove
  6507. */
  6508. removeByType(inputType: string): void;
  6509. private _addCheckInputs;
  6510. /**
  6511. * Attach the input controls to the currently attached dom element to listen the events from.
  6512. * @param input Defines the input to attach
  6513. */
  6514. attachInput(input: ICameraInput<TCamera>): void;
  6515. /**
  6516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6517. * @param element Defines the dom element to collect the events from
  6518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6519. */
  6520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6521. /**
  6522. * Detach the current manager inputs controls from a specific dom element.
  6523. * @param element Defines the dom element to collect the events from
  6524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6525. */
  6526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6527. /**
  6528. * Rebuild the dynamic inputCheck function from the current list of
  6529. * defined inputs in the manager.
  6530. */
  6531. rebuildInputCheck(): void;
  6532. /**
  6533. * Remove all attached input methods from a camera
  6534. */
  6535. clear(): void;
  6536. /**
  6537. * Serialize the current input manager attached to a camera.
  6538. * This ensures than once parsed,
  6539. * the input associated to the camera will be identical to the current ones
  6540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6541. */
  6542. serialize(serializedCamera: any): void;
  6543. /**
  6544. * Parses an input manager serialized JSON to restore the previous list of inputs
  6545. * and states associated to a camera.
  6546. * @param parsedCamera Defines the JSON to parse
  6547. */
  6548. parse(parsedCamera: any): void;
  6549. }
  6550. }
  6551. declare module "babylonjs/Meshes/buffer" {
  6552. import { Nullable, DataArray } from "babylonjs/types";
  6553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6554. /**
  6555. * Class used to store data that will be store in GPU memory
  6556. */
  6557. export class Buffer {
  6558. private _engine;
  6559. private _buffer;
  6560. /** @hidden */
  6561. _data: Nullable<DataArray>;
  6562. private _updatable;
  6563. private _instanced;
  6564. private _divisor;
  6565. /**
  6566. * Gets the byte stride.
  6567. */
  6568. readonly byteStride: number;
  6569. /**
  6570. * Constructor
  6571. * @param engine the engine
  6572. * @param data the data to use for this buffer
  6573. * @param updatable whether the data is updatable
  6574. * @param stride the stride (optional)
  6575. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6576. * @param instanced whether the buffer is instanced (optional)
  6577. * @param useBytes set to true if the stride in in bytes (optional)
  6578. * @param divisor sets an optional divisor for instances (1 by default)
  6579. */
  6580. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6581. /**
  6582. * Create a new VertexBuffer based on the current buffer
  6583. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6584. * @param offset defines offset in the buffer (0 by default)
  6585. * @param size defines the size in floats of attributes (position is 3 for instance)
  6586. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6587. * @param instanced defines if the vertex buffer contains indexed data
  6588. * @param useBytes defines if the offset and stride are in bytes *
  6589. * @param divisor sets an optional divisor for instances (1 by default)
  6590. * @returns the new vertex buffer
  6591. */
  6592. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6593. /**
  6594. * Gets a boolean indicating if the Buffer is updatable?
  6595. * @returns true if the buffer is updatable
  6596. */
  6597. isUpdatable(): boolean;
  6598. /**
  6599. * Gets current buffer's data
  6600. * @returns a DataArray or null
  6601. */
  6602. getData(): Nullable<DataArray>;
  6603. /**
  6604. * Gets underlying native buffer
  6605. * @returns underlying native buffer
  6606. */
  6607. getBuffer(): Nullable<DataBuffer>;
  6608. /**
  6609. * Gets the stride in float32 units (i.e. byte stride / 4).
  6610. * May not be an integer if the byte stride is not divisible by 4.
  6611. * @returns the stride in float32 units
  6612. * @deprecated Please use byteStride instead.
  6613. */
  6614. getStrideSize(): number;
  6615. /**
  6616. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6617. * @param data defines the data to store
  6618. */
  6619. create(data?: Nullable<DataArray>): void;
  6620. /** @hidden */
  6621. _rebuild(): void;
  6622. /**
  6623. * Update current buffer data
  6624. * @param data defines the data to store
  6625. */
  6626. update(data: DataArray): void;
  6627. /**
  6628. * Updates the data directly.
  6629. * @param data the new data
  6630. * @param offset the new offset
  6631. * @param vertexCount the vertex count (optional)
  6632. * @param useBytes set to true if the offset is in bytes
  6633. */
  6634. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6635. /**
  6636. * Release all resources
  6637. */
  6638. dispose(): void;
  6639. }
  6640. /**
  6641. * Specialized buffer used to store vertex data
  6642. */
  6643. export class VertexBuffer {
  6644. /** @hidden */
  6645. _buffer: Buffer;
  6646. private _kind;
  6647. private _size;
  6648. private _ownsBuffer;
  6649. private _instanced;
  6650. private _instanceDivisor;
  6651. /**
  6652. * The byte type.
  6653. */
  6654. static readonly BYTE: number;
  6655. /**
  6656. * The unsigned byte type.
  6657. */
  6658. static readonly UNSIGNED_BYTE: number;
  6659. /**
  6660. * The short type.
  6661. */
  6662. static readonly SHORT: number;
  6663. /**
  6664. * The unsigned short type.
  6665. */
  6666. static readonly UNSIGNED_SHORT: number;
  6667. /**
  6668. * The integer type.
  6669. */
  6670. static readonly INT: number;
  6671. /**
  6672. * The unsigned integer type.
  6673. */
  6674. static readonly UNSIGNED_INT: number;
  6675. /**
  6676. * The float type.
  6677. */
  6678. static readonly FLOAT: number;
  6679. /**
  6680. * Gets or sets the instance divisor when in instanced mode
  6681. */
  6682. get instanceDivisor(): number;
  6683. set instanceDivisor(value: number);
  6684. /**
  6685. * Gets the byte stride.
  6686. */
  6687. readonly byteStride: number;
  6688. /**
  6689. * Gets the byte offset.
  6690. */
  6691. readonly byteOffset: number;
  6692. /**
  6693. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6694. */
  6695. readonly normalized: boolean;
  6696. /**
  6697. * Gets the data type of each component in the array.
  6698. */
  6699. readonly type: number;
  6700. /**
  6701. * Constructor
  6702. * @param engine the engine
  6703. * @param data the data to use for this vertex buffer
  6704. * @param kind the vertex buffer kind
  6705. * @param updatable whether the data is updatable
  6706. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6707. * @param stride the stride (optional)
  6708. * @param instanced whether the buffer is instanced (optional)
  6709. * @param offset the offset of the data (optional)
  6710. * @param size the number of components (optional)
  6711. * @param type the type of the component (optional)
  6712. * @param normalized whether the data contains normalized data (optional)
  6713. * @param useBytes set to true if stride and offset are in bytes (optional)
  6714. * @param divisor defines the instance divisor to use (1 by default)
  6715. */
  6716. 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);
  6717. /** @hidden */
  6718. _rebuild(): void;
  6719. /**
  6720. * Returns the kind of the VertexBuffer (string)
  6721. * @returns a string
  6722. */
  6723. getKind(): string;
  6724. /**
  6725. * Gets a boolean indicating if the VertexBuffer is updatable?
  6726. * @returns true if the buffer is updatable
  6727. */
  6728. isUpdatable(): boolean;
  6729. /**
  6730. * Gets current buffer's data
  6731. * @returns a DataArray or null
  6732. */
  6733. getData(): Nullable<DataArray>;
  6734. /**
  6735. * Gets underlying native buffer
  6736. * @returns underlying native buffer
  6737. */
  6738. getBuffer(): Nullable<DataBuffer>;
  6739. /**
  6740. * Gets the stride in float32 units (i.e. byte stride / 4).
  6741. * May not be an integer if the byte stride is not divisible by 4.
  6742. * @returns the stride in float32 units
  6743. * @deprecated Please use byteStride instead.
  6744. */
  6745. getStrideSize(): number;
  6746. /**
  6747. * Returns the offset as a multiple of the type byte length.
  6748. * @returns the offset in bytes
  6749. * @deprecated Please use byteOffset instead.
  6750. */
  6751. getOffset(): number;
  6752. /**
  6753. * Returns the number of components per vertex attribute (integer)
  6754. * @returns the size in float
  6755. */
  6756. getSize(): number;
  6757. /**
  6758. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6759. * @returns true if this buffer is instanced
  6760. */
  6761. getIsInstanced(): boolean;
  6762. /**
  6763. * Returns the instancing divisor, zero for non-instanced (integer).
  6764. * @returns a number
  6765. */
  6766. getInstanceDivisor(): number;
  6767. /**
  6768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6769. * @param data defines the data to store
  6770. */
  6771. create(data?: DataArray): void;
  6772. /**
  6773. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6774. * This function will create a new buffer if the current one is not updatable
  6775. * @param data defines the data to store
  6776. */
  6777. update(data: DataArray): void;
  6778. /**
  6779. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6780. * Returns the directly updated WebGLBuffer.
  6781. * @param data the new data
  6782. * @param offset the new offset
  6783. * @param useBytes set to true if the offset is in bytes
  6784. */
  6785. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6786. /**
  6787. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6788. */
  6789. dispose(): void;
  6790. /**
  6791. * Enumerates each value of this vertex buffer as numbers.
  6792. * @param count the number of values to enumerate
  6793. * @param callback the callback function called for each value
  6794. */
  6795. forEach(count: number, callback: (value: number, index: number) => void): void;
  6796. /**
  6797. * Positions
  6798. */
  6799. static readonly PositionKind: string;
  6800. /**
  6801. * Normals
  6802. */
  6803. static readonly NormalKind: string;
  6804. /**
  6805. * Tangents
  6806. */
  6807. static readonly TangentKind: string;
  6808. /**
  6809. * Texture coordinates
  6810. */
  6811. static readonly UVKind: string;
  6812. /**
  6813. * Texture coordinates 2
  6814. */
  6815. static readonly UV2Kind: string;
  6816. /**
  6817. * Texture coordinates 3
  6818. */
  6819. static readonly UV3Kind: string;
  6820. /**
  6821. * Texture coordinates 4
  6822. */
  6823. static readonly UV4Kind: string;
  6824. /**
  6825. * Texture coordinates 5
  6826. */
  6827. static readonly UV5Kind: string;
  6828. /**
  6829. * Texture coordinates 6
  6830. */
  6831. static readonly UV6Kind: string;
  6832. /**
  6833. * Colors
  6834. */
  6835. static readonly ColorKind: string;
  6836. /**
  6837. * Matrix indices (for bones)
  6838. */
  6839. static readonly MatricesIndicesKind: string;
  6840. /**
  6841. * Matrix weights (for bones)
  6842. */
  6843. static readonly MatricesWeightsKind: string;
  6844. /**
  6845. * Additional matrix indices (for bones)
  6846. */
  6847. static readonly MatricesIndicesExtraKind: string;
  6848. /**
  6849. * Additional matrix weights (for bones)
  6850. */
  6851. static readonly MatricesWeightsExtraKind: string;
  6852. /**
  6853. * Deduces the stride given a kind.
  6854. * @param kind The kind string to deduce
  6855. * @returns The deduced stride
  6856. */
  6857. static DeduceStride(kind: string): number;
  6858. /**
  6859. * Gets the byte length of the given type.
  6860. * @param type the type
  6861. * @returns the number of bytes
  6862. */
  6863. static GetTypeByteLength(type: number): number;
  6864. /**
  6865. * Enumerates each value of the given parameters as numbers.
  6866. * @param data the data to enumerate
  6867. * @param byteOffset the byte offset of the data
  6868. * @param byteStride the byte stride of the data
  6869. * @param componentCount the number of components per element
  6870. * @param componentType the type of the component
  6871. * @param count the number of values to enumerate
  6872. * @param normalized whether the data is normalized
  6873. * @param callback the callback function called for each value
  6874. */
  6875. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6876. private static _GetFloatValue;
  6877. }
  6878. }
  6879. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6880. import { Vector3 } from "babylonjs/Maths/math.vector";
  6881. import { Mesh } from "babylonjs/Meshes/mesh";
  6882. /**
  6883. * The options Interface for creating a Capsule Mesh
  6884. */
  6885. export interface ICreateCapsuleOptions {
  6886. /** The Orientation of the capsule. Default : Vector3.Up() */
  6887. orientation?: Vector3;
  6888. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6889. subdivisions: number;
  6890. /** Number of cylindrical segments on the capsule. */
  6891. tessellation: number;
  6892. /** Height or Length of the capsule. */
  6893. height: number;
  6894. /** Radius of the capsule. */
  6895. radius: number;
  6896. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6897. capSubdivisions: number;
  6898. /** Overwrite for the top radius. */
  6899. radiusTop?: number;
  6900. /** Overwrite for the bottom radius. */
  6901. radiusBottom?: number;
  6902. /** Overwrite for the top capSubdivisions. */
  6903. topCapSubdivisions?: number;
  6904. /** Overwrite for the bottom capSubdivisions. */
  6905. bottomCapSubdivisions?: number;
  6906. }
  6907. /**
  6908. * Class containing static functions to help procedurally build meshes
  6909. */
  6910. export class CapsuleBuilder {
  6911. /**
  6912. * Creates a capsule or a pill mesh
  6913. * @param name defines the name of the mesh
  6914. * @param options The constructors options.
  6915. * @param scene The scene the mesh is scoped to.
  6916. * @returns Capsule Mesh
  6917. */
  6918. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6919. }
  6920. }
  6921. declare module "babylonjs/Collisions/intersectionInfo" {
  6922. import { Nullable } from "babylonjs/types";
  6923. /**
  6924. * @hidden
  6925. */
  6926. export class IntersectionInfo {
  6927. bu: Nullable<number>;
  6928. bv: Nullable<number>;
  6929. distance: number;
  6930. faceId: number;
  6931. subMeshId: number;
  6932. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingSphere" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6938. import { Plane } from "babylonjs/Maths/math.plane";
  6939. /**
  6940. * Class used to store bounding sphere information
  6941. */
  6942. export class BoundingSphere {
  6943. /**
  6944. * Gets the center of the bounding sphere in local space
  6945. */
  6946. readonly center: Vector3;
  6947. /**
  6948. * Radius of the bounding sphere in local space
  6949. */
  6950. radius: number;
  6951. /**
  6952. * Gets the center of the bounding sphere in world space
  6953. */
  6954. readonly centerWorld: Vector3;
  6955. /**
  6956. * Radius of the bounding sphere in world space
  6957. */
  6958. radiusWorld: number;
  6959. /**
  6960. * Gets the minimum vector in local space
  6961. */
  6962. readonly minimum: Vector3;
  6963. /**
  6964. * Gets the maximum vector in local space
  6965. */
  6966. readonly maximum: Vector3;
  6967. private _worldMatrix;
  6968. private static readonly TmpVector3;
  6969. /**
  6970. * Creates a new bounding sphere
  6971. * @param min defines the minimum vector (in local space)
  6972. * @param max defines the maximum vector (in local space)
  6973. * @param worldMatrix defines the new world matrix
  6974. */
  6975. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6976. /**
  6977. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6978. * @param min defines the new minimum vector (in local space)
  6979. * @param max defines the new maximum vector (in local space)
  6980. * @param worldMatrix defines the new world matrix
  6981. */
  6982. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Scale the current bounding sphere by applying a scale factor
  6985. * @param factor defines the scale factor to apply
  6986. * @returns the current bounding box
  6987. */
  6988. scale(factor: number): BoundingSphere;
  6989. /**
  6990. * Gets the world matrix of the bounding box
  6991. * @returns a matrix
  6992. */
  6993. getWorldMatrix(): DeepImmutable<Matrix>;
  6994. /** @hidden */
  6995. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Tests if the bounding sphere is intersecting the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if the bounding sphere center is in between the frustum planes.
  7004. * Used for optimistic fast inclusion.
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if the sphere center is in between the frustum planes
  7007. */
  7008. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding sphere
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding sphere
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Checks if two sphere intersct
  7017. * @param sphere0 sphere 0
  7018. * @param sphere1 sphere 1
  7019. * @returns true if the speres intersect
  7020. */
  7021. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7022. }
  7023. }
  7024. declare module "babylonjs/Culling/boundingBox" {
  7025. import { DeepImmutable } from "babylonjs/types";
  7026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7027. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7028. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding box information
  7032. */
  7033. export class BoundingBox implements ICullable {
  7034. /**
  7035. * Gets the 8 vectors representing the bounding box in local space
  7036. */
  7037. readonly vectors: Vector3[];
  7038. /**
  7039. * Gets the center of the bounding box in local space
  7040. */
  7041. readonly center: Vector3;
  7042. /**
  7043. * Gets the center of the bounding box in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Gets the extend size in local space
  7048. */
  7049. readonly extendSize: Vector3;
  7050. /**
  7051. * Gets the extend size in world space
  7052. */
  7053. readonly extendSizeWorld: Vector3;
  7054. /**
  7055. * Gets the OBB (object bounding box) directions
  7056. */
  7057. readonly directions: Vector3[];
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in world space
  7060. */
  7061. readonly vectorsWorld: Vector3[];
  7062. /**
  7063. * Gets the minimum vector in world space
  7064. */
  7065. readonly minimumWorld: Vector3;
  7066. /**
  7067. * Gets the maximum vector in world space
  7068. */
  7069. readonly maximumWorld: Vector3;
  7070. /**
  7071. * Gets the minimum vector in local space
  7072. */
  7073. readonly minimum: Vector3;
  7074. /**
  7075. * Gets the maximum vector in local space
  7076. */
  7077. readonly maximum: Vector3;
  7078. private _worldMatrix;
  7079. private static readonly TmpVector3;
  7080. /**
  7081. * @hidden
  7082. */
  7083. _tag: number;
  7084. /**
  7085. * Creates a new bounding box
  7086. * @param min defines the minimum vector (in local space)
  7087. * @param max defines the maximum vector (in local space)
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Scale the current bounding box by applying a scale factor
  7100. * @param factor defines the scale factor to apply
  7101. * @returns the current bounding box
  7102. */
  7103. scale(factor: number): BoundingBox;
  7104. /**
  7105. * Gets the world matrix of the bounding box
  7106. * @returns a matrix
  7107. */
  7108. getWorldMatrix(): DeepImmutable<Matrix>;
  7109. /** @hidden */
  7110. _update(world: DeepImmutable<Matrix>): void;
  7111. /**
  7112. * Tests if the bounding box is intersecting the frustum planes
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. /**
  7118. * Tests if the bounding box is entirely inside the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an inclusion
  7121. */
  7122. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if a point is inside the bounding box
  7125. * @param point defines the point to test
  7126. * @returns true if the point is inside the bounding box
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Tests if the bounding box intersects with a bounding sphere
  7131. * @param sphere defines the sphere to test
  7132. * @returns true if there is an intersection
  7133. */
  7134. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7135. /**
  7136. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7137. * @param min defines the min vector to use
  7138. * @param max defines the max vector to use
  7139. * @returns true if there is an intersection
  7140. */
  7141. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7142. /**
  7143. * Tests if two bounding boxes are intersections
  7144. * @param box0 defines the first box to test
  7145. * @param box1 defines the second box to test
  7146. * @returns true if there is an intersection
  7147. */
  7148. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7149. /**
  7150. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7151. * @param minPoint defines the minimum vector of the bounding box
  7152. * @param maxPoint defines the maximum vector of the bounding box
  7153. * @param sphereCenter defines the sphere center
  7154. * @param sphereRadius defines the sphere radius
  7155. * @returns true if there is an intersection
  7156. */
  7157. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7158. /**
  7159. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7161. * @param frustumPlanes defines the frustum planes to test
  7162. * @return true if there is an inclusion
  7163. */
  7164. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /**
  7166. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7167. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7168. * @param frustumPlanes defines the frustum planes to test
  7169. * @return true if there is an intersection
  7170. */
  7171. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. }
  7173. }
  7174. declare module "babylonjs/Collisions/collider" {
  7175. import { Nullable, IndicesArray } from "babylonjs/types";
  7176. import { Vector3 } from "babylonjs/Maths/math.vector";
  7177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7178. import { Plane } from "babylonjs/Maths/math.plane";
  7179. /** @hidden */
  7180. export class Collider {
  7181. /** Define if a collision was found */
  7182. collisionFound: boolean;
  7183. /**
  7184. * Define last intersection point in local space
  7185. */
  7186. intersectionPoint: Vector3;
  7187. /**
  7188. * Define last collided mesh
  7189. */
  7190. collidedMesh: Nullable<AbstractMesh>;
  7191. private _collisionPoint;
  7192. private _planeIntersectionPoint;
  7193. private _tempVector;
  7194. private _tempVector2;
  7195. private _tempVector3;
  7196. private _tempVector4;
  7197. private _edge;
  7198. private _baseToVertex;
  7199. private _destinationPoint;
  7200. private _slidePlaneNormal;
  7201. private _displacementVector;
  7202. /** @hidden */
  7203. _radius: Vector3;
  7204. /** @hidden */
  7205. _retry: number;
  7206. private _velocity;
  7207. private _basePoint;
  7208. private _epsilon;
  7209. /** @hidden */
  7210. _velocityWorldLength: number;
  7211. /** @hidden */
  7212. _basePointWorld: Vector3;
  7213. private _velocityWorld;
  7214. private _normalizedVelocity;
  7215. /** @hidden */
  7216. _initialVelocity: Vector3;
  7217. /** @hidden */
  7218. _initialPosition: Vector3;
  7219. private _nearestDistance;
  7220. private _collisionMask;
  7221. get collisionMask(): number;
  7222. set collisionMask(mask: number);
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. get slidePlaneNormal(): Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Plane } from "babylonjs/Maths/math.plane";
  7247. import { Collider } from "babylonjs/Collisions/collider";
  7248. /**
  7249. * Interface for cullable objects
  7250. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7251. */
  7252. export interface ICullable {
  7253. /**
  7254. * Checks if the object or part of the object is in the frustum
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isInFrustum(frustumPlanes: Plane[]): boolean;
  7259. /**
  7260. * Checks if a cullable object (mesh...) is in the camera frustum
  7261. * Unlike isInFrustum this cheks the full bounding box
  7262. * @param frustumPlanes Camera near/planes
  7263. * @returns true if the object is in frustum otherwise false
  7264. */
  7265. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7266. }
  7267. /**
  7268. * Info for a bounding data of a mesh
  7269. */
  7270. export class BoundingInfo implements ICullable {
  7271. /**
  7272. * Bounding box for the mesh
  7273. */
  7274. readonly boundingBox: BoundingBox;
  7275. /**
  7276. * Bounding sphere for the mesh
  7277. */
  7278. readonly boundingSphere: BoundingSphere;
  7279. private _isLocked;
  7280. private static readonly TmpVector3;
  7281. /**
  7282. * Constructs bounding info
  7283. * @param minimum min vector of the bounding box/sphere
  7284. * @param maximum max vector of the bounding box/sphere
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * min vector of the bounding box/sphere
  7297. */
  7298. get minimum(): Vector3;
  7299. /**
  7300. * max vector of the bounding box/sphere
  7301. */
  7302. get maximum(): Vector3;
  7303. /**
  7304. * If the info is locked and won't be updated to avoid perf overhead
  7305. */
  7306. get isLocked(): boolean;
  7307. set isLocked(value: boolean);
  7308. /**
  7309. * Updates the bounding sphere and box
  7310. * @param world world matrix to be used to update
  7311. */
  7312. update(world: DeepImmutable<Matrix>): void;
  7313. /**
  7314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7315. * @param center New center of the bounding info
  7316. * @param extend New extend of the bounding info
  7317. * @returns the current bounding info
  7318. */
  7319. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7320. /**
  7321. * Scale the current bounding info by applying a scale factor
  7322. * @param factor defines the scale factor to apply
  7323. * @returns the current bounding info
  7324. */
  7325. scale(factor: number): BoundingInfo;
  7326. /**
  7327. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7328. * @param frustumPlanes defines the frustum to test
  7329. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7330. * @returns true if the bounding info is in the frustum planes
  7331. */
  7332. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7333. /**
  7334. * Gets the world distance between the min and max points of the bounding box
  7335. */
  7336. get diagonalLength(): number;
  7337. /**
  7338. * Checks if a cullable object (mesh...) is in the camera frustum
  7339. * Unlike isInFrustum this cheks the full bounding box
  7340. * @param frustumPlanes Camera near/planes
  7341. * @returns true if the object is in frustum otherwise false
  7342. */
  7343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7344. /** @hidden */
  7345. _checkCollision(collider: Collider): boolean;
  7346. /**
  7347. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param point the point to check intersection with
  7350. * @returns if the point intersects
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7355. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7356. * @param boundingInfo the bounding info to check intersection with
  7357. * @param precise if the intersection should be done using OBB
  7358. * @returns if the bounding info intersects
  7359. */
  7360. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7361. }
  7362. }
  7363. declare module "babylonjs/Maths/math.functions" {
  7364. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7365. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7366. /**
  7367. * Extracts minimum and maximum values from a list of indexed positions
  7368. * @param positions defines the positions to use
  7369. * @param indices defines the indices to the positions
  7370. * @param indexStart defines the start index
  7371. * @param indexCount defines the end index
  7372. * @param bias defines bias value to add to the result
  7373. * @return minimum and maximum values
  7374. */
  7375. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7376. minimum: Vector3;
  7377. maximum: Vector3;
  7378. };
  7379. /**
  7380. * Extracts minimum and maximum values from a list of positions
  7381. * @param positions defines the positions to use
  7382. * @param start defines the start index in the positions array
  7383. * @param count defines the number of positions to handle
  7384. * @param bias defines bias value to add to the result
  7385. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7386. * @return minimum and maximum values
  7387. */
  7388. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7389. minimum: Vector3;
  7390. maximum: Vector3;
  7391. };
  7392. }
  7393. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7395. /** @hidden */
  7396. export class WebGLDataBuffer extends DataBuffer {
  7397. private _buffer;
  7398. constructor(resource: WebGLBuffer);
  7399. get underlyingResource(): any;
  7400. }
  7401. }
  7402. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7403. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7404. import { Nullable } from "babylonjs/types";
  7405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7406. /** @hidden */
  7407. export class WebGLPipelineContext implements IPipelineContext {
  7408. engine: ThinEngine;
  7409. program: Nullable<WebGLProgram>;
  7410. context?: WebGLRenderingContext;
  7411. vertexShader?: WebGLShader;
  7412. fragmentShader?: WebGLShader;
  7413. isParallelCompiled: boolean;
  7414. onCompiled?: () => void;
  7415. transformFeedback?: WebGLTransformFeedback | null;
  7416. vertexCompilationError: Nullable<string>;
  7417. fragmentCompilationError: Nullable<string>;
  7418. programLinkError: Nullable<string>;
  7419. programValidationError: Nullable<string>;
  7420. get isAsync(): boolean;
  7421. get isReady(): boolean;
  7422. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7423. _getVertexShaderCode(): string | null;
  7424. _getFragmentShaderCode(): string | null;
  7425. }
  7426. }
  7427. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7428. import { FloatArray, Nullable } from "babylonjs/types";
  7429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7431. module "babylonjs/Engines/thinEngine" {
  7432. interface ThinEngine {
  7433. /**
  7434. * Create an uniform buffer
  7435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7436. * @param elements defines the content of the uniform buffer
  7437. * @returns the webGL uniform buffer
  7438. */
  7439. createUniformBuffer(elements: FloatArray): DataBuffer;
  7440. /**
  7441. * Create a dynamic uniform buffer
  7442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7443. * @param elements defines the content of the uniform buffer
  7444. * @returns the webGL uniform buffer
  7445. */
  7446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7447. /**
  7448. * Update an existing uniform buffer
  7449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7450. * @param uniformBuffer defines the target uniform buffer
  7451. * @param elements defines the content to update
  7452. * @param offset defines the offset in the uniform buffer where update should start
  7453. * @param count defines the size of the data to update
  7454. */
  7455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7456. /**
  7457. * Bind an uniform buffer to the current webGL context
  7458. * @param buffer defines the buffer to bind
  7459. */
  7460. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7461. /**
  7462. * Bind a buffer to the current webGL context at a given location
  7463. * @param buffer defines the buffer to bind
  7464. * @param location defines the index where to bind the buffer
  7465. */
  7466. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7467. /**
  7468. * Bind a specific block at a given index in a specific shader program
  7469. * @param pipelineContext defines the pipeline context to use
  7470. * @param blockName defines the block name
  7471. * @param index defines the index where to bind the block
  7472. */
  7473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7474. }
  7475. }
  7476. }
  7477. declare module "babylonjs/Materials/uniformBuffer" {
  7478. import { Nullable, FloatArray } from "babylonjs/types";
  7479. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7480. import { Engine } from "babylonjs/Engines/engine";
  7481. import { Effect } from "babylonjs/Materials/effect";
  7482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7484. import { Color3 } from "babylonjs/Maths/math.color";
  7485. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7486. /**
  7487. * Uniform buffer objects.
  7488. *
  7489. * Handles blocks of uniform on the GPU.
  7490. *
  7491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7492. *
  7493. * For more information, please refer to :
  7494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7495. */
  7496. export class UniformBuffer {
  7497. private _engine;
  7498. private _buffer;
  7499. private _data;
  7500. private _bufferData;
  7501. private _dynamic?;
  7502. private _uniformLocations;
  7503. private _uniformSizes;
  7504. private _uniformLocationPointer;
  7505. private _needSync;
  7506. private _noUBO;
  7507. private _currentEffect;
  7508. /** @hidden */
  7509. _alreadyBound: boolean;
  7510. private static _MAX_UNIFORM_SIZE;
  7511. private static _tempBuffer;
  7512. /**
  7513. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7518. /**
  7519. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7524. /**
  7525. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7530. /**
  7531. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7536. /**
  7537. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7542. /**
  7543. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7548. /**
  7549. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7554. /**
  7555. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7560. /**
  7561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateVector4: (name: string, vector: Vector4) => void;
  7566. /**
  7567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7578. /**
  7579. * Instantiates a new Uniform buffer objects.
  7580. *
  7581. * Handles blocks of uniform on the GPU.
  7582. *
  7583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7584. *
  7585. * For more information, please refer to :
  7586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7587. * @param engine Define the engine the buffer is associated with
  7588. * @param data Define the data contained in the buffer
  7589. * @param dynamic Define if the buffer is updatable
  7590. */
  7591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7592. /**
  7593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7594. * or just falling back on setUniformXXX calls.
  7595. */
  7596. get useUbo(): boolean;
  7597. /**
  7598. * Indicates if the WebGL underlying uniform buffer is in sync
  7599. * with the javascript cache data.
  7600. */
  7601. get isSync(): boolean;
  7602. /**
  7603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7604. * Also, a dynamic UniformBuffer will disable cache verification and always
  7605. * update the underlying WebGL uniform buffer to the GPU.
  7606. * @returns if Dynamic, otherwise false
  7607. */
  7608. isDynamic(): boolean;
  7609. /**
  7610. * The data cache on JS side.
  7611. * @returns the underlying data as a float array
  7612. */
  7613. getData(): Float32Array;
  7614. /**
  7615. * The underlying WebGL Uniform buffer.
  7616. * @returns the webgl buffer
  7617. */
  7618. getBuffer(): Nullable<DataBuffer>;
  7619. /**
  7620. * std140 layout specifies how to align data within an UBO structure.
  7621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7622. * for specs.
  7623. */
  7624. private _fillAlignment;
  7625. /**
  7626. * Adds an uniform in the buffer.
  7627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7628. * for the layout to be correct !
  7629. * @param name Name of the uniform, as used in the uniform block in the shader.
  7630. * @param size Data size, or data directly.
  7631. */
  7632. addUniform(name: string, size: number | number[]): void;
  7633. /**
  7634. * Adds a Matrix 4x4 to the uniform buffer.
  7635. * @param name Name of the uniform, as used in the uniform block in the shader.
  7636. * @param mat A 4x4 matrix.
  7637. */
  7638. addMatrix(name: string, mat: Matrix): void;
  7639. /**
  7640. * Adds a vec2 to the uniform buffer.
  7641. * @param name Name of the uniform, as used in the uniform block in the shader.
  7642. * @param x Define the x component value of the vec2
  7643. * @param y Define the y component value of the vec2
  7644. */
  7645. addFloat2(name: string, x: number, y: number): void;
  7646. /**
  7647. * Adds a vec3 to the uniform buffer.
  7648. * @param name Name of the uniform, as used in the uniform block in the shader.
  7649. * @param x Define the x component value of the vec3
  7650. * @param y Define the y component value of the vec3
  7651. * @param z Define the z component value of the vec3
  7652. */
  7653. addFloat3(name: string, x: number, y: number, z: number): void;
  7654. /**
  7655. * Adds a vec3 to the uniform buffer.
  7656. * @param name Name of the uniform, as used in the uniform block in the shader.
  7657. * @param color Define the vec3 from a Color
  7658. */
  7659. addColor3(name: string, color: Color3): void;
  7660. /**
  7661. * Adds a vec4 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. * @param color Define the rgb components from a Color
  7664. * @param alpha Define the a component of the vec4
  7665. */
  7666. addColor4(name: string, color: Color3, alpha: number): void;
  7667. /**
  7668. * Adds a vec3 to the uniform buffer.
  7669. * @param name Name of the uniform, as used in the uniform block in the shader.
  7670. * @param vector Define the vec3 components from a Vector
  7671. */
  7672. addVector3(name: string, vector: Vector3): void;
  7673. /**
  7674. * Adds a Matrix 3x3 to the uniform buffer.
  7675. * @param name Name of the uniform, as used in the uniform block in the shader.
  7676. */
  7677. addMatrix3x3(name: string): void;
  7678. /**
  7679. * Adds a Matrix 2x2 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. */
  7682. addMatrix2x2(name: string): void;
  7683. /**
  7684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7685. */
  7686. create(): void;
  7687. /** @hidden */
  7688. _rebuild(): void;
  7689. /**
  7690. * Updates the WebGL Uniform Buffer on the GPU.
  7691. * If the `dynamic` flag is set to true, no cache comparison is done.
  7692. * Otherwise, the buffer will be updated only if the cache differs.
  7693. */
  7694. update(): void;
  7695. /**
  7696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7698. * @param data Define the flattened data
  7699. * @param size Define the size of the data.
  7700. */
  7701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7702. private _valueCache;
  7703. private _cacheMatrix;
  7704. private _updateMatrix3x3ForUniform;
  7705. private _updateMatrix3x3ForEffect;
  7706. private _updateMatrix2x2ForEffect;
  7707. private _updateMatrix2x2ForUniform;
  7708. private _updateFloatForEffect;
  7709. private _updateFloatForUniform;
  7710. private _updateFloat2ForEffect;
  7711. private _updateFloat2ForUniform;
  7712. private _updateFloat3ForEffect;
  7713. private _updateFloat3ForUniform;
  7714. private _updateFloat4ForEffect;
  7715. private _updateFloat4ForUniform;
  7716. private _updateMatrixForEffect;
  7717. private _updateMatrixForUniform;
  7718. private _updateVector3ForEffect;
  7719. private _updateVector3ForUniform;
  7720. private _updateVector4ForEffect;
  7721. private _updateVector4ForUniform;
  7722. private _updateColor3ForEffect;
  7723. private _updateColor3ForUniform;
  7724. private _updateColor4ForEffect;
  7725. private _updateColor4ForUniform;
  7726. /**
  7727. * Sets a sampler uniform on the effect.
  7728. * @param name Define the name of the sampler.
  7729. * @param texture Define the texture to set in the sampler
  7730. */
  7731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7732. /**
  7733. * Directly updates the value of the uniform in the cache AND on the GPU.
  7734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7735. * @param data Define the flattened data
  7736. */
  7737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7738. /**
  7739. * Binds this uniform buffer to an effect.
  7740. * @param effect Define the effect to bind the buffer to
  7741. * @param name Name of the uniform block in the shader.
  7742. */
  7743. bindToEffect(effect: Effect, name: string): void;
  7744. /**
  7745. * Disposes the uniform buffer.
  7746. */
  7747. dispose(): void;
  7748. }
  7749. }
  7750. declare module "babylonjs/Misc/iInspectable" {
  7751. /**
  7752. * Enum that determines the text-wrapping mode to use.
  7753. */
  7754. export enum InspectableType {
  7755. /**
  7756. * Checkbox for booleans
  7757. */
  7758. Checkbox = 0,
  7759. /**
  7760. * Sliders for numbers
  7761. */
  7762. Slider = 1,
  7763. /**
  7764. * Vector3
  7765. */
  7766. Vector3 = 2,
  7767. /**
  7768. * Quaternions
  7769. */
  7770. Quaternion = 3,
  7771. /**
  7772. * Color3
  7773. */
  7774. Color3 = 4,
  7775. /**
  7776. * String
  7777. */
  7778. String = 5
  7779. }
  7780. /**
  7781. * Interface used to define custom inspectable properties.
  7782. * This interface is used by the inspector to display custom property grids
  7783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7784. */
  7785. export interface IInspectable {
  7786. /**
  7787. * Gets the label to display
  7788. */
  7789. label: string;
  7790. /**
  7791. * Gets the name of the property to edit
  7792. */
  7793. propertyName: string;
  7794. /**
  7795. * Gets the type of the editor to use
  7796. */
  7797. type: InspectableType;
  7798. /**
  7799. * Gets the minimum value of the property when using in "slider" mode
  7800. */
  7801. min?: number;
  7802. /**
  7803. * Gets the maximum value of the property when using in "slider" mode
  7804. */
  7805. max?: number;
  7806. /**
  7807. * Gets the setp to use when using in "slider" mode
  7808. */
  7809. step?: number;
  7810. }
  7811. }
  7812. declare module "babylonjs/Misc/timingTools" {
  7813. /**
  7814. * Class used to provide helper for timing
  7815. */
  7816. export class TimingTools {
  7817. /**
  7818. * Polyfill for setImmediate
  7819. * @param action defines the action to execute after the current execution block
  7820. */
  7821. static SetImmediate(action: () => void): void;
  7822. }
  7823. }
  7824. declare module "babylonjs/Misc/instantiationTools" {
  7825. /**
  7826. * Class used to enable instatition of objects by class name
  7827. */
  7828. export class InstantiationTools {
  7829. /**
  7830. * Use this object to register external classes like custom textures or material
  7831. * to allow the laoders to instantiate them
  7832. */
  7833. static RegisteredExternalClasses: {
  7834. [key: string]: Object;
  7835. };
  7836. /**
  7837. * Tries to instantiate a new object from a given class name
  7838. * @param className defines the class name to instantiate
  7839. * @returns the new object or null if the system was not able to do the instantiation
  7840. */
  7841. static Instantiate(className: string): any;
  7842. }
  7843. }
  7844. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7845. /**
  7846. * Define options used to create a depth texture
  7847. */
  7848. export class DepthTextureCreationOptions {
  7849. /** Specifies whether or not a stencil should be allocated in the texture */
  7850. generateStencil?: boolean;
  7851. /** Specifies whether or not bilinear filtering is enable on the texture */
  7852. bilinearFiltering?: boolean;
  7853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7854. comparisonFunction?: number;
  7855. /** Specifies if the created texture is a cube texture */
  7856. isCube?: boolean;
  7857. }
  7858. }
  7859. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7861. import { Nullable } from "babylonjs/types";
  7862. import { Scene } from "babylonjs/scene";
  7863. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7864. module "babylonjs/Engines/thinEngine" {
  7865. interface ThinEngine {
  7866. /**
  7867. * Creates a depth stencil cube texture.
  7868. * This is only available in WebGL 2.
  7869. * @param size The size of face edge in the cube texture.
  7870. * @param options The options defining the cube texture.
  7871. * @returns The cube texture
  7872. */
  7873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7874. /**
  7875. * Creates a cube texture
  7876. * @param rootUrl defines the url where the files to load is located
  7877. * @param scene defines the current scene
  7878. * @param files defines the list of files to load (1 per face)
  7879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7880. * @param onLoad defines an optional callback raised when the texture is loaded
  7881. * @param onError defines an optional callback raised if there is an issue to load the texture
  7882. * @param format defines the format of the data
  7883. * @param forcedExtension defines the extension to use to pick the right loader
  7884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7888. * @returns the cube texture as an InternalTexture
  7889. */
  7890. 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;
  7891. /**
  7892. * Creates a cube texture
  7893. * @param rootUrl defines the url where the files to load is located
  7894. * @param scene defines the current scene
  7895. * @param files defines the list of files to load (1 per face)
  7896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7897. * @param onLoad defines an optional callback raised when the texture is loaded
  7898. * @param onError defines an optional callback raised if there is an issue to load the texture
  7899. * @param format defines the format of the data
  7900. * @param forcedExtension defines the extension to use to pick the right loader
  7901. * @returns the cube texture as an InternalTexture
  7902. */
  7903. 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;
  7904. /**
  7905. * Creates a cube texture
  7906. * @param rootUrl defines the url where the files to load is located
  7907. * @param scene defines the current scene
  7908. * @param files defines the list of files to load (1 per face)
  7909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7910. * @param onLoad defines an optional callback raised when the texture is loaded
  7911. * @param onError defines an optional callback raised if there is an issue to load the texture
  7912. * @param format defines the format of the data
  7913. * @param forcedExtension defines the extension to use to pick the right loader
  7914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7917. * @returns the cube texture as an InternalTexture
  7918. */
  7919. 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;
  7920. /** @hidden */
  7921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7922. /** @hidden */
  7923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7924. /** @hidden */
  7925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7926. /** @hidden */
  7927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7928. /**
  7929. * @hidden
  7930. */
  7931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7932. }
  7933. }
  7934. }
  7935. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7936. import { Nullable } from "babylonjs/types";
  7937. import { Scene } from "babylonjs/scene";
  7938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7941. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7942. import { Observable } from "babylonjs/Misc/observable";
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * Observable triggered once the texture has been loaded.
  7950. */
  7951. onLoadObservable: Observable<CubeTexture>;
  7952. /**
  7953. * The url of the texture
  7954. */
  7955. url: string;
  7956. /**
  7957. * Gets or sets the center of the bounding box associated with the cube texture.
  7958. * It must define where the camera used to render the texture was set
  7959. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7960. */
  7961. boundingBoxPosition: Vector3;
  7962. private _boundingBoxSize;
  7963. /**
  7964. * Gets or sets the size of the bounding box associated with the cube texture
  7965. * When defined, the cubemap will switch to local mode
  7966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7967. * @example https://www.babylonjs-playground.com/#RNASML
  7968. */
  7969. set boundingBoxSize(value: Vector3);
  7970. /**
  7971. * Returns the bounding box size
  7972. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7973. */
  7974. get boundingBoxSize(): Vector3;
  7975. protected _rotationY: number;
  7976. /**
  7977. * Sets texture matrix rotation angle around Y axis in radians.
  7978. */
  7979. set rotationY(value: number);
  7980. /**
  7981. * Gets texture matrix rotation angle around Y axis radians.
  7982. */
  7983. get rotationY(): number;
  7984. /**
  7985. * Are mip maps generated for this texture or not.
  7986. */
  7987. get noMipmap(): boolean;
  7988. private _noMipmap;
  7989. private _files;
  7990. protected _forcedExtension: Nullable<string>;
  7991. private _extensions;
  7992. private _textureMatrix;
  7993. private _format;
  7994. private _createPolynomials;
  7995. /**
  7996. * Creates a cube texture from an array of image urls
  7997. * @param files defines an array of image urls
  7998. * @param scene defines the hosting scene
  7999. * @param noMipmap specifies if mip maps are not used
  8000. * @returns a cube texture
  8001. */
  8002. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8003. /**
  8004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8005. * @param url defines the url of the prefiltered texture
  8006. * @param scene defines the scene the texture is attached to
  8007. * @param forcedExtension defines the extension of the file if different from the url
  8008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8009. * @return the prefiltered texture
  8010. */
  8011. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8012. /**
  8013. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8014. * as prefiltered data.
  8015. * @param rootUrl defines the url of the texture or the root name of the six images
  8016. * @param null defines the scene or engine the texture is attached to
  8017. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8018. * @param noMipmap defines if mipmaps should be created or not
  8019. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8020. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8021. * @param onError defines a callback triggered in case of error during load
  8022. * @param format defines the internal format to use for the texture once loaded
  8023. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8024. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8025. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8028. * @return the cube texture
  8029. */
  8030. 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);
  8031. /**
  8032. * Get the current class name of the texture useful for serialization or dynamic coding.
  8033. * @returns "CubeTexture"
  8034. */
  8035. getClassName(): string;
  8036. /**
  8037. * Update the url (and optional buffer) of this texture if url was null during construction.
  8038. * @param url the url of the texture
  8039. * @param forcedExtension defines the extension to use
  8040. * @param onLoad callback called when the texture is loaded (defaults to null)
  8041. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8042. */
  8043. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8044. /**
  8045. * Delays loading of the cube texture
  8046. * @param forcedExtension defines the extension to use
  8047. */
  8048. delayLoad(forcedExtension?: string): void;
  8049. /**
  8050. * Returns the reflection texture matrix
  8051. * @returns the reflection texture matrix
  8052. */
  8053. getReflectionTextureMatrix(): Matrix;
  8054. /**
  8055. * Sets the reflection texture matrix
  8056. * @param value Reflection texture matrix
  8057. */
  8058. setReflectionTextureMatrix(value: Matrix): void;
  8059. /**
  8060. * Parses text to create a cube texture
  8061. * @param parsedTexture define the serialized text to read from
  8062. * @param scene defines the hosting scene
  8063. * @param rootUrl defines the root url of the cube texture
  8064. * @returns a cube texture
  8065. */
  8066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8067. /**
  8068. * Makes a clone, or deep copy, of the cube texture
  8069. * @returns a new cube texture
  8070. */
  8071. clone(): CubeTexture;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/materialDefines" {
  8075. /**
  8076. * Manages the defines for the Material
  8077. */
  8078. export class MaterialDefines {
  8079. /** @hidden */
  8080. protected _keys: string[];
  8081. private _isDirty;
  8082. /** @hidden */
  8083. _renderId: number;
  8084. /** @hidden */
  8085. _areLightsDirty: boolean;
  8086. /** @hidden */
  8087. _areLightsDisposed: boolean;
  8088. /** @hidden */
  8089. _areAttributesDirty: boolean;
  8090. /** @hidden */
  8091. _areTexturesDirty: boolean;
  8092. /** @hidden */
  8093. _areFresnelDirty: boolean;
  8094. /** @hidden */
  8095. _areMiscDirty: boolean;
  8096. /** @hidden */
  8097. _areImageProcessingDirty: boolean;
  8098. /** @hidden */
  8099. _normals: boolean;
  8100. /** @hidden */
  8101. _uvs: boolean;
  8102. /** @hidden */
  8103. _needNormals: boolean;
  8104. /** @hidden */
  8105. _needUVs: boolean;
  8106. [id: string]: any;
  8107. /**
  8108. * Specifies if the material needs to be re-calculated
  8109. */
  8110. get isDirty(): boolean;
  8111. /**
  8112. * Marks the material to indicate that it has been re-calculated
  8113. */
  8114. markAsProcessed(): void;
  8115. /**
  8116. * Marks the material to indicate that it needs to be re-calculated
  8117. */
  8118. markAsUnprocessed(): void;
  8119. /**
  8120. * Marks the material to indicate all of its defines need to be re-calculated
  8121. */
  8122. markAllAsDirty(): void;
  8123. /**
  8124. * Marks the material to indicate that image processing needs to be re-calculated
  8125. */
  8126. markAsImageProcessingDirty(): void;
  8127. /**
  8128. * Marks the material to indicate the lights need to be re-calculated
  8129. * @param disposed Defines whether the light is dirty due to dispose or not
  8130. */
  8131. markAsLightDirty(disposed?: boolean): void;
  8132. /**
  8133. * Marks the attribute state as changed
  8134. */
  8135. markAsAttributesDirty(): void;
  8136. /**
  8137. * Marks the texture state as changed
  8138. */
  8139. markAsTexturesDirty(): void;
  8140. /**
  8141. * Marks the fresnel state as changed
  8142. */
  8143. markAsFresnelDirty(): void;
  8144. /**
  8145. * Marks the misc state as changed
  8146. */
  8147. markAsMiscDirty(): void;
  8148. /**
  8149. * Rebuilds the material defines
  8150. */
  8151. rebuild(): void;
  8152. /**
  8153. * Specifies if two material defines are equal
  8154. * @param other - A material define instance to compare to
  8155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8156. */
  8157. isEqual(other: MaterialDefines): boolean;
  8158. /**
  8159. * Clones this instance's defines to another instance
  8160. * @param other - material defines to clone values to
  8161. */
  8162. cloneTo(other: MaterialDefines): void;
  8163. /**
  8164. * Resets the material define values
  8165. */
  8166. reset(): void;
  8167. /**
  8168. * Converts the material define values to a string
  8169. * @returns - String of material define information
  8170. */
  8171. toString(): string;
  8172. }
  8173. }
  8174. declare module "babylonjs/Materials/colorCurves" {
  8175. import { Effect } from "babylonjs/Materials/effect";
  8176. /**
  8177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8179. * 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;
  8180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8181. */
  8182. export class ColorCurves {
  8183. private _dirty;
  8184. private _tempColor;
  8185. private _globalCurve;
  8186. private _highlightsCurve;
  8187. private _midtonesCurve;
  8188. private _shadowsCurve;
  8189. private _positiveCurve;
  8190. private _negativeCurve;
  8191. private _globalHue;
  8192. private _globalDensity;
  8193. private _globalSaturation;
  8194. private _globalExposure;
  8195. /**
  8196. * Gets the global Hue value.
  8197. * 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).
  8198. */
  8199. get globalHue(): number;
  8200. /**
  8201. * Sets the global Hue value.
  8202. * 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).
  8203. */
  8204. set globalHue(value: number);
  8205. /**
  8206. * Gets the global Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get globalDensity(): number;
  8211. /**
  8212. * Sets the global Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set globalDensity(value: number);
  8217. /**
  8218. * Gets the global Saturation value.
  8219. * 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.
  8220. */
  8221. get globalSaturation(): number;
  8222. /**
  8223. * Sets the global Saturation value.
  8224. * 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.
  8225. */
  8226. set globalSaturation(value: number);
  8227. /**
  8228. * Gets the global Exposure value.
  8229. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8230. */
  8231. get globalExposure(): number;
  8232. /**
  8233. * Sets the global Exposure value.
  8234. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8235. */
  8236. set globalExposure(value: number);
  8237. private _highlightsHue;
  8238. private _highlightsDensity;
  8239. private _highlightsSaturation;
  8240. private _highlightsExposure;
  8241. /**
  8242. * Gets the highlights Hue value.
  8243. * 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).
  8244. */
  8245. get highlightsHue(): number;
  8246. /**
  8247. * Sets the highlights Hue value.
  8248. * 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).
  8249. */
  8250. set highlightsHue(value: number);
  8251. /**
  8252. * Gets the highlights Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. get highlightsDensity(): number;
  8257. /**
  8258. * Sets the highlights Density value.
  8259. * 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.
  8260. * Values less than zero provide a filter of opposite hue.
  8261. */
  8262. set highlightsDensity(value: number);
  8263. /**
  8264. * Gets the highlights Saturation value.
  8265. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8266. */
  8267. get highlightsSaturation(): number;
  8268. /**
  8269. * Sets the highlights Saturation value.
  8270. * 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.
  8271. */
  8272. set highlightsSaturation(value: number);
  8273. /**
  8274. * Gets the highlights Exposure value.
  8275. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8276. */
  8277. get highlightsExposure(): number;
  8278. /**
  8279. * Sets the highlights Exposure value.
  8280. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8281. */
  8282. set highlightsExposure(value: number);
  8283. private _midtonesHue;
  8284. private _midtonesDensity;
  8285. private _midtonesSaturation;
  8286. private _midtonesExposure;
  8287. /**
  8288. * Gets the midtones Hue value.
  8289. * 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).
  8290. */
  8291. get midtonesHue(): number;
  8292. /**
  8293. * Sets the midtones Hue value.
  8294. * 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).
  8295. */
  8296. set midtonesHue(value: number);
  8297. /**
  8298. * Gets the midtones Density value.
  8299. * 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.
  8300. * Values less than zero provide a filter of opposite hue.
  8301. */
  8302. get midtonesDensity(): number;
  8303. /**
  8304. * Sets the midtones Density value.
  8305. * 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.
  8306. * Values less than zero provide a filter of opposite hue.
  8307. */
  8308. set midtonesDensity(value: number);
  8309. /**
  8310. * Gets the midtones Saturation value.
  8311. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8312. */
  8313. get midtonesSaturation(): number;
  8314. /**
  8315. * Sets the midtones Saturation value.
  8316. * 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.
  8317. */
  8318. set midtonesSaturation(value: number);
  8319. /**
  8320. * Gets the midtones Exposure value.
  8321. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8322. */
  8323. get midtonesExposure(): number;
  8324. /**
  8325. * Sets the midtones Exposure value.
  8326. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8327. */
  8328. set midtonesExposure(value: number);
  8329. private _shadowsHue;
  8330. private _shadowsDensity;
  8331. private _shadowsSaturation;
  8332. private _shadowsExposure;
  8333. /**
  8334. * Gets the shadows Hue value.
  8335. * 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).
  8336. */
  8337. get shadowsHue(): number;
  8338. /**
  8339. * Sets the shadows Hue value.
  8340. * 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).
  8341. */
  8342. set shadowsHue(value: number);
  8343. /**
  8344. * Gets the shadows Density value.
  8345. * 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.
  8346. * Values less than zero provide a filter of opposite hue.
  8347. */
  8348. get shadowsDensity(): number;
  8349. /**
  8350. * Sets the shadows Density value.
  8351. * 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.
  8352. * Values less than zero provide a filter of opposite hue.
  8353. */
  8354. set shadowsDensity(value: number);
  8355. /**
  8356. * Gets the shadows Saturation value.
  8357. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8358. */
  8359. get shadowsSaturation(): number;
  8360. /**
  8361. * Sets the shadows Saturation value.
  8362. * 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.
  8363. */
  8364. set shadowsSaturation(value: number);
  8365. /**
  8366. * Gets the shadows Exposure value.
  8367. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8368. */
  8369. get shadowsExposure(): number;
  8370. /**
  8371. * Sets the shadows Exposure value.
  8372. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8373. */
  8374. set shadowsExposure(value: number);
  8375. /**
  8376. * Returns the class name
  8377. * @returns The class name
  8378. */
  8379. getClassName(): string;
  8380. /**
  8381. * Binds the color curves to the shader.
  8382. * @param colorCurves The color curve to bind
  8383. * @param effect The effect to bind to
  8384. * @param positiveUniform The positive uniform shader parameter
  8385. * @param neutralUniform The neutral uniform shader parameter
  8386. * @param negativeUniform The negative uniform shader parameter
  8387. */
  8388. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8389. /**
  8390. * Prepare the list of uniforms associated with the ColorCurves effects.
  8391. * @param uniformsList The list of uniforms used in the effect
  8392. */
  8393. static PrepareUniforms(uniformsList: string[]): void;
  8394. /**
  8395. * Returns color grading data based on a hue, density, saturation and exposure value.
  8396. * @param filterHue The hue of the color filter.
  8397. * @param filterDensity The density of the color filter.
  8398. * @param saturation The saturation.
  8399. * @param exposure The exposure.
  8400. * @param result The result data container.
  8401. */
  8402. private getColorGradingDataToRef;
  8403. /**
  8404. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8405. * @param value The input slider value in range [-100,100].
  8406. * @returns Adjusted value.
  8407. */
  8408. private static applyColorGradingSliderNonlinear;
  8409. /**
  8410. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8411. * @param hue The hue (H) input.
  8412. * @param saturation The saturation (S) input.
  8413. * @param brightness The brightness (B) input.
  8414. * @result An RGBA color represented as Vector4.
  8415. */
  8416. private static fromHSBToRef;
  8417. /**
  8418. * Returns a value clamped between min and max
  8419. * @param value The value to clamp
  8420. * @param min The minimum of value
  8421. * @param max The maximum of value
  8422. * @returns The clamped value.
  8423. */
  8424. private static clamp;
  8425. /**
  8426. * Clones the current color curve instance.
  8427. * @return The cloned curves
  8428. */
  8429. clone(): ColorCurves;
  8430. /**
  8431. * Serializes the current color curve instance to a json representation.
  8432. * @return a JSON representation
  8433. */
  8434. serialize(): any;
  8435. /**
  8436. * Parses the color curve from a json representation.
  8437. * @param source the JSON source to parse
  8438. * @return The parsed curves
  8439. */
  8440. static Parse(source: any): ColorCurves;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8444. import { Observable } from "babylonjs/Misc/observable";
  8445. import { Nullable } from "babylonjs/types";
  8446. import { Color4 } from "babylonjs/Maths/math.color";
  8447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8448. import { Effect } from "babylonjs/Materials/effect";
  8449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8450. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8451. /**
  8452. * Interface to follow in your material defines to integrate easily the
  8453. * Image proccessing functions.
  8454. * @hidden
  8455. */
  8456. export interface IImageProcessingConfigurationDefines {
  8457. IMAGEPROCESSING: boolean;
  8458. VIGNETTE: boolean;
  8459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8460. VIGNETTEBLENDMODEOPAQUE: boolean;
  8461. TONEMAPPING: boolean;
  8462. TONEMAPPING_ACES: boolean;
  8463. CONTRAST: boolean;
  8464. EXPOSURE: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. }
  8472. /**
  8473. * @hidden
  8474. */
  8475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8476. IMAGEPROCESSING: boolean;
  8477. VIGNETTE: boolean;
  8478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8479. VIGNETTEBLENDMODEOPAQUE: boolean;
  8480. TONEMAPPING: boolean;
  8481. TONEMAPPING_ACES: boolean;
  8482. CONTRAST: boolean;
  8483. COLORCURVES: boolean;
  8484. COLORGRADING: boolean;
  8485. COLORGRADING3D: boolean;
  8486. SAMPLER3DGREENDEPTH: boolean;
  8487. SAMPLER3DBGRMAP: boolean;
  8488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8489. EXPOSURE: boolean;
  8490. constructor();
  8491. }
  8492. /**
  8493. * This groups together the common properties used for image processing either in direct forward pass
  8494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8495. * or not.
  8496. */
  8497. export class ImageProcessingConfiguration {
  8498. /**
  8499. * Default tone mapping applied in BabylonJS.
  8500. */
  8501. static readonly TONEMAPPING_STANDARD: number;
  8502. /**
  8503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8504. * to other engines rendering to increase portability.
  8505. */
  8506. static readonly TONEMAPPING_ACES: number;
  8507. /**
  8508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8509. */
  8510. colorCurves: Nullable<ColorCurves>;
  8511. private _colorCurvesEnabled;
  8512. /**
  8513. * Gets wether the color curves effect is enabled.
  8514. */
  8515. get colorCurvesEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color curves effect is enabled.
  8518. */
  8519. set colorCurvesEnabled(value: boolean);
  8520. private _colorGradingTexture;
  8521. /**
  8522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8523. */
  8524. get colorGradingTexture(): Nullable<BaseTexture>;
  8525. /**
  8526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8527. */
  8528. set colorGradingTexture(value: Nullable<BaseTexture>);
  8529. private _colorGradingEnabled;
  8530. /**
  8531. * Gets wether the color grading effect is enabled.
  8532. */
  8533. get colorGradingEnabled(): boolean;
  8534. /**
  8535. * Sets wether the color grading effect is enabled.
  8536. */
  8537. set colorGradingEnabled(value: boolean);
  8538. private _colorGradingWithGreenDepth;
  8539. /**
  8540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8541. */
  8542. get colorGradingWithGreenDepth(): boolean;
  8543. /**
  8544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8545. */
  8546. set colorGradingWithGreenDepth(value: boolean);
  8547. private _colorGradingBGR;
  8548. /**
  8549. * Gets wether the color grading texture contains BGR values.
  8550. */
  8551. get colorGradingBGR(): boolean;
  8552. /**
  8553. * Sets wether the color grading texture contains BGR values.
  8554. */
  8555. set colorGradingBGR(value: boolean);
  8556. /** @hidden */
  8557. _exposure: number;
  8558. /**
  8559. * Gets the Exposure used in the effect.
  8560. */
  8561. get exposure(): number;
  8562. /**
  8563. * Sets the Exposure used in the effect.
  8564. */
  8565. set exposure(value: number);
  8566. private _toneMappingEnabled;
  8567. /**
  8568. * Gets wether the tone mapping effect is enabled.
  8569. */
  8570. get toneMappingEnabled(): boolean;
  8571. /**
  8572. * Sets wether the tone mapping effect is enabled.
  8573. */
  8574. set toneMappingEnabled(value: boolean);
  8575. private _toneMappingType;
  8576. /**
  8577. * Gets the type of tone mapping effect.
  8578. */
  8579. get toneMappingType(): number;
  8580. /**
  8581. * Sets the type of tone mapping effect used in BabylonJS.
  8582. */
  8583. set toneMappingType(value: number);
  8584. protected _contrast: number;
  8585. /**
  8586. * Gets the contrast used in the effect.
  8587. */
  8588. get contrast(): number;
  8589. /**
  8590. * Sets the contrast used in the effect.
  8591. */
  8592. set contrast(value: number);
  8593. /**
  8594. * Vignette stretch size.
  8595. */
  8596. vignetteStretch: number;
  8597. /**
  8598. * Vignette centre X Offset.
  8599. */
  8600. vignetteCentreX: number;
  8601. /**
  8602. * Vignette centre Y Offset.
  8603. */
  8604. vignetteCentreY: number;
  8605. /**
  8606. * Vignette weight or intensity of the vignette effect.
  8607. */
  8608. vignetteWeight: number;
  8609. /**
  8610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8611. * if vignetteEnabled is set to true.
  8612. */
  8613. vignetteColor: Color4;
  8614. /**
  8615. * Camera field of view used by the Vignette effect.
  8616. */
  8617. vignetteCameraFov: number;
  8618. private _vignetteBlendMode;
  8619. /**
  8620. * Gets the vignette blend mode allowing different kind of effect.
  8621. */
  8622. get vignetteBlendMode(): number;
  8623. /**
  8624. * Sets the vignette blend mode allowing different kind of effect.
  8625. */
  8626. set vignetteBlendMode(value: number);
  8627. private _vignetteEnabled;
  8628. /**
  8629. * Gets wether the vignette effect is enabled.
  8630. */
  8631. get vignetteEnabled(): boolean;
  8632. /**
  8633. * Sets wether the vignette effect is enabled.
  8634. */
  8635. set vignetteEnabled(value: boolean);
  8636. private _applyByPostProcess;
  8637. /**
  8638. * Gets wether the image processing is applied through a post process or not.
  8639. */
  8640. get applyByPostProcess(): boolean;
  8641. /**
  8642. * Sets wether the image processing is applied through a post process or not.
  8643. */
  8644. set applyByPostProcess(value: boolean);
  8645. private _isEnabled;
  8646. /**
  8647. * Gets wether the image processing is enabled or not.
  8648. */
  8649. get isEnabled(): boolean;
  8650. /**
  8651. * Sets wether the image processing is enabled or not.
  8652. */
  8653. set isEnabled(value: boolean);
  8654. /**
  8655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8656. */
  8657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8658. /**
  8659. * Method called each time the image processing information changes requires to recompile the effect.
  8660. */
  8661. protected _updateParameters(): void;
  8662. /**
  8663. * Gets the current class name.
  8664. * @return "ImageProcessingConfiguration"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Prepare the list of uniforms associated with the Image Processing effects.
  8669. * @param uniforms The list of uniforms used in the effect
  8670. * @param defines the list of defines currently in use
  8671. */
  8672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8673. /**
  8674. * Prepare the list of samplers associated with the Image Processing effects.
  8675. * @param samplersList The list of uniforms used in the effect
  8676. * @param defines the list of defines currently in use
  8677. */
  8678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8679. /**
  8680. * Prepare the list of defines associated to the shader.
  8681. * @param defines the list of defines to complete
  8682. * @param forPostProcess Define if we are currently in post process mode or not
  8683. */
  8684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8685. /**
  8686. * Returns true if all the image processing information are ready.
  8687. * @returns True if ready, otherwise, false
  8688. */
  8689. isReady(): boolean;
  8690. /**
  8691. * Binds the image processing to the shader.
  8692. * @param effect The effect to bind to
  8693. * @param overrideAspectRatio Override the aspect ratio of the effect
  8694. */
  8695. bind(effect: Effect, overrideAspectRatio?: number): void;
  8696. /**
  8697. * Clones the current image processing instance.
  8698. * @return The cloned image processing
  8699. */
  8700. clone(): ImageProcessingConfiguration;
  8701. /**
  8702. * Serializes the current image processing instance to a json representation.
  8703. * @return a JSON representation
  8704. */
  8705. serialize(): any;
  8706. /**
  8707. * Parses the image processing from a json representation.
  8708. * @param source the JSON source to parse
  8709. * @return The parsed image processing
  8710. */
  8711. static Parse(source: any): ImageProcessingConfiguration;
  8712. private static _VIGNETTEMODE_MULTIPLY;
  8713. private static _VIGNETTEMODE_OPAQUE;
  8714. /**
  8715. * Used to apply the vignette as a mix with the pixel color.
  8716. */
  8717. static get VIGNETTEMODE_MULTIPLY(): number;
  8718. /**
  8719. * Used to apply the vignette as a replacement of the pixel color.
  8720. */
  8721. static get VIGNETTEMODE_OPAQUE(): number;
  8722. }
  8723. }
  8724. declare module "babylonjs/Shaders/postprocess.vertex" {
  8725. /** @hidden */
  8726. export var postprocessVertexShader: {
  8727. name: string;
  8728. shader: string;
  8729. };
  8730. }
  8731. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8733. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8734. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8735. /**
  8736. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8737. */
  8738. export type RenderTargetTextureSize = number | {
  8739. width: number;
  8740. height: number;
  8741. layers?: number;
  8742. };
  8743. module "babylonjs/Engines/thinEngine" {
  8744. interface ThinEngine {
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8752. /**
  8753. * Creates a depth stencil texture.
  8754. * This is only available in WebGL 2 or with the depth texture extension available.
  8755. * @param size The size of face edge in the texture.
  8756. * @param options The options defining the texture.
  8757. * @returns The texture
  8758. */
  8759. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8760. /** @hidden */
  8761. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8762. }
  8763. }
  8764. }
  8765. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8766. /**
  8767. * Defines the kind of connection point for node based material
  8768. */
  8769. export enum NodeMaterialBlockConnectionPointTypes {
  8770. /** Float */
  8771. Float = 1,
  8772. /** Int */
  8773. Int = 2,
  8774. /** Vector2 */
  8775. Vector2 = 4,
  8776. /** Vector3 */
  8777. Vector3 = 8,
  8778. /** Vector4 */
  8779. Vector4 = 16,
  8780. /** Color3 */
  8781. Color3 = 32,
  8782. /** Color4 */
  8783. Color4 = 64,
  8784. /** Matrix */
  8785. Matrix = 128,
  8786. /** Custom object */
  8787. Object = 256,
  8788. /** Detect type based on connection */
  8789. AutoDetect = 1024,
  8790. /** Output type that will be defined by input type */
  8791. BasedOnInput = 2048
  8792. }
  8793. }
  8794. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8795. /**
  8796. * Enum used to define the target of a block
  8797. */
  8798. export enum NodeMaterialBlockTargets {
  8799. /** Vertex shader */
  8800. Vertex = 1,
  8801. /** Fragment shader */
  8802. Fragment = 2,
  8803. /** Neutral */
  8804. Neutral = 4,
  8805. /** Vertex and Fragment */
  8806. VertexAndFragment = 3
  8807. }
  8808. }
  8809. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8810. /**
  8811. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8812. */
  8813. export enum NodeMaterialBlockConnectionPointMode {
  8814. /** Value is an uniform */
  8815. Uniform = 0,
  8816. /** Value is a mesh attribute */
  8817. Attribute = 1,
  8818. /** Value is a varying between vertex and fragment shaders */
  8819. Varying = 2,
  8820. /** Mode is undefined */
  8821. Undefined = 3
  8822. }
  8823. }
  8824. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8825. /**
  8826. * Enum used to define system values e.g. values automatically provided by the system
  8827. */
  8828. export enum NodeMaterialSystemValues {
  8829. /** World */
  8830. World = 1,
  8831. /** View */
  8832. View = 2,
  8833. /** Projection */
  8834. Projection = 3,
  8835. /** ViewProjection */
  8836. ViewProjection = 4,
  8837. /** WorldView */
  8838. WorldView = 5,
  8839. /** WorldViewProjection */
  8840. WorldViewProjection = 6,
  8841. /** CameraPosition */
  8842. CameraPosition = 7,
  8843. /** Fog Color */
  8844. FogColor = 8,
  8845. /** Delta time */
  8846. DeltaTime = 9
  8847. }
  8848. }
  8849. declare module "babylonjs/Maths/math.axis" {
  8850. import { Vector3 } from "babylonjs/Maths/math.vector";
  8851. /** Defines supported spaces */
  8852. export enum Space {
  8853. /** Local (object) space */
  8854. LOCAL = 0,
  8855. /** World space */
  8856. WORLD = 1,
  8857. /** Bone space */
  8858. BONE = 2
  8859. }
  8860. /** Defines the 3 main axes */
  8861. export class Axis {
  8862. /** X axis */
  8863. static X: Vector3;
  8864. /** Y axis */
  8865. static Y: Vector3;
  8866. /** Z axis */
  8867. static Z: Vector3;
  8868. }
  8869. }
  8870. declare module "babylonjs/Maths/math.frustum" {
  8871. import { Matrix } from "babylonjs/Maths/math.vector";
  8872. import { DeepImmutable } from "babylonjs/types";
  8873. import { Plane } from "babylonjs/Maths/math.plane";
  8874. /**
  8875. * Represents a camera frustum
  8876. */
  8877. export class Frustum {
  8878. /**
  8879. * Gets the planes representing the frustum
  8880. * @param transform matrix to be applied to the returned planes
  8881. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8882. */
  8883. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8884. /**
  8885. * Gets the near frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the far frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the left frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Gets the right frustum plane transformed by the transform matrix
  8904. * @param transform transformation matrix to be applied to the resulting frustum plane
  8905. * @param frustumPlane the resuling frustum plane
  8906. */
  8907. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8908. /**
  8909. * Gets the top frustum plane transformed by the transform matrix
  8910. * @param transform transformation matrix to be applied to the resulting frustum plane
  8911. * @param frustumPlane the resuling frustum plane
  8912. */
  8913. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8914. /**
  8915. * Gets the bottom frustum plane transformed by the transform matrix
  8916. * @param transform transformation matrix to be applied to the resulting frustum plane
  8917. * @param frustumPlane the resuling frustum plane
  8918. */
  8919. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8920. /**
  8921. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8922. * @param transform transformation matrix to be applied to the resulting frustum planes
  8923. * @param frustumPlanes the resuling frustum planes
  8924. */
  8925. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8926. }
  8927. }
  8928. declare module "babylonjs/Maths/math.size" {
  8929. /**
  8930. * Interface for the size containing width and height
  8931. */
  8932. export interface ISize {
  8933. /**
  8934. * Width
  8935. */
  8936. width: number;
  8937. /**
  8938. * Heighht
  8939. */
  8940. height: number;
  8941. }
  8942. /**
  8943. * Size containing widht and height
  8944. */
  8945. export class Size implements ISize {
  8946. /**
  8947. * Width
  8948. */
  8949. width: number;
  8950. /**
  8951. * Height
  8952. */
  8953. height: number;
  8954. /**
  8955. * Creates a Size object from the given width and height (floats).
  8956. * @param width width of the new size
  8957. * @param height height of the new size
  8958. */
  8959. constructor(width: number, height: number);
  8960. /**
  8961. * Returns a string with the Size width and height
  8962. * @returns a string with the Size width and height
  8963. */
  8964. toString(): string;
  8965. /**
  8966. * "Size"
  8967. * @returns the string "Size"
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Returns the Size hash code.
  8972. * @returns a hash code for a unique width and height
  8973. */
  8974. getHashCode(): number;
  8975. /**
  8976. * Updates the current size from the given one.
  8977. * @param src the given size
  8978. */
  8979. copyFrom(src: Size): void;
  8980. /**
  8981. * Updates in place the current Size from the given floats.
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. * @returns the updated Size.
  8985. */
  8986. copyFromFloats(width: number, height: number): Size;
  8987. /**
  8988. * Updates in place the current Size from the given floats.
  8989. * @param width width to set
  8990. * @param height height to set
  8991. * @returns the updated Size.
  8992. */
  8993. set(width: number, height: number): Size;
  8994. /**
  8995. * Multiplies the width and height by numbers
  8996. * @param w factor to multiple the width by
  8997. * @param h factor to multiple the height by
  8998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8999. */
  9000. multiplyByFloats(w: number, h: number): Size;
  9001. /**
  9002. * Clones the size
  9003. * @returns a new Size copied from the given one.
  9004. */
  9005. clone(): Size;
  9006. /**
  9007. * True if the current Size and the given one width and height are strictly equal.
  9008. * @param other the other size to compare against
  9009. * @returns True if the current Size and the given one width and height are strictly equal.
  9010. */
  9011. equals(other: Size): boolean;
  9012. /**
  9013. * The surface of the Size : width * height (float).
  9014. */
  9015. get surface(): number;
  9016. /**
  9017. * Create a new size of zero
  9018. * @returns a new Size set to (0.0, 0.0)
  9019. */
  9020. static Zero(): Size;
  9021. /**
  9022. * Sums the width and height of two sizes
  9023. * @param otherSize size to add to this size
  9024. * @returns a new Size set as the addition result of the current Size and the given one.
  9025. */
  9026. add(otherSize: Size): Size;
  9027. /**
  9028. * Subtracts the width and height of two
  9029. * @param otherSize size to subtract to this size
  9030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9031. */
  9032. subtract(otherSize: Size): Size;
  9033. /**
  9034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9035. * @param start starting size to lerp between
  9036. * @param end end size to lerp between
  9037. * @param amount amount to lerp between the start and end values
  9038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9039. */
  9040. static Lerp(start: Size, end: Size, amount: number): Size;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math.vertexFormat" {
  9044. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9045. /**
  9046. * Contains position and normal vectors for a vertex
  9047. */
  9048. export class PositionNormalVertex {
  9049. /** the position of the vertex (defaut: 0,0,0) */
  9050. position: Vector3;
  9051. /** the normal of the vertex (defaut: 0,1,0) */
  9052. normal: Vector3;
  9053. /**
  9054. * Creates a PositionNormalVertex
  9055. * @param position the position of the vertex (defaut: 0,0,0)
  9056. * @param normal the normal of the vertex (defaut: 0,1,0)
  9057. */
  9058. constructor(
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position?: Vector3,
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal?: Vector3);
  9063. /**
  9064. * Clones the PositionNormalVertex
  9065. * @returns the cloned PositionNormalVertex
  9066. */
  9067. clone(): PositionNormalVertex;
  9068. }
  9069. /**
  9070. * Contains position, normal and uv vectors for a vertex
  9071. */
  9072. export class PositionNormalTextureVertex {
  9073. /** the position of the vertex (defaut: 0,0,0) */
  9074. position: Vector3;
  9075. /** the normal of the vertex (defaut: 0,1,0) */
  9076. normal: Vector3;
  9077. /** the uv of the vertex (default: 0,0) */
  9078. uv: Vector2;
  9079. /**
  9080. * Creates a PositionNormalTextureVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. * @param uv the uv of the vertex (default: 0,0)
  9084. */
  9085. constructor(
  9086. /** the position of the vertex (defaut: 0,0,0) */
  9087. position?: Vector3,
  9088. /** the normal of the vertex (defaut: 0,1,0) */
  9089. normal?: Vector3,
  9090. /** the uv of the vertex (default: 0,0) */
  9091. uv?: Vector2);
  9092. /**
  9093. * Clones the PositionNormalTextureVertex
  9094. * @returns the cloned PositionNormalTextureVertex
  9095. */
  9096. clone(): PositionNormalTextureVertex;
  9097. }
  9098. }
  9099. declare module "babylonjs/Maths/math" {
  9100. export * from "babylonjs/Maths/math.axis";
  9101. export * from "babylonjs/Maths/math.color";
  9102. export * from "babylonjs/Maths/math.constants";
  9103. export * from "babylonjs/Maths/math.frustum";
  9104. export * from "babylonjs/Maths/math.path";
  9105. export * from "babylonjs/Maths/math.plane";
  9106. export * from "babylonjs/Maths/math.size";
  9107. export * from "babylonjs/Maths/math.vector";
  9108. export * from "babylonjs/Maths/math.vertexFormat";
  9109. export * from "babylonjs/Maths/math.viewport";
  9110. }
  9111. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9112. /**
  9113. * Enum defining the type of animations supported by InputBlock
  9114. */
  9115. export enum AnimatedInputBlockTypes {
  9116. /** No animation */
  9117. None = 0,
  9118. /** Time based animation. Will only work for floats */
  9119. Time = 1
  9120. }
  9121. }
  9122. declare module "babylonjs/Lights/shadowLight" {
  9123. import { Camera } from "babylonjs/Cameras/camera";
  9124. import { Scene } from "babylonjs/scene";
  9125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9127. import { Light } from "babylonjs/Lights/light";
  9128. /**
  9129. * Interface describing all the common properties and methods a shadow light needs to implement.
  9130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9131. * as well as binding the different shadow properties to the effects.
  9132. */
  9133. export interface IShadowLight extends Light {
  9134. /**
  9135. * The light id in the scene (used in scene.findLighById for instance)
  9136. */
  9137. id: string;
  9138. /**
  9139. * The position the shdow will be casted from.
  9140. */
  9141. position: Vector3;
  9142. /**
  9143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9144. */
  9145. direction: Vector3;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. /**
  9155. * The friendly name of the light in the scene.
  9156. */
  9157. name: string;
  9158. /**
  9159. * Defines the shadow projection clipping minimum z value.
  9160. */
  9161. shadowMinZ: number;
  9162. /**
  9163. * Defines the shadow projection clipping maximum z value.
  9164. */
  9165. shadowMaxZ: number;
  9166. /**
  9167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9169. */
  9170. computeTransformedInformation(): boolean;
  9171. /**
  9172. * Gets the scene the light belongs to.
  9173. * @returns The scene
  9174. */
  9175. getScene(): Scene;
  9176. /**
  9177. * Callback defining a custom Projection Matrix Builder.
  9178. * This can be used to override the default projection matrix computation.
  9179. */
  9180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9181. /**
  9182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9183. * @param matrix The materix to updated with the projection information
  9184. * @param viewMatrix The transform matrix of the light
  9185. * @param renderList The list of mesh to render in the map
  9186. * @returns The current light
  9187. */
  9188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9189. /**
  9190. * Gets the current depth scale used in ESM.
  9191. * @returns The scale
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9196. * @returns true if a cube texture needs to be use
  9197. */
  9198. needCube(): boolean;
  9199. /**
  9200. * Detects if the projection matrix requires to be recomputed this frame.
  9201. * @returns true if it requires to be recomputed otherwise, false.
  9202. */
  9203. needProjectionMatrixCompute(): boolean;
  9204. /**
  9205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9206. */
  9207. forceProjectionMatrixCompute(): void;
  9208. /**
  9209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9212. */
  9213. getShadowDirection(faceIndex?: number): Vector3;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. }
  9227. /**
  9228. * Base implementation IShadowLight
  9229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9230. */
  9231. export abstract class ShadowLight extends Light implements IShadowLight {
  9232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9233. protected _position: Vector3;
  9234. protected _setPosition(value: Vector3): void;
  9235. /**
  9236. * Sets the position the shadow will be casted from. Also use as the light position for both
  9237. * point and spot lights.
  9238. */
  9239. get position(): Vector3;
  9240. /**
  9241. * Sets the position the shadow will be casted from. Also use as the light position for both
  9242. * point and spot lights.
  9243. */
  9244. set position(value: Vector3);
  9245. protected _direction: Vector3;
  9246. protected _setDirection(value: Vector3): void;
  9247. /**
  9248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9249. * Also use as the light direction on spot and directional lights.
  9250. */
  9251. get direction(): Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9254. * Also use as the light direction on spot and directional lights.
  9255. */
  9256. set direction(value: Vector3);
  9257. protected _shadowMinZ: number;
  9258. /**
  9259. * Gets the shadow projection clipping minimum z value.
  9260. */
  9261. get shadowMinZ(): number;
  9262. /**
  9263. * Sets the shadow projection clipping minimum z value.
  9264. */
  9265. set shadowMinZ(value: number);
  9266. protected _shadowMaxZ: number;
  9267. /**
  9268. * Sets the shadow projection clipping maximum z value.
  9269. */
  9270. get shadowMaxZ(): number;
  9271. /**
  9272. * Gets the shadow projection clipping maximum z value.
  9273. */
  9274. set shadowMaxZ(value: number);
  9275. /**
  9276. * Callback defining a custom Projection Matrix Builder.
  9277. * This can be used to override the default projection matrix computation.
  9278. */
  9279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9280. /**
  9281. * The transformed position. Position of the light in world space taking parenting in account.
  9282. */
  9283. transformedPosition: Vector3;
  9284. /**
  9285. * The transformed direction. Direction of the light in world space taking parenting in account.
  9286. */
  9287. transformedDirection: Vector3;
  9288. private _needProjectionMatrixCompute;
  9289. /**
  9290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9292. */
  9293. computeTransformedInformation(): boolean;
  9294. /**
  9295. * Return the depth scale used for the shadow map.
  9296. * @returns the depth scale.
  9297. */
  9298. getDepthScale(): number;
  9299. /**
  9300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9303. */
  9304. getShadowDirection(faceIndex?: number): Vector3;
  9305. /**
  9306. * Returns the ShadowLight absolute position in the World.
  9307. * @returns the position vector in world space
  9308. */
  9309. getAbsolutePosition(): Vector3;
  9310. /**
  9311. * Sets the ShadowLight direction toward the passed target.
  9312. * @param target The point to target in local space
  9313. * @returns the updated ShadowLight direction
  9314. */
  9315. setDirectionToTarget(target: Vector3): Vector3;
  9316. /**
  9317. * Returns the light rotation in euler definition.
  9318. * @returns the x y z rotation in local space.
  9319. */
  9320. getRotation(): Vector3;
  9321. /**
  9322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9323. * @returns true if a cube texture needs to be use
  9324. */
  9325. needCube(): boolean;
  9326. /**
  9327. * Detects if the projection matrix requires to be recomputed this frame.
  9328. * @returns true if it requires to be recomputed otherwise, false.
  9329. */
  9330. needProjectionMatrixCompute(): boolean;
  9331. /**
  9332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9333. */
  9334. forceProjectionMatrixCompute(): void;
  9335. /** @hidden */
  9336. _initCache(): void;
  9337. /** @hidden */
  9338. _isSynchronized(): boolean;
  9339. /**
  9340. * Computes the world matrix of the node
  9341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9342. * @returns the world matrix
  9343. */
  9344. computeWorldMatrix(force?: boolean): Matrix;
  9345. /**
  9346. * Gets the minZ used for shadow according to both the scene and the light.
  9347. * @param activeCamera The camera we are returning the min for
  9348. * @returns the depth min z
  9349. */
  9350. getDepthMinZ(activeCamera: Camera): number;
  9351. /**
  9352. * Gets the maxZ used for shadow according to both the scene and the light.
  9353. * @param activeCamera The camera we are returning the max for
  9354. * @returns the depth max z
  9355. */
  9356. getDepthMaxZ(activeCamera: Camera): number;
  9357. /**
  9358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9359. * @param matrix The materix to updated with the projection information
  9360. * @param viewMatrix The transform matrix of the light
  9361. * @param renderList The list of mesh to render in the map
  9362. * @returns The current light
  9363. */
  9364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9368. /** @hidden */
  9369. export var packingFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9375. /** @hidden */
  9376. export var bayerDitherFunctions: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9383. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9384. /** @hidden */
  9385. export var shadowMapFragmentDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9391. /** @hidden */
  9392. export var clipPlaneFragmentDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9398. /** @hidden */
  9399. export var clipPlaneFragment: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9405. /** @hidden */
  9406. export var shadowMapFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9412. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9415. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9416. /** @hidden */
  9417. export var shadowMapPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9423. /** @hidden */
  9424. export var bonesDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9430. /** @hidden */
  9431. export var morphTargetsVertexGlobalDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9437. /** @hidden */
  9438. export var morphTargetsVertexDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9444. /** @hidden */
  9445. export var instancesDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9451. /** @hidden */
  9452. export var helperFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9458. /** @hidden */
  9459. export var shadowMapVertexDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9465. /** @hidden */
  9466. export var clipPlaneVertexDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9493. /** @hidden */
  9494. export var shadowMapVertexNormalBias: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9500. /** @hidden */
  9501. export var shadowMapVertexMetric: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9507. /** @hidden */
  9508. export var clipPlaneVertex: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9514. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9519. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9527. /** @hidden */
  9528. export var shadowMapVertexShader: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9534. /** @hidden */
  9535. export var depthBoxBlurPixelShader: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9541. /** @hidden */
  9542. export var shadowMapFragmentSoftTransparentShadow: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Materials/effectFallbacks" {
  9548. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9549. import { Effect } from "babylonjs/Materials/effect";
  9550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9551. /**
  9552. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9553. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9554. */
  9555. export class EffectFallbacks implements IEffectFallbacks {
  9556. private _defines;
  9557. private _currentRank;
  9558. private _maxRank;
  9559. private _mesh;
  9560. /**
  9561. * Removes the fallback from the bound mesh.
  9562. */
  9563. unBindMesh(): void;
  9564. /**
  9565. * Adds a fallback on the specified property.
  9566. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9567. * @param define The name of the define in the shader
  9568. */
  9569. addFallback(rank: number, define: string): void;
  9570. /**
  9571. * Sets the mesh to use CPU skinning when needing to fallback.
  9572. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9573. * @param mesh The mesh to use the fallbacks.
  9574. */
  9575. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9576. /**
  9577. * Checks to see if more fallbacks are still availible.
  9578. */
  9579. get hasMoreFallbacks(): boolean;
  9580. /**
  9581. * Removes the defines that should be removed when falling back.
  9582. * @param currentDefines defines the current define statements for the shader.
  9583. * @param effect defines the current effect we try to compile
  9584. * @returns The resulting defines with defines of the current rank removed.
  9585. */
  9586. reduce(currentDefines: string, effect: Effect): string;
  9587. }
  9588. }
  9589. declare module "babylonjs/Actions/action" {
  9590. import { Observable } from "babylonjs/Misc/observable";
  9591. import { Condition } from "babylonjs/Actions/condition";
  9592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9593. import { Nullable } from "babylonjs/types";
  9594. import { Scene } from "babylonjs/scene";
  9595. import { ActionManager } from "babylonjs/Actions/actionManager";
  9596. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9597. import { Node } from "babylonjs/node";
  9598. /**
  9599. * Interface used to define Action
  9600. */
  9601. export interface IAction {
  9602. /**
  9603. * Trigger for the action
  9604. */
  9605. trigger: number;
  9606. /** Options of the trigger */
  9607. triggerOptions: any;
  9608. /**
  9609. * Gets the trigger parameters
  9610. * @returns the trigger parameters
  9611. */
  9612. getTriggerParameter(): any;
  9613. /**
  9614. * Internal only - executes current action event
  9615. * @hidden
  9616. */
  9617. _executeCurrent(evt?: ActionEvent): void;
  9618. /**
  9619. * Serialize placeholder for child classes
  9620. * @param parent of child
  9621. * @returns the serialized object
  9622. */
  9623. serialize(parent: any): any;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. _prepare(): void;
  9629. /**
  9630. * Internal only - manager for action
  9631. * @hidden
  9632. */
  9633. _actionManager: Nullable<AbstractActionManager>;
  9634. /**
  9635. * Adds action to chain of actions, may be a DoNothingAction
  9636. * @param action defines the next action to execute
  9637. * @returns The action passed in
  9638. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9639. */
  9640. then(action: IAction): IAction;
  9641. }
  9642. /**
  9643. * The action to be carried out following a trigger
  9644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9645. */
  9646. export class Action implements IAction {
  9647. /** the trigger, with or without parameters, for the action */
  9648. triggerOptions: any;
  9649. /**
  9650. * Trigger for the action
  9651. */
  9652. trigger: number;
  9653. /**
  9654. * Internal only - manager for action
  9655. * @hidden
  9656. */
  9657. _actionManager: ActionManager;
  9658. private _nextActiveAction;
  9659. private _child;
  9660. private _condition?;
  9661. private _triggerParameter;
  9662. /**
  9663. * An event triggered prior to action being executed.
  9664. */
  9665. onBeforeExecuteObservable: Observable<Action>;
  9666. /**
  9667. * Creates a new Action
  9668. * @param triggerOptions the trigger, with or without parameters, for the action
  9669. * @param condition an optional determinant of action
  9670. */
  9671. constructor(
  9672. /** the trigger, with or without parameters, for the action */
  9673. triggerOptions: any, condition?: Condition);
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _prepare(): void;
  9679. /**
  9680. * Gets the trigger parameters
  9681. * @returns the trigger parameters
  9682. */
  9683. getTriggerParameter(): any;
  9684. /**
  9685. * Internal only - executes current action event
  9686. * @hidden
  9687. */
  9688. _executeCurrent(evt?: ActionEvent): void;
  9689. /**
  9690. * Execute placeholder for child classes
  9691. * @param evt optional action event
  9692. */
  9693. execute(evt?: ActionEvent): void;
  9694. /**
  9695. * Skips to next active action
  9696. */
  9697. skipToNextActiveAction(): void;
  9698. /**
  9699. * Adds action to chain of actions, may be a DoNothingAction
  9700. * @param action defines the next action to execute
  9701. * @returns The action passed in
  9702. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9703. */
  9704. then(action: Action): Action;
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _getProperty(propertyPath: string): string;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. _getEffectiveTarget(target: any, propertyPath: string): any;
  9715. /**
  9716. * Serialize placeholder for child classes
  9717. * @param parent of child
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. /**
  9722. * Internal only called by serialize
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedAction: any, parent?: any): any;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. static _SerializeValueAsString: (value: any) => string;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. static _GetTargetProperty: (target: Scene | Node) => {
  9736. name: string;
  9737. targetType: string;
  9738. value: string;
  9739. };
  9740. }
  9741. }
  9742. declare module "babylonjs/Actions/condition" {
  9743. import { ActionManager } from "babylonjs/Actions/actionManager";
  9744. /**
  9745. * A Condition applied to an Action
  9746. */
  9747. export class Condition {
  9748. /**
  9749. * Internal only - manager for action
  9750. * @hidden
  9751. */
  9752. _actionManager: ActionManager;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. _evaluationId: number;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. _currentResult: boolean;
  9763. /**
  9764. * Creates a new Condition
  9765. * @param actionManager the manager of the action the condition is applied to
  9766. */
  9767. constructor(actionManager: ActionManager);
  9768. /**
  9769. * Check if the current condition is valid
  9770. * @returns a boolean
  9771. */
  9772. isValid(): boolean;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. _getProperty(propertyPath: string): string;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. _getEffectiveTarget(target: any, propertyPath: string): any;
  9783. /**
  9784. * Serialize placeholder for child classes
  9785. * @returns the serialized object
  9786. */
  9787. serialize(): any;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. protected _serialize(serializedCondition: any): any;
  9793. }
  9794. /**
  9795. * Defines specific conditional operators as extensions of Condition
  9796. */
  9797. export class ValueCondition extends Condition {
  9798. /** path to specify the property of the target the conditional operator uses */
  9799. propertyPath: string;
  9800. /** the value compared by the conditional operator against the current value of the property */
  9801. value: any;
  9802. /** the conditional operator, default ValueCondition.IsEqual */
  9803. operator: number;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private static _IsEqual;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private static _IsDifferent;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsGreater;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsLesser;
  9824. /**
  9825. * returns the number for IsEqual
  9826. */
  9827. static get IsEqual(): number;
  9828. /**
  9829. * Returns the number for IsDifferent
  9830. */
  9831. static get IsDifferent(): number;
  9832. /**
  9833. * Returns the number for IsGreater
  9834. */
  9835. static get IsGreater(): number;
  9836. /**
  9837. * Returns the number for IsLesser
  9838. */
  9839. static get IsLesser(): number;
  9840. /**
  9841. * Internal only The action manager for the condition
  9842. * @hidden
  9843. */
  9844. _actionManager: ActionManager;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private _target;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private _effectiveTarget;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _property;
  9860. /**
  9861. * Creates a new ValueCondition
  9862. * @param actionManager manager for the action the condition applies to
  9863. * @param target for the action
  9864. * @param propertyPath path to specify the property of the target the conditional operator uses
  9865. * @param value the value compared by the conditional operator against the current value of the property
  9866. * @param operator the conditional operator, default ValueCondition.IsEqual
  9867. */
  9868. constructor(actionManager: ActionManager, target: any,
  9869. /** path to specify the property of the target the conditional operator uses */
  9870. propertyPath: string,
  9871. /** the value compared by the conditional operator against the current value of the property */
  9872. value: any,
  9873. /** the conditional operator, default ValueCondition.IsEqual */
  9874. operator?: number);
  9875. /**
  9876. * Compares the given value with the property value for the specified conditional operator
  9877. * @returns the result of the comparison
  9878. */
  9879. isValid(): boolean;
  9880. /**
  9881. * Serialize the ValueCondition into a JSON compatible object
  9882. * @returns serialization object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Gets the name of the conditional operator for the ValueCondition
  9887. * @param operator the conditional operator
  9888. * @returns the name
  9889. */
  9890. static GetOperatorName(operator: number): string;
  9891. }
  9892. /**
  9893. * Defines a predicate condition as an extension of Condition
  9894. */
  9895. export class PredicateCondition extends Condition {
  9896. /** defines the predicate function used to validate the condition */
  9897. predicate: () => boolean;
  9898. /**
  9899. * Internal only - manager for action
  9900. * @hidden
  9901. */
  9902. _actionManager: ActionManager;
  9903. /**
  9904. * Creates a new PredicateCondition
  9905. * @param actionManager manager for the action the condition applies to
  9906. * @param predicate defines the predicate function used to validate the condition
  9907. */
  9908. constructor(actionManager: ActionManager,
  9909. /** defines the predicate function used to validate the condition */
  9910. predicate: () => boolean);
  9911. /**
  9912. * @returns the validity of the predicate condition
  9913. */
  9914. isValid(): boolean;
  9915. }
  9916. /**
  9917. * Defines a state condition as an extension of Condition
  9918. */
  9919. export class StateCondition extends Condition {
  9920. /** Value to compare with target state */
  9921. value: string;
  9922. /**
  9923. * Internal only - manager for action
  9924. * @hidden
  9925. */
  9926. _actionManager: ActionManager;
  9927. /**
  9928. * Internal only
  9929. * @hidden
  9930. */
  9931. private _target;
  9932. /**
  9933. * Creates a new StateCondition
  9934. * @param actionManager manager for the action the condition applies to
  9935. * @param target of the condition
  9936. * @param value to compare with target state
  9937. */
  9938. constructor(actionManager: ActionManager, target: any,
  9939. /** Value to compare with target state */
  9940. value: string);
  9941. /**
  9942. * Gets a boolean indicating if the current condition is met
  9943. * @returns the validity of the state
  9944. */
  9945. isValid(): boolean;
  9946. /**
  9947. * Serialize the StateCondition into a JSON compatible object
  9948. * @returns serialization object
  9949. */
  9950. serialize(): any;
  9951. }
  9952. }
  9953. declare module "babylonjs/Actions/directActions" {
  9954. import { Action } from "babylonjs/Actions/action";
  9955. import { Condition } from "babylonjs/Actions/condition";
  9956. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9957. /**
  9958. * This defines an action responsible to toggle a boolean once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class SwitchBooleanAction extends Action {
  9962. /**
  9963. * The path to the boolean property in the target object
  9964. */
  9965. propertyPath: string;
  9966. private _target;
  9967. private _effectiveTarget;
  9968. private _property;
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param target defines the object containing the boolean
  9973. * @param propertyPath defines the path to the boolean property in the target object
  9974. * @param condition defines the trigger related conditions
  9975. */
  9976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9977. /** @hidden */
  9978. _prepare(): void;
  9979. /**
  9980. * Execute the action toggle the boolean value.
  9981. */
  9982. execute(): void;
  9983. /**
  9984. * Serializes the actions and its related information.
  9985. * @param parent defines the object to serialize in
  9986. * @returns the serialized object
  9987. */
  9988. serialize(parent: any): any;
  9989. }
  9990. /**
  9991. * This defines an action responsible to set a the state field of the target
  9992. * to a desired value once triggered.
  9993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9994. */
  9995. export class SetStateAction extends Action {
  9996. /**
  9997. * The value to store in the state field.
  9998. */
  9999. value: string;
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the state property
  10005. * @param value defines the value to store in the state field
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10009. /**
  10010. * Execute the action and store the value on the target state property.
  10011. */
  10012. execute(): void;
  10013. /**
  10014. * Serializes the actions and its related information.
  10015. * @param parent defines the object to serialize in
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. }
  10020. /**
  10021. * This defines an action responsible to set a property of the target
  10022. * to a desired value once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class SetValueAction extends Action {
  10026. /**
  10027. * The path of the property to set in the target.
  10028. */
  10029. propertyPath: string;
  10030. /**
  10031. * The value to set in the property
  10032. */
  10033. value: any;
  10034. private _target;
  10035. private _effectiveTarget;
  10036. private _property;
  10037. /**
  10038. * Instantiate the action
  10039. * @param triggerOptions defines the trigger options
  10040. * @param target defines the object containing the property
  10041. * @param propertyPath defines the path of the property to set in the target
  10042. * @param value defines the value to set in the property
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and set the targetted property to the desired value.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible to increment the target value
  10061. * to a desired value once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class IncrementValueAction extends Action {
  10065. /**
  10066. * The path of the property to increment in the target.
  10067. */
  10068. propertyPath: string;
  10069. /**
  10070. * The value we should increment the property by.
  10071. */
  10072. value: any;
  10073. private _target;
  10074. private _effectiveTarget;
  10075. private _property;
  10076. /**
  10077. * Instantiate the action
  10078. * @param triggerOptions defines the trigger options
  10079. * @param target defines the object containing the property
  10080. * @param propertyPath defines the path of the property to increment in the target
  10081. * @param value defines the value value we should increment the property by
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and increment the target of the value amount.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible to start an animation once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class PlayAnimationAction extends Action {
  10103. /**
  10104. * Where the animation should start (animation frame)
  10105. */
  10106. from: number;
  10107. /**
  10108. * Where the animation should stop (animation frame)
  10109. */
  10110. to: number;
  10111. /**
  10112. * Define if the animation should loop or stop after the first play.
  10113. */
  10114. loop?: boolean;
  10115. private _target;
  10116. /**
  10117. * Instantiate the action
  10118. * @param triggerOptions defines the trigger options
  10119. * @param target defines the target animation or animation name
  10120. * @param from defines from where the animation should start (animation frame)
  10121. * @param end defines where the animation should stop (animation frame)
  10122. * @param loop defines if the animation should loop or stop after the first play
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and play the animation.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. /**
  10140. * This defines an action responsible to stop an animation once triggered.
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10142. */
  10143. export class StopAnimationAction extends Action {
  10144. private _target;
  10145. /**
  10146. * Instantiate the action
  10147. * @param triggerOptions defines the trigger options
  10148. * @param target defines the target animation or animation name
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and stop the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible that does nothing once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class DoNothingAction extends Action {
  10170. /**
  10171. * Instantiate the action
  10172. * @param triggerOptions defines the trigger options
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions?: any, condition?: Condition);
  10176. /**
  10177. * Execute the action and do nothing.
  10178. */
  10179. execute(): void;
  10180. /**
  10181. * Serializes the actions and its related information.
  10182. * @param parent defines the object to serialize in
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. }
  10187. /**
  10188. * This defines an action responsible to trigger several actions once triggered.
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10190. */
  10191. export class CombineAction extends Action {
  10192. /**
  10193. * The list of aggregated animations to run.
  10194. */
  10195. children: Action[];
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param children defines the list of aggregated animations to run
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action and executes all the aggregated actions.
  10207. */
  10208. execute(evt: ActionEvent): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to run code (external event) once triggered.
  10218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10219. */
  10220. export class ExecuteCodeAction extends Action {
  10221. /**
  10222. * The callback function to run.
  10223. */
  10224. func: (evt: ActionEvent) => void;
  10225. /**
  10226. * Instantiate the action
  10227. * @param triggerOptions defines the trigger options
  10228. * @param func defines the callback function to run
  10229. * @param condition defines the trigger related conditions
  10230. */
  10231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10232. /**
  10233. * Execute the action and run the attached code.
  10234. */
  10235. execute(evt: ActionEvent): void;
  10236. }
  10237. /**
  10238. * This defines an action responsible to set the parent property of the target once triggered.
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10240. */
  10241. export class SetParentAction extends Action {
  10242. private _parent;
  10243. private _target;
  10244. /**
  10245. * Instantiate the action
  10246. * @param triggerOptions defines the trigger options
  10247. * @param target defines the target containing the parent property
  10248. * @param parent defines from where the animation should start (animation frame)
  10249. * @param condition defines the trigger related conditions
  10250. */
  10251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10252. /** @hidden */
  10253. _prepare(): void;
  10254. /**
  10255. * Execute the action and set the parent property.
  10256. */
  10257. execute(): void;
  10258. /**
  10259. * Serializes the actions and its related information.
  10260. * @param parent defines the object to serialize in
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. }
  10265. }
  10266. declare module "babylonjs/Actions/actionManager" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10269. import { Scene } from "babylonjs/scene";
  10270. import { IAction } from "babylonjs/Actions/action";
  10271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10272. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10273. /**
  10274. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10275. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10277. */
  10278. export class ActionManager extends AbstractActionManager {
  10279. /**
  10280. * Nothing
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly NothingTrigger: number;
  10284. /**
  10285. * On pick
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickTrigger: number;
  10289. /**
  10290. * On left pick
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLeftPickTrigger: number;
  10294. /**
  10295. * On right pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnRightPickTrigger: number;
  10299. /**
  10300. * On center pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnCenterPickTrigger: number;
  10304. /**
  10305. * On pick down
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnPickDownTrigger: number;
  10309. /**
  10310. * On double pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnDoublePickTrigger: number;
  10314. /**
  10315. * On pick up
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickUpTrigger: number;
  10319. /**
  10320. * On pick out.
  10321. * This trigger will only be raised if you also declared a OnPickDown
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickOutTrigger: number;
  10325. /**
  10326. * On long press
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnLongPressTrigger: number;
  10330. /**
  10331. * On pointer over
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPointerOverTrigger: number;
  10335. /**
  10336. * On pointer out
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPointerOutTrigger: number;
  10340. /**
  10341. * On every frame
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnEveryFrameTrigger: number;
  10345. /**
  10346. * On intersection enter
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnIntersectionEnterTrigger: number;
  10350. /**
  10351. * On intersection exit
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnIntersectionExitTrigger: number;
  10355. /**
  10356. * On key down
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnKeyDownTrigger: number;
  10360. /**
  10361. * On key up
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnKeyUpTrigger: number;
  10365. private _scene;
  10366. /**
  10367. * Creates a new action manager
  10368. * @param scene defines the hosting scene
  10369. */
  10370. constructor(scene: Scene);
  10371. /**
  10372. * Releases all associated resources
  10373. */
  10374. dispose(): void;
  10375. /**
  10376. * Gets hosting scene
  10377. * @returns the hosting scene
  10378. */
  10379. getScene(): Scene;
  10380. /**
  10381. * Does this action manager handles actions of any of the given triggers
  10382. * @param triggers defines the triggers to be tested
  10383. * @return a boolean indicating whether one (or more) of the triggers is handled
  10384. */
  10385. hasSpecificTriggers(triggers: number[]): boolean;
  10386. /**
  10387. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10388. * speed.
  10389. * @param triggerA defines the trigger to be tested
  10390. * @param triggerB defines the trigger to be tested
  10391. * @return a boolean indicating whether one (or more) of the triggers is handled
  10392. */
  10393. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10394. /**
  10395. * Does this action manager handles actions of a given trigger
  10396. * @param trigger defines the trigger to be tested
  10397. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10398. * @return whether the trigger is handled
  10399. */
  10400. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10401. /**
  10402. * Does this action manager has pointer triggers
  10403. */
  10404. get hasPointerTriggers(): boolean;
  10405. /**
  10406. * Does this action manager has pick triggers
  10407. */
  10408. get hasPickTriggers(): boolean;
  10409. /**
  10410. * Registers an action to this action manager
  10411. * @param action defines the action to be registered
  10412. * @return the action amended (prepared) after registration
  10413. */
  10414. registerAction(action: IAction): Nullable<IAction>;
  10415. /**
  10416. * Unregisters an action to this action manager
  10417. * @param action defines the action to be unregistered
  10418. * @return a boolean indicating whether the action has been unregistered
  10419. */
  10420. unregisterAction(action: IAction): Boolean;
  10421. /**
  10422. * Process a specific trigger
  10423. * @param trigger defines the trigger to process
  10424. * @param evt defines the event details to be processed
  10425. */
  10426. processTrigger(trigger: number, evt?: IActionEvent): void;
  10427. /** @hidden */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /** @hidden */
  10430. _getProperty(propertyPath: string): string;
  10431. /**
  10432. * Serialize this manager to a JSON object
  10433. * @param name defines the property name to store this manager
  10434. * @returns a JSON representation of this manager
  10435. */
  10436. serialize(name: string): any;
  10437. /**
  10438. * Creates a new ActionManager from a JSON data
  10439. * @param parsedActions defines the JSON data to read from
  10440. * @param object defines the hosting mesh
  10441. * @param scene defines the hosting scene
  10442. */
  10443. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10444. /**
  10445. * Get a trigger name by index
  10446. * @param trigger defines the trigger index
  10447. * @returns a trigger name
  10448. */
  10449. static GetTriggerName(trigger: number): string;
  10450. }
  10451. }
  10452. declare module "babylonjs/Sprites/sprite" {
  10453. import { Vector3 } from "babylonjs/Maths/math.vector";
  10454. import { Nullable } from "babylonjs/types";
  10455. import { ActionManager } from "babylonjs/Actions/actionManager";
  10456. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10457. import { Color4 } from "babylonjs/Maths/math.color";
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10460. import { Animation } from "babylonjs/Animations/animation";
  10461. /**
  10462. * Class used to represent a sprite
  10463. * @see https://doc.babylonjs.com/babylon101/sprites
  10464. */
  10465. export class Sprite implements IAnimatable {
  10466. /** defines the name */
  10467. name: string;
  10468. /** Gets or sets the current world position */
  10469. position: Vector3;
  10470. /** Gets or sets the main color */
  10471. color: Color4;
  10472. /** Gets or sets the width */
  10473. width: number;
  10474. /** Gets or sets the height */
  10475. height: number;
  10476. /** Gets or sets rotation angle */
  10477. angle: number;
  10478. /** Gets or sets the cell index in the sprite sheet */
  10479. cellIndex: number;
  10480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10481. cellRef: string;
  10482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10483. invertU: boolean;
  10484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10485. invertV: boolean;
  10486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10487. disposeWhenFinishedAnimating: boolean;
  10488. /** Gets the list of attached animations */
  10489. animations: Nullable<Array<Animation>>;
  10490. /** Gets or sets a boolean indicating if the sprite can be picked */
  10491. isPickable: boolean;
  10492. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10493. useAlphaForPicking: boolean;
  10494. /** @hidden */
  10495. _xOffset: number;
  10496. /** @hidden */
  10497. _yOffset: number;
  10498. /** @hidden */
  10499. _xSize: number;
  10500. /** @hidden */
  10501. _ySize: number;
  10502. /**
  10503. * Gets or sets the associated action manager
  10504. */
  10505. actionManager: Nullable<ActionManager>;
  10506. /**
  10507. * An event triggered when the control has been disposed
  10508. */
  10509. onDisposeObservable: Observable<Sprite>;
  10510. private _animationStarted;
  10511. private _loopAnimation;
  10512. private _fromIndex;
  10513. private _toIndex;
  10514. private _delay;
  10515. private _direction;
  10516. private _manager;
  10517. private _time;
  10518. private _onAnimationEnd;
  10519. /**
  10520. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10521. */
  10522. isVisible: boolean;
  10523. /**
  10524. * Gets or sets the sprite size
  10525. */
  10526. get size(): number;
  10527. set size(value: number);
  10528. /**
  10529. * Returns a boolean indicating if the animation is started
  10530. */
  10531. get animationStarted(): boolean;
  10532. /**
  10533. * Gets or sets the unique id of the sprite
  10534. */
  10535. uniqueId: number;
  10536. /**
  10537. * Gets the manager of this sprite
  10538. */
  10539. get manager(): ISpriteManager;
  10540. /**
  10541. * Creates a new Sprite
  10542. * @param name defines the name
  10543. * @param manager defines the manager
  10544. */
  10545. constructor(
  10546. /** defines the name */
  10547. name: string, manager: ISpriteManager);
  10548. /**
  10549. * Returns the string "Sprite"
  10550. * @returns "Sprite"
  10551. */
  10552. getClassName(): string;
  10553. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10554. get fromIndex(): number;
  10555. set fromIndex(value: number);
  10556. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10557. get toIndex(): number;
  10558. set toIndex(value: number);
  10559. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10560. get loopAnimation(): boolean;
  10561. set loopAnimation(value: boolean);
  10562. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10563. get delay(): number;
  10564. set delay(value: number);
  10565. /**
  10566. * Starts an animation
  10567. * @param from defines the initial key
  10568. * @param to defines the end key
  10569. * @param loop defines if the animation must loop
  10570. * @param delay defines the start delay (in ms)
  10571. * @param onAnimationEnd defines a callback to call when animation ends
  10572. */
  10573. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10574. /** Stops current animation (if any) */
  10575. stopAnimation(): void;
  10576. /** @hidden */
  10577. _animate(deltaTime: number): void;
  10578. /** Release associated resources */
  10579. dispose(): void;
  10580. /**
  10581. * Serializes the sprite to a JSON object
  10582. * @returns the JSON object
  10583. */
  10584. serialize(): any;
  10585. /**
  10586. * Parses a JSON object to create a new sprite
  10587. * @param parsedSprite The JSON object to parse
  10588. * @param manager defines the hosting manager
  10589. * @returns the new sprite
  10590. */
  10591. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10592. }
  10593. }
  10594. declare module "babylonjs/Collisions/pickingInfo" {
  10595. import { Nullable } from "babylonjs/types";
  10596. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10598. import { Sprite } from "babylonjs/Sprites/sprite";
  10599. import { Ray } from "babylonjs/Culling/ray";
  10600. /**
  10601. * Information about the result of picking within a scene
  10602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10603. */
  10604. export class PickingInfo {
  10605. /** @hidden */
  10606. _pickingUnavailable: boolean;
  10607. /**
  10608. * If the pick collided with an object
  10609. */
  10610. hit: boolean;
  10611. /**
  10612. * Distance away where the pick collided
  10613. */
  10614. distance: number;
  10615. /**
  10616. * The location of pick collision
  10617. */
  10618. pickedPoint: Nullable<Vector3>;
  10619. /**
  10620. * The mesh corresponding the the pick collision
  10621. */
  10622. pickedMesh: Nullable<AbstractMesh>;
  10623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10624. bu: number;
  10625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10626. bv: number;
  10627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10628. faceId: number;
  10629. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10630. subMeshFaceId: number;
  10631. /** Id of the the submesh that was picked */
  10632. subMeshId: number;
  10633. /** If a sprite was picked, this will be the sprite the pick collided with */
  10634. pickedSprite: Nullable<Sprite>;
  10635. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10636. thinInstanceIndex: number;
  10637. /**
  10638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10639. */
  10640. originMesh: Nullable<AbstractMesh>;
  10641. /**
  10642. * The ray that was used to perform the picking.
  10643. */
  10644. ray: Nullable<Ray>;
  10645. /**
  10646. * Gets the normal correspodning to the face the pick collided with
  10647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10649. * @returns The normal correspodning to the face the pick collided with
  10650. */
  10651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10652. /**
  10653. * Gets the texture coordinates of where the pick occured
  10654. * @returns the vector containing the coordnates of the texture
  10655. */
  10656. getTextureCoordinates(): Nullable<Vector2>;
  10657. }
  10658. }
  10659. declare module "babylonjs/Culling/ray" {
  10660. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10664. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10665. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10667. import { Plane } from "babylonjs/Maths/math.plane";
  10668. /**
  10669. * Class representing a ray with position and direction
  10670. */
  10671. export class Ray {
  10672. /** origin point */
  10673. origin: Vector3;
  10674. /** direction */
  10675. direction: Vector3;
  10676. /** length of the ray */
  10677. length: number;
  10678. private static readonly _TmpVector3;
  10679. private _tmpRay;
  10680. /**
  10681. * Creates a new ray
  10682. * @param origin origin point
  10683. * @param direction direction
  10684. * @param length length of the ray
  10685. */
  10686. constructor(
  10687. /** origin point */
  10688. origin: Vector3,
  10689. /** direction */
  10690. direction: Vector3,
  10691. /** length of the ray */
  10692. length?: number);
  10693. /**
  10694. * Checks if the ray intersects a box
  10695. * This does not account for the ray lenght by design to improve perfs.
  10696. * @param minimum bound of the box
  10697. * @param maximum bound of the box
  10698. * @param intersectionTreshold extra extend to be added to the box in all direction
  10699. * @returns if the box was hit
  10700. */
  10701. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10702. /**
  10703. * Checks if the ray intersects a box
  10704. * This does not account for the ray lenght by design to improve perfs.
  10705. * @param box the bounding box to check
  10706. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10707. * @returns if the box was hit
  10708. */
  10709. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10710. /**
  10711. * If the ray hits a sphere
  10712. * @param sphere the bounding sphere to check
  10713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10714. * @returns true if it hits the sphere
  10715. */
  10716. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10717. /**
  10718. * If the ray hits a triange
  10719. * @param vertex0 triangle vertex
  10720. * @param vertex1 triangle vertex
  10721. * @param vertex2 triangle vertex
  10722. * @returns intersection information if hit
  10723. */
  10724. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10725. /**
  10726. * Checks if ray intersects a plane
  10727. * @param plane the plane to check
  10728. * @returns the distance away it was hit
  10729. */
  10730. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10731. /**
  10732. * Calculate the intercept of a ray on a given axis
  10733. * @param axis to check 'x' | 'y' | 'z'
  10734. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10735. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10736. */
  10737. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10738. /**
  10739. * Checks if ray intersects a mesh
  10740. * @param mesh the mesh to check
  10741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10742. * @returns picking info of the intersecton
  10743. */
  10744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10745. /**
  10746. * Checks if ray intersects a mesh
  10747. * @param meshes the meshes to check
  10748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10749. * @param results array to store result in
  10750. * @returns Array of picking infos
  10751. */
  10752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10753. private _comparePickingInfo;
  10754. private static smallnum;
  10755. private static rayl;
  10756. /**
  10757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10758. * @param sega the first point of the segment to test the intersection against
  10759. * @param segb the second point of the segment to test the intersection against
  10760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10762. */
  10763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10764. /**
  10765. * Update the ray from viewport position
  10766. * @param x position
  10767. * @param y y position
  10768. * @param viewportWidth viewport width
  10769. * @param viewportHeight viewport height
  10770. * @param world world matrix
  10771. * @param view view matrix
  10772. * @param projection projection matrix
  10773. * @returns this ray updated
  10774. */
  10775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10776. /**
  10777. * Creates a ray with origin and direction of 0,0,0
  10778. * @returns the new ray
  10779. */
  10780. static Zero(): Ray;
  10781. /**
  10782. * Creates a new ray from screen space and viewport
  10783. * @param x position
  10784. * @param y y position
  10785. * @param viewportWidth viewport width
  10786. * @param viewportHeight viewport height
  10787. * @param world world matrix
  10788. * @param view view matrix
  10789. * @param projection projection matrix
  10790. * @returns new ray
  10791. */
  10792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10793. /**
  10794. * 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
  10795. * transformed to the given world matrix.
  10796. * @param origin The origin point
  10797. * @param end The end point
  10798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10799. * @returns the new ray
  10800. */
  10801. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Transforms a ray by a matrix
  10804. * @param ray ray to transform
  10805. * @param matrix matrix to apply
  10806. * @returns the resulting new ray
  10807. */
  10808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Transforms a ray by a matrix
  10811. * @param ray ray to transform
  10812. * @param matrix matrix to apply
  10813. * @param result ray to store result in
  10814. */
  10815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10816. /**
  10817. * Unproject a ray from screen space to object space
  10818. * @param sourceX defines the screen space x coordinate to use
  10819. * @param sourceY defines the screen space y coordinate to use
  10820. * @param viewportWidth defines the current width of the viewport
  10821. * @param viewportHeight defines the current height of the viewport
  10822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10823. * @param view defines the view matrix to use
  10824. * @param projection defines the projection matrix to use
  10825. */
  10826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10827. }
  10828. /**
  10829. * Type used to define predicate used to select faces when a mesh intersection is detected
  10830. */
  10831. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10832. module "babylonjs/scene" {
  10833. interface Scene {
  10834. /** @hidden */
  10835. _tempPickingRay: Nullable<Ray>;
  10836. /** @hidden */
  10837. _cachedRayForTransform: Ray;
  10838. /** @hidden */
  10839. _pickWithRayInverseMatrix: Matrix;
  10840. /** @hidden */
  10841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10842. /** @hidden */
  10843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10844. /** @hidden */
  10845. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/sceneComponent" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10853. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10855. import { Nullable } from "babylonjs/types";
  10856. import { Camera } from "babylonjs/Cameras/camera";
  10857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10858. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10859. import { AbstractScene } from "babylonjs/abstractScene";
  10860. import { Mesh } from "babylonjs/Meshes/mesh";
  10861. /**
  10862. * Groups all the scene component constants in one place to ease maintenance.
  10863. * @hidden
  10864. */
  10865. export class SceneComponentConstants {
  10866. static readonly NAME_EFFECTLAYER: string;
  10867. static readonly NAME_LAYER: string;
  10868. static readonly NAME_LENSFLARESYSTEM: string;
  10869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10870. static readonly NAME_PARTICLESYSTEM: string;
  10871. static readonly NAME_GAMEPAD: string;
  10872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10874. static readonly NAME_PREPASSRENDERER: string;
  10875. static readonly NAME_DEPTHRENDERER: string;
  10876. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10877. static readonly NAME_SPRITE: string;
  10878. static readonly NAME_SUBSURFACE: string;
  10879. static readonly NAME_OUTLINERENDERER: string;
  10880. static readonly NAME_PROCEDURALTEXTURE: string;
  10881. static readonly NAME_SHADOWGENERATOR: string;
  10882. static readonly NAME_OCTREE: string;
  10883. static readonly NAME_PHYSICSENGINE: string;
  10884. static readonly NAME_AUDIO: string;
  10885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10893. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10894. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10895. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10900. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10901. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10902. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10905. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10906. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10907. static readonly STEP_AFTERRENDER_AUDIO: number;
  10908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10912. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10913. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10914. static readonly STEP_POINTERMOVE_SPRITE: number;
  10915. static readonly STEP_POINTERDOWN_SPRITE: number;
  10916. static readonly STEP_POINTERUP_SPRITE: number;
  10917. }
  10918. /**
  10919. * This represents a scene component.
  10920. *
  10921. * This is used to decouple the dependency the scene is having on the different workloads like
  10922. * layers, post processes...
  10923. */
  10924. export interface ISceneComponent {
  10925. /**
  10926. * The name of the component. Each component must have a unique name.
  10927. */
  10928. name: string;
  10929. /**
  10930. * The scene the component belongs to.
  10931. */
  10932. scene: Scene;
  10933. /**
  10934. * Register the component to one instance of a scene.
  10935. */
  10936. register(): void;
  10937. /**
  10938. * Rebuilds the elements related to this component in case of
  10939. * context lost for instance.
  10940. */
  10941. rebuild(): void;
  10942. /**
  10943. * Disposes the component and the associated ressources.
  10944. */
  10945. dispose(): void;
  10946. }
  10947. /**
  10948. * This represents a SERIALIZABLE scene component.
  10949. *
  10950. * This extends Scene Component to add Serialization methods on top.
  10951. */
  10952. export interface ISceneSerializableComponent extends ISceneComponent {
  10953. /**
  10954. * Adds all the elements from the container to the scene
  10955. * @param container the container holding the elements
  10956. */
  10957. addFromContainer(container: AbstractScene): void;
  10958. /**
  10959. * Removes all the elements in the container from the scene
  10960. * @param container contains the elements to remove
  10961. * @param dispose if the removed element should be disposed (default: false)
  10962. */
  10963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10964. /**
  10965. * Serializes the component data to the specified json object
  10966. * @param serializationObject The object to serialize to
  10967. */
  10968. serialize(serializationObject: any): void;
  10969. }
  10970. /**
  10971. * Strong typing of a Mesh related stage step action
  10972. */
  10973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10974. /**
  10975. * Strong typing of a Evaluate Sub Mesh related stage step action
  10976. */
  10977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10978. /**
  10979. * Strong typing of a Active Mesh related stage step action
  10980. */
  10981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10982. /**
  10983. * Strong typing of a Camera related stage step action
  10984. */
  10985. export type CameraStageAction = (camera: Camera) => void;
  10986. /**
  10987. * Strong typing of a Camera Frame buffer related stage step action
  10988. */
  10989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10990. /**
  10991. * Strong typing of a Render Target related stage step action
  10992. */
  10993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10994. /**
  10995. * Strong typing of a RenderingGroup related stage step action
  10996. */
  10997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10998. /**
  10999. * Strong typing of a Mesh Render related stage step action
  11000. */
  11001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11002. /**
  11003. * Strong typing of a simple stage step action
  11004. */
  11005. export type SimpleStageAction = () => void;
  11006. /**
  11007. * Strong typing of a render target action.
  11008. */
  11009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11010. /**
  11011. * Strong typing of a pointer move action.
  11012. */
  11013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11014. /**
  11015. * Strong typing of a pointer up/down action.
  11016. */
  11017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11018. /**
  11019. * Representation of a stage in the scene (Basically a list of ordered steps)
  11020. * @hidden
  11021. */
  11022. export class Stage<T extends Function> extends Array<{
  11023. index: number;
  11024. component: ISceneComponent;
  11025. action: T;
  11026. }> {
  11027. /**
  11028. * Hide ctor from the rest of the world.
  11029. * @param items The items to add.
  11030. */
  11031. private constructor();
  11032. /**
  11033. * Creates a new Stage.
  11034. * @returns A new instance of a Stage
  11035. */
  11036. static Create<T extends Function>(): Stage<T>;
  11037. /**
  11038. * Registers a step in an ordered way in the targeted stage.
  11039. * @param index Defines the position to register the step in
  11040. * @param component Defines the component attached to the step
  11041. * @param action Defines the action to launch during the step
  11042. */
  11043. registerStep(index: number, component: ISceneComponent, action: T): void;
  11044. /**
  11045. * Clears all the steps from the stage.
  11046. */
  11047. clear(): void;
  11048. }
  11049. }
  11050. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11051. import { Nullable } from "babylonjs/types";
  11052. import { Observable } from "babylonjs/Misc/observable";
  11053. import { Scene } from "babylonjs/scene";
  11054. import { Sprite } from "babylonjs/Sprites/sprite";
  11055. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11056. import { Ray } from "babylonjs/Culling/ray";
  11057. import { Camera } from "babylonjs/Cameras/camera";
  11058. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11059. import { ISceneComponent } from "babylonjs/sceneComponent";
  11060. module "babylonjs/scene" {
  11061. interface Scene {
  11062. /** @hidden */
  11063. _pointerOverSprite: Nullable<Sprite>;
  11064. /** @hidden */
  11065. _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */
  11067. _tempSpritePickingRay: Nullable<Ray>;
  11068. /**
  11069. * All of the sprite managers added to this scene
  11070. * @see https://doc.babylonjs.com/babylon101/sprites
  11071. */
  11072. spriteManagers: Array<ISpriteManager>;
  11073. /**
  11074. * An event triggered when sprites rendering is about to start
  11075. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11076. */
  11077. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11078. /**
  11079. * An event triggered when sprites rendering is done
  11080. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11081. */
  11082. onAfterSpritesRenderingObservable: Observable<Scene>;
  11083. /** @hidden */
  11084. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11085. /** Launch a ray to try to pick a sprite in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @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
  11089. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11090. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11091. * @returns a PickingInfo
  11092. */
  11093. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11094. /** Use the given ray to pick a sprite in the scene
  11095. * @param ray The ray (in world space) to use to pick meshes
  11096. * @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
  11097. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11099. * @returns a PickingInfo
  11100. */
  11101. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11102. /** @hidden */
  11103. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /** Launch a ray to try to pick sprites in the scene
  11105. * @param x position on screen
  11106. * @param y position on screen
  11107. * @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
  11108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo array
  11110. */
  11111. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11112. /** Use the given ray to pick sprites in the scene
  11113. * @param ray The ray (in world space) to use to pick meshes
  11114. * @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
  11115. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11116. * @returns a PickingInfo array
  11117. */
  11118. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11119. /**
  11120. * Force the sprite under the pointer
  11121. * @param sprite defines the sprite to use
  11122. */
  11123. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11124. /**
  11125. * Gets the sprite under the pointer
  11126. * @returns a Sprite or null if no sprite is under the pointer
  11127. */
  11128. getPointerOverSprite(): Nullable<Sprite>;
  11129. }
  11130. }
  11131. /**
  11132. * Defines the sprite scene component responsible to manage sprites
  11133. * in a given scene.
  11134. */
  11135. export class SpriteSceneComponent implements ISceneComponent {
  11136. /**
  11137. * The component name helpfull to identify the component in the list of scene components.
  11138. */
  11139. readonly name: string;
  11140. /**
  11141. * The scene the component belongs to.
  11142. */
  11143. scene: Scene;
  11144. /** @hidden */
  11145. private _spritePredicate;
  11146. /**
  11147. * Creates a new instance of the component for the given scene
  11148. * @param scene Defines the scene to register the component in
  11149. */
  11150. constructor(scene: Scene);
  11151. /**
  11152. * Registers the component in a given scene
  11153. */
  11154. register(): void;
  11155. /**
  11156. * Rebuilds the elements related to this component in case of
  11157. * context lost for instance.
  11158. */
  11159. rebuild(): void;
  11160. /**
  11161. * Disposes the component and the associated ressources.
  11162. */
  11163. dispose(): void;
  11164. private _pickSpriteButKeepRay;
  11165. private _pointerMove;
  11166. private _pointerDown;
  11167. private _pointerUp;
  11168. }
  11169. }
  11170. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11171. /** @hidden */
  11172. export var fogFragmentDeclaration: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11178. /** @hidden */
  11179. export var fogFragment: {
  11180. name: string;
  11181. shader: string;
  11182. };
  11183. }
  11184. declare module "babylonjs/Shaders/sprites.fragment" {
  11185. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11187. /** @hidden */
  11188. export var spritesPixelShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11194. /** @hidden */
  11195. export var fogVertexDeclaration: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/sprites.vertex" {
  11201. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11202. /** @hidden */
  11203. export var spritesVertexShader: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Sprites/spriteManager" {
  11209. import { IDisposable, Scene } from "babylonjs/scene";
  11210. import { Nullable } from "babylonjs/types";
  11211. import { Observable } from "babylonjs/Misc/observable";
  11212. import { Sprite } from "babylonjs/Sprites/sprite";
  11213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { Texture } from "babylonjs/Materials/Textures/texture";
  11216. import "babylonjs/Shaders/sprites.fragment";
  11217. import "babylonjs/Shaders/sprites.vertex";
  11218. import { Ray } from "babylonjs/Culling/ray";
  11219. /**
  11220. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11221. */
  11222. export interface ISpriteManager extends IDisposable {
  11223. /**
  11224. * Gets manager's name
  11225. */
  11226. name: string;
  11227. /**
  11228. * Restricts the camera to viewing objects with the same layerMask.
  11229. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11230. */
  11231. layerMask: number;
  11232. /**
  11233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11234. */
  11235. isPickable: boolean;
  11236. /**
  11237. * Gets the hosting scene
  11238. */
  11239. scene: Scene;
  11240. /**
  11241. * Specifies the rendering group id for this mesh (0 by default)
  11242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11243. */
  11244. renderingGroupId: number;
  11245. /**
  11246. * Defines the list of sprites managed by the manager.
  11247. */
  11248. sprites: Array<Sprite>;
  11249. /**
  11250. * Gets or sets the spritesheet texture
  11251. */
  11252. texture: Texture;
  11253. /** Defines the default width of a cell in the spritesheet */
  11254. cellWidth: number;
  11255. /** Defines the default height of a cell in the spritesheet */
  11256. cellHeight: number;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see https://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Define the Url to load snippets */
  11287. static SnippetUrl: string;
  11288. /** Snippet ID if the manager was created from the snippet server */
  11289. snippetId: string;
  11290. /** Gets the list of sprites */
  11291. sprites: Sprite[];
  11292. /** Gets or sets the rendering group id (0 by default) */
  11293. renderingGroupId: number;
  11294. /** Gets or sets camera layer mask */
  11295. layerMask: number;
  11296. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11297. fogEnabled: boolean;
  11298. /** Gets or sets a boolean indicating if the sprites are pickable */
  11299. isPickable: boolean;
  11300. /** Defines the default width of a cell in the spritesheet */
  11301. cellWidth: number;
  11302. /** Defines the default height of a cell in the spritesheet */
  11303. cellHeight: number;
  11304. /** Associative array from JSON sprite data file */
  11305. private _cellData;
  11306. /** Array of sprite names from JSON sprite data file */
  11307. private _spriteMap;
  11308. /** True when packed cell data from JSON file is ready*/
  11309. private _packedAndReady;
  11310. private _textureContent;
  11311. private _useInstancing;
  11312. /**
  11313. * An event triggered when the manager is disposed.
  11314. */
  11315. onDisposeObservable: Observable<SpriteManager>;
  11316. private _onDisposeObserver;
  11317. /**
  11318. * Callback called when the manager is disposed
  11319. */
  11320. set onDispose(callback: () => void);
  11321. private _capacity;
  11322. private _fromPacked;
  11323. private _spriteTexture;
  11324. private _epsilon;
  11325. private _scene;
  11326. private _vertexData;
  11327. private _buffer;
  11328. private _vertexBuffers;
  11329. private _spriteBuffer;
  11330. private _indexBuffer;
  11331. private _effectBase;
  11332. private _effectFog;
  11333. private _vertexBufferSize;
  11334. /**
  11335. * Gets or sets the unique id of the sprite
  11336. */
  11337. uniqueId: number;
  11338. /**
  11339. * Gets the array of sprites
  11340. */
  11341. get children(): Sprite[];
  11342. /**
  11343. * Gets the hosting scene
  11344. */
  11345. get scene(): Scene;
  11346. /**
  11347. * Gets the capacity of the manager
  11348. */
  11349. get capacity(): number;
  11350. /**
  11351. * Gets or sets the spritesheet texture
  11352. */
  11353. get texture(): Texture;
  11354. set texture(value: Texture);
  11355. private _blendMode;
  11356. /**
  11357. * Blend mode use to render the particle, it can be any of
  11358. * the static Constants.ALPHA_x properties provided in this class.
  11359. * Default value is Constants.ALPHA_COMBINE
  11360. */
  11361. get blendMode(): number;
  11362. set blendMode(blendMode: number);
  11363. /** Disables writing to the depth buffer when rendering the sprites.
  11364. * It can be handy to disable depth writing when using textures without alpha channel
  11365. * and setting some specific blend modes.
  11366. */
  11367. disableDepthWrite: boolean;
  11368. /**
  11369. * Creates a new sprite manager
  11370. * @param name defines the manager's name
  11371. * @param imgUrl defines the sprite sheet url
  11372. * @param capacity defines the maximum allowed number of sprites
  11373. * @param cellSize defines the size of a sprite cell
  11374. * @param scene defines the hosting scene
  11375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11376. * @param samplingMode defines the smapling mode to use with spritesheet
  11377. * @param fromPacked set to false; do not alter
  11378. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11379. */
  11380. constructor(
  11381. /** defines the manager's name */
  11382. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11383. /**
  11384. * Returns the string "SpriteManager"
  11385. * @returns "SpriteManager"
  11386. */
  11387. getClassName(): string;
  11388. private _makePacked;
  11389. private _appendSpriteVertex;
  11390. private _checkTextureAlpha;
  11391. /**
  11392. * Intersects the sprites with a ray
  11393. * @param ray defines the ray to intersect with
  11394. * @param camera defines the current active camera
  11395. * @param predicate defines a predicate used to select candidate sprites
  11396. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11397. * @returns null if no hit or a PickingInfo
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Render all child sprites
  11410. */
  11411. render(): void;
  11412. /**
  11413. * Release associated resources
  11414. */
  11415. dispose(): void;
  11416. /**
  11417. * Serializes the sprite manager to a JSON object
  11418. * @param serializeTexture defines if the texture must be serialized as well
  11419. * @returns the JSON object
  11420. */
  11421. serialize(serializeTexture?: boolean): any;
  11422. /**
  11423. * Parses a JSON object to create a new sprite manager.
  11424. * @param parsedManager The JSON object to parse
  11425. * @param scene The scene to create the sprite managerin
  11426. * @param rootUrl The root url to use to load external dependencies like texture
  11427. * @returns the new sprite manager
  11428. */
  11429. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11430. /**
  11431. * Creates a sprite manager from a snippet saved in a remote file
  11432. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11433. * @param url defines the url to load from
  11434. * @param scene defines the hosting scene
  11435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11436. * @returns a promise that will resolve to the new sprite manager
  11437. */
  11438. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11439. /**
  11440. * Creates a sprite manager from a snippet saved by the sprite editor
  11441. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11442. * @param scene defines the hosting scene
  11443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11444. * @returns a promise that will resolve to the new sprite manager
  11445. */
  11446. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11447. }
  11448. }
  11449. declare module "babylonjs/Misc/gradients" {
  11450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11451. /** Interface used by value gradients (color, factor, ...) */
  11452. export interface IValueGradient {
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number;
  11457. }
  11458. /** Class used to store color4 gradient */
  11459. export class ColorGradient implements IValueGradient {
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number;
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4;
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined;
  11472. /**
  11473. * Creates a new color4 gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param color1 gets or sets first associated color
  11476. * @param color2 gets or sets first second color
  11477. */
  11478. constructor(
  11479. /**
  11480. * Gets or sets the gradient value (between 0 and 1)
  11481. */
  11482. gradient: number,
  11483. /**
  11484. * Gets or sets first associated color
  11485. */
  11486. color1: Color4,
  11487. /**
  11488. * Gets or sets second associated color
  11489. */
  11490. color2?: Color4 | undefined);
  11491. /**
  11492. * Will get a color picked randomly between color1 and color2.
  11493. * If color2 is undefined then color1 will be used
  11494. * @param result defines the target Color4 to store the result in
  11495. */
  11496. getColorToRef(result: Color4): void;
  11497. }
  11498. /** Class used to store color 3 gradient */
  11499. export class Color3Gradient implements IValueGradient {
  11500. /**
  11501. * Gets or sets the gradient value (between 0 and 1)
  11502. */
  11503. gradient: number;
  11504. /**
  11505. * Gets or sets the associated color
  11506. */
  11507. color: Color3;
  11508. /**
  11509. * Creates a new color3 gradient
  11510. * @param gradient gets or sets the gradient value (between 0 and 1)
  11511. * @param color gets or sets associated color
  11512. */
  11513. constructor(
  11514. /**
  11515. * Gets or sets the gradient value (between 0 and 1)
  11516. */
  11517. gradient: number,
  11518. /**
  11519. * Gets or sets the associated color
  11520. */
  11521. color: Color3);
  11522. }
  11523. /** Class used to store factor gradient */
  11524. export class FactorGradient implements IValueGradient {
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number;
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number;
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined;
  11537. /**
  11538. * Creates a new factor gradient
  11539. * @param gradient gets or sets the gradient value (between 0 and 1)
  11540. * @param factor1 gets or sets first associated factor
  11541. * @param factor2 gets or sets second associated factor
  11542. */
  11543. constructor(
  11544. /**
  11545. * Gets or sets the gradient value (between 0 and 1)
  11546. */
  11547. gradient: number,
  11548. /**
  11549. * Gets or sets first associated factor
  11550. */
  11551. factor1: number,
  11552. /**
  11553. * Gets or sets second associated factor
  11554. */
  11555. factor2?: number | undefined);
  11556. /**
  11557. * Will get a number picked randomly between factor1 and factor2.
  11558. * If factor2 is undefined then factor1 will be used
  11559. * @returns the picked number
  11560. */
  11561. getFactor(): number;
  11562. }
  11563. /**
  11564. * Helper used to simplify some generic gradient tasks
  11565. */
  11566. export class GradientHelper {
  11567. /**
  11568. * Gets the current gradient from an array of IValueGradient
  11569. * @param ratio defines the current ratio to get
  11570. * @param gradients defines the array of IValueGradient
  11571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11572. */
  11573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11574. }
  11575. }
  11576. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11577. import { Nullable } from "babylonjs/types";
  11578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11579. import { Scene } from "babylonjs/scene";
  11580. module "babylonjs/Engines/thinEngine" {
  11581. interface ThinEngine {
  11582. /**
  11583. * Creates a raw texture
  11584. * @param data defines the data to store in the texture
  11585. * @param width defines the width of the texture
  11586. * @param height defines the height of the texture
  11587. * @param format defines the format of the data
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. * @returns the raw texture inside an InternalTexture
  11594. */
  11595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11596. /**
  11597. * Update a raw texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store in the texture
  11600. * @param format defines the format of the data
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11614. /**
  11615. * Creates a new raw cube texture
  11616. * @param data defines the array of data to use to create each face
  11617. * @param size defines the size of the textures
  11618. * @param format defines the format of the data
  11619. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11623. * @param compression defines the compression used (null by default)
  11624. * @returns the cube texture as an InternalTexture
  11625. */
  11626. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. */
  11635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11636. /**
  11637. * Update a raw cube texture
  11638. * @param texture defines the texture to udpdate
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param compression defines the compression used (null by default)
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. * @param level defines which level of the texture to update
  11655. */
  11656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  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. * @returns the cube texture as an InternalTexture
  11670. */
  11671. 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;
  11672. /**
  11673. * Creates a new raw cube texture from a specified url
  11674. * @param url defines the url where the data is located
  11675. * @param scene defines the current scene
  11676. * @param size defines the size of the textures
  11677. * @param format defines the format of the data
  11678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11679. * @param noMipmap defines if the engine should avoid generating the mip levels
  11680. * @param callback defines a callback used to extract texture data from loaded data
  11681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11682. * @param onLoad defines a callback called when texture is loaded
  11683. * @param onError defines a callback called if there is an error
  11684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @returns the cube texture as an InternalTexture
  11687. */
  11688. 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;
  11689. /**
  11690. * Creates a new raw 3D texture
  11691. * @param data defines the data used to create the texture
  11692. * @param width defines the width of the texture
  11693. * @param height defines the height of the texture
  11694. * @param depth defines the depth of the texture
  11695. * @param format defines the format of the texture
  11696. * @param generateMipMaps defines if the engine must generate mip levels
  11697. * @param invertY defines if data must be stored with Y axis inverted
  11698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11699. * @param compression defines the compressed used (can be null)
  11700. * @param textureType defines the compressed used (can be null)
  11701. * @returns a new raw 3D texture (stored in an InternalTexture)
  11702. */
  11703. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11704. /**
  11705. * Update a raw 3D texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11712. /**
  11713. * Update a raw 3D texture
  11714. * @param texture defines the texture to update
  11715. * @param data defines the data to store
  11716. * @param format defines the data format
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param compression defines the used compression (can be null)
  11719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11722. /**
  11723. * Creates a new raw 2D array texture
  11724. * @param data defines the data used to create the texture
  11725. * @param width defines the width of the texture
  11726. * @param height defines the height of the texture
  11727. * @param depth defines the number of layers of the texture
  11728. * @param format defines the format of the texture
  11729. * @param generateMipMaps defines if the engine must generate mip levels
  11730. * @param invertY defines if data must be stored with Y axis inverted
  11731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11732. * @param compression defines the compressed used (can be null)
  11733. * @param textureType defines the compressed used (can be null)
  11734. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11735. */
  11736. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11737. /**
  11738. * Update a raw 2D array texture
  11739. * @param texture defines the texture to update
  11740. * @param data defines the data to store
  11741. * @param format defines the data format
  11742. * @param invertY defines if data must be stored with Y axis inverted
  11743. */
  11744. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11745. /**
  11746. * Update a raw 2D array texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @param compression defines the used compression (can be null)
  11752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11755. }
  11756. }
  11757. }
  11758. declare module "babylonjs/Materials/Textures/rawTexture" {
  11759. import { Texture } from "babylonjs/Materials/Textures/texture";
  11760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11763. import { Scene } from "babylonjs/scene";
  11764. /**
  11765. * Raw texture can help creating a texture directly from an array of data.
  11766. * This can be super useful if you either get the data from an uncompressed source or
  11767. * if you wish to create your texture pixel by pixel.
  11768. */
  11769. export class RawTexture extends Texture {
  11770. /**
  11771. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11772. */
  11773. format: number;
  11774. /**
  11775. * Instantiates a new RawTexture.
  11776. * Raw texture can help creating a texture directly from an array of data.
  11777. * This can be super useful if you either get the data from an uncompressed source or
  11778. * if you wish to create your texture pixel by pixel.
  11779. * @param data define the array of data to use to create the texture
  11780. * @param width define the width of the texture
  11781. * @param height define the height of the texture
  11782. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps define whether mip maps should be generated or not
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. */
  11789. constructor(data: ArrayBufferView, width: number, height: number,
  11790. /**
  11791. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11792. */
  11793. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11794. /**
  11795. * Updates the texture underlying data.
  11796. * @param data Define the new data of the texture
  11797. */
  11798. update(data: ArrayBufferView): void;
  11799. /**
  11800. * Creates a luminance texture from some data.
  11801. * @param data Define the texture data
  11802. * @param width Define the width of the texture
  11803. * @param height Define the height of the texture
  11804. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11808. * @returns the luminance texture
  11809. */
  11810. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11811. /**
  11812. * Creates a luminance alpha texture from some data.
  11813. * @param data Define the texture data
  11814. * @param width Define the width of the texture
  11815. * @param height Define the height of the texture
  11816. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11820. * @returns the luminance alpha texture
  11821. */
  11822. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11823. /**
  11824. * Creates an alpha texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the alpha texture
  11833. */
  11834. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a RGB texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11845. * @returns the RGB alpha texture
  11846. */
  11847. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11848. /**
  11849. * Creates a RGBA texture from some data.
  11850. * @param data Define the texture data
  11851. * @param width Define the width of the texture
  11852. * @param height Define the height of the texture
  11853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11858. * @returns the RGBA texture
  11859. */
  11860. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11861. /**
  11862. * Creates a R texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11871. * @returns the R texture
  11872. */
  11873. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11874. }
  11875. }
  11876. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11878. import { IndicesArray, DataArray } from "babylonjs/types";
  11879. module "babylonjs/Engines/thinEngine" {
  11880. interface ThinEngine {
  11881. /**
  11882. * Update a dynamic index buffer
  11883. * @param indexBuffer defines the target index buffer
  11884. * @param indices defines the data to update
  11885. * @param offset defines the offset in the target index buffer where update should start
  11886. */
  11887. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11888. /**
  11889. * Updates a dynamic vertex buffer.
  11890. * @param vertexBuffer the vertex buffer to update
  11891. * @param data the data used to update the vertex buffer
  11892. * @param byteOffset the byte offset of the data
  11893. * @param byteLength the byte length of the data
  11894. */
  11895. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11896. }
  11897. }
  11898. }
  11899. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11900. import { Scene } from "babylonjs/scene";
  11901. import { ISceneComponent } from "babylonjs/sceneComponent";
  11902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11903. module "babylonjs/abstractScene" {
  11904. interface AbstractScene {
  11905. /**
  11906. * The list of procedural textures added to the scene
  11907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11908. */
  11909. proceduralTextures: Array<ProceduralTexture>;
  11910. }
  11911. }
  11912. /**
  11913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11914. * in a given scene.
  11915. */
  11916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11917. /**
  11918. * The component name helpfull to identify the component in the list of scene components.
  11919. */
  11920. readonly name: string;
  11921. /**
  11922. * The scene the component belongs to.
  11923. */
  11924. scene: Scene;
  11925. /**
  11926. * Creates a new instance of the component for the given scene
  11927. * @param scene Defines the scene to register the component in
  11928. */
  11929. constructor(scene: Scene);
  11930. /**
  11931. * Registers the component in a given scene
  11932. */
  11933. register(): void;
  11934. /**
  11935. * Rebuilds the elements related to this component in case of
  11936. * context lost for instance.
  11937. */
  11938. rebuild(): void;
  11939. /**
  11940. * Disposes the component and the associated ressources.
  11941. */
  11942. dispose(): void;
  11943. private _beforeClear;
  11944. }
  11945. }
  11946. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11949. module "babylonjs/Engines/thinEngine" {
  11950. interface ThinEngine {
  11951. /**
  11952. * Creates a new render target cube texture
  11953. * @param size defines the size of the texture
  11954. * @param options defines the options used to create the texture
  11955. * @returns a new render target cube texture stored in an InternalTexture
  11956. */
  11957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11958. }
  11959. }
  11960. }
  11961. declare module "babylonjs/Shaders/procedural.vertex" {
  11962. /** @hidden */
  11963. export var proceduralVertexShader: {
  11964. name: string;
  11965. shader: string;
  11966. };
  11967. }
  11968. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11969. import { Observable } from "babylonjs/Misc/observable";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Scene } from "babylonjs/scene";
  11972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11973. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11974. import { Effect } from "babylonjs/Materials/effect";
  11975. import { Texture } from "babylonjs/Materials/Textures/texture";
  11976. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11977. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11978. import "babylonjs/Shaders/procedural.vertex";
  11979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11980. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11981. /**
  11982. * 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.
  11983. * This is the base class of any Procedural texture and contains most of the shareable code.
  11984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11985. */
  11986. export class ProceduralTexture extends Texture {
  11987. /**
  11988. * Define if the texture is enabled or not (disabled texture will not render)
  11989. */
  11990. isEnabled: boolean;
  11991. /**
  11992. * Define if the texture must be cleared before rendering (default is true)
  11993. */
  11994. autoClear: boolean;
  11995. /**
  11996. * Callback called when the texture is generated
  11997. */
  11998. onGenerated: () => void;
  11999. /**
  12000. * Event raised when the texture is generated
  12001. */
  12002. onGeneratedObservable: Observable<ProceduralTexture>;
  12003. /**
  12004. * Event raised before the texture is generated
  12005. */
  12006. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12007. /**
  12008. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12009. */
  12010. nodeMaterialSource: Nullable<NodeMaterial>;
  12011. /** @hidden */
  12012. _generateMipMaps: boolean;
  12013. /** @hidden **/
  12014. _effect: Effect;
  12015. /** @hidden */
  12016. _textures: {
  12017. [key: string]: Texture;
  12018. };
  12019. /** @hidden */
  12020. protected _fallbackTexture: Nullable<Texture>;
  12021. private _size;
  12022. private _currentRefreshId;
  12023. private _frameId;
  12024. private _refreshRate;
  12025. private _vertexBuffers;
  12026. private _indexBuffer;
  12027. private _uniforms;
  12028. private _samplers;
  12029. private _fragment;
  12030. private _floats;
  12031. private _ints;
  12032. private _floatsArrays;
  12033. private _colors3;
  12034. private _colors4;
  12035. private _vectors2;
  12036. private _vectors3;
  12037. private _matrices;
  12038. private _fallbackTextureUsed;
  12039. private _fullEngine;
  12040. private _cachedDefines;
  12041. private _contentUpdateId;
  12042. private _contentData;
  12043. /**
  12044. * Instantiates a new procedural texture.
  12045. * 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.
  12046. * This is the base class of any Procedural texture and contains most of the shareable code.
  12047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12048. * @param name Define the name of the texture
  12049. * @param size Define the size of the texture to create
  12050. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12051. * @param scene Define the scene the texture belongs to
  12052. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12053. * @param generateMipMaps Define if the texture should creates mip maps or not
  12054. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12055. */
  12056. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12057. /**
  12058. * The effect that is created when initializing the post process.
  12059. * @returns The created effect corresponding the the postprocess.
  12060. */
  12061. getEffect(): Effect;
  12062. /**
  12063. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12064. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12065. */
  12066. getContent(): Nullable<ArrayBufferView>;
  12067. private _createIndexBuffer;
  12068. /** @hidden */
  12069. _rebuild(): void;
  12070. /**
  12071. * Resets the texture in order to recreate its associated resources.
  12072. * This can be called in case of context loss
  12073. */
  12074. reset(): void;
  12075. protected _getDefines(): string;
  12076. /**
  12077. * Is the texture ready to be used ? (rendered at least once)
  12078. * @returns true if ready, otherwise, false.
  12079. */
  12080. isReady(): boolean;
  12081. /**
  12082. * Resets the refresh counter of the texture and start bak from scratch.
  12083. * Could be useful to regenerate the texture if it is setup to render only once.
  12084. */
  12085. resetRefreshCounter(): void;
  12086. /**
  12087. * Set the fragment shader to use in order to render the texture.
  12088. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12089. */
  12090. setFragment(fragment: any): void;
  12091. /**
  12092. * Define the refresh rate of the texture or the rendering frequency.
  12093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12094. */
  12095. get refreshRate(): number;
  12096. set refreshRate(value: number);
  12097. /** @hidden */
  12098. _shouldRender(): boolean;
  12099. /**
  12100. * Get the size the texture is rendering at.
  12101. * @returns the size (on cube texture it is always squared)
  12102. */
  12103. getRenderSize(): RenderTargetTextureSize;
  12104. /**
  12105. * Resize the texture to new value.
  12106. * @param size Define the new size the texture should have
  12107. * @param generateMipMaps Define whether the new texture should create mip maps
  12108. */
  12109. resize(size: number, generateMipMaps: boolean): void;
  12110. private _checkUniform;
  12111. /**
  12112. * Set a texture in the shader program used to render.
  12113. * @param name Define the name of the uniform samplers as defined in the shader
  12114. * @param texture Define the texture to bind to this sampler
  12115. * @return the texture itself allowing "fluent" like uniform updates
  12116. */
  12117. setTexture(name: string, texture: Texture): ProceduralTexture;
  12118. /**
  12119. * Set a float in the shader.
  12120. * @param name Define the name of the uniform as defined in the shader
  12121. * @param value Define the value to give to the uniform
  12122. * @return the texture itself allowing "fluent" like uniform updates
  12123. */
  12124. setFloat(name: string, value: number): ProceduralTexture;
  12125. /**
  12126. * Set a int in the shader.
  12127. * @param name Define the name of the uniform as defined in the shader
  12128. * @param value Define the value to give to the uniform
  12129. * @return the texture itself allowing "fluent" like uniform updates
  12130. */
  12131. setInt(name: string, value: number): ProceduralTexture;
  12132. /**
  12133. * Set an array of floats in the shader.
  12134. * @param name Define the name of the uniform as defined in the shader
  12135. * @param value Define the value to give to the uniform
  12136. * @return the texture itself allowing "fluent" like uniform updates
  12137. */
  12138. setFloats(name: string, value: number[]): ProceduralTexture;
  12139. /**
  12140. * Set a vec3 in the shader from a Color3.
  12141. * @param name Define the name of the uniform as defined in the shader
  12142. * @param value Define the value to give to the uniform
  12143. * @return the texture itself allowing "fluent" like uniform updates
  12144. */
  12145. setColor3(name: string, value: Color3): ProceduralTexture;
  12146. /**
  12147. * Set a vec4 in the shader from a Color4.
  12148. * @param name Define the name of the uniform as defined in the shader
  12149. * @param value Define the value to give to the uniform
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setColor4(name: string, value: Color4): ProceduralTexture;
  12153. /**
  12154. * Set a vec2 in the shader from a Vector2.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setVector2(name: string, value: Vector2): ProceduralTexture;
  12160. /**
  12161. * Set a vec3 in the shader from a Vector3.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setVector3(name: string, value: Vector3): ProceduralTexture;
  12167. /**
  12168. * Set a mat4 in the shader from a MAtrix.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12174. /**
  12175. * Render the texture to its associated render target.
  12176. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12177. */
  12178. render(useCameraPostProcess?: boolean): void;
  12179. /**
  12180. * Clone the texture.
  12181. * @returns the cloned texture
  12182. */
  12183. clone(): ProceduralTexture;
  12184. /**
  12185. * Dispose the texture and release its asoociated resources.
  12186. */
  12187. dispose(): void;
  12188. }
  12189. }
  12190. declare module "babylonjs/Particles/baseParticleSystem" {
  12191. import { Nullable } from "babylonjs/types";
  12192. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12194. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12195. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12196. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12198. import { Color4 } from "babylonjs/Maths/math.color";
  12199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12200. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12201. import { Animation } from "babylonjs/Animations/animation";
  12202. import { Scene } from "babylonjs/scene";
  12203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12205. /**
  12206. * This represents the base class for particle system in Babylon.
  12207. * 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.
  12208. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12209. * @example https://doc.babylonjs.com/babylon101/particles
  12210. */
  12211. export class BaseParticleSystem {
  12212. /**
  12213. * Source color is added to the destination color without alpha affecting the result
  12214. */
  12215. static BLENDMODE_ONEONE: number;
  12216. /**
  12217. * Blend current color and particle color using particle’s alpha
  12218. */
  12219. static BLENDMODE_STANDARD: number;
  12220. /**
  12221. * Add current color and particle color multiplied by particle’s alpha
  12222. */
  12223. static BLENDMODE_ADD: number;
  12224. /**
  12225. * Multiply current color with particle color
  12226. */
  12227. static BLENDMODE_MULTIPLY: number;
  12228. /**
  12229. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12230. */
  12231. static BLENDMODE_MULTIPLYADD: number;
  12232. /**
  12233. * List of animations used by the particle system.
  12234. */
  12235. animations: Animation[];
  12236. /**
  12237. * Gets or sets the unique id of the particle system
  12238. */
  12239. uniqueId: number;
  12240. /**
  12241. * The id of the Particle system.
  12242. */
  12243. id: string;
  12244. /**
  12245. * The friendly name of the Particle system.
  12246. */
  12247. name: string;
  12248. /**
  12249. * Snippet ID if the particle system was created from the snippet server
  12250. */
  12251. snippetId: string;
  12252. /**
  12253. * The rendering group used by the Particle system to chose when to render.
  12254. */
  12255. renderingGroupId: number;
  12256. /**
  12257. * The emitter represents the Mesh or position we are attaching the particle system to.
  12258. */
  12259. emitter: Nullable<AbstractMesh | Vector3>;
  12260. /**
  12261. * The maximum number of particles to emit per frame
  12262. */
  12263. emitRate: number;
  12264. /**
  12265. * If you want to launch only a few particles at once, that can be done, as well.
  12266. */
  12267. manualEmitCount: number;
  12268. /**
  12269. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12270. */
  12271. updateSpeed: number;
  12272. /**
  12273. * The amount of time the particle system is running (depends of the overall update speed).
  12274. */
  12275. targetStopDuration: number;
  12276. /**
  12277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12278. */
  12279. disposeOnStop: boolean;
  12280. /**
  12281. * Minimum power of emitting particles.
  12282. */
  12283. minEmitPower: number;
  12284. /**
  12285. * Maximum power of emitting particles.
  12286. */
  12287. maxEmitPower: number;
  12288. /**
  12289. * Minimum life time of emitting particles.
  12290. */
  12291. minLifeTime: number;
  12292. /**
  12293. * Maximum life time of emitting particles.
  12294. */
  12295. maxLifeTime: number;
  12296. /**
  12297. * Minimum Size of emitting particles.
  12298. */
  12299. minSize: number;
  12300. /**
  12301. * Maximum Size of emitting particles.
  12302. */
  12303. maxSize: number;
  12304. /**
  12305. * Minimum scale of emitting particles on X axis.
  12306. */
  12307. minScaleX: number;
  12308. /**
  12309. * Maximum scale of emitting particles on X axis.
  12310. */
  12311. maxScaleX: number;
  12312. /**
  12313. * Minimum scale of emitting particles on Y axis.
  12314. */
  12315. minScaleY: number;
  12316. /**
  12317. * Maximum scale of emitting particles on Y axis.
  12318. */
  12319. maxScaleY: number;
  12320. /**
  12321. * Gets or sets the minimal initial rotation in radians.
  12322. */
  12323. minInitialRotation: number;
  12324. /**
  12325. * Gets or sets the maximal initial rotation in radians.
  12326. */
  12327. maxInitialRotation: number;
  12328. /**
  12329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12330. */
  12331. minAngularSpeed: number;
  12332. /**
  12333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12334. */
  12335. maxAngularSpeed: number;
  12336. /**
  12337. * The texture used to render each particle. (this can be a spritesheet)
  12338. */
  12339. particleTexture: Nullable<BaseTexture>;
  12340. /**
  12341. * The layer mask we are rendering the particles through.
  12342. */
  12343. layerMask: number;
  12344. /**
  12345. * This can help using your own shader to render the particle system.
  12346. * The according effect will be created
  12347. */
  12348. customShader: any;
  12349. /**
  12350. * By default particle system starts as soon as they are created. This prevents the
  12351. * automatic start to happen and let you decide when to start emitting particles.
  12352. */
  12353. preventAutoStart: boolean;
  12354. private _noiseTexture;
  12355. /**
  12356. * Gets or sets a texture used to add random noise to particle positions
  12357. */
  12358. get noiseTexture(): Nullable<ProceduralTexture>;
  12359. set noiseTexture(value: Nullable<ProceduralTexture>);
  12360. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12361. noiseStrength: Vector3;
  12362. /**
  12363. * Callback triggered when the particle animation is ending.
  12364. */
  12365. onAnimationEnd: Nullable<() => void>;
  12366. /**
  12367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12368. */
  12369. blendMode: number;
  12370. /**
  12371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12372. * to override the particles.
  12373. */
  12374. forceDepthWrite: boolean;
  12375. /** 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 */
  12376. preWarmCycles: number;
  12377. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12378. preWarmStepOffset: number;
  12379. /**
  12380. * 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)
  12381. */
  12382. spriteCellChangeSpeed: number;
  12383. /**
  12384. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12385. */
  12386. startSpriteCellID: number;
  12387. /**
  12388. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12389. */
  12390. endSpriteCellID: number;
  12391. /**
  12392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12393. */
  12394. spriteCellWidth: number;
  12395. /**
  12396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12397. */
  12398. spriteCellHeight: number;
  12399. /**
  12400. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12401. */
  12402. spriteRandomStartCell: boolean;
  12403. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12404. translationPivot: Vector2;
  12405. /** @hidden */
  12406. protected _isAnimationSheetEnabled: boolean;
  12407. /**
  12408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12409. */
  12410. beginAnimationOnStart: boolean;
  12411. /**
  12412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12413. */
  12414. beginAnimationFrom: number;
  12415. /**
  12416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12417. */
  12418. beginAnimationTo: number;
  12419. /**
  12420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12421. */
  12422. beginAnimationLoop: boolean;
  12423. /**
  12424. * Gets or sets a world offset applied to all particles
  12425. */
  12426. worldOffset: Vector3;
  12427. /**
  12428. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12429. */
  12430. get isAnimationSheetEnabled(): boolean;
  12431. set isAnimationSheetEnabled(value: boolean);
  12432. /**
  12433. * Get hosting scene
  12434. * @returns the scene
  12435. */
  12436. getScene(): Nullable<Scene>;
  12437. /**
  12438. * You can use gravity if you want to give an orientation to your particles.
  12439. */
  12440. gravity: Vector3;
  12441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12454. /**
  12455. * Defines the delay in milliseconds before starting the system (0 by default)
  12456. */
  12457. startDelay: number;
  12458. /**
  12459. * Gets the current list of drag gradients.
  12460. * You must use addDragGradient and removeDragGradient to udpate this list
  12461. * @returns the list of drag gradients
  12462. */
  12463. getDragGradients(): Nullable<Array<FactorGradient>>;
  12464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12465. limitVelocityDamping: number;
  12466. /**
  12467. * Gets the current list of limit velocity gradients.
  12468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12469. * @returns the list of limit velocity gradients
  12470. */
  12471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12472. /**
  12473. * Gets the current list of color gradients.
  12474. * You must use addColorGradient and removeColorGradient to udpate this list
  12475. * @returns the list of color gradients
  12476. */
  12477. getColorGradients(): Nullable<Array<ColorGradient>>;
  12478. /**
  12479. * Gets the current list of size gradients.
  12480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12481. * @returns the list of size gradients
  12482. */
  12483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12484. /**
  12485. * Gets the current list of color remap gradients.
  12486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12487. * @returns the list of color remap gradients
  12488. */
  12489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12490. /**
  12491. * Gets the current list of alpha remap gradients.
  12492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12493. * @returns the list of alpha remap gradients
  12494. */
  12495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12496. /**
  12497. * Gets the current list of life time gradients.
  12498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12499. * @returns the list of life time gradients
  12500. */
  12501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12502. /**
  12503. * Gets the current list of angular speed gradients.
  12504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12505. * @returns the list of angular speed gradients
  12506. */
  12507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12508. /**
  12509. * Gets the current list of velocity gradients.
  12510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12511. * @returns the list of velocity gradients
  12512. */
  12513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of start size gradients.
  12516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12517. * @returns the list of start size gradients
  12518. */
  12519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12520. /**
  12521. * Gets the current list of emit rate gradients.
  12522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12523. * @returns the list of emit rate gradients
  12524. */
  12525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12529. */
  12530. get direction1(): Vector3;
  12531. set direction1(value: Vector3);
  12532. /**
  12533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12535. */
  12536. get direction2(): Vector3;
  12537. set direction2(value: Vector3);
  12538. /**
  12539. * 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.
  12540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12541. */
  12542. get minEmitBox(): Vector3;
  12543. set minEmitBox(value: Vector3);
  12544. /**
  12545. * 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.
  12546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12547. */
  12548. get maxEmitBox(): Vector3;
  12549. set maxEmitBox(value: Vector3);
  12550. /**
  12551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12552. */
  12553. color1: Color4;
  12554. /**
  12555. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12556. */
  12557. color2: Color4;
  12558. /**
  12559. * Color the particle will have at the end of its lifetime
  12560. */
  12561. colorDead: Color4;
  12562. /**
  12563. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12564. */
  12565. textureMask: Color4;
  12566. /**
  12567. * The particle emitter type defines the emitter used by the particle system.
  12568. * It can be for example box, sphere, or cone...
  12569. */
  12570. particleEmitterType: IParticleEmitterType;
  12571. /** @hidden */
  12572. _isSubEmitter: boolean;
  12573. /**
  12574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12576. */
  12577. billboardMode: number;
  12578. protected _isBillboardBased: boolean;
  12579. /**
  12580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12581. */
  12582. get isBillboardBased(): boolean;
  12583. set isBillboardBased(value: boolean);
  12584. /**
  12585. * The scene the particle system belongs to.
  12586. */
  12587. protected _scene: Nullable<Scene>;
  12588. /**
  12589. * The engine the particle system belongs to.
  12590. */
  12591. protected _engine: ThinEngine;
  12592. /**
  12593. * Local cache of defines for image processing.
  12594. */
  12595. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12596. /**
  12597. * Default configuration related to image processing available in the standard Material.
  12598. */
  12599. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12600. /**
  12601. * Gets the image processing configuration used either in this material.
  12602. */
  12603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12604. /**
  12605. * Sets the Default image processing configuration used either in the this material.
  12606. *
  12607. * If sets to null, the scene one is in use.
  12608. */
  12609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12610. /**
  12611. * Attaches a new image processing configuration to the Standard Material.
  12612. * @param configuration
  12613. */
  12614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12615. /** @hidden */
  12616. protected _reset(): void;
  12617. /** @hidden */
  12618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12619. /**
  12620. * Instantiates a particle system.
  12621. * 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.
  12622. * @param name The name of the particle system
  12623. */
  12624. constructor(name: string);
  12625. /**
  12626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @returns the emitter
  12630. */
  12631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12632. /**
  12633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12634. * @param radius The radius of the hemisphere to emit from
  12635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12636. * @returns the emitter
  12637. */
  12638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12639. /**
  12640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12641. * @param radius The radius of the sphere to emit from
  12642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12643. * @returns the emitter
  12644. */
  12645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12646. /**
  12647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12648. * @param radius The radius of the sphere to emit from
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @returns the emitter
  12652. */
  12653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12656. * @param radius The radius of the emission cylinder
  12657. * @param height The height of the emission cylinder
  12658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12660. * @returns the emitter
  12661. */
  12662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12663. /**
  12664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12665. * @param radius The radius of the cylinder to emit from
  12666. * @param height The height of the emission cylinder
  12667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @returns the emitter
  12671. */
  12672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12675. * @param radius The radius of the cone to emit from
  12676. * @param angle The base angle of the cone
  12677. * @returns the emitter
  12678. */
  12679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12680. /**
  12681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @returns the emitter
  12687. */
  12688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12689. }
  12690. }
  12691. declare module "babylonjs/Particles/subEmitter" {
  12692. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12693. import { Scene } from "babylonjs/scene";
  12694. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12695. /**
  12696. * Type of sub emitter
  12697. */
  12698. export enum SubEmitterType {
  12699. /**
  12700. * Attached to the particle over it's lifetime
  12701. */
  12702. ATTACHED = 0,
  12703. /**
  12704. * Created when the particle dies
  12705. */
  12706. END = 1
  12707. }
  12708. /**
  12709. * Sub emitter class used to emit particles from an existing particle
  12710. */
  12711. export class SubEmitter {
  12712. /**
  12713. * the particle system to be used by the sub emitter
  12714. */
  12715. particleSystem: ParticleSystem;
  12716. /**
  12717. * Type of the submitter (Default: END)
  12718. */
  12719. type: SubEmitterType;
  12720. /**
  12721. * 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)
  12722. * Note: This only is supported when using an emitter of type Mesh
  12723. */
  12724. inheritDirection: boolean;
  12725. /**
  12726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12727. */
  12728. inheritedVelocityAmount: number;
  12729. /**
  12730. * Creates a sub emitter
  12731. * @param particleSystem the particle system to be used by the sub emitter
  12732. */
  12733. constructor(
  12734. /**
  12735. * the particle system to be used by the sub emitter
  12736. */
  12737. particleSystem: ParticleSystem);
  12738. /**
  12739. * Clones the sub emitter
  12740. * @returns the cloned sub emitter
  12741. */
  12742. clone(): SubEmitter;
  12743. /**
  12744. * Serialize current object to a JSON object
  12745. * @returns the serialized object
  12746. */
  12747. serialize(): any;
  12748. /** @hidden */
  12749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12750. /**
  12751. * Creates a new SubEmitter from a serialized JSON version
  12752. * @param serializationObject defines the JSON object to read from
  12753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12754. * @param rootUrl defines the rootUrl for data loading
  12755. * @returns a new SubEmitter
  12756. */
  12757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12758. /** Release associated resources */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12763. /** @hidden */
  12764. export var imageProcessingDeclaration: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12770. /** @hidden */
  12771. export var imageProcessingFunctions: {
  12772. name: string;
  12773. shader: string;
  12774. };
  12775. }
  12776. declare module "babylonjs/Shaders/particles.fragment" {
  12777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12782. /** @hidden */
  12783. export var particlesPixelShader: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/particles.vertex" {
  12789. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12791. /** @hidden */
  12792. export var particlesVertexShader: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12798. import { Nullable } from "babylonjs/types";
  12799. import { Plane } from "babylonjs/Maths/math";
  12800. /**
  12801. * Interface used to define entities containing multiple clip planes
  12802. */
  12803. export interface IClipPlanesHolder {
  12804. /**
  12805. * Gets or sets the active clipplane 1
  12806. */
  12807. clipPlane: Nullable<Plane>;
  12808. /**
  12809. * Gets or sets the active clipplane 2
  12810. */
  12811. clipPlane2: Nullable<Plane>;
  12812. /**
  12813. * Gets or sets the active clipplane 3
  12814. */
  12815. clipPlane3: Nullable<Plane>;
  12816. /**
  12817. * Gets or sets the active clipplane 4
  12818. */
  12819. clipPlane4: Nullable<Plane>;
  12820. /**
  12821. * Gets or sets the active clipplane 5
  12822. */
  12823. clipPlane5: Nullable<Plane>;
  12824. /**
  12825. * Gets or sets the active clipplane 6
  12826. */
  12827. clipPlane6: Nullable<Plane>;
  12828. }
  12829. }
  12830. declare module "babylonjs/Materials/thinMaterialHelper" {
  12831. import { Effect } from "babylonjs/Materials/effect";
  12832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12833. /**
  12834. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12835. *
  12836. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12837. *
  12838. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12839. */
  12840. export class ThinMaterialHelper {
  12841. /**
  12842. * Binds the clip plane information from the holder to the effect.
  12843. * @param effect The effect we are binding the data to
  12844. * @param holder The entity containing the clip plane information
  12845. */
  12846. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12847. }
  12848. }
  12849. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12850. module "babylonjs/Engines/thinEngine" {
  12851. interface ThinEngine {
  12852. /**
  12853. * Sets alpha constants used by some alpha blending modes
  12854. * @param r defines the red component
  12855. * @param g defines the green component
  12856. * @param b defines the blue component
  12857. * @param a defines the alpha component
  12858. */
  12859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12860. /**
  12861. * Sets the current alpha mode
  12862. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12865. */
  12866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12867. /**
  12868. * Gets the current alpha mode
  12869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12870. * @returns the current alpha mode
  12871. */
  12872. getAlphaMode(): number;
  12873. /**
  12874. * Sets the current alpha equation
  12875. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12876. */
  12877. setAlphaEquation(equation: number): void;
  12878. /**
  12879. * Gets the current alpha equation.
  12880. * @returns the current alpha equation
  12881. */
  12882. getAlphaEquation(): number;
  12883. }
  12884. }
  12885. }
  12886. declare module "babylonjs/Particles/particleSystem" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12889. import { Observable } from "babylonjs/Misc/observable";
  12890. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12891. import { Effect } from "babylonjs/Materials/effect";
  12892. import { IDisposable } from "babylonjs/scene";
  12893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12895. import { Particle } from "babylonjs/Particles/particle";
  12896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12897. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12898. import "babylonjs/Shaders/particles.fragment";
  12899. import "babylonjs/Shaders/particles.vertex";
  12900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12902. import "babylonjs/Engines/Extensions/engine.alpha";
  12903. import { Scene } from "babylonjs/scene";
  12904. /**
  12905. * This represents a particle system in Babylon.
  12906. * 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.
  12907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12908. * @example https://doc.babylonjs.com/babylon101/particles
  12909. */
  12910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12911. /**
  12912. * Billboard mode will only apply to Y axis
  12913. */
  12914. static readonly BILLBOARDMODE_Y: number;
  12915. /**
  12916. * Billboard mode will apply to all axes
  12917. */
  12918. static readonly BILLBOARDMODE_ALL: number;
  12919. /**
  12920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12921. */
  12922. static readonly BILLBOARDMODE_STRETCHED: number;
  12923. /**
  12924. * This function can be defined to provide custom update for active particles.
  12925. * This function will be called instead of regular update (age, position, color, etc.).
  12926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12927. */
  12928. updateFunction: (particles: Particle[]) => void;
  12929. private _emitterWorldMatrix;
  12930. /**
  12931. * This function can be defined to specify initial direction for every new particle.
  12932. * It by default use the emitterType defined function
  12933. */
  12934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12935. /**
  12936. * This function can be defined to specify initial position for every new particle.
  12937. * It by default use the emitterType defined function
  12938. */
  12939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12940. /**
  12941. * @hidden
  12942. */
  12943. _inheritedVelocityOffset: Vector3;
  12944. /**
  12945. * An event triggered when the system is disposed
  12946. */
  12947. onDisposeObservable: Observable<IParticleSystem>;
  12948. private _onDisposeObserver;
  12949. /**
  12950. * Sets a callback that will be triggered when the system is disposed
  12951. */
  12952. set onDispose(callback: () => void);
  12953. private _particles;
  12954. private _epsilon;
  12955. private _capacity;
  12956. private _stockParticles;
  12957. private _newPartsExcess;
  12958. private _vertexData;
  12959. private _vertexBuffer;
  12960. private _vertexBuffers;
  12961. private _spriteBuffer;
  12962. private _indexBuffer;
  12963. private _effect;
  12964. private _customEffect;
  12965. private _cachedDefines;
  12966. private _scaledColorStep;
  12967. private _colorDiff;
  12968. private _scaledDirection;
  12969. private _scaledGravity;
  12970. private _currentRenderId;
  12971. private _alive;
  12972. private _useInstancing;
  12973. private _started;
  12974. private _stopped;
  12975. private _actualFrame;
  12976. private _scaledUpdateSpeed;
  12977. private _vertexBufferSize;
  12978. /** @hidden */
  12979. _currentEmitRateGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentEmitRate1: number;
  12982. /** @hidden */
  12983. _currentEmitRate2: number;
  12984. /** @hidden */
  12985. _currentStartSizeGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentStartSize1: number;
  12988. /** @hidden */
  12989. _currentStartSize2: number;
  12990. private readonly _rawTextureWidth;
  12991. private _rampGradientsTexture;
  12992. private _useRampGradients;
  12993. /** Gets or sets a matrix to use to compute projection */
  12994. defaultProjectionMatrix: Matrix;
  12995. /** Gets or sets a matrix to use to compute view */
  12996. defaultViewMatrix: Matrix;
  12997. /** Gets or sets a boolean indicating that ramp gradients must be used
  12998. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12999. */
  13000. get useRampGradients(): boolean;
  13001. set useRampGradients(value: boolean);
  13002. /**
  13003. * 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.
  13004. * 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: [])
  13005. */
  13006. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13007. private _subEmitters;
  13008. /**
  13009. * @hidden
  13010. * If the particle systems emitter should be disposed when the particle system is disposed
  13011. */
  13012. _disposeEmitterOnDispose: boolean;
  13013. /**
  13014. * The current active Sub-systems, this property is used by the root particle system only.
  13015. */
  13016. activeSubSystems: Array<ParticleSystem>;
  13017. /**
  13018. * Specifies if the particles are updated in emitter local space or world space
  13019. */
  13020. isLocal: boolean;
  13021. private _rootParticleSystem;
  13022. /**
  13023. * Gets the current list of active particles
  13024. */
  13025. get particles(): Particle[];
  13026. /**
  13027. * Gets the number of particles active at the same time.
  13028. * @returns The number of active particles.
  13029. */
  13030. getActiveCount(): number;
  13031. /**
  13032. * Returns the string "ParticleSystem"
  13033. * @returns a string containing the class name
  13034. */
  13035. getClassName(): string;
  13036. /**
  13037. * Gets a boolean indicating that the system is stopping
  13038. * @returns true if the system is currently stopping
  13039. */
  13040. isStopping(): boolean;
  13041. /**
  13042. * Gets the custom effect used to render the particles
  13043. * @param blendMode Blend mode for which the effect should be retrieved
  13044. * @returns The effect
  13045. */
  13046. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13047. /**
  13048. * Sets the custom effect used to render the particles
  13049. * @param effect The effect to set
  13050. * @param blendMode Blend mode for which the effect should be set
  13051. */
  13052. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13053. /** @hidden */
  13054. private _onBeforeDrawParticlesObservable;
  13055. /**
  13056. * Observable that will be called just before the particles are drawn
  13057. */
  13058. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13059. /**
  13060. * Gets the name of the particle vertex shader
  13061. */
  13062. get vertexShaderName(): string;
  13063. /**
  13064. * Instantiates a particle system.
  13065. * 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.
  13066. * @param name The name of the particle system
  13067. * @param capacity The max number of particles alive at the same time
  13068. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13069. * @param customEffect a custom effect used to change the way particles are rendered by default
  13070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13071. * @param epsilon Offset used to render the particles
  13072. */
  13073. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13074. private _addFactorGradient;
  13075. private _removeFactorGradient;
  13076. /**
  13077. * Adds a new life time gradient
  13078. * @param gradient defines the gradient to use (between 0 and 1)
  13079. * @param factor defines the life time factor to affect to the specified gradient
  13080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13081. * @returns the current particle system
  13082. */
  13083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13084. /**
  13085. * Remove a specific life time gradient
  13086. * @param gradient defines the gradient to remove
  13087. * @returns the current particle system
  13088. */
  13089. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13090. /**
  13091. * Adds a new size gradient
  13092. * @param gradient defines the gradient to use (between 0 and 1)
  13093. * @param factor defines the size factor to affect to the specified gradient
  13094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13095. * @returns the current particle system
  13096. */
  13097. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13098. /**
  13099. * Remove a specific size gradient
  13100. * @param gradient defines the gradient to remove
  13101. * @returns the current particle system
  13102. */
  13103. removeSizeGradient(gradient: number): IParticleSystem;
  13104. /**
  13105. * Adds a new color remap gradient
  13106. * @param gradient defines the gradient to use (between 0 and 1)
  13107. * @param min defines the color remap minimal range
  13108. * @param max defines the color remap maximal range
  13109. * @returns the current particle system
  13110. */
  13111. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13112. /**
  13113. * Remove a specific color remap gradient
  13114. * @param gradient defines the gradient to remove
  13115. * @returns the current particle system
  13116. */
  13117. removeColorRemapGradient(gradient: number): IParticleSystem;
  13118. /**
  13119. * Adds a new alpha remap gradient
  13120. * @param gradient defines the gradient to use (between 0 and 1)
  13121. * @param min defines the alpha remap minimal range
  13122. * @param max defines the alpha remap maximal range
  13123. * @returns the current particle system
  13124. */
  13125. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13126. /**
  13127. * Remove a specific alpha remap gradient
  13128. * @param gradient defines the gradient to remove
  13129. * @returns the current particle system
  13130. */
  13131. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13132. /**
  13133. * Adds a new angular speed gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the angular speed to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific angular speed gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new velocity gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the velocity to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific velocity gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeVelocityGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new limit velocity gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param factor defines the limit velocity value to affect to the specified gradient
  13164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13165. * @returns the current particle system
  13166. */
  13167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific limit velocity gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new drag gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param factor defines the drag value to affect to the specified gradient
  13178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13179. * @returns the current particle system
  13180. */
  13181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific drag gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeDragGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the emit rate value to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific emit rate gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeEmitRateGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the start size value to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific start size gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeStartSizeGradient(gradient: number): IParticleSystem;
  13216. private _createRampGradientTexture;
  13217. /**
  13218. * Gets the current list of ramp gradients.
  13219. * You must use addRampGradient and removeRampGradient to udpate this list
  13220. * @returns the list of ramp gradients
  13221. */
  13222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13223. /** Force the system to rebuild all gradients that need to be resync */
  13224. forceRefreshGradients(): void;
  13225. private _syncRampGradientTexture;
  13226. /**
  13227. * Adds a new ramp gradient used to remap particle colors
  13228. * @param gradient defines the gradient to use (between 0 and 1)
  13229. * @param color defines the color to affect to the specified gradient
  13230. * @returns the current particle system
  13231. */
  13232. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13233. /**
  13234. * Remove a specific ramp gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeRampGradient(gradient: number): ParticleSystem;
  13239. /**
  13240. * Adds a new color gradient
  13241. * @param gradient defines the gradient to use (between 0 and 1)
  13242. * @param color1 defines the color to affect to the specified gradient
  13243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13244. * @returns this particle system
  13245. */
  13246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13247. /**
  13248. * Remove a specific color gradient
  13249. * @param gradient defines the gradient to remove
  13250. * @returns this particle system
  13251. */
  13252. removeColorGradient(gradient: number): IParticleSystem;
  13253. private _fetchR;
  13254. protected _reset(): void;
  13255. private _resetEffect;
  13256. private _createVertexBuffers;
  13257. private _createIndexBuffer;
  13258. /**
  13259. * Gets the maximum number of particles active at the same time.
  13260. * @returns The max number of active particles.
  13261. */
  13262. getCapacity(): number;
  13263. /**
  13264. * Gets whether there are still active particles in the system.
  13265. * @returns True if it is alive, otherwise false.
  13266. */
  13267. isAlive(): boolean;
  13268. /**
  13269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13270. * @returns True if it has been started, otherwise false.
  13271. */
  13272. isStarted(): boolean;
  13273. private _prepareSubEmitterInternalArray;
  13274. /**
  13275. * Starts the particle system and begins to emit
  13276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13277. */
  13278. start(delay?: number): void;
  13279. /**
  13280. * Stops the particle system.
  13281. * @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.
  13282. */
  13283. stop(stopSubEmitters?: boolean): void;
  13284. /**
  13285. * Remove all active particles
  13286. */
  13287. reset(): void;
  13288. /**
  13289. * @hidden (for internal use only)
  13290. */
  13291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13292. /**
  13293. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13294. * Its lifetime will start back at 0.
  13295. */
  13296. recycleParticle: (particle: Particle) => void;
  13297. private _stopSubEmitters;
  13298. private _createParticle;
  13299. private _removeFromRoot;
  13300. private _emitFromParticle;
  13301. private _update;
  13302. /** @hidden */
  13303. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13304. /** @hidden */
  13305. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13306. /**
  13307. * Fill the defines array according to the current settings of the particle system
  13308. * @param defines Array to be updated
  13309. * @param blendMode blend mode to take into account when updating the array
  13310. */
  13311. fillDefines(defines: Array<string>, blendMode: number): void;
  13312. /**
  13313. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13314. * @param uniforms Uniforms array to fill
  13315. * @param attributes Attributes array to fill
  13316. * @param samplers Samplers array to fill
  13317. */
  13318. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13319. /** @hidden */
  13320. private _getEffect;
  13321. /**
  13322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13323. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13324. */
  13325. animate(preWarmOnly?: boolean): void;
  13326. private _appendParticleVertices;
  13327. /**
  13328. * Rebuilds the particle system.
  13329. */
  13330. rebuild(): void;
  13331. /**
  13332. * Is this system ready to be used/rendered
  13333. * @return true if the system is ready
  13334. */
  13335. isReady(): boolean;
  13336. private _render;
  13337. /**
  13338. * Renders the particle system in its current state.
  13339. * @returns the current number of particles
  13340. */
  13341. render(): number;
  13342. /**
  13343. * Disposes the particle system and free the associated resources
  13344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13345. */
  13346. dispose(disposeTexture?: boolean): void;
  13347. /**
  13348. * Clones the particle system.
  13349. * @param name The name of the cloned object
  13350. * @param newEmitter The new emitter to use
  13351. * @returns the cloned particle system
  13352. */
  13353. clone(name: string, newEmitter: any): ParticleSystem;
  13354. /**
  13355. * Serializes the particle system to a JSON object
  13356. * @param serializeTexture defines if the texture must be serialized as well
  13357. * @returns the JSON object
  13358. */
  13359. serialize(serializeTexture?: boolean): any;
  13360. /** @hidden */
  13361. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13362. /** @hidden */
  13363. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13364. /**
  13365. * Parses a JSON object to create a particle system.
  13366. * @param parsedParticleSystem The JSON object to parse
  13367. * @param sceneOrEngine The scene or the engine to create the particle system in
  13368. * @param rootUrl The root url to use to load external dependencies like texture
  13369. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13370. * @returns the Parsed particle system
  13371. */
  13372. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13373. }
  13374. }
  13375. declare module "babylonjs/Particles/particle" {
  13376. import { Nullable } from "babylonjs/types";
  13377. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13378. import { Color4 } from "babylonjs/Maths/math.color";
  13379. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13380. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13381. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13382. /**
  13383. * A particle represents one of the element emitted by a particle system.
  13384. * This is mainly define by its coordinates, direction, velocity and age.
  13385. */
  13386. export class Particle {
  13387. /**
  13388. * The particle system the particle belongs to.
  13389. */
  13390. particleSystem: ParticleSystem;
  13391. private static _Count;
  13392. /**
  13393. * Unique ID of the particle
  13394. */
  13395. id: number;
  13396. /**
  13397. * The world position of the particle in the scene.
  13398. */
  13399. position: Vector3;
  13400. /**
  13401. * The world direction of the particle in the scene.
  13402. */
  13403. direction: Vector3;
  13404. /**
  13405. * The color of the particle.
  13406. */
  13407. color: Color4;
  13408. /**
  13409. * The color change of the particle per step.
  13410. */
  13411. colorStep: Color4;
  13412. /**
  13413. * Defines how long will the life of the particle be.
  13414. */
  13415. lifeTime: number;
  13416. /**
  13417. * The current age of the particle.
  13418. */
  13419. age: number;
  13420. /**
  13421. * The current size of the particle.
  13422. */
  13423. size: number;
  13424. /**
  13425. * The current scale of the particle.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * The current angle of the particle.
  13430. */
  13431. angle: number;
  13432. /**
  13433. * Defines how fast is the angle changing.
  13434. */
  13435. angularSpeed: number;
  13436. /**
  13437. * Defines the cell index used by the particle to be rendered from a sprite.
  13438. */
  13439. cellIndex: number;
  13440. /**
  13441. * The information required to support color remapping
  13442. */
  13443. remapData: Vector4;
  13444. /** @hidden */
  13445. _randomCellOffset?: number;
  13446. /** @hidden */
  13447. _initialDirection: Nullable<Vector3>;
  13448. /** @hidden */
  13449. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13450. /** @hidden */
  13451. _initialStartSpriteCellID: number;
  13452. /** @hidden */
  13453. _initialEndSpriteCellID: number;
  13454. /** @hidden */
  13455. _currentColorGradient: Nullable<ColorGradient>;
  13456. /** @hidden */
  13457. _currentColor1: Color4;
  13458. /** @hidden */
  13459. _currentColor2: Color4;
  13460. /** @hidden */
  13461. _currentSizeGradient: Nullable<FactorGradient>;
  13462. /** @hidden */
  13463. _currentSize1: number;
  13464. /** @hidden */
  13465. _currentSize2: number;
  13466. /** @hidden */
  13467. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13468. /** @hidden */
  13469. _currentAngularSpeed1: number;
  13470. /** @hidden */
  13471. _currentAngularSpeed2: number;
  13472. /** @hidden */
  13473. _currentVelocityGradient: Nullable<FactorGradient>;
  13474. /** @hidden */
  13475. _currentVelocity1: number;
  13476. /** @hidden */
  13477. _currentVelocity2: number;
  13478. /** @hidden */
  13479. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13480. /** @hidden */
  13481. _currentLimitVelocity1: number;
  13482. /** @hidden */
  13483. _currentLimitVelocity2: number;
  13484. /** @hidden */
  13485. _currentDragGradient: Nullable<FactorGradient>;
  13486. /** @hidden */
  13487. _currentDrag1: number;
  13488. /** @hidden */
  13489. _currentDrag2: number;
  13490. /** @hidden */
  13491. _randomNoiseCoordinates1: Vector3;
  13492. /** @hidden */
  13493. _randomNoiseCoordinates2: Vector3;
  13494. /** @hidden */
  13495. _localPosition?: Vector3;
  13496. /**
  13497. * Creates a new instance Particle
  13498. * @param particleSystem the particle system the particle belongs to
  13499. */
  13500. constructor(
  13501. /**
  13502. * The particle system the particle belongs to.
  13503. */
  13504. particleSystem: ParticleSystem);
  13505. private updateCellInfoFromSystem;
  13506. /**
  13507. * Defines how the sprite cell index is updated for the particle
  13508. */
  13509. updateCellIndex(): void;
  13510. /** @hidden */
  13511. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13512. /** @hidden */
  13513. _inheritParticleInfoToSubEmitters(): void;
  13514. /** @hidden */
  13515. _reset(): void;
  13516. /**
  13517. * Copy the properties of particle to another one.
  13518. * @param other the particle to copy the information to.
  13519. */
  13520. copyTo(other: Particle): void;
  13521. }
  13522. }
  13523. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13525. import { Effect } from "babylonjs/Materials/effect";
  13526. import { Particle } from "babylonjs/Particles/particle";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { Scene } from "babylonjs/scene";
  13529. /**
  13530. * Particle emitter represents a volume emitting particles.
  13531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13532. */
  13533. export interface IParticleEmitterType {
  13534. /**
  13535. * Called by the particle System when the direction is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param directionToUpdate is the direction vector to update with the result
  13538. * @param particle is the particle we are computed the direction for
  13539. * @param isLocal defines if the direction should be set in local space
  13540. */
  13541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Called by the particle System when the position is computed for the created particle.
  13544. * @param worldMatrix is the world matrix of the particle system
  13545. * @param positionToUpdate is the position vector to update with the result
  13546. * @param particle is the particle we are computed the position for
  13547. * @param isLocal defines if the position should be set in local space
  13548. */
  13549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13550. /**
  13551. * Clones the current emitter and returns a copy of it
  13552. * @returns the new emitter
  13553. */
  13554. clone(): IParticleEmitterType;
  13555. /**
  13556. * Called by the GPUParticleSystem to setup the update shader
  13557. * @param effect defines the update shader
  13558. */
  13559. applyToShader(effect: Effect): void;
  13560. /**
  13561. * Returns a string to use to update the GPU particles update shader
  13562. * @returns the effect defines string
  13563. */
  13564. getEffectDefines(): string;
  13565. /**
  13566. * Returns a string representing the class name
  13567. * @returns a string containing the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Serializes the particle system to a JSON object.
  13572. * @returns the JSON object
  13573. */
  13574. serialize(): any;
  13575. /**
  13576. * Parse properties from a JSON object
  13577. * @param serializationObject defines the JSON object
  13578. * @param scene defines the hosting scene
  13579. */
  13580. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13585. import { Effect } from "babylonjs/Materials/effect";
  13586. import { Particle } from "babylonjs/Particles/particle";
  13587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a box.
  13590. * It emits the particles randomly between 2 given directions.
  13591. */
  13592. export class BoxParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13595. */
  13596. direction1: Vector3;
  13597. /**
  13598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13599. */
  13600. direction2: Vector3;
  13601. /**
  13602. * 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.
  13603. */
  13604. minEmitBox: Vector3;
  13605. /**
  13606. * 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.
  13607. */
  13608. maxEmitBox: Vector3;
  13609. /**
  13610. * Creates a new instance BoxParticleEmitter
  13611. */
  13612. constructor();
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. * @param isLocal defines if the direction should be set in local space
  13619. */
  13620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Called by the particle System when the position is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param positionToUpdate is the position vector to update with the result
  13625. * @param particle is the particle we are computed the position for
  13626. * @param isLocal defines if the position should be set in local space
  13627. */
  13628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): BoxParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "BoxParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13663. import { Effect } from "babylonjs/Materials/effect";
  13664. import { Particle } from "babylonjs/Particles/particle";
  13665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13666. /**
  13667. * Particle emitter emitting particles from the inside of a cone.
  13668. * It emits the particles alongside the cone volume from the base to the particle.
  13669. * The emission direction might be randomized.
  13670. */
  13671. export class ConeParticleEmitter implements IParticleEmitterType {
  13672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13673. directionRandomizer: number;
  13674. private _radius;
  13675. private _angle;
  13676. private _height;
  13677. /**
  13678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13679. */
  13680. radiusRange: number;
  13681. /**
  13682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13683. */
  13684. heightRange: number;
  13685. /**
  13686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13687. */
  13688. emitFromSpawnPointOnly: boolean;
  13689. /**
  13690. * Gets or sets the radius of the emission cone
  13691. */
  13692. get radius(): number;
  13693. set radius(value: number);
  13694. /**
  13695. * Gets or sets the angle of the emission cone
  13696. */
  13697. get angle(): number;
  13698. set angle(value: number);
  13699. private _buildHeight;
  13700. /**
  13701. * Creates a new instance ConeParticleEmitter
  13702. * @param radius the radius of the emission cone (1 by default)
  13703. * @param angle the cone base angle (PI by default)
  13704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13705. */
  13706. constructor(radius?: number, angle?: number,
  13707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13708. directionRandomizer?: number);
  13709. /**
  13710. * Called by the particle System when the direction is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param directionToUpdate is the direction vector to update with the result
  13713. * @param particle is the particle we are computed the direction for
  13714. * @param isLocal defines if the direction should be set in local space
  13715. */
  13716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Called by the particle System when the position is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param positionToUpdate is the position vector to update with the result
  13721. * @param particle is the particle we are computed the position for
  13722. * @param isLocal defines if the position should be set in local space
  13723. */
  13724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Clones the current emitter and returns a copy of it
  13727. * @returns the new emitter
  13728. */
  13729. clone(): ConeParticleEmitter;
  13730. /**
  13731. * Called by the GPUParticleSystem to setup the update shader
  13732. * @param effect defines the update shader
  13733. */
  13734. applyToShader(effect: Effect): void;
  13735. /**
  13736. * Returns a string to use to update the GPU particles update shader
  13737. * @returns a string containng the defines string
  13738. */
  13739. getEffectDefines(): string;
  13740. /**
  13741. * Returns the string "ConeParticleEmitter"
  13742. * @returns a string containing the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Serializes the particle system to a JSON object.
  13747. * @returns the JSON object
  13748. */
  13749. serialize(): any;
  13750. /**
  13751. * Parse properties from a JSON object
  13752. * @param serializationObject defines the JSON object
  13753. */
  13754. parse(serializationObject: any): void;
  13755. }
  13756. }
  13757. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13759. import { Effect } from "babylonjs/Materials/effect";
  13760. import { Particle } from "babylonjs/Particles/particle";
  13761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a cylinder.
  13764. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13765. */
  13766. export class CylinderParticleEmitter implements IParticleEmitterType {
  13767. /**
  13768. * The radius of the emission cylinder.
  13769. */
  13770. radius: number;
  13771. /**
  13772. * The height of the emission cylinder.
  13773. */
  13774. height: number;
  13775. /**
  13776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13777. */
  13778. radiusRange: number;
  13779. /**
  13780. * How much to randomize the particle direction [0-1].
  13781. */
  13782. directionRandomizer: number;
  13783. /**
  13784. * Creates a new instance CylinderParticleEmitter
  13785. * @param radius the radius of the emission cylinder (1 by default)
  13786. * @param height the height of the emission cylinder (1 by default)
  13787. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission cylinder.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The height of the emission cylinder.
  13797. */
  13798. height?: number,
  13799. /**
  13800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13801. */
  13802. radiusRange?: number,
  13803. /**
  13804. * How much to randomize the particle direction [0-1].
  13805. */
  13806. directionRandomizer?: number);
  13807. /**
  13808. * Called by the particle System when the direction is computed for the created particle.
  13809. * @param worldMatrix is the world matrix of the particle system
  13810. * @param directionToUpdate is the direction vector to update with the result
  13811. * @param particle is the particle we are computed the direction for
  13812. * @param isLocal defines if the direction should be set in local space
  13813. */
  13814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13815. /**
  13816. * Called by the particle System when the position is computed for the created particle.
  13817. * @param worldMatrix is the world matrix of the particle system
  13818. * @param positionToUpdate is the position vector to update with the result
  13819. * @param particle is the particle we are computed the position for
  13820. * @param isLocal defines if the position should be set in local space
  13821. */
  13822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13823. /**
  13824. * Clones the current emitter and returns a copy of it
  13825. * @returns the new emitter
  13826. */
  13827. clone(): CylinderParticleEmitter;
  13828. /**
  13829. * Called by the GPUParticleSystem to setup the update shader
  13830. * @param effect defines the update shader
  13831. */
  13832. applyToShader(effect: Effect): void;
  13833. /**
  13834. * Returns a string to use to update the GPU particles update shader
  13835. * @returns a string containng the defines string
  13836. */
  13837. getEffectDefines(): string;
  13838. /**
  13839. * Returns the string "CylinderParticleEmitter"
  13840. * @returns a string containing the class name
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Serializes the particle system to a JSON object.
  13845. * @returns the JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Parse properties from a JSON object
  13850. * @param serializationObject defines the JSON object
  13851. */
  13852. parse(serializationObject: any): void;
  13853. }
  13854. /**
  13855. * Particle emitter emitting particles from the inside of a cylinder.
  13856. * It emits the particles randomly between two vectors.
  13857. */
  13858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13859. /**
  13860. * The min limit of the emission direction.
  13861. */
  13862. direction1: Vector3;
  13863. /**
  13864. * The max limit of the emission direction.
  13865. */
  13866. direction2: Vector3;
  13867. /**
  13868. * Creates a new instance CylinderDirectedParticleEmitter
  13869. * @param radius the radius of the emission cylinder (1 by default)
  13870. * @param height the height of the emission cylinder (1 by default)
  13871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13872. * @param direction1 the min limit of the emission direction (up vector by default)
  13873. * @param direction2 the max limit of the emission direction (up vector by default)
  13874. */
  13875. constructor(radius?: number, height?: number, radiusRange?: number,
  13876. /**
  13877. * The min limit of the emission direction.
  13878. */
  13879. direction1?: Vector3,
  13880. /**
  13881. * The max limit of the emission direction.
  13882. */
  13883. direction2?: Vector3);
  13884. /**
  13885. * Called by the particle System when the direction is computed for the created particle.
  13886. * @param worldMatrix is the world matrix of the particle system
  13887. * @param directionToUpdate is the direction vector to update with the result
  13888. * @param particle is the particle we are computed the direction for
  13889. */
  13890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13891. /**
  13892. * Clones the current emitter and returns a copy of it
  13893. * @returns the new emitter
  13894. */
  13895. clone(): CylinderDirectedParticleEmitter;
  13896. /**
  13897. * Called by the GPUParticleSystem to setup the update shader
  13898. * @param effect defines the update shader
  13899. */
  13900. applyToShader(effect: Effect): void;
  13901. /**
  13902. * Returns a string to use to update the GPU particles update shader
  13903. * @returns a string containng the defines string
  13904. */
  13905. getEffectDefines(): string;
  13906. /**
  13907. * Returns the string "CylinderDirectedParticleEmitter"
  13908. * @returns a string containing the class name
  13909. */
  13910. getClassName(): string;
  13911. /**
  13912. * Serializes the particle system to a JSON object.
  13913. * @returns the JSON object
  13914. */
  13915. serialize(): any;
  13916. /**
  13917. * Parse properties from a JSON object
  13918. * @param serializationObject defines the JSON object
  13919. */
  13920. parse(serializationObject: any): void;
  13921. }
  13922. }
  13923. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13924. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13925. import { Effect } from "babylonjs/Materials/effect";
  13926. import { Particle } from "babylonjs/Particles/particle";
  13927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13928. /**
  13929. * Particle emitter emitting particles from the inside of a hemisphere.
  13930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13931. */
  13932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius: number;
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange: number;
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer: number;
  13945. /**
  13946. * Creates a new instance HemisphericParticleEmitter
  13947. * @param radius the radius of the emission hemisphere (1 by default)
  13948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13950. */
  13951. constructor(
  13952. /**
  13953. * The radius of the emission hemisphere.
  13954. */
  13955. radius?: number,
  13956. /**
  13957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13958. */
  13959. radiusRange?: number,
  13960. /**
  13961. * How much to randomize the particle direction [0-1].
  13962. */
  13963. directionRandomizer?: number);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): HemisphericParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "HemisphericParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. */
  14009. parse(serializationObject: any): void;
  14010. }
  14011. }
  14012. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14013. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14014. import { Effect } from "babylonjs/Materials/effect";
  14015. import { Particle } from "babylonjs/Particles/particle";
  14016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14017. /**
  14018. * Particle emitter emitting particles from a point.
  14019. * It emits the particles randomly between 2 given directions.
  14020. */
  14021. export class PointParticleEmitter implements IParticleEmitterType {
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Creates a new instance PointParticleEmitter
  14032. */
  14033. constructor();
  14034. /**
  14035. * Called by the particle System when the direction is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param directionToUpdate is the direction vector to update with the result
  14038. * @param particle is the particle we are computed the direction for
  14039. * @param isLocal defines if the direction should be set in local space
  14040. */
  14041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Called by the particle System when the position is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param positionToUpdate is the position vector to update with the result
  14046. * @param particle is the particle we are computed the position for
  14047. * @param isLocal defines if the position should be set in local space
  14048. */
  14049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Clones the current emitter and returns a copy of it
  14052. * @returns the new emitter
  14053. */
  14054. clone(): PointParticleEmitter;
  14055. /**
  14056. * Called by the GPUParticleSystem to setup the update shader
  14057. * @param effect defines the update shader
  14058. */
  14059. applyToShader(effect: Effect): void;
  14060. /**
  14061. * Returns a string to use to update the GPU particles update shader
  14062. * @returns a string containng the defines string
  14063. */
  14064. getEffectDefines(): string;
  14065. /**
  14066. * Returns the string "PointParticleEmitter"
  14067. * @returns a string containing the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Serializes the particle system to a JSON object.
  14072. * @returns the JSON object
  14073. */
  14074. serialize(): any;
  14075. /**
  14076. * Parse properties from a JSON object
  14077. * @param serializationObject defines the JSON object
  14078. */
  14079. parse(serializationObject: any): void;
  14080. }
  14081. }
  14082. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14084. import { Effect } from "babylonjs/Materials/effect";
  14085. import { Particle } from "babylonjs/Particles/particle";
  14086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14087. /**
  14088. * Particle emitter emitting particles from the inside of a sphere.
  14089. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14090. */
  14091. export class SphereParticleEmitter implements IParticleEmitterType {
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius: number;
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange: number;
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer: number;
  14104. /**
  14105. * Creates a new instance SphereParticleEmitter
  14106. * @param radius the radius of the emission sphere (1 by default)
  14107. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14109. */
  14110. constructor(
  14111. /**
  14112. * The radius of the emission sphere.
  14113. */
  14114. radius?: number,
  14115. /**
  14116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14117. */
  14118. radiusRange?: number,
  14119. /**
  14120. * How much to randomize the particle direction [0-1].
  14121. */
  14122. directionRandomizer?: number);
  14123. /**
  14124. * Called by the particle System when the direction is computed for the created particle.
  14125. * @param worldMatrix is the world matrix of the particle system
  14126. * @param directionToUpdate is the direction vector to update with the result
  14127. * @param particle is the particle we are computed the direction for
  14128. * @param isLocal defines if the direction should be set in local space
  14129. */
  14130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14131. /**
  14132. * Called by the particle System when the position is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param positionToUpdate is the position vector to update with the result
  14135. * @param particle is the particle we are computed the position for
  14136. * @param isLocal defines if the position should be set in local space
  14137. */
  14138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14139. /**
  14140. * Clones the current emitter and returns a copy of it
  14141. * @returns the new emitter
  14142. */
  14143. clone(): SphereParticleEmitter;
  14144. /**
  14145. * Called by the GPUParticleSystem to setup the update shader
  14146. * @param effect defines the update shader
  14147. */
  14148. applyToShader(effect: Effect): void;
  14149. /**
  14150. * Returns a string to use to update the GPU particles update shader
  14151. * @returns a string containng the defines string
  14152. */
  14153. getEffectDefines(): string;
  14154. /**
  14155. * Returns the string "SphereParticleEmitter"
  14156. * @returns a string containing the class name
  14157. */
  14158. getClassName(): string;
  14159. /**
  14160. * Serializes the particle system to a JSON object.
  14161. * @returns the JSON object
  14162. */
  14163. serialize(): any;
  14164. /**
  14165. * Parse properties from a JSON object
  14166. * @param serializationObject defines the JSON object
  14167. */
  14168. parse(serializationObject: any): void;
  14169. }
  14170. /**
  14171. * Particle emitter emitting particles from the inside of a sphere.
  14172. * It emits the particles randomly between two vectors.
  14173. */
  14174. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14175. /**
  14176. * The min limit of the emission direction.
  14177. */
  14178. direction1: Vector3;
  14179. /**
  14180. * The max limit of the emission direction.
  14181. */
  14182. direction2: Vector3;
  14183. /**
  14184. * Creates a new instance SphereDirectedParticleEmitter
  14185. * @param radius the radius of the emission sphere (1 by default)
  14186. * @param direction1 the min limit of the emission direction (up vector by default)
  14187. * @param direction2 the max limit of the emission direction (up vector by default)
  14188. */
  14189. constructor(radius?: number,
  14190. /**
  14191. * The min limit of the emission direction.
  14192. */
  14193. direction1?: Vector3,
  14194. /**
  14195. * The max limit of the emission direction.
  14196. */
  14197. direction2?: Vector3);
  14198. /**
  14199. * Called by the particle System when the direction is computed for the created particle.
  14200. * @param worldMatrix is the world matrix of the particle system
  14201. * @param directionToUpdate is the direction vector to update with the result
  14202. * @param particle is the particle we are computed the direction for
  14203. */
  14204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14205. /**
  14206. * Clones the current emitter and returns a copy of it
  14207. * @returns the new emitter
  14208. */
  14209. clone(): SphereDirectedParticleEmitter;
  14210. /**
  14211. * Called by the GPUParticleSystem to setup the update shader
  14212. * @param effect defines the update shader
  14213. */
  14214. applyToShader(effect: Effect): void;
  14215. /**
  14216. * Returns a string to use to update the GPU particles update shader
  14217. * @returns a string containng the defines string
  14218. */
  14219. getEffectDefines(): string;
  14220. /**
  14221. * Returns the string "SphereDirectedParticleEmitter"
  14222. * @returns a string containing the class name
  14223. */
  14224. getClassName(): string;
  14225. /**
  14226. * Serializes the particle system to a JSON object.
  14227. * @returns the JSON object
  14228. */
  14229. serialize(): any;
  14230. /**
  14231. * Parse properties from a JSON object
  14232. * @param serializationObject defines the JSON object
  14233. */
  14234. parse(serializationObject: any): void;
  14235. }
  14236. }
  14237. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14239. import { Effect } from "babylonjs/Materials/effect";
  14240. import { Particle } from "babylonjs/Particles/particle";
  14241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14242. import { Nullable } from "babylonjs/types";
  14243. /**
  14244. * Particle emitter emitting particles from a custom list of positions.
  14245. */
  14246. export class CustomParticleEmitter implements IParticleEmitterType {
  14247. /**
  14248. * Gets or sets the position generator that will create the inital position of each particle.
  14249. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14250. */
  14251. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14252. /**
  14253. * Gets or sets the destination generator that will create the final destination of each particle.
  14254. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14255. */
  14256. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14257. /**
  14258. * Creates a new instance CustomParticleEmitter
  14259. */
  14260. constructor();
  14261. /**
  14262. * Called by the particle System when the direction is computed for the created particle.
  14263. * @param worldMatrix is the world matrix of the particle system
  14264. * @param directionToUpdate is the direction vector to update with the result
  14265. * @param particle is the particle we are computed the direction for
  14266. * @param isLocal defines if the direction should be set in local space
  14267. */
  14268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14269. /**
  14270. * Called by the particle System when the position is computed for the created particle.
  14271. * @param worldMatrix is the world matrix of the particle system
  14272. * @param positionToUpdate is the position vector to update with the result
  14273. * @param particle is the particle we are computed the position for
  14274. * @param isLocal defines if the position should be set in local space
  14275. */
  14276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14277. /**
  14278. * Clones the current emitter and returns a copy of it
  14279. * @returns the new emitter
  14280. */
  14281. clone(): CustomParticleEmitter;
  14282. /**
  14283. * Called by the GPUParticleSystem to setup the update shader
  14284. * @param effect defines the update shader
  14285. */
  14286. applyToShader(effect: Effect): void;
  14287. /**
  14288. * Returns a string to use to update the GPU particles update shader
  14289. * @returns a string containng the defines string
  14290. */
  14291. getEffectDefines(): string;
  14292. /**
  14293. * Returns the string "PointParticleEmitter"
  14294. * @returns a string containing the class name
  14295. */
  14296. getClassName(): string;
  14297. /**
  14298. * Serializes the particle system to a JSON object.
  14299. * @returns the JSON object
  14300. */
  14301. serialize(): any;
  14302. /**
  14303. * Parse properties from a JSON object
  14304. * @param serializationObject defines the JSON object
  14305. */
  14306. parse(serializationObject: any): void;
  14307. }
  14308. }
  14309. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14311. import { Effect } from "babylonjs/Materials/effect";
  14312. import { Particle } from "babylonjs/Particles/particle";
  14313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14314. import { Nullable } from "babylonjs/types";
  14315. import { Scene } from "babylonjs/scene";
  14316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14317. /**
  14318. * Particle emitter emitting particles from the inside of a box.
  14319. * It emits the particles randomly between 2 given directions.
  14320. */
  14321. export class MeshParticleEmitter implements IParticleEmitterType {
  14322. private _indices;
  14323. private _positions;
  14324. private _normals;
  14325. private _storedNormal;
  14326. private _mesh;
  14327. /**
  14328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14329. */
  14330. direction1: Vector3;
  14331. /**
  14332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14333. */
  14334. direction2: Vector3;
  14335. /**
  14336. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14337. */
  14338. useMeshNormalsForDirection: boolean;
  14339. /** Defines the mesh to use as source */
  14340. get mesh(): Nullable<AbstractMesh>;
  14341. set mesh(value: Nullable<AbstractMesh>);
  14342. /**
  14343. * Creates a new instance MeshParticleEmitter
  14344. * @param mesh defines the mesh to use as source
  14345. */
  14346. constructor(mesh?: Nullable<AbstractMesh>);
  14347. /**
  14348. * Called by the particle System when the direction is computed for the created particle.
  14349. * @param worldMatrix is the world matrix of the particle system
  14350. * @param directionToUpdate is the direction vector to update with the result
  14351. * @param particle is the particle we are computed the direction for
  14352. * @param isLocal defines if the direction should be set in local space
  14353. */
  14354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14355. /**
  14356. * Called by the particle System when the position is computed for the created particle.
  14357. * @param worldMatrix is the world matrix of the particle system
  14358. * @param positionToUpdate is the position vector to update with the result
  14359. * @param particle is the particle we are computed the position for
  14360. * @param isLocal defines if the position should be set in local space
  14361. */
  14362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14363. /**
  14364. * Clones the current emitter and returns a copy of it
  14365. * @returns the new emitter
  14366. */
  14367. clone(): MeshParticleEmitter;
  14368. /**
  14369. * Called by the GPUParticleSystem to setup the update shader
  14370. * @param effect defines the update shader
  14371. */
  14372. applyToShader(effect: Effect): void;
  14373. /**
  14374. * Returns a string to use to update the GPU particles update shader
  14375. * @returns a string containng the defines string
  14376. */
  14377. getEffectDefines(): string;
  14378. /**
  14379. * Returns the string "BoxParticleEmitter"
  14380. * @returns a string containing the class name
  14381. */
  14382. getClassName(): string;
  14383. /**
  14384. * Serializes the particle system to a JSON object.
  14385. * @returns the JSON object
  14386. */
  14387. serialize(): any;
  14388. /**
  14389. * Parse properties from a JSON object
  14390. * @param serializationObject defines the JSON object
  14391. * @param scene defines the hosting scene
  14392. */
  14393. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14394. }
  14395. }
  14396. declare module "babylonjs/Particles/EmitterTypes/index" {
  14397. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14398. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14402. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14403. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14406. }
  14407. declare module "babylonjs/Particles/IParticleSystem" {
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14415. import { Effect } from "babylonjs/Materials/effect";
  14416. import { Observable } from "babylonjs/Misc/observable";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14419. /**
  14420. * Interface representing a particle system in Babylon.js.
  14421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14423. */
  14424. export interface IParticleSystem {
  14425. /**
  14426. * List of animations used by the particle system.
  14427. */
  14428. animations: Animation[];
  14429. /**
  14430. * The id of the Particle system.
  14431. */
  14432. id: string;
  14433. /**
  14434. * The name of the Particle system.
  14435. */
  14436. name: string;
  14437. /**
  14438. * The emitter represents the Mesh or position we are attaching the particle system to.
  14439. */
  14440. emitter: Nullable<AbstractMesh | Vector3>;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The layer mask we are rendering the particles through.
  14451. */
  14452. layerMask: number;
  14453. /**
  14454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14455. */
  14456. updateSpeed: number;
  14457. /**
  14458. * The amount of time the particle system is running (depends of the overall update speed).
  14459. */
  14460. targetStopDuration: number;
  14461. /**
  14462. * The texture used to render each particle. (this can be a spritesheet)
  14463. */
  14464. particleTexture: Nullable<BaseTexture>;
  14465. /**
  14466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14467. */
  14468. blendMode: number;
  14469. /**
  14470. * Minimum life time of emitting particles.
  14471. */
  14472. minLifeTime: number;
  14473. /**
  14474. * Maximum life time of emitting particles.
  14475. */
  14476. maxLifeTime: number;
  14477. /**
  14478. * Minimum Size of emitting particles.
  14479. */
  14480. minSize: number;
  14481. /**
  14482. * Maximum Size of emitting particles.
  14483. */
  14484. maxSize: number;
  14485. /**
  14486. * Minimum scale of emitting particles on X axis.
  14487. */
  14488. minScaleX: number;
  14489. /**
  14490. * Maximum scale of emitting particles on X axis.
  14491. */
  14492. maxScaleX: number;
  14493. /**
  14494. * Minimum scale of emitting particles on Y axis.
  14495. */
  14496. minScaleY: number;
  14497. /**
  14498. * Maximum scale of emitting particles on Y axis.
  14499. */
  14500. maxScaleY: number;
  14501. /**
  14502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14503. */
  14504. color1: Color4;
  14505. /**
  14506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14507. */
  14508. color2: Color4;
  14509. /**
  14510. * Color the particle will have at the end of its lifetime.
  14511. */
  14512. colorDead: Color4;
  14513. /**
  14514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14515. */
  14516. emitRate: number;
  14517. /**
  14518. * You can use gravity if you want to give an orientation to your particles.
  14519. */
  14520. gravity: Vector3;
  14521. /**
  14522. * Minimum power of emitting particles.
  14523. */
  14524. minEmitPower: number;
  14525. /**
  14526. * Maximum power of emitting particles.
  14527. */
  14528. maxEmitPower: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * Gets or sets the minimal initial rotation in radians.
  14539. */
  14540. minInitialRotation: number;
  14541. /**
  14542. * Gets or sets the maximal initial rotation in radians.
  14543. */
  14544. maxInitialRotation: number;
  14545. /**
  14546. * The particle emitter type defines the emitter used by the particle system.
  14547. * It can be for example box, sphere, or cone...
  14548. */
  14549. particleEmitterType: Nullable<IParticleEmitterType>;
  14550. /**
  14551. * Defines the delay in milliseconds before starting the system (0 by default)
  14552. */
  14553. startDelay: number;
  14554. /**
  14555. * 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
  14556. */
  14557. preWarmCycles: number;
  14558. /**
  14559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14560. */
  14561. preWarmStepOffset: number;
  14562. /**
  14563. * 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)
  14564. */
  14565. spriteCellChangeSpeed: number;
  14566. /**
  14567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14568. */
  14569. startSpriteCellID: number;
  14570. /**
  14571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14572. */
  14573. endSpriteCellID: number;
  14574. /**
  14575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14576. */
  14577. spriteCellWidth: number;
  14578. /**
  14579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14580. */
  14581. spriteCellHeight: number;
  14582. /**
  14583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14584. */
  14585. spriteRandomStartCell: boolean;
  14586. /**
  14587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14588. */
  14589. isAnimationSheetEnabled: boolean;
  14590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14591. translationPivot: Vector2;
  14592. /**
  14593. * Gets or sets a texture used to add random noise to particle positions
  14594. */
  14595. noiseTexture: Nullable<BaseTexture>;
  14596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14597. noiseStrength: Vector3;
  14598. /**
  14599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14601. */
  14602. billboardMode: number;
  14603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14604. limitVelocityDamping: number;
  14605. /**
  14606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14607. */
  14608. beginAnimationOnStart: boolean;
  14609. /**
  14610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14611. */
  14612. beginAnimationFrom: number;
  14613. /**
  14614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14615. */
  14616. beginAnimationTo: number;
  14617. /**
  14618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationLoop: boolean;
  14621. /**
  14622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14623. */
  14624. disposeOnStop: boolean;
  14625. /**
  14626. * Specifies if the particles are updated in emitter local space or world space
  14627. */
  14628. isLocal: boolean;
  14629. /** Snippet ID if the particle system was created from the snippet server */
  14630. snippetId: string;
  14631. /** Gets or sets a matrix to use to compute projection */
  14632. defaultProjectionMatrix: Matrix;
  14633. /**
  14634. * Gets the maximum number of particles active at the same time.
  14635. * @returns The max number of active particles.
  14636. */
  14637. getCapacity(): number;
  14638. /**
  14639. * Gets the number of particles active at the same time.
  14640. * @returns The number of active particles.
  14641. */
  14642. getActiveCount(): number;
  14643. /**
  14644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14645. * @returns True if it has been started, otherwise false.
  14646. */
  14647. isStarted(): boolean;
  14648. /**
  14649. * Animates the particle system for this frame.
  14650. */
  14651. animate(): void;
  14652. /**
  14653. * Renders the particle system in its current state.
  14654. * @returns the current number of particles
  14655. */
  14656. render(): number;
  14657. /**
  14658. * Dispose the particle system and frees its associated resources.
  14659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14660. */
  14661. dispose(disposeTexture?: boolean): void;
  14662. /**
  14663. * An event triggered when the system is disposed
  14664. */
  14665. onDisposeObservable: Observable<IParticleSystem>;
  14666. /**
  14667. * Clones the particle system.
  14668. * @param name The name of the cloned object
  14669. * @param newEmitter The new emitter to use
  14670. * @returns the cloned particle system
  14671. */
  14672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14673. /**
  14674. * Serializes the particle system to a JSON object
  14675. * @param serializeTexture defines if the texture must be serialized as well
  14676. * @returns the JSON object
  14677. */
  14678. serialize(serializeTexture: boolean): any;
  14679. /**
  14680. * Rebuild the particle system
  14681. */
  14682. rebuild(): void;
  14683. /** Force the system to rebuild all gradients that need to be resync */
  14684. forceRefreshGradients(): void;
  14685. /**
  14686. * Starts the particle system and begins to emit
  14687. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14688. */
  14689. start(delay?: number): void;
  14690. /**
  14691. * Stops the particle system.
  14692. */
  14693. stop(): void;
  14694. /**
  14695. * Remove all active particles
  14696. */
  14697. reset(): void;
  14698. /**
  14699. * Gets a boolean indicating that the system is stopping
  14700. * @returns true if the system is currently stopping
  14701. */
  14702. isStopping(): boolean;
  14703. /**
  14704. * Is this system ready to be used/rendered
  14705. * @return true if the system is ready
  14706. */
  14707. isReady(): boolean;
  14708. /**
  14709. * Returns the string "ParticleSystem"
  14710. * @returns a string containing the class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets the custom effect used to render the particles
  14715. * @param blendMode Blend mode for which the effect should be retrieved
  14716. * @returns The effect
  14717. */
  14718. getCustomEffect(blendMode: number): Nullable<Effect>;
  14719. /**
  14720. * Sets the custom effect used to render the particles
  14721. * @param effect The effect to set
  14722. * @param blendMode Blend mode for which the effect should be set
  14723. */
  14724. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14725. /**
  14726. * Fill the defines array according to the current settings of the particle system
  14727. * @param defines Array to be updated
  14728. * @param blendMode blend mode to take into account when updating the array
  14729. */
  14730. fillDefines(defines: Array<string>, blendMode: number): void;
  14731. /**
  14732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14733. * @param uniforms Uniforms array to fill
  14734. * @param attributes Attributes array to fill
  14735. * @param samplers Samplers array to fill
  14736. */
  14737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14738. /**
  14739. * Observable that will be called just before the particles are drawn
  14740. */
  14741. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14742. /**
  14743. * Gets the name of the particle vertex shader
  14744. */
  14745. vertexShaderName: string;
  14746. /**
  14747. * Adds a new color gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color1 defines the color to affect to the specified gradient
  14750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14751. * @returns the current particle system
  14752. */
  14753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14754. /**
  14755. * Remove a specific color gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeColorGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new size gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the size factor to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific size gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeSizeGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Gets the current list of color gradients.
  14776. * You must use addColorGradient and removeColorGradient to udpate this list
  14777. * @returns the list of color gradients
  14778. */
  14779. getColorGradients(): Nullable<Array<ColorGradient>>;
  14780. /**
  14781. * Gets the current list of size gradients.
  14782. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14783. * @returns the list of size gradients
  14784. */
  14785. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14786. /**
  14787. * Gets the current list of angular speed gradients.
  14788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14789. * @returns the list of angular speed gradients
  14790. */
  14791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Gets the current list of velocity gradients.
  14808. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14809. * @returns the list of velocity gradients
  14810. */
  14811. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Adds a new velocity gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the velocity to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific velocity gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeVelocityGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of limit velocity gradients.
  14828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14829. * @returns the list of limit velocity gradients
  14830. */
  14831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new limit velocity gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the limit velocity to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific limit velocity gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new drag gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the drag to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific drag gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeDragGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Gets the current list of drag gradients.
  14862. * You must use addDragGradient and removeDragGradient to udpate this list
  14863. * @returns the list of drag gradients
  14864. */
  14865. getDragGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param factor defines the emit rate to affect to the specified gradient
  14870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14871. * @returns the current particle system
  14872. */
  14873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific emit rate gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeEmitRateGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Gets the current list of emit rate gradients.
  14882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14883. * @returns the list of emit rate gradients
  14884. */
  14885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14886. /**
  14887. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param factor defines the start size to affect to the specified gradient
  14890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14891. * @returns the current particle system
  14892. */
  14893. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific start size gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeStartSizeGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Gets the current list of start size gradients.
  14902. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14903. * @returns the list of start size gradients
  14904. */
  14905. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14906. /**
  14907. * Adds a new life time gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the life time factor to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific life time gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of life time gradients.
  14922. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14923. * @returns the list of life time gradients
  14924. */
  14925. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Gets the current list of color gradients.
  14928. * You must use addColorGradient and removeColorGradient to udpate this list
  14929. * @returns the list of color gradients
  14930. */
  14931. getColorGradients(): Nullable<Array<ColorGradient>>;
  14932. /**
  14933. * Adds a new ramp gradient used to remap particle colors
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param color defines the color to affect to the specified gradient
  14936. * @returns the current particle system
  14937. */
  14938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14939. /**
  14940. * Gets the current list of ramp gradients.
  14941. * You must use addRampGradient and removeRampGradient to udpate this list
  14942. * @returns the list of ramp gradients
  14943. */
  14944. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14945. /** Gets or sets a boolean indicating that ramp gradients must be used
  14946. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14947. */
  14948. useRampGradients: boolean;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of color remap gradients.
  14959. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14960. * @returns the list of color remap gradients
  14961. */
  14962. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @returns the emitter
  14982. */
  14983. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14984. /**
  14985. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14986. * @param radius The radius of the hemisphere to emit from
  14987. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14988. * @returns the emitter
  14989. */
  14990. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14991. /**
  14992. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14993. * @param radius The radius of the sphere to emit from
  14994. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14995. * @returns the emitter
  14996. */
  14997. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14998. /**
  14999. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15000. * @param radius The radius of the sphere to emit from
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @returns the emitter
  15004. */
  15005. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15008. * @param radius The radius of the emission cylinder
  15009. * @param height The height of the emission cylinder
  15010. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15011. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15012. * @returns the emitter
  15013. */
  15014. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15015. /**
  15016. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15017. * @param radius The radius of the cylinder to emit from
  15018. * @param height The height of the emission cylinder
  15019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @returns the emitter
  15023. */
  15024. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15025. /**
  15026. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15027. * @param radius The radius of the cone to emit from
  15028. * @param angle The base angle of the cone
  15029. * @returns the emitter
  15030. */
  15031. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15032. /**
  15033. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15037. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @returns the emitter
  15039. */
  15040. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15041. /**
  15042. * Get hosting scene
  15043. * @returns the scene
  15044. */
  15045. getScene(): Nullable<Scene>;
  15046. }
  15047. }
  15048. declare module "babylonjs/Meshes/transformNode" {
  15049. import { DeepImmutable } from "babylonjs/types";
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Nullable } from "babylonjs/types";
  15052. import { Camera } from "babylonjs/Cameras/camera";
  15053. import { Scene } from "babylonjs/scene";
  15054. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15055. import { Node } from "babylonjs/node";
  15056. import { Bone } from "babylonjs/Bones/bone";
  15057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15058. import { Space } from "babylonjs/Maths/math.axis";
  15059. /**
  15060. * 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.
  15061. * @see https://doc.babylonjs.com/how_to/transformnode
  15062. */
  15063. export class TransformNode extends Node {
  15064. /**
  15065. * Object will not rotate to face the camera
  15066. */
  15067. static BILLBOARDMODE_NONE: number;
  15068. /**
  15069. * Object will rotate to face the camera but only on the x axis
  15070. */
  15071. static BILLBOARDMODE_X: number;
  15072. /**
  15073. * Object will rotate to face the camera but only on the y axis
  15074. */
  15075. static BILLBOARDMODE_Y: number;
  15076. /**
  15077. * Object will rotate to face the camera but only on the z axis
  15078. */
  15079. static BILLBOARDMODE_Z: number;
  15080. /**
  15081. * Object will rotate to face the camera
  15082. */
  15083. static BILLBOARDMODE_ALL: number;
  15084. /**
  15085. * Object will rotate to face the camera's position instead of orientation
  15086. */
  15087. static BILLBOARDMODE_USE_POSITION: number;
  15088. private static _TmpRotation;
  15089. private static _TmpScaling;
  15090. private static _TmpTranslation;
  15091. private _forward;
  15092. private _forwardInverted;
  15093. private _up;
  15094. private _right;
  15095. private _rightInverted;
  15096. private _position;
  15097. private _rotation;
  15098. private _rotationQuaternion;
  15099. protected _scaling: Vector3;
  15100. protected _isDirty: boolean;
  15101. private _transformToBoneReferal;
  15102. private _isAbsoluteSynced;
  15103. private _billboardMode;
  15104. /**
  15105. * Gets or sets the billboard mode. Default is 0.
  15106. *
  15107. * | Value | Type | Description |
  15108. * | --- | --- | --- |
  15109. * | 0 | BILLBOARDMODE_NONE | |
  15110. * | 1 | BILLBOARDMODE_X | |
  15111. * | 2 | BILLBOARDMODE_Y | |
  15112. * | 4 | BILLBOARDMODE_Z | |
  15113. * | 7 | BILLBOARDMODE_ALL | |
  15114. *
  15115. */
  15116. get billboardMode(): number;
  15117. set billboardMode(value: number);
  15118. private _preserveParentRotationForBillboard;
  15119. /**
  15120. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15121. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15122. */
  15123. get preserveParentRotationForBillboard(): boolean;
  15124. set preserveParentRotationForBillboard(value: boolean);
  15125. /**
  15126. * 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
  15127. */
  15128. scalingDeterminant: number;
  15129. private _infiniteDistance;
  15130. /**
  15131. * Gets or sets the distance of the object to max, often used by skybox
  15132. */
  15133. get infiniteDistance(): boolean;
  15134. set infiniteDistance(value: boolean);
  15135. /**
  15136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15137. * By default the system will update normals to compensate
  15138. */
  15139. ignoreNonUniformScaling: boolean;
  15140. /**
  15141. * 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
  15142. */
  15143. reIntegrateRotationIntoRotationQuaternion: boolean;
  15144. /** @hidden */
  15145. _poseMatrix: Nullable<Matrix>;
  15146. /** @hidden */
  15147. _localMatrix: Matrix;
  15148. private _usePivotMatrix;
  15149. private _absolutePosition;
  15150. private _absoluteScaling;
  15151. private _absoluteRotationQuaternion;
  15152. private _pivotMatrix;
  15153. private _pivotMatrixInverse;
  15154. /** @hidden */
  15155. _postMultiplyPivotMatrix: boolean;
  15156. protected _isWorldMatrixFrozen: boolean;
  15157. /** @hidden */
  15158. _indexInSceneTransformNodesArray: number;
  15159. /**
  15160. * An event triggered after the world matrix is updated
  15161. */
  15162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15164. /**
  15165. * Gets a string identifying the name of the class
  15166. * @returns "TransformNode" string
  15167. */
  15168. getClassName(): string;
  15169. /**
  15170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15171. */
  15172. get position(): Vector3;
  15173. set position(newPosition: Vector3);
  15174. /**
  15175. * 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)).
  15176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15177. */
  15178. get rotation(): Vector3;
  15179. set rotation(newRotation: Vector3);
  15180. /**
  15181. * 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)).
  15182. */
  15183. get scaling(): Vector3;
  15184. set scaling(newScaling: Vector3);
  15185. /**
  15186. * 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).
  15187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15188. */
  15189. get rotationQuaternion(): Nullable<Quaternion>;
  15190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15191. /**
  15192. * The forward direction of that transform in world space.
  15193. */
  15194. get forward(): Vector3;
  15195. /**
  15196. * The up direction of that transform in world space.
  15197. */
  15198. get up(): Vector3;
  15199. /**
  15200. * The right direction of that transform in world space.
  15201. */
  15202. get right(): Vector3;
  15203. /**
  15204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15205. * @param matrix the matrix to copy the pose from
  15206. * @returns this TransformNode.
  15207. */
  15208. updatePoseMatrix(matrix: Matrix): TransformNode;
  15209. /**
  15210. * Returns the mesh Pose matrix.
  15211. * @returns the pose matrix
  15212. */
  15213. getPoseMatrix(): Matrix;
  15214. /** @hidden */
  15215. _isSynchronized(): boolean;
  15216. /** @hidden */
  15217. _initCache(): void;
  15218. /**
  15219. * Flag the transform node as dirty (Forcing it to update everything)
  15220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15221. * @returns this transform node
  15222. */
  15223. markAsDirty(property: string): TransformNode;
  15224. /**
  15225. * Returns the current mesh absolute position.
  15226. * Returns a Vector3.
  15227. */
  15228. get absolutePosition(): Vector3;
  15229. /**
  15230. * Returns the current mesh absolute scaling.
  15231. * Returns a Vector3.
  15232. */
  15233. get absoluteScaling(): Vector3;
  15234. /**
  15235. * Returns the current mesh absolute rotation.
  15236. * Returns a Quaternion.
  15237. */
  15238. get absoluteRotationQuaternion(): Quaternion;
  15239. /**
  15240. * Sets a new matrix to apply before all other transformation
  15241. * @param matrix defines the transform matrix
  15242. * @returns the current TransformNode
  15243. */
  15244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15245. /**
  15246. * Sets a new pivot matrix to the current node
  15247. * @param matrix defines the new pivot matrix to use
  15248. * @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
  15249. * @returns the current TransformNode
  15250. */
  15251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15252. /**
  15253. * Returns the mesh pivot matrix.
  15254. * Default : Identity.
  15255. * @returns the matrix
  15256. */
  15257. getPivotMatrix(): Matrix;
  15258. /**
  15259. * Instantiate (when possible) or clone that node with its hierarchy
  15260. * @param newParent defines the new parent to use for the instance (or clone)
  15261. * @param options defines options to configure how copy is done
  15262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15263. * @returns an instance (or a clone) of the current node with its hiearchy
  15264. */
  15265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15266. doNotInstantiate: boolean;
  15267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15268. /**
  15269. * Prevents the World matrix to be computed any longer
  15270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15271. * @returns the TransformNode.
  15272. */
  15273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15274. /**
  15275. * Allows back the World matrix computation.
  15276. * @returns the TransformNode.
  15277. */
  15278. unfreezeWorldMatrix(): this;
  15279. /**
  15280. * True if the World matrix has been frozen.
  15281. */
  15282. get isWorldMatrixFrozen(): boolean;
  15283. /**
  15284. * Retuns the mesh absolute position in the World.
  15285. * @returns a Vector3.
  15286. */
  15287. getAbsolutePosition(): Vector3;
  15288. /**
  15289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15290. * @param absolutePosition the absolute position to set
  15291. * @returns the TransformNode.
  15292. */
  15293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15294. /**
  15295. * Sets the mesh position in its local space.
  15296. * @param vector3 the position to set in localspace
  15297. * @returns the TransformNode.
  15298. */
  15299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15300. /**
  15301. * Returns the mesh position in the local space from the current World matrix values.
  15302. * @returns a new Vector3.
  15303. */
  15304. getPositionExpressedInLocalSpace(): Vector3;
  15305. /**
  15306. * Translates the mesh along the passed Vector3 in its local space.
  15307. * @param vector3 the distance to translate in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. locallyTranslate(vector3: Vector3): TransformNode;
  15311. private static _lookAtVectorCache;
  15312. /**
  15313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15314. * @param targetPoint the position (must be in same space as current mesh) to look at
  15315. * @param yawCor optional yaw (y-axis) correction in radians
  15316. * @param pitchCor optional pitch (x-axis) correction in radians
  15317. * @param rollCor optional roll (z-axis) correction in radians
  15318. * @param space the choosen space of the target
  15319. * @returns the TransformNode.
  15320. */
  15321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15322. /**
  15323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15324. * This Vector3 is expressed in the World space.
  15325. * @param localAxis axis to rotate
  15326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15327. */
  15328. getDirection(localAxis: Vector3): Vector3;
  15329. /**
  15330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15331. * localAxis is expressed in the mesh local space.
  15332. * result is computed in the Wordl space from the mesh World matrix.
  15333. * @param localAxis axis to rotate
  15334. * @param result the resulting transformnode
  15335. * @returns this TransformNode.
  15336. */
  15337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15338. /**
  15339. * Sets this transform node rotation to the given local axis.
  15340. * @param localAxis the axis in local space
  15341. * @param yawCor optional yaw (y-axis) correction in radians
  15342. * @param pitchCor optional pitch (x-axis) correction in radians
  15343. * @param rollCor optional roll (z-axis) correction in radians
  15344. * @returns this TransformNode
  15345. */
  15346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15347. /**
  15348. * Sets a new pivot point to the current node
  15349. * @param point defines the new pivot point to use
  15350. * @param space defines if the point is in world or local space (local by default)
  15351. * @returns the current TransformNode
  15352. */
  15353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15354. /**
  15355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15356. * @returns the pivot point
  15357. */
  15358. getPivotPoint(): Vector3;
  15359. /**
  15360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15361. * @param result the vector3 to store the result
  15362. * @returns this TransformNode.
  15363. */
  15364. getPivotPointToRef(result: Vector3): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. */
  15369. getAbsolutePivotPoint(): Vector3;
  15370. /**
  15371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15372. * @param result vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Defines the passed node as the parent of the current node.
  15378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15379. * @see https://doc.babylonjs.com/how_to/parenting
  15380. * @param node the node ot set as the parent
  15381. * @returns this TransformNode.
  15382. */
  15383. setParent(node: Nullable<Node>): TransformNode;
  15384. private _nonUniformScaling;
  15385. /**
  15386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15387. */
  15388. get nonUniformScaling(): boolean;
  15389. /** @hidden */
  15390. _updateNonUniformScalingState(value: boolean): boolean;
  15391. /**
  15392. * Attach the current TransformNode to another TransformNode associated with a bone
  15393. * @param bone Bone affecting the TransformNode
  15394. * @param affectedTransformNode TransformNode associated with the bone
  15395. * @returns this object
  15396. */
  15397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15398. /**
  15399. * Detach the transform node if its associated with a bone
  15400. * @returns this object
  15401. */
  15402. detachFromBone(): TransformNode;
  15403. private static _rotationAxisCache;
  15404. /**
  15405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15408. * The passed axis is also normalized.
  15409. * @param axis the axis to rotate around
  15410. * @param amount the amount to rotate in radians
  15411. * @param space Space to rotate in (Default: local)
  15412. * @returns the TransformNode.
  15413. */
  15414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized. .
  15419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15420. * @param point the point to rotate around
  15421. * @param axis the axis to rotate around
  15422. * @param amount the amount to rotate in radians
  15423. * @returns the TransformNode
  15424. */
  15425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15426. /**
  15427. * Translates the mesh along the axis vector for the passed distance in the given space.
  15428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15429. * @param axis the axis to translate in
  15430. * @param distance the distance to translate
  15431. * @param space Space to rotate in (Default: local)
  15432. * @returns the TransformNode.
  15433. */
  15434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15435. /**
  15436. * Adds a rotation step to the mesh current rotation.
  15437. * x, y, z are Euler angles expressed in radians.
  15438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15439. * This means this rotation is made in the mesh local space only.
  15440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15442. * ```javascript
  15443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15444. * ```
  15445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15446. * 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.
  15447. * @param x Rotation to add
  15448. * @param y Rotation to add
  15449. * @param z Rotation to add
  15450. * @returns the TransformNode.
  15451. */
  15452. addRotation(x: number, y: number, z: number): TransformNode;
  15453. /**
  15454. * @hidden
  15455. */
  15456. protected _getEffectiveParent(): Nullable<Node>;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15465. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15466. */
  15467. resetLocalMatrix(independentOfChildren?: boolean): void;
  15468. protected _afterComputeWorldMatrix(): void;
  15469. /**
  15470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15471. * @param func callback function to add
  15472. *
  15473. * @returns the TransformNode.
  15474. */
  15475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15476. /**
  15477. * Removes a registered callback function.
  15478. * @param func callback function to remove
  15479. * @returns the TransformNode.
  15480. */
  15481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15482. /**
  15483. * Gets the position of the current mesh in camera space
  15484. * @param camera defines the camera to use
  15485. * @returns a position
  15486. */
  15487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15488. /**
  15489. * Returns the distance from the mesh to the active camera
  15490. * @param camera defines the camera to use
  15491. * @returns the distance
  15492. */
  15493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15494. /**
  15495. * Clone the current transform node
  15496. * @param name Name of the new clone
  15497. * @param newParent New parent for the clone
  15498. * @param doNotCloneChildren Do not clone children hierarchy
  15499. * @returns the new transform node
  15500. */
  15501. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15502. /**
  15503. * Serializes the objects information.
  15504. * @param currentSerializationObject defines the object to serialize in
  15505. * @returns the serialized object
  15506. */
  15507. serialize(currentSerializationObject?: any): any;
  15508. /**
  15509. * Returns a new TransformNode object parsed from the source provided.
  15510. * @param parsedTransformNode is the source.
  15511. * @param scene the scne the object belongs to
  15512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15513. * @returns a new TransformNode object parsed from the source provided.
  15514. */
  15515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15516. /**
  15517. * Get all child-transformNodes of this node
  15518. * @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
  15519. * @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
  15520. * @returns an array of TransformNode
  15521. */
  15522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15523. /**
  15524. * Releases resources associated with this transform node.
  15525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15527. */
  15528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15529. /**
  15530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15534. * @returns the current mesh
  15535. */
  15536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15537. private _syncAbsoluteScalingAndRotation;
  15538. }
  15539. }
  15540. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15541. /**
  15542. * Class used to override all child animations of a given target
  15543. */
  15544. export class AnimationPropertiesOverride {
  15545. /**
  15546. * Gets or sets a value indicating if animation blending must be used
  15547. */
  15548. enableBlending: boolean;
  15549. /**
  15550. * Gets or sets the blending speed to use when enableBlending is true
  15551. */
  15552. blendingSpeed: number;
  15553. /**
  15554. * Gets or sets the default loop mode to use
  15555. */
  15556. loopMode: number;
  15557. }
  15558. }
  15559. declare module "babylonjs/Bones/bone" {
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15562. import { Nullable } from "babylonjs/types";
  15563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15565. import { Node } from "babylonjs/node";
  15566. import { Space } from "babylonjs/Maths/math.axis";
  15567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15568. /**
  15569. * Class used to store bone information
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15571. */
  15572. export class Bone extends Node {
  15573. /**
  15574. * defines the bone name
  15575. */
  15576. name: string;
  15577. private static _tmpVecs;
  15578. private static _tmpQuat;
  15579. private static _tmpMats;
  15580. /**
  15581. * Gets the list of child bones
  15582. */
  15583. children: Bone[];
  15584. /** Gets the animations associated with this bone */
  15585. animations: import("babylonjs/Animations/animation").Animation[];
  15586. /**
  15587. * Gets or sets bone length
  15588. */
  15589. length: number;
  15590. /**
  15591. * @hidden Internal only
  15592. * Set this value to map this bone to a different index in the transform matrices
  15593. * Set this value to -1 to exclude the bone from the transform matrices
  15594. */
  15595. _index: Nullable<number>;
  15596. private _skeleton;
  15597. private _localMatrix;
  15598. private _restPose;
  15599. private _bindPose;
  15600. private _baseMatrix;
  15601. private _absoluteTransform;
  15602. private _invertedAbsoluteTransform;
  15603. private _parent;
  15604. private _scalingDeterminant;
  15605. private _worldTransform;
  15606. private _localScaling;
  15607. private _localRotation;
  15608. private _localPosition;
  15609. private _needToDecompose;
  15610. private _needToCompose;
  15611. /** @hidden */
  15612. _linkedTransformNode: Nullable<TransformNode>;
  15613. /** @hidden */
  15614. _waitingTransformNodeId: Nullable<string>;
  15615. /** @hidden */
  15616. get _matrix(): Matrix;
  15617. /** @hidden */
  15618. set _matrix(value: Matrix);
  15619. /**
  15620. * Create a new bone
  15621. * @param name defines the bone name
  15622. * @param skeleton defines the parent skeleton
  15623. * @param parentBone defines the parent (can be null if the bone is the root)
  15624. * @param localMatrix defines the local matrix
  15625. * @param restPose defines the rest pose matrix
  15626. * @param baseMatrix defines the base matrix
  15627. * @param index defines index of the bone in the hiearchy
  15628. */
  15629. constructor(
  15630. /**
  15631. * defines the bone name
  15632. */
  15633. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15634. /**
  15635. * Gets the current object class name.
  15636. * @return the class name
  15637. */
  15638. getClassName(): string;
  15639. /**
  15640. * Gets the parent skeleton
  15641. * @returns a skeleton
  15642. */
  15643. getSkeleton(): Skeleton;
  15644. /**
  15645. * Gets parent bone
  15646. * @returns a bone or null if the bone is the root of the bone hierarchy
  15647. */
  15648. getParent(): Nullable<Bone>;
  15649. /**
  15650. * Returns an array containing the root bones
  15651. * @returns an array containing the root bones
  15652. */
  15653. getChildren(): Array<Bone>;
  15654. /**
  15655. * Gets the node index in matrix array generated for rendering
  15656. * @returns the node index
  15657. */
  15658. getIndex(): number;
  15659. /**
  15660. * Sets the parent bone
  15661. * @param parent defines the parent (can be null if the bone is the root)
  15662. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15663. */
  15664. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15665. /**
  15666. * Gets the local matrix
  15667. * @returns a matrix
  15668. */
  15669. getLocalMatrix(): Matrix;
  15670. /**
  15671. * Gets the base matrix (initial matrix which remains unchanged)
  15672. * @returns a matrix
  15673. */
  15674. getBaseMatrix(): Matrix;
  15675. /**
  15676. * Gets the rest pose matrix
  15677. * @returns a matrix
  15678. */
  15679. getRestPose(): Matrix;
  15680. /**
  15681. * Sets the rest pose matrix
  15682. * @param matrix the local-space rest pose to set for this bone
  15683. */
  15684. setRestPose(matrix: Matrix): void;
  15685. /**
  15686. * Gets the bind pose matrix
  15687. * @returns the bind pose matrix
  15688. */
  15689. getBindPose(): Matrix;
  15690. /**
  15691. * Sets the bind pose matrix
  15692. * @param matrix the local-space bind pose to set for this bone
  15693. */
  15694. setBindPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15697. */
  15698. getWorldMatrix(): Matrix;
  15699. /**
  15700. * Sets the local matrix to rest pose matrix
  15701. */
  15702. returnToRest(): void;
  15703. /**
  15704. * Gets the inverse of the absolute transform matrix.
  15705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15706. * @returns a matrix
  15707. */
  15708. getInvertedAbsoluteTransform(): Matrix;
  15709. /**
  15710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15711. * @returns a matrix
  15712. */
  15713. getAbsoluteTransform(): Matrix;
  15714. /**
  15715. * Links with the given transform node.
  15716. * The local matrix of this bone is copied from the transform node every frame.
  15717. * @param transformNode defines the transform node to link to
  15718. */
  15719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15720. /**
  15721. * Gets the node used to drive the bone's transformation
  15722. * @returns a transform node or null
  15723. */
  15724. getTransformNode(): Nullable<TransformNode>;
  15725. /** Gets or sets current position (in local space) */
  15726. get position(): Vector3;
  15727. set position(newPosition: Vector3);
  15728. /** Gets or sets current rotation (in local space) */
  15729. get rotation(): Vector3;
  15730. set rotation(newRotation: Vector3);
  15731. /** Gets or sets current rotation quaternion (in local space) */
  15732. get rotationQuaternion(): Quaternion;
  15733. set rotationQuaternion(newRotation: Quaternion);
  15734. /** Gets or sets current scaling (in local space) */
  15735. get scaling(): Vector3;
  15736. set scaling(newScaling: Vector3);
  15737. /**
  15738. * Gets the animation properties override
  15739. */
  15740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15741. private _decompose;
  15742. private _compose;
  15743. /**
  15744. * Update the base and local matrices
  15745. * @param matrix defines the new base or local matrix
  15746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15747. * @param updateLocalMatrix defines if the local matrix should be updated
  15748. */
  15749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15750. /** @hidden */
  15751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15752. /**
  15753. * Flag the bone as dirty (Forcing it to update everything)
  15754. */
  15755. markAsDirty(): void;
  15756. /** @hidden */
  15757. _markAsDirtyAndCompose(): void;
  15758. private _markAsDirtyAndDecompose;
  15759. /**
  15760. * Translate the bone in local or world space
  15761. * @param vec The amount to translate the bone
  15762. * @param space The space that the translation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the postion of the bone in local or world space
  15768. * @param position The position to set the bone
  15769. * @param space The space that the position is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the absolute position of the bone (world space)
  15775. * @param position The position to set the bone
  15776. * @param mesh The mesh that this bone is attached to
  15777. */
  15778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15779. /**
  15780. * Scale the bone on the x, y and z axes (in local space)
  15781. * @param x The amount to scale the bone on the x axis
  15782. * @param y The amount to scale the bone on the y axis
  15783. * @param z The amount to scale the bone on the z axis
  15784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15785. */
  15786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15787. /**
  15788. * Set the bone scaling in local space
  15789. * @param scale defines the scaling vector
  15790. */
  15791. setScale(scale: Vector3): void;
  15792. /**
  15793. * Gets the current scaling in local space
  15794. * @returns the current scaling vector
  15795. */
  15796. getScale(): Vector3;
  15797. /**
  15798. * Gets the current scaling in local space and stores it in a target vector
  15799. * @param result defines the target vector
  15800. */
  15801. getScaleToRef(result: Vector3): void;
  15802. /**
  15803. * Set the yaw, pitch, and roll of the bone in local or world space
  15804. * @param yaw The rotation of the bone on the y axis
  15805. * @param pitch The rotation of the bone on the x axis
  15806. * @param roll The rotation of the bone on the z axis
  15807. * @param space The space that the axes of rotation are in
  15808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15809. */
  15810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15811. /**
  15812. * Add a rotation to the bone on an axis in local or world space
  15813. * @param axis The axis to rotate the bone on
  15814. * @param amount The amount to rotate the bone
  15815. * @param space The space that the axis is in
  15816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15817. */
  15818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15819. /**
  15820. * Set the rotation of the bone to a particular axis angle in local or world space
  15821. * @param axis The axis to rotate the bone on
  15822. * @param angle The angle that the bone should be rotated to
  15823. * @param space The space that the axis is in
  15824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15825. */
  15826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15827. /**
  15828. * Set the euler rotation of the bone in local or world space
  15829. * @param rotation The euler rotation that the bone should be set to
  15830. * @param space The space that the rotation is in
  15831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15832. */
  15833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15834. /**
  15835. * Set the quaternion rotation of the bone in local or world space
  15836. * @param quat The quaternion rotation that the bone should be set to
  15837. * @param space The space that the rotation is in
  15838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15839. */
  15840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Set the rotation matrix of the bone in local or world space
  15843. * @param rotMat The rotation matrix that the bone should be set to
  15844. * @param space The space that the rotation is in
  15845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15846. */
  15847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15848. private _rotateWithMatrix;
  15849. private _getNegativeRotationToRef;
  15850. /**
  15851. * Get the position of the bone in local or world space
  15852. * @param space The space that the returned position is in
  15853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15854. * @returns The position of the bone
  15855. */
  15856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15857. /**
  15858. * Copy the position of the bone to a vector3 in local or world space
  15859. * @param space The space that the returned position is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. * @param result The vector3 to copy the position to
  15862. */
  15863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15864. /**
  15865. * Get the absolute position of the bone (world space)
  15866. * @param mesh The mesh that this bone is attached to
  15867. * @returns The absolute position of the bone
  15868. */
  15869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15870. /**
  15871. * Copy the absolute position of the bone (world space) to the result param
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @param result The vector3 to copy the absolute position to
  15874. */
  15875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15876. /**
  15877. * Compute the absolute transforms of this bone and its children
  15878. */
  15879. computeAbsoluteTransforms(): void;
  15880. /**
  15881. * Get the world direction from an axis that is in the local space of the bone
  15882. * @param localAxis The local direction that is used to compute the world direction
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @returns The world direction
  15885. */
  15886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15887. /**
  15888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15889. * @param localAxis The local direction that is used to compute the world direction
  15890. * @param mesh The mesh that this bone is attached to
  15891. * @param result The vector3 that the world direction will be copied to
  15892. */
  15893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15894. /**
  15895. * Get the euler rotation of the bone in local or world space
  15896. * @param space The space that the rotation should be in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The euler rotation
  15899. */
  15900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15903. * @param space The space that the rotation should be in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 that the rotation should be copied to
  15906. */
  15907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15908. /**
  15909. * Get the quaternion rotation of the bone in either local or world space
  15910. * @param space The space that the rotation should be in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @returns The quaternion rotation
  15913. */
  15914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15915. /**
  15916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15917. * @param space The space that the rotation should be in
  15918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15919. * @param result The quaternion that the rotation should be copied to
  15920. */
  15921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15922. /**
  15923. * Get the rotation matrix of the bone in local or world space
  15924. * @param space The space that the rotation should be in
  15925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15926. * @returns The rotation matrix
  15927. */
  15928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15929. /**
  15930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15931. * @param space The space that the rotation should be in
  15932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15933. * @param result The quaternion that the rotation should be copied to
  15934. */
  15935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15936. /**
  15937. * Get the world position of a point that is in the local space of the bone
  15938. * @param position The local position
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @returns The world position
  15941. */
  15942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15943. /**
  15944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15945. * @param position The local position
  15946. * @param mesh The mesh that this bone is attached to
  15947. * @param result The vector3 that the world position should be copied to
  15948. */
  15949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15950. /**
  15951. * Get the local position of a point that is in world space
  15952. * @param position The world position
  15953. * @param mesh The mesh that this bone is attached to
  15954. * @returns The local position
  15955. */
  15956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15957. /**
  15958. * Get the local position of a point that is in world space and copy it to the result param
  15959. * @param position The world position
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @param result The vector3 that the local position should be copied to
  15962. */
  15963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15964. /**
  15965. * Set the current local matrix as the restPose for this bone.
  15966. */
  15967. setCurrentPoseAsRest(): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Animations/runtimeAnimation" {
  15971. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15972. import { Animatable } from "babylonjs/Animations/animatable";
  15973. import { Scene } from "babylonjs/scene";
  15974. /**
  15975. * Defines a runtime animation
  15976. */
  15977. export class RuntimeAnimation {
  15978. private _events;
  15979. /**
  15980. * The current frame of the runtime animation
  15981. */
  15982. private _currentFrame;
  15983. /**
  15984. * The animation used by the runtime animation
  15985. */
  15986. private _animation;
  15987. /**
  15988. * The target of the runtime animation
  15989. */
  15990. private _target;
  15991. /**
  15992. * The initiating animatable
  15993. */
  15994. private _host;
  15995. /**
  15996. * The original value of the runtime animation
  15997. */
  15998. private _originalValue;
  15999. /**
  16000. * The original blend value of the runtime animation
  16001. */
  16002. private _originalBlendValue;
  16003. /**
  16004. * The offsets cache of the runtime animation
  16005. */
  16006. private _offsetsCache;
  16007. /**
  16008. * The high limits cache of the runtime animation
  16009. */
  16010. private _highLimitsCache;
  16011. /**
  16012. * Specifies if the runtime animation has been stopped
  16013. */
  16014. private _stopped;
  16015. /**
  16016. * The blending factor of the runtime animation
  16017. */
  16018. private _blendingFactor;
  16019. /**
  16020. * The BabylonJS scene
  16021. */
  16022. private _scene;
  16023. /**
  16024. * The current value of the runtime animation
  16025. */
  16026. private _currentValue;
  16027. /** @hidden */
  16028. _animationState: _IAnimationState;
  16029. /**
  16030. * The active target of the runtime animation
  16031. */
  16032. private _activeTargets;
  16033. private _currentActiveTarget;
  16034. private _directTarget;
  16035. /**
  16036. * The target path of the runtime animation
  16037. */
  16038. private _targetPath;
  16039. /**
  16040. * The weight of the runtime animation
  16041. */
  16042. private _weight;
  16043. /**
  16044. * The ratio offset of the runtime animation
  16045. */
  16046. private _ratioOffset;
  16047. /**
  16048. * The previous delay of the runtime animation
  16049. */
  16050. private _previousDelay;
  16051. /**
  16052. * The previous ratio of the runtime animation
  16053. */
  16054. private _previousRatio;
  16055. private _enableBlending;
  16056. private _keys;
  16057. private _minFrame;
  16058. private _maxFrame;
  16059. private _minValue;
  16060. private _maxValue;
  16061. private _targetIsArray;
  16062. /**
  16063. * Gets the current frame of the runtime animation
  16064. */
  16065. get currentFrame(): number;
  16066. /**
  16067. * Gets the weight of the runtime animation
  16068. */
  16069. get weight(): number;
  16070. /**
  16071. * Gets the current value of the runtime animation
  16072. */
  16073. get currentValue(): any;
  16074. /**
  16075. * Gets the target path of the runtime animation
  16076. */
  16077. get targetPath(): string;
  16078. /**
  16079. * Gets the actual target of the runtime animation
  16080. */
  16081. get target(): any;
  16082. /**
  16083. * Gets the additive state of the runtime animation
  16084. */
  16085. get isAdditive(): boolean;
  16086. /** @hidden */
  16087. _onLoop: () => void;
  16088. /**
  16089. * Create a new RuntimeAnimation object
  16090. * @param target defines the target of the animation
  16091. * @param animation defines the source animation object
  16092. * @param scene defines the hosting scene
  16093. * @param host defines the initiating Animatable
  16094. */
  16095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16096. private _preparePath;
  16097. /**
  16098. * Gets the animation from the runtime animation
  16099. */
  16100. get animation(): Animation;
  16101. /**
  16102. * Resets the runtime animation to the beginning
  16103. * @param restoreOriginal defines whether to restore the target property to the original value
  16104. */
  16105. reset(restoreOriginal?: boolean): void;
  16106. /**
  16107. * Specifies if the runtime animation is stopped
  16108. * @returns Boolean specifying if the runtime animation is stopped
  16109. */
  16110. isStopped(): boolean;
  16111. /**
  16112. * Disposes of the runtime animation
  16113. */
  16114. dispose(): void;
  16115. /**
  16116. * Apply the interpolated value to the target
  16117. * @param currentValue defines the value computed by the animation
  16118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16119. */
  16120. setValue(currentValue: any, weight: number): void;
  16121. private _getOriginalValues;
  16122. private _setValue;
  16123. /**
  16124. * Gets the loop pmode of the runtime animation
  16125. * @returns Loop Mode
  16126. */
  16127. private _getCorrectLoopMode;
  16128. /**
  16129. * Move the current animation to a given frame
  16130. * @param frame defines the frame to move to
  16131. */
  16132. goToFrame(frame: number): void;
  16133. /**
  16134. * @hidden Internal use only
  16135. */
  16136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16137. /**
  16138. * Execute the current animation
  16139. * @param delay defines the delay to add to the current frame
  16140. * @param from defines the lower bound of the animation range
  16141. * @param to defines the upper bound of the animation range
  16142. * @param loop defines if the current animation must loop
  16143. * @param speedRatio defines the current speed ratio
  16144. * @param weight defines the weight of the animation (default is -1 so no weight)
  16145. * @param onLoop optional callback called when animation loops
  16146. * @returns a boolean indicating if the animation is running
  16147. */
  16148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16149. }
  16150. }
  16151. declare module "babylonjs/Animations/animatable" {
  16152. import { Animation } from "babylonjs/Animations/animation";
  16153. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16154. import { Nullable } from "babylonjs/types";
  16155. import { Observable } from "babylonjs/Misc/observable";
  16156. import { Scene } from "babylonjs/scene";
  16157. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16158. import { Node } from "babylonjs/node";
  16159. /**
  16160. * Class used to store an actual running animation
  16161. */
  16162. export class Animatable {
  16163. /** defines the target object */
  16164. target: any;
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame: number;
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame: number;
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation: boolean;
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined;
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined;
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive: boolean;
  16177. private _localDelayOffset;
  16178. private _pausedDelay;
  16179. private _runtimeAnimations;
  16180. private _paused;
  16181. private _scene;
  16182. private _speedRatio;
  16183. private _weight;
  16184. private _syncRoot;
  16185. /**
  16186. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16187. * This will only apply for non looping animation (default is true)
  16188. */
  16189. disposeOnEnd: boolean;
  16190. /**
  16191. * Gets a boolean indicating if the animation has started
  16192. */
  16193. animationStarted: boolean;
  16194. /**
  16195. * Observer raised when the animation ends
  16196. */
  16197. onAnimationEndObservable: Observable<Animatable>;
  16198. /**
  16199. * Observer raised when the animation loops
  16200. */
  16201. onAnimationLoopObservable: Observable<Animatable>;
  16202. /**
  16203. * Gets the root Animatable used to synchronize and normalize animations
  16204. */
  16205. get syncRoot(): Nullable<Animatable>;
  16206. /**
  16207. * Gets the current frame of the first RuntimeAnimation
  16208. * Used to synchronize Animatables
  16209. */
  16210. get masterFrame(): number;
  16211. /**
  16212. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16213. */
  16214. get weight(): number;
  16215. set weight(value: number);
  16216. /**
  16217. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16218. */
  16219. get speedRatio(): number;
  16220. set speedRatio(value: number);
  16221. /**
  16222. * Creates a new Animatable
  16223. * @param scene defines the hosting scene
  16224. * @param target defines the target object
  16225. * @param fromFrame defines the starting frame number (default is 0)
  16226. * @param toFrame defines the ending frame number (default is 100)
  16227. * @param loopAnimation defines if the animation must loop (default is false)
  16228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16230. * @param animations defines a group of animation to add to the new Animatable
  16231. * @param onAnimationLoop defines a callback to call when animation loops
  16232. * @param isAdditive defines whether the animation should be evaluated additively
  16233. */
  16234. constructor(scene: Scene,
  16235. /** defines the target object */
  16236. target: any,
  16237. /** defines the starting frame number (default is 0) */
  16238. fromFrame?: number,
  16239. /** defines the ending frame number (default is 100) */
  16240. toFrame?: number,
  16241. /** defines if the animation must loop (default is false) */
  16242. loopAnimation?: boolean, speedRatio?: number,
  16243. /** defines a callback to call when animation ends if it is not looping */
  16244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16245. /** defines a callback to call when animation loops */
  16246. onAnimationLoop?: (() => void) | null | undefined,
  16247. /** defines whether the animation should be evaluated additively */
  16248. isAdditive?: boolean);
  16249. /**
  16250. * Synchronize and normalize current Animatable with a source Animatable
  16251. * This is useful when using animation weights and when animations are not of the same length
  16252. * @param root defines the root Animatable to synchronize with
  16253. * @returns the current Animatable
  16254. */
  16255. syncWith(root: Animatable): Animatable;
  16256. /**
  16257. * Gets the list of runtime animations
  16258. * @returns an array of RuntimeAnimation
  16259. */
  16260. getAnimations(): RuntimeAnimation[];
  16261. /**
  16262. * Adds more animations to the current animatable
  16263. * @param target defines the target of the animations
  16264. * @param animations defines the new animations to add
  16265. */
  16266. appendAnimations(target: any, animations: Animation[]): void;
  16267. /**
  16268. * Gets the source animation for a specific property
  16269. * @param property defines the propertyu to look for
  16270. * @returns null or the source animation for the given property
  16271. */
  16272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16273. /**
  16274. * Gets the runtime animation for a specific property
  16275. * @param property defines the propertyu to look for
  16276. * @returns null or the runtime animation for the given property
  16277. */
  16278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16279. /**
  16280. * Resets the animatable to its original state
  16281. */
  16282. reset(): void;
  16283. /**
  16284. * Allows the animatable to blend with current running animations
  16285. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16286. * @param blendingSpeed defines the blending speed to use
  16287. */
  16288. enableBlending(blendingSpeed: number): void;
  16289. /**
  16290. * Disable animation blending
  16291. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16292. */
  16293. disableBlending(): void;
  16294. /**
  16295. * Jump directly to a given frame
  16296. * @param frame defines the frame to jump to
  16297. */
  16298. goToFrame(frame: number): void;
  16299. /**
  16300. * Pause the animation
  16301. */
  16302. pause(): void;
  16303. /**
  16304. * Restart the animation
  16305. */
  16306. restart(): void;
  16307. private _raiseOnAnimationEnd;
  16308. /**
  16309. * Stop and delete the current animation
  16310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16311. * @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)
  16312. */
  16313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16314. /**
  16315. * Wait asynchronously for the animation to end
  16316. * @returns a promise which will be fullfilled when the animation ends
  16317. */
  16318. waitAsync(): Promise<Animatable>;
  16319. /** @hidden */
  16320. _animate(delay: number): boolean;
  16321. }
  16322. module "babylonjs/scene" {
  16323. interface Scene {
  16324. /** @hidden */
  16325. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16326. /** @hidden */
  16327. _processLateAnimationBindingsForMatrices(holder: {
  16328. totalWeight: number;
  16329. totalAdditiveWeight: number;
  16330. animations: RuntimeAnimation[];
  16331. additiveAnimations: RuntimeAnimation[];
  16332. originalValue: Matrix;
  16333. }): any;
  16334. /** @hidden */
  16335. _processLateAnimationBindingsForQuaternions(holder: {
  16336. totalWeight: number;
  16337. totalAdditiveWeight: number;
  16338. animations: RuntimeAnimation[];
  16339. additiveAnimations: RuntimeAnimation[];
  16340. originalValue: Quaternion;
  16341. }, refQuaternion: Quaternion): Quaternion;
  16342. /** @hidden */
  16343. _processLateAnimationBindings(): void;
  16344. /**
  16345. * Will start the animation sequence of a given target
  16346. * @param target defines the target
  16347. * @param from defines from which frame should animation start
  16348. * @param to defines until which frame should animation run.
  16349. * @param weight defines the weight to apply to the animation (1.0 by default)
  16350. * @param loop defines if the animation loops
  16351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16352. * @param onAnimationEnd defines the function to be executed when the animation ends
  16353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16354. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16355. * @param onAnimationLoop defines the callback to call when an animation loops
  16356. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16357. * @returns the animatable object created for this animation
  16358. */
  16359. 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;
  16360. /**
  16361. * Will start the animation sequence of a given target
  16362. * @param target defines the target
  16363. * @param from defines from which frame should animation start
  16364. * @param to defines until which frame should animation run.
  16365. * @param loop defines if the animation loops
  16366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16367. * @param onAnimationEnd defines the function to be executed when the animation ends
  16368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16370. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16371. * @param onAnimationLoop defines the callback to call when an animation loops
  16372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16373. * @returns the animatable object created for this animation
  16374. */
  16375. 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;
  16376. /**
  16377. * Will start the animation sequence of a given target and its hierarchy
  16378. * @param target defines the target
  16379. * @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.
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param loop defines if the animation loops
  16383. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16384. * @param onAnimationEnd defines the function to be executed when the animation ends
  16385. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16386. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  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 created animatables
  16391. */
  16392. 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[];
  16393. /**
  16394. * Begin a new animation on a given node
  16395. * @param target defines the target where the animation will take place
  16396. * @param animations defines the list of animations to start
  16397. * @param from defines the initial value
  16398. * @param to defines the final value
  16399. * @param loop defines if you want animation to loop (off by default)
  16400. * @param speedRatio defines the speed ratio to apply to all animations
  16401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16402. * @param onAnimationLoop defines the callback to call when an animation loops
  16403. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16404. * @returns the list of created animatables
  16405. */
  16406. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16407. /**
  16408. * Begin a new animation on a given node and its hierarchy
  16409. * @param target defines the root node where the animation will take place
  16410. * @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.
  16411. * @param animations defines the list of animations to start
  16412. * @param from defines the initial value
  16413. * @param to defines the final value
  16414. * @param loop defines if you want animation to loop (off by default)
  16415. * @param speedRatio defines the speed ratio to apply to all animations
  16416. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the list of animatables created for all nodes
  16420. */
  16421. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16422. /**
  16423. * Gets the animatable associated with a specific target
  16424. * @param target defines the target of the animatable
  16425. * @returns the required animatable if found
  16426. */
  16427. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16428. /**
  16429. * Gets all animatables associated with a given target
  16430. * @param target defines the target to look animatables for
  16431. * @returns an array of Animatables
  16432. */
  16433. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16434. /**
  16435. * Stops and removes all animations that have been applied to the scene
  16436. */
  16437. stopAllAnimations(): void;
  16438. /**
  16439. * Gets the current delta time used by animation engine
  16440. */
  16441. deltaTime: number;
  16442. }
  16443. }
  16444. module "babylonjs/Bones/bone" {
  16445. interface Bone {
  16446. /**
  16447. * Copy an animation range from another bone
  16448. * @param source defines the source bone
  16449. * @param rangeName defines the range name to copy
  16450. * @param frameOffset defines the frame offset
  16451. * @param rescaleAsRequired defines if rescaling must be applied if required
  16452. * @param skelDimensionsRatio defines the scaling ratio
  16453. * @returns true if operation was successful
  16454. */
  16455. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16456. }
  16457. }
  16458. }
  16459. declare module "babylonjs/Bones/skeleton" {
  16460. import { Bone } from "babylonjs/Bones/bone";
  16461. import { Observable } from "babylonjs/Misc/observable";
  16462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16463. import { Scene } from "babylonjs/scene";
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16467. import { Animatable } from "babylonjs/Animations/animatable";
  16468. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16469. import { Animation } from "babylonjs/Animations/animation";
  16470. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16471. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16472. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16473. /**
  16474. * Class used to handle skinning animations
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16476. */
  16477. export class Skeleton implements IAnimatable {
  16478. /** defines the skeleton name */
  16479. name: string;
  16480. /** defines the skeleton Id */
  16481. id: string;
  16482. /**
  16483. * Defines the list of child bones
  16484. */
  16485. bones: Bone[];
  16486. /**
  16487. * Defines an estimate of the dimension of the skeleton at rest
  16488. */
  16489. dimensionsAtRest: Vector3;
  16490. /**
  16491. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16492. */
  16493. needInitialSkinMatrix: boolean;
  16494. /**
  16495. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16496. */
  16497. overrideMesh: Nullable<AbstractMesh>;
  16498. /**
  16499. * Gets the list of animations attached to this skeleton
  16500. */
  16501. animations: Array<Animation>;
  16502. private _scene;
  16503. private _isDirty;
  16504. private _transformMatrices;
  16505. private _transformMatrixTexture;
  16506. private _meshesWithPoseMatrix;
  16507. private _animatables;
  16508. private _identity;
  16509. private _synchronizedWithMesh;
  16510. private _ranges;
  16511. private _lastAbsoluteTransformsUpdateId;
  16512. private _canUseTextureForBones;
  16513. private _uniqueId;
  16514. /** @hidden */
  16515. _numBonesWithLinkedTransformNode: number;
  16516. /** @hidden */
  16517. _hasWaitingData: Nullable<boolean>;
  16518. /** @hidden */
  16519. _waitingOverrideMeshId: Nullable<string>;
  16520. /**
  16521. * Specifies if the skeleton should be serialized
  16522. */
  16523. doNotSerialize: boolean;
  16524. private _useTextureToStoreBoneMatrices;
  16525. /**
  16526. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16527. * Please note that this option is not available if the hardware does not support it
  16528. */
  16529. get useTextureToStoreBoneMatrices(): boolean;
  16530. set useTextureToStoreBoneMatrices(value: boolean);
  16531. private _animationPropertiesOverride;
  16532. /**
  16533. * Gets or sets the animation properties override
  16534. */
  16535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16537. /**
  16538. * List of inspectable custom properties (used by the Inspector)
  16539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16540. */
  16541. inspectableCustomProperties: IInspectable[];
  16542. /**
  16543. * An observable triggered before computing the skeleton's matrices
  16544. */
  16545. onBeforeComputeObservable: Observable<Skeleton>;
  16546. /**
  16547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16548. */
  16549. get isUsingTextureForMatrices(): boolean;
  16550. /**
  16551. * Gets the unique ID of this skeleton
  16552. */
  16553. get uniqueId(): number;
  16554. /**
  16555. * Creates a new skeleton
  16556. * @param name defines the skeleton name
  16557. * @param id defines the skeleton Id
  16558. * @param scene defines the hosting scene
  16559. */
  16560. constructor(
  16561. /** defines the skeleton name */
  16562. name: string,
  16563. /** defines the skeleton Id */
  16564. id: string, scene: Scene);
  16565. /**
  16566. * Gets the current object class name.
  16567. * @return the class name
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * Returns an array containing the root bones
  16572. * @returns an array containing the root bones
  16573. */
  16574. getChildren(): Array<Bone>;
  16575. /**
  16576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16578. * @returns a Float32Array containing matrices data
  16579. */
  16580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16581. /**
  16582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16584. * @returns a raw texture containing the data
  16585. */
  16586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16587. /**
  16588. * Gets the current hosting scene
  16589. * @returns a scene object
  16590. */
  16591. getScene(): Scene;
  16592. /**
  16593. * Gets a string representing the current skeleton data
  16594. * @param fullDetails defines a boolean indicating if we want a verbose version
  16595. * @returns a string representing the current skeleton data
  16596. */
  16597. toString(fullDetails?: boolean): string;
  16598. /**
  16599. * Get bone's index searching by name
  16600. * @param name defines bone's name to search for
  16601. * @return the indice of the bone. Returns -1 if not found
  16602. */
  16603. getBoneIndexByName(name: string): number;
  16604. /**
  16605. * Creater a new animation range
  16606. * @param name defines the name of the range
  16607. * @param from defines the start key
  16608. * @param to defines the end key
  16609. */
  16610. createAnimationRange(name: string, from: number, to: number): void;
  16611. /**
  16612. * Delete a specific animation range
  16613. * @param name defines the name of the range
  16614. * @param deleteFrames defines if frames must be removed as well
  16615. */
  16616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16617. /**
  16618. * Gets a specific animation range
  16619. * @param name defines the name of the range to look for
  16620. * @returns the requested animation range or null if not found
  16621. */
  16622. getAnimationRange(name: string): Nullable<AnimationRange>;
  16623. /**
  16624. * Gets the list of all animation ranges defined on this skeleton
  16625. * @returns an array
  16626. */
  16627. getAnimationRanges(): Nullable<AnimationRange>[];
  16628. /**
  16629. * Copy animation range from a source skeleton.
  16630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16631. * @param source defines the source skeleton
  16632. * @param name defines the name of the range to copy
  16633. * @param rescaleAsRequired defines if rescaling must be applied if required
  16634. * @returns true if operation was successful
  16635. */
  16636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16637. /**
  16638. * Forces the skeleton to go to rest pose
  16639. */
  16640. returnToRest(): void;
  16641. private _getHighestAnimationFrame;
  16642. /**
  16643. * Begin a specific animation range
  16644. * @param name defines the name of the range to start
  16645. * @param loop defines if looping must be turned on (false by default)
  16646. * @param speedRatio defines the speed ratio to apply (1 by default)
  16647. * @param onAnimationEnd defines a callback which will be called when animation will end
  16648. * @returns a new animatable
  16649. */
  16650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16651. /**
  16652. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16653. * @param skeleton defines the Skeleton containing the animation range to convert
  16654. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16655. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16656. * @returns the original skeleton
  16657. */
  16658. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16659. /** @hidden */
  16660. _markAsDirty(): void;
  16661. /** @hidden */
  16662. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16663. /** @hidden */
  16664. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16665. private _computeTransformMatrices;
  16666. /**
  16667. * Build all resources required to render a skeleton
  16668. */
  16669. prepare(): void;
  16670. /**
  16671. * Gets the list of animatables currently running for this skeleton
  16672. * @returns an array of animatables
  16673. */
  16674. getAnimatables(): IAnimatable[];
  16675. /**
  16676. * Clone the current skeleton
  16677. * @param name defines the name of the new skeleton
  16678. * @param id defines the id of the new skeleton
  16679. * @returns the new skeleton
  16680. */
  16681. clone(name: string, id?: string): Skeleton;
  16682. /**
  16683. * Enable animation blending for this skeleton
  16684. * @param blendingSpeed defines the blending speed to apply
  16685. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16686. */
  16687. enableBlending(blendingSpeed?: number): void;
  16688. /**
  16689. * Releases all resources associated with the current skeleton
  16690. */
  16691. dispose(): void;
  16692. /**
  16693. * Serialize the skeleton in a JSON object
  16694. * @returns a JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Creates a new skeleton from serialized data
  16699. * @param parsedSkeleton defines the serialized data
  16700. * @param scene defines the hosting scene
  16701. * @returns a new skeleton
  16702. */
  16703. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16704. /**
  16705. * Compute all node absolute transforms
  16706. * @param forceUpdate defines if computation must be done even if cache is up to date
  16707. */
  16708. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16709. /**
  16710. * Gets the root pose matrix
  16711. * @returns a matrix
  16712. */
  16713. getPoseMatrix(): Nullable<Matrix>;
  16714. /**
  16715. * Sorts bones per internal index
  16716. */
  16717. sortBones(): void;
  16718. private _sortBones;
  16719. /**
  16720. * Set the current local matrix as the restPose for all bones in the skeleton.
  16721. */
  16722. setCurrentPoseAsRest(): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Meshes/instancedMesh" {
  16726. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16728. import { Camera } from "babylonjs/Cameras/camera";
  16729. import { Node } from "babylonjs/node";
  16730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16731. import { Mesh } from "babylonjs/Meshes/mesh";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. import { Skeleton } from "babylonjs/Bones/skeleton";
  16734. import { Light } from "babylonjs/Lights/light";
  16735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16736. /**
  16737. * Creates an instance based on a source mesh.
  16738. */
  16739. export class InstancedMesh extends AbstractMesh {
  16740. private _sourceMesh;
  16741. private _currentLOD;
  16742. /** @hidden */
  16743. _indexInSourceMeshInstanceArray: number;
  16744. constructor(name: string, source: Mesh);
  16745. /**
  16746. * Returns the string "InstancedMesh".
  16747. */
  16748. getClassName(): string;
  16749. /** Gets the list of lights affecting that mesh */
  16750. get lightSources(): Light[];
  16751. _resyncLightSources(): void;
  16752. _resyncLightSource(light: Light): void;
  16753. _removeLightSource(light: Light, dispose: boolean): void;
  16754. /**
  16755. * If the source mesh receives shadows
  16756. */
  16757. get receiveShadows(): boolean;
  16758. /**
  16759. * The material of the source mesh
  16760. */
  16761. get material(): Nullable<Material>;
  16762. /**
  16763. * Visibility of the source mesh
  16764. */
  16765. get visibility(): number;
  16766. /**
  16767. * Skeleton of the source mesh
  16768. */
  16769. get skeleton(): Nullable<Skeleton>;
  16770. /**
  16771. * Rendering ground id of the source mesh
  16772. */
  16773. get renderingGroupId(): number;
  16774. set renderingGroupId(value: number);
  16775. /**
  16776. * Returns the total number of vertices (integer).
  16777. */
  16778. getTotalVertices(): number;
  16779. /**
  16780. * Returns a positive integer : the total number of indices in this mesh geometry.
  16781. * @returns the numner of indices or zero if the mesh has no geometry.
  16782. */
  16783. getTotalIndices(): number;
  16784. /**
  16785. * The source mesh of the instance
  16786. */
  16787. get sourceMesh(): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16791. * @param name defines the name of the new instance
  16792. * @returns a new InstancedMesh
  16793. */
  16794. createInstance(name: string): InstancedMesh;
  16795. /**
  16796. * Is this node ready to be used/rendered
  16797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16798. * @return {boolean} is it ready
  16799. */
  16800. isReady(completeCheck?: boolean): boolean;
  16801. /**
  16802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16803. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16804. * @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.
  16805. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16806. */
  16807. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16808. /**
  16809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16811. * The `data` are either a numeric array either a Float32Array.
  16812. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16813. * 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).
  16814. * Note that a new underlying VertexBuffer object is created each call.
  16815. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16816. *
  16817. * Possible `kind` values :
  16818. * - VertexBuffer.PositionKind
  16819. * - VertexBuffer.UVKind
  16820. * - VertexBuffer.UV2Kind
  16821. * - VertexBuffer.UV3Kind
  16822. * - VertexBuffer.UV4Kind
  16823. * - VertexBuffer.UV5Kind
  16824. * - VertexBuffer.UV6Kind
  16825. * - VertexBuffer.ColorKind
  16826. * - VertexBuffer.MatricesIndicesKind
  16827. * - VertexBuffer.MatricesIndicesExtraKind
  16828. * - VertexBuffer.MatricesWeightsKind
  16829. * - VertexBuffer.MatricesWeightsExtraKind
  16830. *
  16831. * Returns the Mesh.
  16832. */
  16833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16834. /**
  16835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16836. * If the mesh has no geometry, it is simply returned as it is.
  16837. * The `data` are either a numeric array either a Float32Array.
  16838. * No new underlying VertexBuffer object is created.
  16839. * 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.
  16840. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16841. *
  16842. * Possible `kind` values :
  16843. * - VertexBuffer.PositionKind
  16844. * - VertexBuffer.UVKind
  16845. * - VertexBuffer.UV2Kind
  16846. * - VertexBuffer.UV3Kind
  16847. * - VertexBuffer.UV4Kind
  16848. * - VertexBuffer.UV5Kind
  16849. * - VertexBuffer.UV6Kind
  16850. * - VertexBuffer.ColorKind
  16851. * - VertexBuffer.MatricesIndicesKind
  16852. * - VertexBuffer.MatricesIndicesExtraKind
  16853. * - VertexBuffer.MatricesWeightsKind
  16854. * - VertexBuffer.MatricesWeightsExtraKind
  16855. *
  16856. * Returns the Mesh.
  16857. */
  16858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16859. /**
  16860. * Sets the mesh indices.
  16861. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16862. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16863. * This method creates a new index buffer each call.
  16864. * Returns the Mesh.
  16865. */
  16866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16867. /**
  16868. * Boolean : True if the mesh owns the requested kind of data.
  16869. */
  16870. isVerticesDataPresent(kind: string): boolean;
  16871. /**
  16872. * Returns an array of indices (IndicesArray).
  16873. */
  16874. getIndices(): Nullable<IndicesArray>;
  16875. get _positions(): Nullable<Vector3[]>;
  16876. /**
  16877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16878. * This means the mesh underlying bounding box and sphere are recomputed.
  16879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16880. * @returns the current mesh
  16881. */
  16882. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16883. /** @hidden */
  16884. _preActivate(): InstancedMesh;
  16885. /** @hidden */
  16886. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16887. /** @hidden */
  16888. _postActivate(): void;
  16889. getWorldMatrix(): Matrix;
  16890. get isAnInstance(): boolean;
  16891. /**
  16892. * Returns the current associated LOD AbstractMesh.
  16893. */
  16894. getLOD(camera: Camera): AbstractMesh;
  16895. /** @hidden */
  16896. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16897. /** @hidden */
  16898. _syncSubMeshes(): InstancedMesh;
  16899. /** @hidden */
  16900. _generatePointsArray(): boolean;
  16901. /** @hidden */
  16902. _updateBoundingInfo(): AbstractMesh;
  16903. /**
  16904. * Creates a new InstancedMesh from the current mesh.
  16905. * - name (string) : the cloned mesh name
  16906. * - newParent (optional Node) : the optional Node to parent the clone to.
  16907. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16908. *
  16909. * Returns the clone.
  16910. */
  16911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16912. /**
  16913. * Disposes the InstancedMesh.
  16914. * Returns nothing.
  16915. */
  16916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16917. }
  16918. module "babylonjs/Meshes/mesh" {
  16919. interface Mesh {
  16920. /**
  16921. * Register a custom buffer that will be instanced
  16922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16923. * @param kind defines the buffer kind
  16924. * @param stride defines the stride in floats
  16925. */
  16926. registerInstancedBuffer(kind: string, stride: number): void;
  16927. /**
  16928. * true to use the edge renderer for all instances of this mesh
  16929. */
  16930. edgesShareWithInstances: boolean;
  16931. /** @hidden */
  16932. _userInstancedBuffersStorage: {
  16933. data: {
  16934. [key: string]: Float32Array;
  16935. };
  16936. sizes: {
  16937. [key: string]: number;
  16938. };
  16939. vertexBuffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. strides: {
  16943. [key: string]: number;
  16944. };
  16945. };
  16946. }
  16947. }
  16948. module "babylonjs/Meshes/abstractMesh" {
  16949. interface AbstractMesh {
  16950. /**
  16951. * Object used to store instanced buffers defined by user
  16952. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16953. */
  16954. instancedBuffers: {
  16955. [key: string]: any;
  16956. };
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Materials/shaderMaterial" {
  16961. import { Nullable } from "babylonjs/types";
  16962. import { Scene } from "babylonjs/scene";
  16963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16965. import { Mesh } from "babylonjs/Meshes/mesh";
  16966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16968. import { Effect } from "babylonjs/Materials/effect";
  16969. import { Material } from "babylonjs/Materials/material";
  16970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16971. /**
  16972. * Defines the options associated with the creation of a shader material.
  16973. */
  16974. export interface IShaderMaterialOptions {
  16975. /**
  16976. * Does the material work in alpha blend mode
  16977. */
  16978. needAlphaBlending: boolean;
  16979. /**
  16980. * Does the material work in alpha test mode
  16981. */
  16982. needAlphaTesting: boolean;
  16983. /**
  16984. * The list of attribute names used in the shader
  16985. */
  16986. attributes: string[];
  16987. /**
  16988. * The list of unifrom names used in the shader
  16989. */
  16990. uniforms: string[];
  16991. /**
  16992. * The list of UBO names used in the shader
  16993. */
  16994. uniformBuffers: string[];
  16995. /**
  16996. * The list of sampler names used in the shader
  16997. */
  16998. samplers: string[];
  16999. /**
  17000. * The list of defines used in the shader
  17001. */
  17002. defines: string[];
  17003. }
  17004. /**
  17005. * 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.
  17006. *
  17007. * This returned material effects how the mesh will look based on the code in the shaders.
  17008. *
  17009. * @see https://doc.babylonjs.com/how_to/shader_material
  17010. */
  17011. export class ShaderMaterial extends Material {
  17012. private _shaderPath;
  17013. private _options;
  17014. private _textures;
  17015. private _textureArrays;
  17016. private _floats;
  17017. private _ints;
  17018. private _floatsArrays;
  17019. private _colors3;
  17020. private _colors3Arrays;
  17021. private _colors4;
  17022. private _colors4Arrays;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _vectors4;
  17026. private _matrices;
  17027. private _matrixArrays;
  17028. private _matrices3x3;
  17029. private _matrices2x2;
  17030. private _vectors2Arrays;
  17031. private _vectors3Arrays;
  17032. private _vectors4Arrays;
  17033. private _cachedWorldViewMatrix;
  17034. private _cachedWorldViewProjectionMatrix;
  17035. private _renderId;
  17036. private _multiview;
  17037. private _cachedDefines;
  17038. /** Define the Url to load snippets */
  17039. static SnippetUrl: string;
  17040. /** Snippet ID if the material was created from the snippet server */
  17041. snippetId: string;
  17042. /**
  17043. * Instantiate a new shader material.
  17044. * 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.
  17045. * This returned material effects how the mesh will look based on the code in the shaders.
  17046. * @see https://doc.babylonjs.com/how_to/shader_material
  17047. * @param name Define the name of the material in the scene
  17048. * @param scene Define the scene the material belongs to
  17049. * @param shaderPath Defines the route to the shader code in one of three ways:
  17050. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17051. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17052. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17053. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17054. * @param options Define the options used to create the shader
  17055. */
  17056. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17057. /**
  17058. * Gets the shader path used to define the shader code
  17059. * It can be modified to trigger a new compilation
  17060. */
  17061. get shaderPath(): any;
  17062. /**
  17063. * Sets the shader path used to define the shader code
  17064. * It can be modified to trigger a new compilation
  17065. */
  17066. set shaderPath(shaderPath: any);
  17067. /**
  17068. * Gets the options used to compile the shader.
  17069. * They can be modified to trigger a new compilation
  17070. */
  17071. get options(): IShaderMaterialOptions;
  17072. /**
  17073. * Gets the current class name of the material e.g. "ShaderMaterial"
  17074. * Mainly use in serialization.
  17075. * @returns the class name
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * Specifies if the material will require alpha blending
  17080. * @returns a boolean specifying if alpha blending is needed
  17081. */
  17082. needAlphaBlending(): boolean;
  17083. /**
  17084. * Specifies if this material should be rendered in alpha test mode
  17085. * @returns a boolean specifying if an alpha test is needed.
  17086. */
  17087. needAlphaTesting(): boolean;
  17088. private _checkUniform;
  17089. /**
  17090. * Set a texture in the shader.
  17091. * @param name Define the name of the uniform samplers as defined in the shader
  17092. * @param texture Define the texture to bind to this sampler
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17096. /**
  17097. * Set a texture array in the shader.
  17098. * @param name Define the name of the uniform sampler array as defined in the shader
  17099. * @param textures Define the list of textures to bind to this sampler
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17103. /**
  17104. * Set a float in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloat(name: string, value: number): ShaderMaterial;
  17110. /**
  17111. * Set a int in the shader.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setInt(name: string, value: number): ShaderMaterial;
  17117. /**
  17118. * Set an array of floats in the shader.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setFloats(name: string, value: number[]): ShaderMaterial;
  17124. /**
  17125. * Set a vec3 in the shader from a Color3.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the material itself allowing "fluent" like uniform updates
  17129. */
  17130. setColor3(name: string, value: Color3): ShaderMaterial;
  17131. /**
  17132. * Set a vec3 array in the shader from a Color3 array.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the material itself allowing "fluent" like uniform updates
  17136. */
  17137. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17138. /**
  17139. * Set a vec4 in the shader from a Color4.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setColor4(name: string, value: Color4): ShaderMaterial;
  17145. /**
  17146. * Set a vec4 array in the shader from a Color4 array.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17152. /**
  17153. * Set a vec2 in the shader from a Vector2.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setVector2(name: string, value: Vector2): ShaderMaterial;
  17159. /**
  17160. * Set a vec3 in the shader from a Vector3.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setVector3(name: string, value: Vector3): ShaderMaterial;
  17166. /**
  17167. * Set a vec4 in the shader from a Vector4.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setVector4(name: string, value: Vector4): ShaderMaterial;
  17173. /**
  17174. * Set a mat4 in the shader from a Matrix.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17180. /**
  17181. * Set a float32Array in the shader from a matrix array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17187. /**
  17188. * Set a mat3 in the shader from a Float32Array.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17194. /**
  17195. * Set a mat2 in the shader from a Float32Array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 array in the shader from a number array.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setArray2(name: string, value: number[]): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a number array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setArray3(name: string, value: number[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 array in the shader from a number array.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setArray4(name: string, value: number[]): ShaderMaterial;
  17222. private _checkCache;
  17223. /**
  17224. * Specifies that the submesh is ready to be used
  17225. * @param mesh defines the mesh to check
  17226. * @param subMesh defines which submesh to check
  17227. * @param useInstances specifies that instances should be used
  17228. * @returns a boolean indicating that the submesh is ready or not
  17229. */
  17230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17231. /**
  17232. * Checks if the material is ready to render the requested mesh
  17233. * @param mesh Define the mesh to render
  17234. * @param useInstances Define whether or not the material is used with instances
  17235. * @returns true if ready, otherwise false
  17236. */
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. /**
  17239. * Binds the world matrix to the material
  17240. * @param world defines the world transformation matrix
  17241. * @param effectOverride - If provided, use this effect instead of internal effect
  17242. */
  17243. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17244. /**
  17245. * Binds the submesh to this material by preparing the effect and shader to draw
  17246. * @param world defines the world transformation matrix
  17247. * @param mesh defines the mesh containing the submesh
  17248. * @param subMesh defines the submesh to bind the material to
  17249. */
  17250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17251. /**
  17252. * Binds the material to the mesh
  17253. * @param world defines the world transformation matrix
  17254. * @param mesh defines the mesh to bind the material to
  17255. * @param effectOverride - If provided, use this effect instead of internal effect
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17258. protected _afterBind(mesh?: Mesh): void;
  17259. /**
  17260. * Gets the active textures from the material
  17261. * @returns an array of textures
  17262. */
  17263. getActiveTextures(): BaseTexture[];
  17264. /**
  17265. * Specifies if the material uses a texture
  17266. * @param texture defines the texture to check against the material
  17267. * @returns a boolean specifying if the material uses the texture
  17268. */
  17269. hasTexture(texture: BaseTexture): boolean;
  17270. /**
  17271. * Makes a duplicate of the material, and gives it a new name
  17272. * @param name defines the new name for the duplicated material
  17273. * @returns the cloned material
  17274. */
  17275. clone(name: string): ShaderMaterial;
  17276. /**
  17277. * Disposes the material
  17278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17281. */
  17282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17283. /**
  17284. * Serializes this material in a JSON representation
  17285. * @returns the serialized material object
  17286. */
  17287. serialize(): any;
  17288. /**
  17289. * Creates a shader material from parsed shader material data
  17290. * @param source defines the JSON represnetation of the material
  17291. * @param scene defines the hosting scene
  17292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17293. * @returns a new material
  17294. */
  17295. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17296. /**
  17297. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17298. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17299. * @param url defines the url to load from
  17300. * @param scene defines the hosting scene
  17301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17302. * @returns a promise that will resolve to the new ShaderMaterial
  17303. */
  17304. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17305. /**
  17306. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17307. * @param snippetId defines the snippet to load
  17308. * @param scene defines the hosting scene
  17309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17310. * @returns a promise that will resolve to the new ShaderMaterial
  17311. */
  17312. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17313. }
  17314. }
  17315. declare module "babylonjs/Shaders/color.fragment" {
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17318. /** @hidden */
  17319. export var colorPixelShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module "babylonjs/Shaders/color.vertex" {
  17325. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17331. /** @hidden */
  17332. export var colorVertexShader: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Meshes/linesMesh" {
  17338. import { Nullable } from "babylonjs/types";
  17339. import { Scene } from "babylonjs/scene";
  17340. import { Color3 } from "babylonjs/Maths/math.color";
  17341. import { Node } from "babylonjs/node";
  17342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17343. import { Mesh } from "babylonjs/Meshes/mesh";
  17344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { Material } from "babylonjs/Materials/material";
  17347. import "babylonjs/Shaders/color.fragment";
  17348. import "babylonjs/Shaders/color.vertex";
  17349. /**
  17350. * Line mesh
  17351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17352. */
  17353. export class LinesMesh extends Mesh {
  17354. /**
  17355. * If vertex color should be applied to the mesh
  17356. */
  17357. readonly useVertexColor?: boolean | undefined;
  17358. /**
  17359. * If vertex alpha should be applied to the mesh
  17360. */
  17361. readonly useVertexAlpha?: boolean | undefined;
  17362. /**
  17363. * Color of the line (Default: White)
  17364. */
  17365. color: Color3;
  17366. /**
  17367. * Alpha of the line (Default: 1)
  17368. */
  17369. alpha: number;
  17370. /**
  17371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17372. * This margin is expressed in world space coordinates, so its value may vary.
  17373. * Default value is 0.1
  17374. */
  17375. intersectionThreshold: number;
  17376. private _colorShader;
  17377. private color4;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. get material(): Material;
  17410. /**
  17411. * @hidden
  17412. */
  17413. set material(value: Material);
  17414. /**
  17415. * @hidden
  17416. */
  17417. get checkCollisions(): boolean;
  17418. /** @hidden */
  17419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17420. /** @hidden */
  17421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17422. /**
  17423. * Disposes of the line mesh
  17424. * @param doNotRecurse If children should be disposed
  17425. */
  17426. dispose(doNotRecurse?: boolean): void;
  17427. /**
  17428. * Returns a new LineMesh object cloned from the current one.
  17429. */
  17430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17431. /**
  17432. * Creates a new InstancedLinesMesh object from the mesh model.
  17433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17434. * @param name defines the name of the new instance
  17435. * @returns a new InstancedLinesMesh
  17436. */
  17437. createInstance(name: string): InstancedLinesMesh;
  17438. }
  17439. /**
  17440. * Creates an instance based on a source LinesMesh
  17441. */
  17442. export class InstancedLinesMesh extends InstancedMesh {
  17443. /**
  17444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17445. * This margin is expressed in world space coordinates, so its value may vary.
  17446. * Initilized with the intersectionThreshold value of the source LinesMesh
  17447. */
  17448. intersectionThreshold: number;
  17449. constructor(name: string, source: LinesMesh);
  17450. /**
  17451. * Returns the string "InstancedLinesMesh".
  17452. */
  17453. getClassName(): string;
  17454. }
  17455. }
  17456. declare module "babylonjs/Shaders/line.fragment" {
  17457. /** @hidden */
  17458. export var linePixelShader: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/line.vertex" {
  17464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17482. import { SmartArray } from "babylonjs/Misc/smartArray";
  17483. module "babylonjs/scene" {
  17484. interface Scene {
  17485. /** @hidden */
  17486. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/abstractMesh" {
  17490. interface AbstractMesh {
  17491. /**
  17492. * Gets the edgesRenderer associated with the mesh
  17493. */
  17494. edgesRenderer: Nullable<EdgesRenderer>;
  17495. }
  17496. }
  17497. module "babylonjs/Meshes/linesMesh" {
  17498. interface LinesMesh {
  17499. /**
  17500. * Enables the edge rendering mode on the mesh.
  17501. * This mode makes the mesh edges visible
  17502. * @param epsilon defines the maximal distance between two angles to detect a face
  17503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17504. * @returns the currentAbstractMesh
  17505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17506. */
  17507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17508. }
  17509. }
  17510. module "babylonjs/Meshes/linesMesh" {
  17511. interface InstancedLinesMesh {
  17512. /**
  17513. * Enables the edge rendering mode on the mesh.
  17514. * This mode makes the mesh edges visible
  17515. * @param epsilon defines the maximal distance between two angles to detect a face
  17516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17517. * @returns the current InstancedLinesMesh
  17518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17519. */
  17520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17521. }
  17522. }
  17523. /**
  17524. * Defines the minimum contract an Edges renderer should follow.
  17525. */
  17526. export interface IEdgesRenderer extends IDisposable {
  17527. /**
  17528. * Gets or sets a boolean indicating if the edgesRenderer is active
  17529. */
  17530. isEnabled: boolean;
  17531. /**
  17532. * Renders the edges of the attached mesh,
  17533. */
  17534. render(): void;
  17535. /**
  17536. * Checks wether or not the edges renderer is ready to render.
  17537. * @return true if ready, otherwise false.
  17538. */
  17539. isReady(): boolean;
  17540. /**
  17541. * List of instances to render in case the source mesh has instances
  17542. */
  17543. customInstances: SmartArray<Matrix>;
  17544. }
  17545. /**
  17546. * Defines the additional options of the edges renderer
  17547. */
  17548. export interface IEdgesRendererOptions {
  17549. /**
  17550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17551. * If not defined, the default value is true
  17552. */
  17553. useAlternateEdgeFinder?: boolean;
  17554. /**
  17555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17556. * If not defined, the default value is true.
  17557. * 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)
  17558. * This option is used only if useAlternateEdgeFinder = true
  17559. */
  17560. useFastVertexMerger?: boolean;
  17561. /**
  17562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17563. * The default value is 1e-6
  17564. * This option is used only if useAlternateEdgeFinder = true
  17565. */
  17566. epsilonVertexMerge?: number;
  17567. /**
  17568. * 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
  17569. * 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.
  17570. * This option is used only if useAlternateEdgeFinder = true
  17571. */
  17572. applyTessellation?: boolean;
  17573. /**
  17574. * 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
  17575. * The default value is 1e-6
  17576. * This option is used only if useAlternateEdgeFinder = true
  17577. */
  17578. epsilonVertexAligned?: number;
  17579. }
  17580. /**
  17581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17582. */
  17583. export class EdgesRenderer implements IEdgesRenderer {
  17584. /**
  17585. * Define the size of the edges with an orthographic camera
  17586. */
  17587. edgesWidthScalerForOrthographic: number;
  17588. /**
  17589. * Define the size of the edges with a perspective camera
  17590. */
  17591. edgesWidthScalerForPerspective: number;
  17592. protected _source: AbstractMesh;
  17593. protected _linesPositions: number[];
  17594. protected _linesNormals: number[];
  17595. protected _linesIndices: number[];
  17596. protected _epsilon: number;
  17597. protected _indicesCount: number;
  17598. protected _lineShader: ShaderMaterial;
  17599. protected _ib: DataBuffer;
  17600. protected _buffers: {
  17601. [key: string]: Nullable<VertexBuffer>;
  17602. };
  17603. protected _buffersForInstances: {
  17604. [key: string]: Nullable<VertexBuffer>;
  17605. };
  17606. protected _checkVerticesInsteadOfIndices: boolean;
  17607. protected _options: Nullable<IEdgesRendererOptions>;
  17608. private _meshRebuildObserver;
  17609. private _meshDisposeObserver;
  17610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17611. isEnabled: boolean;
  17612. /**
  17613. * List of instances to render in case the source mesh has instances
  17614. */
  17615. customInstances: SmartArray<Matrix>;
  17616. private static GetShader;
  17617. /**
  17618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17620. * @param source Mesh used to create edges
  17621. * @param epsilon sum of angles in adjacency to check for edge
  17622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17624. * @param options The options to apply when generating the edges
  17625. */
  17626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17627. protected _prepareRessources(): void;
  17628. /** @hidden */
  17629. _rebuild(): void;
  17630. /**
  17631. * Releases the required resources for the edges renderer
  17632. */
  17633. dispose(): void;
  17634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17636. /**
  17637. * Checks if the pair of p0 and p1 is en edge
  17638. * @param faceIndex
  17639. * @param edge
  17640. * @param faceNormals
  17641. * @param p0
  17642. * @param p1
  17643. * @private
  17644. */
  17645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17646. /**
  17647. * push line into the position, normal and index buffer
  17648. * @protected
  17649. */
  17650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17651. /**
  17652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17653. */
  17654. private _tessellateTriangle;
  17655. private _generateEdgesLinesAlternate;
  17656. /**
  17657. * Generates lines edges from adjacencjes
  17658. * @private
  17659. */
  17660. _generateEdgesLines(): void;
  17661. /**
  17662. * Checks wether or not the edges renderer is ready to render.
  17663. * @return true if ready, otherwise false.
  17664. */
  17665. isReady(): boolean;
  17666. /**
  17667. * Renders the edges of the attached mesh,
  17668. */
  17669. render(): void;
  17670. }
  17671. /**
  17672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17673. */
  17674. export class LineEdgesRenderer extends EdgesRenderer {
  17675. /**
  17676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17677. * @param source LineMesh used to generate edges
  17678. * @param epsilon not important (specified angle for edge detection)
  17679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17680. */
  17681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17682. /**
  17683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17684. */
  17685. _generateEdgesLines(): void;
  17686. }
  17687. }
  17688. declare module "babylonjs/Rendering/renderingGroup" {
  17689. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17692. import { Nullable } from "babylonjs/types";
  17693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17694. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17695. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17696. import { Material } from "babylonjs/Materials/material";
  17697. import { Scene } from "babylonjs/scene";
  17698. /**
  17699. * This represents the object necessary to create a rendering group.
  17700. * This is exclusively used and created by the rendering manager.
  17701. * To modify the behavior, you use the available helpers in your scene or meshes.
  17702. * @hidden
  17703. */
  17704. export class RenderingGroup {
  17705. index: number;
  17706. private static _zeroVector;
  17707. private _scene;
  17708. private _opaqueSubMeshes;
  17709. private _transparentSubMeshes;
  17710. private _alphaTestSubMeshes;
  17711. private _depthOnlySubMeshes;
  17712. private _particleSystems;
  17713. private _spriteManagers;
  17714. private _opaqueSortCompareFn;
  17715. private _alphaTestSortCompareFn;
  17716. private _transparentSortCompareFn;
  17717. private _renderOpaque;
  17718. private _renderAlphaTest;
  17719. private _renderTransparent;
  17720. /** @hidden */
  17721. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17722. onBeforeTransparentRendering: () => void;
  17723. /**
  17724. * Set the opaque sort comparison function.
  17725. * If null the sub meshes will be render in the order they were created
  17726. */
  17727. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17728. /**
  17729. * Set the alpha test sort comparison function.
  17730. * If null the sub meshes will be render in the order they were created
  17731. */
  17732. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17733. /**
  17734. * Set the transparent sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Creates a new rendering group.
  17740. * @param index The rendering group index
  17741. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17742. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17743. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17744. */
  17745. 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>);
  17746. /**
  17747. * Render all the sub meshes contained in the group.
  17748. * @param customRenderFunction Used to override the default render behaviour of the group.
  17749. * @returns true if rendered some submeshes.
  17750. */
  17751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17752. /**
  17753. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17754. * @param subMeshes The submeshes to render
  17755. */
  17756. private renderOpaqueSorted;
  17757. /**
  17758. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17759. * @param subMeshes The submeshes to render
  17760. */
  17761. private renderAlphaTestSorted;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderTransparentSorted;
  17767. /**
  17768. * Renders the submeshes in a specified order.
  17769. * @param subMeshes The submeshes to sort before render
  17770. * @param sortCompareFn The comparison function use to sort
  17771. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17772. * @param transparent Specifies to activate blending if true
  17773. */
  17774. private static renderSorted;
  17775. /**
  17776. * Renders the submeshes in the order they were dispatched (no sort applied).
  17777. * @param subMeshes The submeshes to render
  17778. */
  17779. private static renderUnsorted;
  17780. /**
  17781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17782. * are rendered back to front if in the same alpha index.
  17783. *
  17784. * @param a The first submesh
  17785. * @param b The second submesh
  17786. * @returns The result of the comparison
  17787. */
  17788. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17789. /**
  17790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17791. * are rendered back to front.
  17792. *
  17793. * @param a The first submesh
  17794. * @param b The second submesh
  17795. * @returns The result of the comparison
  17796. */
  17797. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17798. /**
  17799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17800. * are rendered front to back (prevent overdraw).
  17801. *
  17802. * @param a The first submesh
  17803. * @param b The second submesh
  17804. * @returns The result of the comparison
  17805. */
  17806. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17807. /**
  17808. * Resets the different lists of submeshes to prepare a new frame.
  17809. */
  17810. prepare(): void;
  17811. dispose(): void;
  17812. /**
  17813. * Inserts the submesh in its correct queue depending on its material.
  17814. * @param subMesh The submesh to dispatch
  17815. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17816. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17817. */
  17818. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17819. dispatchSprites(spriteManager: ISpriteManager): void;
  17820. dispatchParticles(particleSystem: IParticleSystem): void;
  17821. private _renderParticles;
  17822. private _renderSprites;
  17823. }
  17824. }
  17825. declare module "babylonjs/Rendering/renderingManager" {
  17826. import { Nullable } from "babylonjs/types";
  17827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17829. import { SmartArray } from "babylonjs/Misc/smartArray";
  17830. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17832. import { Material } from "babylonjs/Materials/material";
  17833. import { Scene } from "babylonjs/scene";
  17834. import { Camera } from "babylonjs/Cameras/camera";
  17835. /**
  17836. * Interface describing the different options available in the rendering manager
  17837. * regarding Auto Clear between groups.
  17838. */
  17839. export interface IRenderingManagerAutoClearSetup {
  17840. /**
  17841. * Defines whether or not autoclear is enable.
  17842. */
  17843. autoClear: boolean;
  17844. /**
  17845. * Defines whether or not to autoclear the depth buffer.
  17846. */
  17847. depth: boolean;
  17848. /**
  17849. * Defines whether or not to autoclear the stencil buffer.
  17850. */
  17851. stencil: boolean;
  17852. }
  17853. /**
  17854. * This class is used by the onRenderingGroupObservable
  17855. */
  17856. export class RenderingGroupInfo {
  17857. /**
  17858. * The Scene that being rendered
  17859. */
  17860. scene: Scene;
  17861. /**
  17862. * The camera currently used for the rendering pass
  17863. */
  17864. camera: Nullable<Camera>;
  17865. /**
  17866. * The ID of the renderingGroup being processed
  17867. */
  17868. renderingGroupId: number;
  17869. }
  17870. /**
  17871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17872. * It is enable to manage the different groups as well as the different necessary sort functions.
  17873. * This should not be used directly aside of the few static configurations
  17874. */
  17875. export class RenderingManager {
  17876. /**
  17877. * The max id used for rendering groups (not included)
  17878. */
  17879. static MAX_RENDERINGGROUPS: number;
  17880. /**
  17881. * The min id used for rendering groups (included)
  17882. */
  17883. static MIN_RENDERINGGROUPS: number;
  17884. /**
  17885. * Used to globally prevent autoclearing scenes.
  17886. */
  17887. static AUTOCLEAR: boolean;
  17888. /**
  17889. * @hidden
  17890. */
  17891. _useSceneAutoClearSetup: boolean;
  17892. private _scene;
  17893. private _renderingGroups;
  17894. private _depthStencilBufferAlreadyCleaned;
  17895. private _autoClearDepthStencil;
  17896. private _customOpaqueSortCompareFn;
  17897. private _customAlphaTestSortCompareFn;
  17898. private _customTransparentSortCompareFn;
  17899. private _renderingGroupInfo;
  17900. /**
  17901. * Instantiates a new rendering group for a particular scene
  17902. * @param scene Defines the scene the groups belongs to
  17903. */
  17904. constructor(scene: Scene);
  17905. private _clearDepthStencilBuffer;
  17906. /**
  17907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17908. * @hidden
  17909. */
  17910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17911. /**
  17912. * Resets the different information of the group to prepare a new frame
  17913. * @hidden
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Dispose and release the group and its associated resources.
  17918. * @hidden
  17919. */
  17920. dispose(): void;
  17921. /**
  17922. * Clear the info related to rendering groups preventing retention points during dispose.
  17923. */
  17924. freeRenderingGroups(): void;
  17925. private _prepareRenderingGroup;
  17926. /**
  17927. * Add a sprite manager to the rendering manager in order to render it this frame.
  17928. * @param spriteManager Define the sprite manager to render
  17929. */
  17930. dispatchSprites(spriteManager: ISpriteManager): void;
  17931. /**
  17932. * Add a particle system to the rendering manager in order to render it this frame.
  17933. * @param particleSystem Define the particle system to render
  17934. */
  17935. dispatchParticles(particleSystem: IParticleSystem): void;
  17936. /**
  17937. * Add a submesh to the manager in order to render it this frame
  17938. * @param subMesh The submesh to dispatch
  17939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17941. */
  17942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17943. /**
  17944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17945. * This allowed control for front to back rendering or reversly depending of the special needs.
  17946. *
  17947. * @param renderingGroupId The rendering group id corresponding to its index
  17948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17951. */
  17952. 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;
  17953. /**
  17954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17955. *
  17956. * @param renderingGroupId The rendering group id corresponding to its index
  17957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17960. */
  17961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17962. /**
  17963. * Gets the current auto clear configuration for one rendering group of the rendering
  17964. * manager.
  17965. * @param index the rendering group index to get the information for
  17966. * @returns The auto clear setup for the requested rendering group
  17967. */
  17968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17969. }
  17970. }
  17971. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17972. import { SmartArray } from "babylonjs/Misc/smartArray";
  17973. import { Nullable } from "babylonjs/types";
  17974. import { Scene } from "babylonjs/scene";
  17975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17978. import { Mesh } from "babylonjs/Meshes/mesh";
  17979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17980. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17981. import { Effect } from "babylonjs/Materials/effect";
  17982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17984. import "babylonjs/Shaders/shadowMap.fragment";
  17985. import "babylonjs/Shaders/shadowMap.vertex";
  17986. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17987. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. /**
  17990. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17991. */
  17992. export interface ICustomShaderOptions {
  17993. /**
  17994. * Gets or sets the custom shader name to use
  17995. */
  17996. shaderName: string;
  17997. /**
  17998. * The list of attribute names used in the shader
  17999. */
  18000. attributes?: string[];
  18001. /**
  18002. * The list of unifrom names used in the shader
  18003. */
  18004. uniforms?: string[];
  18005. /**
  18006. * The list of sampler names used in the shader
  18007. */
  18008. samplers?: string[];
  18009. /**
  18010. * The list of defines used in the shader
  18011. */
  18012. defines?: string[];
  18013. }
  18014. /**
  18015. * Interface to implement to create a shadow generator compatible with BJS.
  18016. */
  18017. export interface IShadowGenerator {
  18018. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18019. id: string;
  18020. /**
  18021. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18022. * @returns The render target texture if present otherwise, null
  18023. */
  18024. getShadowMap(): Nullable<RenderTargetTexture>;
  18025. /**
  18026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18027. * @param subMesh The submesh we want to render in the shadow map
  18028. * @param useInstances Defines wether will draw in the map using instances
  18029. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18030. * @returns true if ready otherwise, false
  18031. */
  18032. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18033. /**
  18034. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18035. * @param defines Defines of the material we want to update
  18036. * @param lightIndex Index of the light in the enabled light list of the material
  18037. */
  18038. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18039. /**
  18040. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18041. * defined in the generator but impacting the effect).
  18042. * It implies the unifroms available on the materials are the standard BJS ones.
  18043. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18044. * @param effect The effect we are binfing the information for
  18045. */
  18046. bindShadowLight(lightIndex: string, effect: Effect): void;
  18047. /**
  18048. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18049. * (eq to shadow prjection matrix * light transform matrix)
  18050. * @returns The transform matrix used to create the shadow map
  18051. */
  18052. getTransformMatrix(): Matrix;
  18053. /**
  18054. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18055. * Cube and 2D textures for instance.
  18056. */
  18057. recreateShadowMap(): void;
  18058. /**
  18059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18060. * @param onCompiled Callback triggered at the and of the effects compilation
  18061. * @param options Sets of optional options forcing the compilation with different modes
  18062. */
  18063. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18064. useInstances: boolean;
  18065. }>): void;
  18066. /**
  18067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18068. * @param options Sets of optional options forcing the compilation with different modes
  18069. * @returns A promise that resolves when the compilation completes
  18070. */
  18071. forceCompilationAsync(options?: Partial<{
  18072. useInstances: boolean;
  18073. }>): Promise<void>;
  18074. /**
  18075. * Serializes the shadow generator setup to a json object.
  18076. * @returns The serialized JSON object
  18077. */
  18078. serialize(): any;
  18079. /**
  18080. * Disposes the Shadow map and related Textures and effects.
  18081. */
  18082. dispose(): void;
  18083. }
  18084. /**
  18085. * Default implementation IShadowGenerator.
  18086. * This is the main object responsible of generating shadows in the framework.
  18087. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18088. */
  18089. export class ShadowGenerator implements IShadowGenerator {
  18090. /**
  18091. * Name of the shadow generator class
  18092. */
  18093. static CLASSNAME: string;
  18094. /**
  18095. * Shadow generator mode None: no filtering applied.
  18096. */
  18097. static readonly FILTER_NONE: number;
  18098. /**
  18099. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18100. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18101. */
  18102. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18103. /**
  18104. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18105. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18106. */
  18107. static readonly FILTER_POISSONSAMPLING: number;
  18108. /**
  18109. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18115. * edge artifacts on steep falloff.
  18116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18117. */
  18118. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18121. * edge artifacts on steep falloff.
  18122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18123. */
  18124. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18125. /**
  18126. * Shadow generator mode PCF: Percentage Closer Filtering
  18127. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18128. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18129. */
  18130. static readonly FILTER_PCF: number;
  18131. /**
  18132. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18134. * Contact Hardening
  18135. */
  18136. static readonly FILTER_PCSS: number;
  18137. /**
  18138. * Reserved for PCF and PCSS
  18139. * Highest Quality.
  18140. *
  18141. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18142. *
  18143. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18144. */
  18145. static readonly QUALITY_HIGH: number;
  18146. /**
  18147. * Reserved for PCF and PCSS
  18148. * Good tradeoff for quality/perf cross devices
  18149. *
  18150. * Execute PCF on a 3*3 kernel.
  18151. *
  18152. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18153. */
  18154. static readonly QUALITY_MEDIUM: number;
  18155. /**
  18156. * Reserved for PCF and PCSS
  18157. * The lowest quality but the fastest.
  18158. *
  18159. * Execute PCF on a 1*1 kernel.
  18160. *
  18161. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18162. */
  18163. static readonly QUALITY_LOW: number;
  18164. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18165. id: string;
  18166. /** Gets or sets the custom shader name to use */
  18167. customShaderOptions: ICustomShaderOptions;
  18168. /**
  18169. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18170. */
  18171. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18172. /**
  18173. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18174. */
  18175. onAfterShadowMapRenderObservable: Observable<Effect>;
  18176. /**
  18177. * Observable triggered before a mesh is rendered in the shadow map.
  18178. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18179. */
  18180. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18181. /**
  18182. * Observable triggered after a mesh is rendered in the shadow map.
  18183. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18184. */
  18185. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18186. protected _bias: number;
  18187. /**
  18188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18189. */
  18190. get bias(): number;
  18191. /**
  18192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18193. */
  18194. set bias(bias: number);
  18195. protected _normalBias: number;
  18196. /**
  18197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18198. */
  18199. get normalBias(): number;
  18200. /**
  18201. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18202. */
  18203. set normalBias(normalBias: number);
  18204. protected _blurBoxOffset: number;
  18205. /**
  18206. * Gets the blur box offset: offset applied during the blur pass.
  18207. * Only useful if useKernelBlur = false
  18208. */
  18209. get blurBoxOffset(): number;
  18210. /**
  18211. * Sets the blur box offset: offset applied during the blur pass.
  18212. * Only useful if useKernelBlur = false
  18213. */
  18214. set blurBoxOffset(value: number);
  18215. protected _blurScale: number;
  18216. /**
  18217. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18218. * 2 means half of the size.
  18219. */
  18220. get blurScale(): number;
  18221. /**
  18222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18223. * 2 means half of the size.
  18224. */
  18225. set blurScale(value: number);
  18226. protected _blurKernel: number;
  18227. /**
  18228. * Gets the blur kernel: kernel size of the blur pass.
  18229. * Only useful if useKernelBlur = true
  18230. */
  18231. get blurKernel(): number;
  18232. /**
  18233. * Sets the blur kernel: kernel size of the blur pass.
  18234. * Only useful if useKernelBlur = true
  18235. */
  18236. set blurKernel(value: number);
  18237. protected _useKernelBlur: boolean;
  18238. /**
  18239. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18241. */
  18242. get useKernelBlur(): boolean;
  18243. /**
  18244. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18245. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18246. */
  18247. set useKernelBlur(value: boolean);
  18248. protected _depthScale: number;
  18249. /**
  18250. * Gets the depth scale used in ESM mode.
  18251. */
  18252. get depthScale(): number;
  18253. /**
  18254. * Sets the depth scale used in ESM mode.
  18255. * This can override the scale stored on the light.
  18256. */
  18257. set depthScale(value: number);
  18258. protected _validateFilter(filter: number): number;
  18259. protected _filter: number;
  18260. /**
  18261. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18263. */
  18264. get filter(): number;
  18265. /**
  18266. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18267. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18268. */
  18269. set filter(value: number);
  18270. /**
  18271. * Gets if the current filter is set to Poisson Sampling.
  18272. */
  18273. get usePoissonSampling(): boolean;
  18274. /**
  18275. * Sets the current filter to Poisson Sampling.
  18276. */
  18277. set usePoissonSampling(value: boolean);
  18278. /**
  18279. * Gets if the current filter is set to ESM.
  18280. */
  18281. get useExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter is to ESM.
  18284. */
  18285. set useExponentialShadowMap(value: boolean);
  18286. /**
  18287. * Gets if the current filter is set to filtered ESM.
  18288. */
  18289. get useBlurExponentialShadowMap(): boolean;
  18290. /**
  18291. * Gets if the current filter is set to filtered ESM.
  18292. */
  18293. set useBlurExponentialShadowMap(value: boolean);
  18294. /**
  18295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18296. * exponential to prevent steep falloff artifacts).
  18297. */
  18298. get useCloseExponentialShadowMap(): boolean;
  18299. /**
  18300. * Sets the current filter to "close ESM" (using the inverse of the
  18301. * exponential to prevent steep falloff artifacts).
  18302. */
  18303. set useCloseExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useBlurCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useBlurCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18316. */
  18317. get usePercentageCloserFiltering(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCF" (percentage closer filtering).
  18320. */
  18321. set usePercentageCloserFiltering(value: boolean);
  18322. protected _filteringQuality: number;
  18323. /**
  18324. * Gets the PCF or PCSS Quality.
  18325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18326. */
  18327. get filteringQuality(): number;
  18328. /**
  18329. * Sets the PCF or PCSS Quality.
  18330. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18331. */
  18332. set filteringQuality(filteringQuality: number);
  18333. /**
  18334. * Gets if the current filter is set to "PCSS" (contact hardening).
  18335. */
  18336. get useContactHardeningShadow(): boolean;
  18337. /**
  18338. * Sets the current filter to "PCSS" (contact hardening).
  18339. */
  18340. set useContactHardeningShadow(value: boolean);
  18341. protected _contactHardeningLightSizeUVRatio: number;
  18342. /**
  18343. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18344. * Using a ratio helps keeping shape stability independently of the map size.
  18345. *
  18346. * It does not account for the light projection as it was having too much
  18347. * instability during the light setup or during light position changes.
  18348. *
  18349. * Only valid if useContactHardeningShadow is true.
  18350. */
  18351. get contactHardeningLightSizeUVRatio(): number;
  18352. /**
  18353. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18362. protected _darkness: number;
  18363. /** Gets or sets the actual darkness of a shadow */
  18364. get darkness(): number;
  18365. set darkness(value: number);
  18366. /**
  18367. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18368. * 0 means strongest and 1 would means no shadow.
  18369. * @returns the darkness.
  18370. */
  18371. getDarkness(): number;
  18372. /**
  18373. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18374. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18375. * @returns the shadow generator allowing fluent coding.
  18376. */
  18377. setDarkness(darkness: number): ShadowGenerator;
  18378. protected _transparencyShadow: boolean;
  18379. /** Gets or sets the ability to have transparent shadow */
  18380. get transparencyShadow(): boolean;
  18381. set transparencyShadow(value: boolean);
  18382. /**
  18383. * Sets the ability to have transparent shadow (boolean).
  18384. * @param transparent True if transparent else False
  18385. * @returns the shadow generator allowing fluent coding
  18386. */
  18387. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18388. /**
  18389. * Enables or disables shadows with varying strength based on the transparency
  18390. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18391. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18392. * mesh.visibility * alphaTexture.a
  18393. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18394. */
  18395. enableSoftTransparentShadow: boolean;
  18396. protected _shadowMap: Nullable<RenderTargetTexture>;
  18397. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18398. /**
  18399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18400. * @returns The render target texture if present otherwise, null
  18401. */
  18402. getShadowMap(): Nullable<RenderTargetTexture>;
  18403. /**
  18404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18405. * @returns The render target texture if the shadow map is present otherwise, null
  18406. */
  18407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the class name of that object
  18410. * @returns "ShadowGenerator"
  18411. */
  18412. getClassName(): string;
  18413. /**
  18414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18415. * @param mesh Mesh to add
  18416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18417. * @returns the Shadow Generator itself
  18418. */
  18419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18420. /**
  18421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18422. * @param mesh Mesh to remove
  18423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18424. * @returns the Shadow Generator itself
  18425. */
  18426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18427. /**
  18428. * Controls the extent to which the shadows fade out at the edge of the frustum
  18429. */
  18430. frustumEdgeFalloff: number;
  18431. protected _light: IShadowLight;
  18432. /**
  18433. * Returns the associated light object.
  18434. * @returns the light generating the shadow
  18435. */
  18436. getLight(): IShadowLight;
  18437. /**
  18438. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18439. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18440. * It might on the other hand introduce peter panning.
  18441. */
  18442. forceBackFacesOnly: boolean;
  18443. protected _scene: Scene;
  18444. protected _lightDirection: Vector3;
  18445. protected _effect: Effect;
  18446. protected _viewMatrix: Matrix;
  18447. protected _projectionMatrix: Matrix;
  18448. protected _transformMatrix: Matrix;
  18449. protected _cachedPosition: Vector3;
  18450. protected _cachedDirection: Vector3;
  18451. protected _cachedDefines: string;
  18452. protected _currentRenderID: number;
  18453. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18454. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18456. protected _blurPostProcesses: PostProcess[];
  18457. protected _mapSize: number;
  18458. protected _currentFaceIndex: number;
  18459. protected _currentFaceIndexCache: number;
  18460. protected _textureType: number;
  18461. protected _defaultTextureMatrix: Matrix;
  18462. protected _storedUniqueId: Nullable<number>;
  18463. /** @hidden */
  18464. static _SceneComponentInitialization: (scene: Scene) => void;
  18465. /**
  18466. * Creates a ShadowGenerator object.
  18467. * A ShadowGenerator is the required tool to use the shadows.
  18468. * Each light casting shadows needs to use its own ShadowGenerator.
  18469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18471. * @param light The light object generating the shadows.
  18472. * @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.
  18473. */
  18474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18475. protected _initializeGenerator(): void;
  18476. protected _createTargetRenderTexture(): void;
  18477. protected _initializeShadowMap(): void;
  18478. protected _initializeBlurRTTAndPostProcesses(): void;
  18479. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18480. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18481. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18482. protected _applyFilterValues(): void;
  18483. /**
  18484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18485. * @param onCompiled Callback triggered at the and of the effects compilation
  18486. * @param options Sets of optional options forcing the compilation with different modes
  18487. */
  18488. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18489. useInstances: boolean;
  18490. }>): void;
  18491. /**
  18492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18493. * @param options Sets of optional options forcing the compilation with different modes
  18494. * @returns A promise that resolves when the compilation completes
  18495. */
  18496. forceCompilationAsync(options?: Partial<{
  18497. useInstances: boolean;
  18498. }>): Promise<void>;
  18499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18500. private _prepareShadowDefines;
  18501. /**
  18502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18503. * @param subMesh The submesh we want to render in the shadow map
  18504. * @param useInstances Defines wether will draw in the map using instances
  18505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18506. * @returns true if ready otherwise, false
  18507. */
  18508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18509. /**
  18510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18511. * @param defines Defines of the material we want to update
  18512. * @param lightIndex Index of the light in the enabled light list of the material
  18513. */
  18514. prepareDefines(defines: any, lightIndex: number): void;
  18515. /**
  18516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18517. * defined in the generator but impacting the effect).
  18518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18519. * @param effect The effect we are binfing the information for
  18520. */
  18521. bindShadowLight(lightIndex: string, effect: Effect): void;
  18522. /**
  18523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18524. * (eq to shadow prjection matrix * light transform matrix)
  18525. * @returns The transform matrix used to create the shadow map
  18526. */
  18527. getTransformMatrix(): Matrix;
  18528. /**
  18529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18530. * Cube and 2D textures for instance.
  18531. */
  18532. recreateShadowMap(): void;
  18533. protected _disposeBlurPostProcesses(): void;
  18534. protected _disposeRTTandPostProcesses(): void;
  18535. /**
  18536. * Disposes the ShadowGenerator.
  18537. * Returns nothing.
  18538. */
  18539. dispose(): void;
  18540. /**
  18541. * Serializes the shadow generator setup to a json object.
  18542. * @returns The serialized JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18547. * @param parsedShadowGenerator The JSON object to parse
  18548. * @param scene The scene to create the shadow map for
  18549. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18550. * @returns The parsed shadow generator
  18551. */
  18552. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18553. }
  18554. }
  18555. declare module "babylonjs/Lights/light" {
  18556. import { Nullable } from "babylonjs/types";
  18557. import { Scene } from "babylonjs/scene";
  18558. import { Vector3 } from "babylonjs/Maths/math.vector";
  18559. import { Color3 } from "babylonjs/Maths/math.color";
  18560. import { Node } from "babylonjs/node";
  18561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18564. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18565. /**
  18566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18568. * 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.
  18569. */
  18570. export abstract class Light extends Node {
  18571. /**
  18572. * Falloff Default: light is falling off following the material specification:
  18573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18574. */
  18575. static readonly FALLOFF_DEFAULT: number;
  18576. /**
  18577. * Falloff Physical: light is falling off following the inverse squared distance law.
  18578. */
  18579. static readonly FALLOFF_PHYSICAL: number;
  18580. /**
  18581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18582. * to enhance interoperability with other engines.
  18583. */
  18584. static readonly FALLOFF_GLTF: number;
  18585. /**
  18586. * Falloff Standard: light is falling off like in the standard material
  18587. * to enhance interoperability with other materials.
  18588. */
  18589. static readonly FALLOFF_STANDARD: number;
  18590. /**
  18591. * If every light affecting the material is in this lightmapMode,
  18592. * material.lightmapTexture adds or multiplies
  18593. * (depends on material.useLightmapAsShadowmap)
  18594. * after every other light calculations.
  18595. */
  18596. static readonly LIGHTMAP_DEFAULT: number;
  18597. /**
  18598. * material.lightmapTexture as only diffuse lighting from this light
  18599. * adds only specular lighting from this light
  18600. * adds dynamic shadows
  18601. */
  18602. static readonly LIGHTMAP_SPECULAR: number;
  18603. /**
  18604. * material.lightmapTexture as only lighting
  18605. * no light calculation from this light
  18606. * only adds dynamic shadows from this light
  18607. */
  18608. static readonly LIGHTMAP_SHADOWSONLY: number;
  18609. /**
  18610. * Each light type uses the default quantity according to its type:
  18611. * point/spot lights use luminous intensity
  18612. * directional lights use illuminance
  18613. */
  18614. static readonly INTENSITYMODE_AUTOMATIC: number;
  18615. /**
  18616. * lumen (lm)
  18617. */
  18618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18619. /**
  18620. * candela (lm/sr)
  18621. */
  18622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18623. /**
  18624. * lux (lm/m^2)
  18625. */
  18626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18627. /**
  18628. * nit (cd/m^2)
  18629. */
  18630. static readonly INTENSITYMODE_LUMINANCE: number;
  18631. /**
  18632. * Light type const id of the point light.
  18633. */
  18634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18635. /**
  18636. * Light type const id of the directional light.
  18637. */
  18638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18639. /**
  18640. * Light type const id of the spot light.
  18641. */
  18642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18643. /**
  18644. * Light type const id of the hemispheric light.
  18645. */
  18646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18647. /**
  18648. * Diffuse gives the basic color to an object.
  18649. */
  18650. diffuse: Color3;
  18651. /**
  18652. * Specular produces a highlight color on an object.
  18653. * Note: This is note affecting PBR materials.
  18654. */
  18655. specular: Color3;
  18656. /**
  18657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18658. * falling off base on range or angle.
  18659. * This can be set to any values in Light.FALLOFF_x.
  18660. *
  18661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18662. * other types of materials.
  18663. */
  18664. falloffType: number;
  18665. /**
  18666. * Strength of the light.
  18667. * Note: By default it is define in the framework own unit.
  18668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18669. */
  18670. intensity: number;
  18671. private _range;
  18672. protected _inverseSquaredRange: number;
  18673. /**
  18674. * Defines how far from the source the light is impacting in scene units.
  18675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18676. */
  18677. get range(): number;
  18678. /**
  18679. * Defines how far from the source the light is impacting in scene units.
  18680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18681. */
  18682. set range(value: number);
  18683. /**
  18684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18685. * of light.
  18686. */
  18687. private _photometricScale;
  18688. private _intensityMode;
  18689. /**
  18690. * Gets the photometric scale used to interpret the intensity.
  18691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18692. */
  18693. get intensityMode(): number;
  18694. /**
  18695. * Sets the photometric scale used to interpret the intensity.
  18696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18697. */
  18698. set intensityMode(value: number);
  18699. private _radius;
  18700. /**
  18701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18702. */
  18703. get radius(): number;
  18704. /**
  18705. * sets the light radius used by PBR Materials to simulate soft area lights.
  18706. */
  18707. set radius(value: number);
  18708. private _renderPriority;
  18709. /**
  18710. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18711. * exceeding the number allowed of the materials.
  18712. */
  18713. renderPriority: number;
  18714. private _shadowEnabled;
  18715. /**
  18716. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18717. * the current shadow generator.
  18718. */
  18719. get shadowEnabled(): boolean;
  18720. /**
  18721. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18722. * the current shadow generator.
  18723. */
  18724. set shadowEnabled(value: boolean);
  18725. private _includedOnlyMeshes;
  18726. /**
  18727. * Gets the only meshes impacted by this light.
  18728. */
  18729. get includedOnlyMeshes(): AbstractMesh[];
  18730. /**
  18731. * Sets the only meshes impacted by this light.
  18732. */
  18733. set includedOnlyMeshes(value: AbstractMesh[]);
  18734. private _excludedMeshes;
  18735. /**
  18736. * Gets the meshes not impacted by this light.
  18737. */
  18738. get excludedMeshes(): AbstractMesh[];
  18739. /**
  18740. * Sets the meshes not impacted by this light.
  18741. */
  18742. set excludedMeshes(value: AbstractMesh[]);
  18743. private _excludeWithLayerMask;
  18744. /**
  18745. * Gets the layer id use to find what meshes are not impacted by the light.
  18746. * Inactive if 0
  18747. */
  18748. get excludeWithLayerMask(): number;
  18749. /**
  18750. * Sets the layer id use to find what meshes are not impacted by the light.
  18751. * Inactive if 0
  18752. */
  18753. set excludeWithLayerMask(value: number);
  18754. private _includeOnlyWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get includeOnlyWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set includeOnlyWithLayerMask(value: number);
  18765. private _lightmapMode;
  18766. /**
  18767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18768. */
  18769. get lightmapMode(): number;
  18770. /**
  18771. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18772. */
  18773. set lightmapMode(value: number);
  18774. /**
  18775. * Shadow generator associted to the light.
  18776. * @hidden Internal use only.
  18777. */
  18778. _shadowGenerator: Nullable<IShadowGenerator>;
  18779. /**
  18780. * @hidden Internal use only.
  18781. */
  18782. _excludedMeshesIds: string[];
  18783. /**
  18784. * @hidden Internal use only.
  18785. */
  18786. _includedOnlyMeshesIds: string[];
  18787. /**
  18788. * The current light unifom buffer.
  18789. * @hidden Internal use only.
  18790. */
  18791. _uniformBuffer: UniformBuffer;
  18792. /** @hidden */
  18793. _renderId: number;
  18794. /**
  18795. * Creates a Light object in the scene.
  18796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18797. * @param name The firendly name of the light
  18798. * @param scene The scene the light belongs too
  18799. */
  18800. constructor(name: string, scene: Scene);
  18801. protected abstract _buildUniformLayout(): void;
  18802. /**
  18803. * Sets the passed Effect "effect" with the Light information.
  18804. * @param effect The effect to update
  18805. * @param lightIndex The index of the light in the effect to update
  18806. * @returns The light
  18807. */
  18808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18809. /**
  18810. * Sets the passed Effect "effect" with the Light textures.
  18811. * @param effect The effect to update
  18812. * @param lightIndex The index of the light in the effect to update
  18813. * @returns The light
  18814. */
  18815. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18816. /**
  18817. * Binds the lights information from the scene to the effect for the given mesh.
  18818. * @param lightIndex Light index
  18819. * @param scene The scene where the light belongs to
  18820. * @param effect The effect we are binding the data to
  18821. * @param useSpecular Defines if specular is supported
  18822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18823. */
  18824. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18825. /**
  18826. * Sets the passed Effect "effect" with the Light information.
  18827. * @param effect The effect to update
  18828. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18829. * @returns The light
  18830. */
  18831. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18832. /**
  18833. * Returns the string "Light".
  18834. * @returns the class name
  18835. */
  18836. getClassName(): string;
  18837. /** @hidden */
  18838. readonly _isLight: boolean;
  18839. /**
  18840. * Converts the light information to a readable string for debug purpose.
  18841. * @param fullDetails Supports for multiple levels of logging within scene loading
  18842. * @returns the human readable light info
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /** @hidden */
  18846. protected _syncParentEnabledState(): void;
  18847. /**
  18848. * Set the enabled state of this node.
  18849. * @param value - the new enabled state
  18850. */
  18851. setEnabled(value: boolean): void;
  18852. /**
  18853. * Returns the Light associated shadow generator if any.
  18854. * @return the associated shadow generator.
  18855. */
  18856. getShadowGenerator(): Nullable<IShadowGenerator>;
  18857. /**
  18858. * Returns a Vector3, the absolute light position in the World.
  18859. * @returns the world space position of the light
  18860. */
  18861. getAbsolutePosition(): Vector3;
  18862. /**
  18863. * Specifies if the light will affect the passed mesh.
  18864. * @param mesh The mesh to test against the light
  18865. * @return true the mesh is affected otherwise, false.
  18866. */
  18867. canAffectMesh(mesh: AbstractMesh): boolean;
  18868. /**
  18869. * Sort function to order lights for rendering.
  18870. * @param a First Light object to compare to second.
  18871. * @param b Second Light object to compare first.
  18872. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18873. */
  18874. static CompareLightsPriority(a: Light, b: Light): number;
  18875. /**
  18876. * Releases resources associated with this node.
  18877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18879. */
  18880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18881. /**
  18882. * Returns the light type ID (integer).
  18883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18884. */
  18885. getTypeID(): number;
  18886. /**
  18887. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18888. * @returns the scaled intensity in intensity mode unit
  18889. */
  18890. getScaledIntensity(): number;
  18891. /**
  18892. * Returns a new Light object, named "name", from the current one.
  18893. * @param name The name of the cloned light
  18894. * @param newParent The parent of this light, if it has one
  18895. * @returns the new created light
  18896. */
  18897. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18898. /**
  18899. * Serializes the current light into a Serialization object.
  18900. * @returns the serialized object.
  18901. */
  18902. serialize(): any;
  18903. /**
  18904. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18905. * This new light is named "name" and added to the passed scene.
  18906. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18907. * @param name The friendly name of the light
  18908. * @param scene The scene the new light will belong to
  18909. * @returns the constructor function
  18910. */
  18911. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18912. /**
  18913. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18914. * @param parsedLight The JSON representation of the light
  18915. * @param scene The scene to create the parsed light in
  18916. * @returns the created light after parsing
  18917. */
  18918. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18919. private _hookArrayForExcluded;
  18920. private _hookArrayForIncludedOnly;
  18921. private _resyncMeshes;
  18922. /**
  18923. * Forces the meshes to update their light related information in their rendering used effects
  18924. * @hidden Internal Use Only
  18925. */
  18926. _markMeshesAsLightDirty(): void;
  18927. /**
  18928. * Recomputes the cached photometric scale if needed.
  18929. */
  18930. private _computePhotometricScale;
  18931. /**
  18932. * Returns the Photometric Scale according to the light type and intensity mode.
  18933. */
  18934. private _getPhotometricScale;
  18935. /**
  18936. * Reorder the light in the scene according to their defined priority.
  18937. * @hidden Internal Use Only
  18938. */
  18939. _reorderLightsInScene(): void;
  18940. /**
  18941. * Prepares the list of defines specific to the light type.
  18942. * @param defines the list of defines
  18943. * @param lightIndex defines the index of the light for the effect
  18944. */
  18945. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18946. }
  18947. }
  18948. declare module "babylonjs/Cameras/targetCamera" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Camera } from "babylonjs/Cameras/camera";
  18951. import { Scene } from "babylonjs/scene";
  18952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18953. /**
  18954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. */
  18958. export class TargetCamera extends Camera {
  18959. private static _RigCamTransformMatrix;
  18960. private static _TargetTransformMatrix;
  18961. private static _TargetFocalPoint;
  18962. private _tmpUpVector;
  18963. private _tmpTargetVector;
  18964. /**
  18965. * Define the current direction the camera is moving to
  18966. */
  18967. cameraDirection: Vector3;
  18968. /**
  18969. * Define the current rotation the camera is rotating to
  18970. */
  18971. cameraRotation: Vector2;
  18972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18973. ignoreParentScaling: boolean;
  18974. /**
  18975. * When set, the up vector of the camera will be updated by the rotation of the camera
  18976. */
  18977. updateUpVectorFromRotation: boolean;
  18978. private _tmpQuaternion;
  18979. /**
  18980. * Define the current rotation of the camera
  18981. */
  18982. rotation: Vector3;
  18983. /**
  18984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18985. */
  18986. rotationQuaternion: Quaternion;
  18987. /**
  18988. * Define the current speed of the camera
  18989. */
  18990. speed: number;
  18991. /**
  18992. * Add constraint to the camera to prevent it to move freely in all directions and
  18993. * around all axis.
  18994. */
  18995. noRotationConstraint: boolean;
  18996. /**
  18997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18998. * panning
  18999. */
  19000. invertRotation: boolean;
  19001. /**
  19002. * Speed multiplier for inverse camera panning
  19003. */
  19004. inverseRotationSpeed: number;
  19005. /**
  19006. * Define the current target of the camera as an object or a position.
  19007. */
  19008. lockedTarget: any;
  19009. /** @hidden */
  19010. _currentTarget: Vector3;
  19011. /** @hidden */
  19012. _initialFocalDistance: number;
  19013. /** @hidden */
  19014. _viewMatrix: Matrix;
  19015. /** @hidden */
  19016. _camMatrix: Matrix;
  19017. /** @hidden */
  19018. _cameraTransformMatrix: Matrix;
  19019. /** @hidden */
  19020. _cameraRotationMatrix: Matrix;
  19021. /** @hidden */
  19022. _referencePoint: Vector3;
  19023. /** @hidden */
  19024. _transformedReferencePoint: Vector3;
  19025. /** @hidden */
  19026. _reset: () => void;
  19027. private _defaultUp;
  19028. /**
  19029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19030. * This is the base of the follow, arc rotate cameras and Free camera
  19031. * @see https://doc.babylonjs.com/features/cameras
  19032. * @param name Defines the name of the camera in the scene
  19033. * @param position Defines the start position of the camera in the scene
  19034. * @param scene Defines the scene the camera belongs to
  19035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19036. */
  19037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19038. /**
  19039. * Gets the position in front of the camera at a given distance.
  19040. * @param distance The distance from the camera we want the position to be
  19041. * @returns the position
  19042. */
  19043. getFrontPosition(distance: number): Vector3;
  19044. /** @hidden */
  19045. _getLockedTargetPosition(): Nullable<Vector3>;
  19046. private _storedPosition;
  19047. private _storedRotation;
  19048. private _storedRotationQuaternion;
  19049. /**
  19050. * Store current camera state of the camera (fov, position, rotation, etc..)
  19051. * @returns the camera
  19052. */
  19053. storeState(): Camera;
  19054. /**
  19055. * Restored camera state. You must call storeState() first
  19056. * @returns whether it was successful or not
  19057. * @hidden
  19058. */
  19059. _restoreStateValues(): boolean;
  19060. /** @hidden */
  19061. _initCache(): void;
  19062. /** @hidden */
  19063. _updateCache(ignoreParentClass?: boolean): void;
  19064. /** @hidden */
  19065. _isSynchronizedViewMatrix(): boolean;
  19066. /** @hidden */
  19067. _computeLocalCameraSpeed(): number;
  19068. /**
  19069. * Defines the target the camera should look at.
  19070. * @param target Defines the new target as a Vector or a mesh
  19071. */
  19072. setTarget(target: Vector3): void;
  19073. /**
  19074. * Defines the target point of the camera.
  19075. * The camera looks towards it form the radius distance.
  19076. */
  19077. get target(): Vector3;
  19078. set target(value: Vector3);
  19079. /**
  19080. * Return the current target position of the camera. This value is expressed in local space.
  19081. * @returns the target position
  19082. */
  19083. getTarget(): Vector3;
  19084. /** @hidden */
  19085. _decideIfNeedsToMove(): boolean;
  19086. /** @hidden */
  19087. _updatePosition(): void;
  19088. /** @hidden */
  19089. _checkInputs(): void;
  19090. protected _updateCameraRotationMatrix(): void;
  19091. /**
  19092. * 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)
  19093. * @returns the current camera
  19094. */
  19095. private _rotateUpVectorWithCameraRotationMatrix;
  19096. private _cachedRotationZ;
  19097. private _cachedQuaternionRotationZ;
  19098. /** @hidden */
  19099. _getViewMatrix(): Matrix;
  19100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19101. /**
  19102. * @hidden
  19103. */
  19104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19105. /**
  19106. * @hidden
  19107. */
  19108. _updateRigCameras(): void;
  19109. private _getRigCamPositionAndTarget;
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. }
  19116. }
  19117. declare module "babylonjs/Events/keyboardEvents" {
  19118. /**
  19119. * Gather the list of keyboard event types as constants.
  19120. */
  19121. export class KeyboardEventTypes {
  19122. /**
  19123. * The keydown event is fired when a key becomes active (pressed).
  19124. */
  19125. static readonly KEYDOWN: number;
  19126. /**
  19127. * The keyup event is fired when a key has been released.
  19128. */
  19129. static readonly KEYUP: number;
  19130. }
  19131. /**
  19132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19133. */
  19134. export class KeyboardInfo {
  19135. /**
  19136. * Defines the type of event (KeyboardEventTypes)
  19137. */
  19138. type: number;
  19139. /**
  19140. * Defines the related dom event
  19141. */
  19142. event: KeyboardEvent;
  19143. /**
  19144. * Instantiates a new keyboard info.
  19145. * This class is used to store keyboard related info for the onKeyboardObservable 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. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19162. */
  19163. export class KeyboardInfoPre extends KeyboardInfo {
  19164. /**
  19165. * Defines the type of event (KeyboardEventTypes)
  19166. */
  19167. type: number;
  19168. /**
  19169. * Defines the related dom event
  19170. */
  19171. event: KeyboardEvent;
  19172. /**
  19173. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19174. */
  19175. skipOnPointerObservable: boolean;
  19176. /**
  19177. * Instantiates a new keyboard pre info.
  19178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19179. * @param type Defines the type of event (KeyboardEventTypes)
  19180. * @param event Defines the related dom event
  19181. */
  19182. constructor(
  19183. /**
  19184. * Defines the type of event (KeyboardEventTypes)
  19185. */
  19186. type: number,
  19187. /**
  19188. * Defines the related dom event
  19189. */
  19190. event: KeyboardEvent);
  19191. }
  19192. }
  19193. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19194. import { Nullable } from "babylonjs/types";
  19195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19197. /**
  19198. * Manage the keyboard inputs to control the movement of a free camera.
  19199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19200. */
  19201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19202. /**
  19203. * Defines the camera the input is attached to.
  19204. */
  19205. camera: FreeCamera;
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19208. */
  19209. keysUp: number[];
  19210. /**
  19211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19212. */
  19213. keysUpward: number[];
  19214. /**
  19215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19216. */
  19217. keysDown: number[];
  19218. /**
  19219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19220. */
  19221. keysDownward: number[];
  19222. /**
  19223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19224. */
  19225. keysLeft: number[];
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19228. */
  19229. keysRight: number[];
  19230. private _keys;
  19231. private _onCanvasBlurObserver;
  19232. private _onKeyboardObserver;
  19233. private _engine;
  19234. private _scene;
  19235. /**
  19236. * Attach the input controls to a specific dom element to get the input from.
  19237. * @param element Defines the element the controls should be listened from
  19238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19239. */
  19240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19241. /**
  19242. * Detach the current controls from the specified dom element.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: Nullable<HTMLElement>): void;
  19246. /**
  19247. * Update the current camera state depending on the inputs that have been used this frame.
  19248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19249. */
  19250. checkInputs(): void;
  19251. /**
  19252. * Gets the class name of the current intput.
  19253. * @returns the class name
  19254. */
  19255. getClassName(): string;
  19256. /** @hidden */
  19257. _onLostFocus(): void;
  19258. /**
  19259. * Get the friendly name associated with the input class.
  19260. * @returns the input friendly name
  19261. */
  19262. getSimpleName(): string;
  19263. }
  19264. }
  19265. declare module "babylonjs/Events/pointerEvents" {
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Vector2 } from "babylonjs/Maths/math.vector";
  19268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19269. import { Ray } from "babylonjs/Culling/ray";
  19270. /**
  19271. * Gather the list of pointer event types as constants.
  19272. */
  19273. export class PointerEventTypes {
  19274. /**
  19275. * 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.
  19276. */
  19277. static readonly POINTERDOWN: number;
  19278. /**
  19279. * The pointerup event is fired when a pointer is no longer active.
  19280. */
  19281. static readonly POINTERUP: number;
  19282. /**
  19283. * The pointermove event is fired when a pointer changes coordinates.
  19284. */
  19285. static readonly POINTERMOVE: number;
  19286. /**
  19287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19288. */
  19289. static readonly POINTERWHEEL: number;
  19290. /**
  19291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19292. */
  19293. static readonly POINTERPICK: number;
  19294. /**
  19295. * The pointertap event is fired when a the object has been touched and released without drag.
  19296. */
  19297. static readonly POINTERTAP: number;
  19298. /**
  19299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19300. */
  19301. static readonly POINTERDOUBLETAP: number;
  19302. }
  19303. /**
  19304. * Base class of pointer info types.
  19305. */
  19306. export class PointerInfoBase {
  19307. /**
  19308. * Defines the type of event (PointerEventTypes)
  19309. */
  19310. type: number;
  19311. /**
  19312. * Defines the related dom event
  19313. */
  19314. event: PointerEvent | MouseWheelEvent;
  19315. /**
  19316. * Instantiates the base class of pointers info.
  19317. * @param type Defines the type of event (PointerEventTypes)
  19318. * @param event Defines the related dom event
  19319. */
  19320. constructor(
  19321. /**
  19322. * Defines the type of event (PointerEventTypes)
  19323. */
  19324. type: number,
  19325. /**
  19326. * Defines the related dom event
  19327. */
  19328. event: PointerEvent | MouseWheelEvent);
  19329. }
  19330. /**
  19331. * This class is used to store pointer related info for the onPrePointerObservable event.
  19332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19333. */
  19334. export class PointerInfoPre extends PointerInfoBase {
  19335. /**
  19336. * Ray from a pointer if availible (eg. 6dof controller)
  19337. */
  19338. ray: Nullable<Ray>;
  19339. /**
  19340. * Defines the local position of the pointer on the canvas.
  19341. */
  19342. localPosition: Vector2;
  19343. /**
  19344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19345. */
  19346. skipOnPointerObservable: boolean;
  19347. /**
  19348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19349. * @param type Defines the type of event (PointerEventTypes)
  19350. * @param event Defines the related dom event
  19351. * @param localX Defines the local x coordinates of the pointer when the event occured
  19352. * @param localY Defines the local y coordinates of the pointer when the event occured
  19353. */
  19354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19355. }
  19356. /**
  19357. * This type contains all the data related to a pointer event in Babylon.js.
  19358. * 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.
  19359. */
  19360. export class PointerInfo extends PointerInfoBase {
  19361. /**
  19362. * Defines the picking info associated to the info (if any)\
  19363. */
  19364. pickInfo: Nullable<PickingInfo>;
  19365. /**
  19366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19367. * @param type Defines the type of event (PointerEventTypes)
  19368. * @param event Defines the related dom event
  19369. * @param pickInfo Defines the picking info associated to the info (if any)\
  19370. */
  19371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19372. /**
  19373. * Defines the picking info associated to the info (if any)\
  19374. */
  19375. pickInfo: Nullable<PickingInfo>);
  19376. }
  19377. /**
  19378. * Data relating to a touch event on the screen.
  19379. */
  19380. export interface PointerTouch {
  19381. /**
  19382. * X coordinate of touch.
  19383. */
  19384. x: number;
  19385. /**
  19386. * Y coordinate of touch.
  19387. */
  19388. y: number;
  19389. /**
  19390. * Id of touch. Unique for each finger.
  19391. */
  19392. pointerId: number;
  19393. /**
  19394. * Event type passed from DOM.
  19395. */
  19396. type: any;
  19397. }
  19398. }
  19399. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19400. import { Observable } from "babylonjs/Misc/observable";
  19401. import { Nullable } from "babylonjs/types";
  19402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19404. /**
  19405. * Manage the mouse inputs to control the movement of a free camera.
  19406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19407. */
  19408. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19409. /**
  19410. * Define if touch is enabled in the mouse input
  19411. */
  19412. touchEnabled: boolean;
  19413. /**
  19414. * Defines the camera the input is attached to.
  19415. */
  19416. camera: FreeCamera;
  19417. /**
  19418. * Defines the buttons associated with the input to handle camera move.
  19419. */
  19420. buttons: number[];
  19421. /**
  19422. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19423. */
  19424. angularSensibility: number;
  19425. private _pointerInput;
  19426. private _onMouseMove;
  19427. private _observer;
  19428. private previousPosition;
  19429. /**
  19430. * Observable for when a pointer move event occurs containing the move offset
  19431. */
  19432. onPointerMovedObservable: Observable<{
  19433. offsetX: number;
  19434. offsetY: number;
  19435. }>;
  19436. /**
  19437. * @hidden
  19438. * If the camera should be rotated automatically based on pointer movement
  19439. */
  19440. _allowCameraRotation: boolean;
  19441. /**
  19442. * Manage the mouse inputs to control the movement of a free camera.
  19443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19444. * @param touchEnabled Defines if touch is enabled or not
  19445. */
  19446. constructor(
  19447. /**
  19448. * Define if touch is enabled in the mouse input
  19449. */
  19450. touchEnabled?: boolean);
  19451. /**
  19452. * Attach the input controls to a specific dom element to get the input from.
  19453. * @param element Defines the element the controls should be listened from
  19454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19455. */
  19456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19457. /**
  19458. * Called on JS contextmenu event.
  19459. * Override this method to provide functionality.
  19460. */
  19461. protected onContextMenu(evt: PointerEvent): void;
  19462. /**
  19463. * Detach the current controls from the specified dom element.
  19464. * @param element Defines the element to stop listening the inputs from
  19465. */
  19466. detachControl(element: Nullable<HTMLElement>): void;
  19467. /**
  19468. * Gets the class name of the current intput.
  19469. * @returns the class name
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Get the friendly name associated with the input class.
  19474. * @returns the input friendly name
  19475. */
  19476. getSimpleName(): string;
  19477. }
  19478. }
  19479. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19480. import { Nullable } from "babylonjs/types";
  19481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19483. /**
  19484. * Manage the touch inputs to control the movement of a free camera.
  19485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19486. */
  19487. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19488. /**
  19489. * Define if mouse events can be treated as touch events
  19490. */
  19491. allowMouse: boolean;
  19492. /**
  19493. * Defines the camera the input is attached to.
  19494. */
  19495. camera: FreeCamera;
  19496. /**
  19497. * Defines the touch sensibility for rotation.
  19498. * The higher the faster.
  19499. */
  19500. touchAngularSensibility: number;
  19501. /**
  19502. * Defines the touch sensibility for move.
  19503. * The higher the faster.
  19504. */
  19505. touchMoveSensibility: number;
  19506. private _offsetX;
  19507. private _offsetY;
  19508. private _pointerPressed;
  19509. private _pointerInput;
  19510. private _observer;
  19511. private _onLostFocus;
  19512. /**
  19513. * Manage the touch inputs to control the movement of a free camera.
  19514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19515. * @param allowMouse Defines if mouse events can be treated as touch events
  19516. */
  19517. constructor(
  19518. /**
  19519. * Define if mouse events can be treated as touch events
  19520. */
  19521. allowMouse?: boolean);
  19522. /**
  19523. * Attach the input controls to a specific dom element to get the input from.
  19524. * @param element Defines the element the controls should be listened from
  19525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19526. */
  19527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19528. /**
  19529. * Detach the current controls from the specified dom element.
  19530. * @param element Defines the element to stop listening the inputs from
  19531. */
  19532. detachControl(element: Nullable<HTMLElement>): void;
  19533. /**
  19534. * Update the current camera state depending on the inputs that have been used this frame.
  19535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19536. */
  19537. checkInputs(): void;
  19538. /**
  19539. * Gets the class name of the current intput.
  19540. * @returns the class name
  19541. */
  19542. getClassName(): string;
  19543. /**
  19544. * Get the friendly name associated with the input class.
  19545. * @returns the input friendly name
  19546. */
  19547. getSimpleName(): string;
  19548. }
  19549. }
  19550. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19553. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19554. import { Nullable } from "babylonjs/types";
  19555. /**
  19556. * Default Inputs manager for the FreeCamera.
  19557. * It groups all the default supported inputs for ease of use.
  19558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19559. */
  19560. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19561. /**
  19562. * @hidden
  19563. */
  19564. _mouseInput: Nullable<FreeCameraMouseInput>;
  19565. /**
  19566. * Instantiates a new FreeCameraInputsManager.
  19567. * @param camera Defines the camera the inputs belong to
  19568. */
  19569. constructor(camera: FreeCamera);
  19570. /**
  19571. * Add keyboard input support to the input manager.
  19572. * @returns the current input manager
  19573. */
  19574. addKeyboard(): FreeCameraInputsManager;
  19575. /**
  19576. * Add mouse input support to the input manager.
  19577. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19578. * @returns the current input manager
  19579. */
  19580. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19581. /**
  19582. * Removes the mouse input support from the manager
  19583. * @returns the current input manager
  19584. */
  19585. removeMouse(): FreeCameraInputsManager;
  19586. /**
  19587. * Add touch input support to the input manager.
  19588. * @returns the current input manager
  19589. */
  19590. addTouch(): FreeCameraInputsManager;
  19591. /**
  19592. * Remove all attached input methods from a camera
  19593. */
  19594. clear(): void;
  19595. }
  19596. }
  19597. declare module "babylonjs/Cameras/freeCamera" {
  19598. import { Vector3 } from "babylonjs/Maths/math.vector";
  19599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19600. import { Scene } from "babylonjs/scene";
  19601. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19602. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19603. /**
  19604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19606. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19607. */
  19608. export class FreeCamera extends TargetCamera {
  19609. /**
  19610. * Define the collision ellipsoid of the camera.
  19611. * This is helpful to simulate a camera body like the player body around the camera
  19612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19613. */
  19614. ellipsoid: Vector3;
  19615. /**
  19616. * Define an offset for the position of the ellipsoid around the camera.
  19617. * This can be helpful to determine the center of the body near the gravity center of the body
  19618. * instead of its head.
  19619. */
  19620. ellipsoidOffset: Vector3;
  19621. /**
  19622. * Enable or disable collisions of the camera with the rest of the scene objects.
  19623. */
  19624. checkCollisions: boolean;
  19625. /**
  19626. * Enable or disable gravity on the camera.
  19627. */
  19628. applyGravity: boolean;
  19629. /**
  19630. * Define the input manager associated to the camera.
  19631. */
  19632. inputs: FreeCameraInputsManager;
  19633. /**
  19634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19635. * Higher values reduce sensitivity.
  19636. */
  19637. get angularSensibility(): number;
  19638. /**
  19639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19640. * Higher values reduce sensitivity.
  19641. */
  19642. set angularSensibility(value: number);
  19643. /**
  19644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19645. */
  19646. get keysUp(): number[];
  19647. set keysUp(value: number[]);
  19648. /**
  19649. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19650. */
  19651. get keysUpward(): number[];
  19652. set keysUpward(value: number[]);
  19653. /**
  19654. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19655. */
  19656. get keysDown(): number[];
  19657. set keysDown(value: number[]);
  19658. /**
  19659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19660. */
  19661. get keysDownward(): number[];
  19662. set keysDownward(value: number[]);
  19663. /**
  19664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19665. */
  19666. get keysLeft(): number[];
  19667. set keysLeft(value: number[]);
  19668. /**
  19669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19670. */
  19671. get keysRight(): number[];
  19672. set keysRight(value: number[]);
  19673. /**
  19674. * Event raised when the camera collide with a mesh in the scene.
  19675. */
  19676. onCollide: (collidedMesh: AbstractMesh) => void;
  19677. private _collider;
  19678. private _needMoveForGravity;
  19679. private _oldPosition;
  19680. private _diffPosition;
  19681. private _newPosition;
  19682. /** @hidden */
  19683. _localDirection: Vector3;
  19684. /** @hidden */
  19685. _transformedDirection: Vector3;
  19686. /**
  19687. * Instantiates a Free Camera.
  19688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19691. * @param name Define the name of the camera in the scene
  19692. * @param position Define the start position of the camera in the scene
  19693. * @param scene Define the scene the camera belongs to
  19694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19697. /**
  19698. * Attached controls to the current camera.
  19699. * @param element Defines the element the controls should be listened from
  19700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19701. */
  19702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19703. /**
  19704. * Detach the current controls from the camera.
  19705. * The camera will stop reacting to inputs.
  19706. * @param element Defines the element to stop listening the inputs from
  19707. */
  19708. detachControl(element: HTMLElement): void;
  19709. private _collisionMask;
  19710. /**
  19711. * Define a collision mask to limit the list of object the camera can collide with
  19712. */
  19713. get collisionMask(): number;
  19714. set collisionMask(mask: number);
  19715. /** @hidden */
  19716. _collideWithWorld(displacement: Vector3): void;
  19717. private _onCollisionPositionChange;
  19718. /** @hidden */
  19719. _checkInputs(): void;
  19720. /** @hidden */
  19721. _decideIfNeedsToMove(): boolean;
  19722. /** @hidden */
  19723. _updatePosition(): void;
  19724. /**
  19725. * Destroy the camera and release the current resources hold by it.
  19726. */
  19727. dispose(): void;
  19728. /**
  19729. * Gets the current object class name.
  19730. * @return the class name
  19731. */
  19732. getClassName(): string;
  19733. }
  19734. }
  19735. declare module "babylonjs/Gamepads/gamepad" {
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. /**
  19738. * Represents a gamepad control stick position
  19739. */
  19740. export class StickValues {
  19741. /**
  19742. * The x component of the control stick
  19743. */
  19744. x: number;
  19745. /**
  19746. * The y component of the control stick
  19747. */
  19748. y: number;
  19749. /**
  19750. * Initializes the gamepad x and y control stick values
  19751. * @param x The x component of the gamepad control stick value
  19752. * @param y The y component of the gamepad control stick value
  19753. */
  19754. constructor(
  19755. /**
  19756. * The x component of the control stick
  19757. */
  19758. x: number,
  19759. /**
  19760. * The y component of the control stick
  19761. */
  19762. y: number);
  19763. }
  19764. /**
  19765. * An interface which manages callbacks for gamepad button changes
  19766. */
  19767. export interface GamepadButtonChanges {
  19768. /**
  19769. * Called when a gamepad has been changed
  19770. */
  19771. changed: boolean;
  19772. /**
  19773. * Called when a gamepad press event has been triggered
  19774. */
  19775. pressChanged: boolean;
  19776. /**
  19777. * Called when a touch event has been triggered
  19778. */
  19779. touchChanged: boolean;
  19780. /**
  19781. * Called when a value has changed
  19782. */
  19783. valueChanged: boolean;
  19784. }
  19785. /**
  19786. * Represents a gamepad
  19787. */
  19788. export class Gamepad {
  19789. /**
  19790. * The id of the gamepad
  19791. */
  19792. id: string;
  19793. /**
  19794. * The index of the gamepad
  19795. */
  19796. index: number;
  19797. /**
  19798. * The browser gamepad
  19799. */
  19800. browserGamepad: any;
  19801. /**
  19802. * Specifies what type of gamepad this represents
  19803. */
  19804. type: number;
  19805. private _leftStick;
  19806. private _rightStick;
  19807. /** @hidden */
  19808. _isConnected: boolean;
  19809. private _leftStickAxisX;
  19810. private _leftStickAxisY;
  19811. private _rightStickAxisX;
  19812. private _rightStickAxisY;
  19813. /**
  19814. * Triggered when the left control stick has been changed
  19815. */
  19816. private _onleftstickchanged;
  19817. /**
  19818. * Triggered when the right control stick has been changed
  19819. */
  19820. private _onrightstickchanged;
  19821. /**
  19822. * Represents a gamepad controller
  19823. */
  19824. static GAMEPAD: number;
  19825. /**
  19826. * Represents a generic controller
  19827. */
  19828. static GENERIC: number;
  19829. /**
  19830. * Represents an XBox controller
  19831. */
  19832. static XBOX: number;
  19833. /**
  19834. * Represents a pose-enabled controller
  19835. */
  19836. static POSE_ENABLED: number;
  19837. /**
  19838. * Represents an Dual Shock controller
  19839. */
  19840. static DUALSHOCK: number;
  19841. /**
  19842. * Specifies whether the left control stick should be Y-inverted
  19843. */
  19844. protected _invertLeftStickY: boolean;
  19845. /**
  19846. * Specifies if the gamepad has been connected
  19847. */
  19848. get isConnected(): boolean;
  19849. /**
  19850. * Initializes the gamepad
  19851. * @param id The id of the gamepad
  19852. * @param index The index of the gamepad
  19853. * @param browserGamepad The browser gamepad
  19854. * @param leftStickX The x component of the left joystick
  19855. * @param leftStickY The y component of the left joystick
  19856. * @param rightStickX The x component of the right joystick
  19857. * @param rightStickY The y component of the right joystick
  19858. */
  19859. constructor(
  19860. /**
  19861. * The id of the gamepad
  19862. */
  19863. id: string,
  19864. /**
  19865. * The index of the gamepad
  19866. */
  19867. index: number,
  19868. /**
  19869. * The browser gamepad
  19870. */
  19871. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19872. /**
  19873. * Callback triggered when the left joystick has changed
  19874. * @param callback
  19875. */
  19876. onleftstickchanged(callback: (values: StickValues) => void): void;
  19877. /**
  19878. * Callback triggered when the right joystick has changed
  19879. * @param callback
  19880. */
  19881. onrightstickchanged(callback: (values: StickValues) => void): void;
  19882. /**
  19883. * Gets the left joystick
  19884. */
  19885. get leftStick(): StickValues;
  19886. /**
  19887. * Sets the left joystick values
  19888. */
  19889. set leftStick(newValues: StickValues);
  19890. /**
  19891. * Gets the right joystick
  19892. */
  19893. get rightStick(): StickValues;
  19894. /**
  19895. * Sets the right joystick value
  19896. */
  19897. set rightStick(newValues: StickValues);
  19898. /**
  19899. * Updates the gamepad joystick positions
  19900. */
  19901. update(): void;
  19902. /**
  19903. * Disposes the gamepad
  19904. */
  19905. dispose(): void;
  19906. }
  19907. /**
  19908. * Represents a generic gamepad
  19909. */
  19910. export class GenericPad extends Gamepad {
  19911. private _buttons;
  19912. private _onbuttondown;
  19913. private _onbuttonup;
  19914. /**
  19915. * Observable triggered when a button has been pressed
  19916. */
  19917. onButtonDownObservable: Observable<number>;
  19918. /**
  19919. * Observable triggered when a button has been released
  19920. */
  19921. onButtonUpObservable: Observable<number>;
  19922. /**
  19923. * Callback triggered when a button has been pressed
  19924. * @param callback Called when a button has been pressed
  19925. */
  19926. onbuttondown(callback: (buttonPressed: number) => void): void;
  19927. /**
  19928. * Callback triggered when a button has been released
  19929. * @param callback Called when a button has been released
  19930. */
  19931. onbuttonup(callback: (buttonReleased: number) => void): void;
  19932. /**
  19933. * Initializes the generic gamepad
  19934. * @param id The id of the generic gamepad
  19935. * @param index The index of the generic gamepad
  19936. * @param browserGamepad The browser gamepad
  19937. */
  19938. constructor(id: string, index: number, browserGamepad: any);
  19939. private _setButtonValue;
  19940. /**
  19941. * Updates the generic gamepad
  19942. */
  19943. update(): void;
  19944. /**
  19945. * Disposes the generic gamepad
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19951. import { Observable } from "babylonjs/Misc/observable";
  19952. import { Nullable } from "babylonjs/types";
  19953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19956. import { Ray } from "babylonjs/Culling/ray";
  19957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19958. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19959. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19960. /**
  19961. * Defines the types of pose enabled controllers that are supported
  19962. */
  19963. export enum PoseEnabledControllerType {
  19964. /**
  19965. * HTC Vive
  19966. */
  19967. VIVE = 0,
  19968. /**
  19969. * Oculus Rift
  19970. */
  19971. OCULUS = 1,
  19972. /**
  19973. * Windows mixed reality
  19974. */
  19975. WINDOWS = 2,
  19976. /**
  19977. * Samsung gear VR
  19978. */
  19979. GEAR_VR = 3,
  19980. /**
  19981. * Google Daydream
  19982. */
  19983. DAYDREAM = 4,
  19984. /**
  19985. * Generic
  19986. */
  19987. GENERIC = 5
  19988. }
  19989. /**
  19990. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19991. */
  19992. export interface MutableGamepadButton {
  19993. /**
  19994. * Value of the button/trigger
  19995. */
  19996. value: number;
  19997. /**
  19998. * If the button/trigger is currently touched
  19999. */
  20000. touched: boolean;
  20001. /**
  20002. * If the button/trigger is currently pressed
  20003. */
  20004. pressed: boolean;
  20005. }
  20006. /**
  20007. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20008. * @hidden
  20009. */
  20010. export interface ExtendedGamepadButton extends GamepadButton {
  20011. /**
  20012. * If the button/trigger is currently pressed
  20013. */
  20014. readonly pressed: boolean;
  20015. /**
  20016. * If the button/trigger is currently touched
  20017. */
  20018. readonly touched: boolean;
  20019. /**
  20020. * Value of the button/trigger
  20021. */
  20022. readonly value: number;
  20023. }
  20024. /** @hidden */
  20025. export interface _GamePadFactory {
  20026. /**
  20027. * Returns whether or not the current gamepad can be created for this type of controller.
  20028. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20029. * @returns true if it can be created, otherwise false
  20030. */
  20031. canCreate(gamepadInfo: any): boolean;
  20032. /**
  20033. * Creates a new instance of the Gamepad.
  20034. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20035. * @returns the new gamepad instance
  20036. */
  20037. create(gamepadInfo: any): Gamepad;
  20038. }
  20039. /**
  20040. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20041. */
  20042. export class PoseEnabledControllerHelper {
  20043. /** @hidden */
  20044. static _ControllerFactories: _GamePadFactory[];
  20045. /** @hidden */
  20046. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20047. /**
  20048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20049. * @param vrGamepad the gamepad to initialized
  20050. * @returns a vr controller of the type the gamepad identified as
  20051. */
  20052. static InitiateController(vrGamepad: any): Gamepad;
  20053. }
  20054. /**
  20055. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20056. */
  20057. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20058. /**
  20059. * If the controller is used in a webXR session
  20060. */
  20061. isXR: boolean;
  20062. private _deviceRoomPosition;
  20063. private _deviceRoomRotationQuaternion;
  20064. /**
  20065. * The device position in babylon space
  20066. */
  20067. devicePosition: Vector3;
  20068. /**
  20069. * The device rotation in babylon space
  20070. */
  20071. deviceRotationQuaternion: Quaternion;
  20072. /**
  20073. * The scale factor of the device in babylon space
  20074. */
  20075. deviceScaleFactor: number;
  20076. /**
  20077. * (Likely devicePosition should be used instead) The device position in its room space
  20078. */
  20079. position: Vector3;
  20080. /**
  20081. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20082. */
  20083. rotationQuaternion: Quaternion;
  20084. /**
  20085. * The type of controller (Eg. Windows mixed reality)
  20086. */
  20087. controllerType: PoseEnabledControllerType;
  20088. protected _calculatedPosition: Vector3;
  20089. private _calculatedRotation;
  20090. /**
  20091. * The raw pose from the device
  20092. */
  20093. rawPose: DevicePose;
  20094. private _trackPosition;
  20095. private _maxRotationDistFromHeadset;
  20096. private _draggedRoomRotation;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _disableTrackPosition(fixedPosition: Vector3): void;
  20101. /**
  20102. * Internal, the mesh attached to the controller
  20103. * @hidden
  20104. */
  20105. _mesh: Nullable<AbstractMesh>;
  20106. private _poseControlledCamera;
  20107. private _leftHandSystemQuaternion;
  20108. /**
  20109. * Internal, matrix used to convert room space to babylon space
  20110. * @hidden
  20111. */
  20112. _deviceToWorld: Matrix;
  20113. /**
  20114. * Node to be used when casting a ray from the controller
  20115. * @hidden
  20116. */
  20117. _pointingPoseNode: Nullable<TransformNode>;
  20118. /**
  20119. * Name of the child mesh that can be used to cast a ray from the controller
  20120. */
  20121. static readonly POINTING_POSE: string;
  20122. /**
  20123. * Creates a new PoseEnabledController from a gamepad
  20124. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20125. */
  20126. constructor(browserGamepad: any);
  20127. private _workingMatrix;
  20128. /**
  20129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20130. */
  20131. update(): void;
  20132. /**
  20133. * Updates only the pose device and mesh without doing any button event checking
  20134. */
  20135. protected _updatePoseAndMesh(): void;
  20136. /**
  20137. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20138. * @param poseData raw pose fromthe device
  20139. */
  20140. updateFromDevice(poseData: DevicePose): void;
  20141. /**
  20142. * @hidden
  20143. */
  20144. _meshAttachedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Attaches a mesh to the controller
  20147. * @param mesh the mesh to be attached
  20148. */
  20149. attachToMesh(mesh: AbstractMesh): void;
  20150. /**
  20151. * Attaches the controllers mesh to a camera
  20152. * @param camera the camera the mesh should be attached to
  20153. */
  20154. attachToPoseControlledCamera(camera: TargetCamera): void;
  20155. /**
  20156. * Disposes of the controller
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * The mesh that is attached to the controller
  20161. */
  20162. get mesh(): Nullable<AbstractMesh>;
  20163. /**
  20164. * Gets the ray of the controller in the direction the controller is pointing
  20165. * @param length the length the resulting ray should be
  20166. * @returns a ray in the direction the controller is pointing
  20167. */
  20168. getForwardRay(length?: number): Ray;
  20169. }
  20170. }
  20171. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20172. import { Observable } from "babylonjs/Misc/observable";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20177. import { Nullable } from "babylonjs/types";
  20178. /**
  20179. * Defines the WebVRController object that represents controllers tracked in 3D space
  20180. */
  20181. export abstract class WebVRController extends PoseEnabledController {
  20182. /**
  20183. * Internal, the default controller model for the controller
  20184. */
  20185. protected _defaultModel: Nullable<AbstractMesh>;
  20186. /**
  20187. * Fired when the trigger state has changed
  20188. */
  20189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20190. /**
  20191. * Fired when the main button state has changed
  20192. */
  20193. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20194. /**
  20195. * Fired when the secondary button state has changed
  20196. */
  20197. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20198. /**
  20199. * Fired when the pad state has changed
  20200. */
  20201. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20202. /**
  20203. * Fired when controllers stick values have changed
  20204. */
  20205. onPadValuesChangedObservable: Observable<StickValues>;
  20206. /**
  20207. * Array of button availible on the controller
  20208. */
  20209. protected _buttons: Array<MutableGamepadButton>;
  20210. private _onButtonStateChange;
  20211. /**
  20212. * Fired when a controller button's state has changed
  20213. * @param callback the callback containing the button that was modified
  20214. */
  20215. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20216. /**
  20217. * X and Y axis corresponding to the controllers joystick
  20218. */
  20219. pad: StickValues;
  20220. /**
  20221. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20222. */
  20223. hand: string;
  20224. /**
  20225. * The default controller model for the controller
  20226. */
  20227. get defaultModel(): Nullable<AbstractMesh>;
  20228. /**
  20229. * Creates a new WebVRController from a gamepad
  20230. * @param vrGamepad the gamepad that the WebVRController should be created from
  20231. */
  20232. constructor(vrGamepad: any);
  20233. /**
  20234. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Function to be called when a button is modified
  20239. */
  20240. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20241. /**
  20242. * Loads a mesh and attaches it to the controller
  20243. * @param scene the scene the mesh should be added to
  20244. * @param meshLoaded callback for when the mesh has been loaded
  20245. */
  20246. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20247. private _setButtonValue;
  20248. private _changes;
  20249. private _checkChanges;
  20250. /**
  20251. * Disposes of th webVRCOntroller
  20252. */
  20253. dispose(): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Lights/hemisphericLight" {
  20257. import { Nullable } from "babylonjs/types";
  20258. import { Scene } from "babylonjs/scene";
  20259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20260. import { Color3 } from "babylonjs/Maths/math.color";
  20261. import { Effect } from "babylonjs/Materials/effect";
  20262. import { Light } from "babylonjs/Lights/light";
  20263. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20264. /**
  20265. * The HemisphericLight simulates the ambient environment light,
  20266. * so the passed direction is the light reflection direction, not the incoming direction.
  20267. */
  20268. export class HemisphericLight extends Light {
  20269. /**
  20270. * The groundColor is the light in the opposite direction to the one specified during creation.
  20271. * 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.
  20272. */
  20273. groundColor: Color3;
  20274. /**
  20275. * The light reflection direction, not the incoming direction.
  20276. */
  20277. direction: Vector3;
  20278. /**
  20279. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20280. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20281. * The HemisphericLight can't cast shadows.
  20282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20283. * @param name The friendly name of the light
  20284. * @param direction The direction of the light reflection
  20285. * @param scene The scene the light belongs to
  20286. */
  20287. constructor(name: string, direction: Vector3, scene: Scene);
  20288. protected _buildUniformLayout(): void;
  20289. /**
  20290. * Returns the string "HemisphericLight".
  20291. * @return The class name
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20296. * Returns the updated direction.
  20297. * @param target The target the direction should point to
  20298. * @return The computed direction
  20299. */
  20300. setDirectionToTarget(target: Vector3): Vector3;
  20301. /**
  20302. * Returns the shadow generator associated to the light.
  20303. * @returns Always null for hemispheric lights because it does not support shadows.
  20304. */
  20305. getShadowGenerator(): Nullable<IShadowGenerator>;
  20306. /**
  20307. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20308. * @param effect The effect to update
  20309. * @param lightIndex The index of the light in the effect to update
  20310. * @returns The hemispheric light
  20311. */
  20312. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20314. /**
  20315. * Computes the world matrix of the node
  20316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20317. * @param useWasUpdatedFlag defines a reserved property
  20318. * @returns the world matrix
  20319. */
  20320. computeWorldMatrix(): Matrix;
  20321. /**
  20322. * Returns the integer 3.
  20323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20324. */
  20325. getTypeID(): number;
  20326. /**
  20327. * Prepares the list of defines specific to the light type.
  20328. * @param defines the list of defines
  20329. * @param lightIndex defines the index of the light for the effect
  20330. */
  20331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20332. }
  20333. }
  20334. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20335. /** @hidden */
  20336. export var vrMultiviewToSingleviewPixelShader: {
  20337. name: string;
  20338. shader: string;
  20339. };
  20340. }
  20341. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20343. import { Scene } from "babylonjs/scene";
  20344. /**
  20345. * Renders to multiple views with a single draw call
  20346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20347. */
  20348. export class MultiviewRenderTarget extends RenderTargetTexture {
  20349. /**
  20350. * Creates a multiview render target
  20351. * @param scene scene used with the render target
  20352. * @param size the size of the render target (used for each view)
  20353. */
  20354. constructor(scene: Scene, size?: number | {
  20355. width: number;
  20356. height: number;
  20357. } | {
  20358. ratio: number;
  20359. });
  20360. /**
  20361. * @hidden
  20362. * @param faceIndex the face index, if its a cube texture
  20363. */
  20364. _bindFrameBuffer(faceIndex?: number): void;
  20365. /**
  20366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20367. * @returns the view count
  20368. */
  20369. getViewCount(): number;
  20370. }
  20371. }
  20372. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20377. import { Matrix } from "babylonjs/Maths/math.vector";
  20378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20379. module "babylonjs/Engines/engine" {
  20380. interface Engine {
  20381. /**
  20382. * Creates a new multiview render target
  20383. * @param width defines the width of the texture
  20384. * @param height defines the height of the texture
  20385. * @returns the created multiview texture
  20386. */
  20387. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20388. /**
  20389. * Binds a multiview framebuffer to be drawn to
  20390. * @param multiviewTexture texture to bind
  20391. */
  20392. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20393. }
  20394. }
  20395. module "babylonjs/Cameras/camera" {
  20396. interface Camera {
  20397. /**
  20398. * @hidden
  20399. * 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)
  20400. */
  20401. _useMultiviewToSingleView: boolean;
  20402. /**
  20403. * @hidden
  20404. * 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)
  20405. */
  20406. _multiviewTexture: Nullable<RenderTargetTexture>;
  20407. /**
  20408. * @hidden
  20409. * ensures the multiview texture of the camera exists and has the specified width/height
  20410. * @param width height to set on the multiview texture
  20411. * @param height width to set on the multiview texture
  20412. */
  20413. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20414. }
  20415. }
  20416. module "babylonjs/scene" {
  20417. interface Scene {
  20418. /** @hidden */
  20419. _transformMatrixR: Matrix;
  20420. /** @hidden */
  20421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20422. /** @hidden */
  20423. _createMultiviewUbo(): void;
  20424. /** @hidden */
  20425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20426. /** @hidden */
  20427. _renderMultiviewToSingleView(camera: Camera): void;
  20428. }
  20429. }
  20430. }
  20431. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20434. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20435. import "babylonjs/Engines/Extensions/engine.multiview";
  20436. /**
  20437. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20438. * This will not be used for webXR as it supports displaying texture arrays directly
  20439. */
  20440. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20441. /**
  20442. * Gets a string identifying the name of the class
  20443. * @returns "VRMultiviewToSingleviewPostProcess" string
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Initializes a VRMultiviewToSingleview
  20448. * @param name name of the post process
  20449. * @param camera camera to be applied to
  20450. * @param scaleFactor scaling factor to the size of the output texture
  20451. */
  20452. constructor(name: string, camera: Camera, scaleFactor: number);
  20453. }
  20454. }
  20455. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20456. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20457. import { Nullable } from "babylonjs/types";
  20458. import { Size } from "babylonjs/Maths/math.size";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20461. /**
  20462. * Interface used to define additional presentation attributes
  20463. */
  20464. export interface IVRPresentationAttributes {
  20465. /**
  20466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20467. */
  20468. highRefreshRate: boolean;
  20469. /**
  20470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20471. */
  20472. foveationLevel: number;
  20473. }
  20474. module "babylonjs/Engines/engine" {
  20475. interface Engine {
  20476. /** @hidden */
  20477. _vrDisplay: any;
  20478. /** @hidden */
  20479. _vrSupported: boolean;
  20480. /** @hidden */
  20481. _oldSize: Size;
  20482. /** @hidden */
  20483. _oldHardwareScaleFactor: number;
  20484. /** @hidden */
  20485. _vrExclusivePointerMode: boolean;
  20486. /** @hidden */
  20487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20488. /** @hidden */
  20489. _onVRDisplayPointerRestricted: () => void;
  20490. /** @hidden */
  20491. _onVRDisplayPointerUnrestricted: () => void;
  20492. /** @hidden */
  20493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20494. /** @hidden */
  20495. _onVrDisplayDisconnect: Nullable<() => void>;
  20496. /** @hidden */
  20497. _onVrDisplayPresentChange: Nullable<() => void>;
  20498. /**
  20499. * Observable signaled when VR display mode changes
  20500. */
  20501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20502. /**
  20503. * Observable signaled when VR request present is complete
  20504. */
  20505. onVRRequestPresentComplete: Observable<boolean>;
  20506. /**
  20507. * Observable signaled when VR request present starts
  20508. */
  20509. onVRRequestPresentStart: Observable<Engine>;
  20510. /**
  20511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20513. */
  20514. isInVRExclusivePointerMode: boolean;
  20515. /**
  20516. * Gets a boolean indicating if a webVR device was detected
  20517. * @returns true if a webVR device was detected
  20518. */
  20519. isVRDevicePresent(): boolean;
  20520. /**
  20521. * Gets the current webVR device
  20522. * @returns the current webVR device (or null)
  20523. */
  20524. getVRDevice(): any;
  20525. /**
  20526. * Initializes a webVR display and starts listening to display change events
  20527. * The onVRDisplayChangedObservable will be notified upon these changes
  20528. * @returns A promise containing a VRDisplay and if vr is supported
  20529. */
  20530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20531. /** @hidden */
  20532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20533. /**
  20534. * Gets or sets the presentation attributes used to configure VR rendering
  20535. */
  20536. vrPresentationAttributes?: IVRPresentationAttributes;
  20537. /**
  20538. * Call this function to switch to webVR mode
  20539. * Will do nothing if webVR is not supported or if there is no webVR device
  20540. * @param options the webvr options provided to the camera. mainly used for multiview
  20541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20542. */
  20543. enableVR(options: WebVROptions): void;
  20544. /** @hidden */
  20545. _onVRFullScreenTriggered(): void;
  20546. }
  20547. }
  20548. }
  20549. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20550. import { Nullable } from "babylonjs/types";
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20553. import { Scene } from "babylonjs/scene";
  20554. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20556. import { Node } from "babylonjs/node";
  20557. import { Ray } from "babylonjs/Culling/ray";
  20558. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20559. import "babylonjs/Engines/Extensions/engine.webVR";
  20560. /**
  20561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20562. * IMPORTANT!! The data is right-hand data.
  20563. * @export
  20564. * @interface DevicePose
  20565. */
  20566. export interface DevicePose {
  20567. /**
  20568. * The position of the device, values in array are [x,y,z].
  20569. */
  20570. readonly position: Nullable<Float32Array>;
  20571. /**
  20572. * The linearVelocity of the device, values in array are [x,y,z].
  20573. */
  20574. readonly linearVelocity: Nullable<Float32Array>;
  20575. /**
  20576. * The linearAcceleration of the device, values in array are [x,y,z].
  20577. */
  20578. readonly linearAcceleration: Nullable<Float32Array>;
  20579. /**
  20580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20581. */
  20582. readonly orientation: Nullable<Float32Array>;
  20583. /**
  20584. * The angularVelocity of the device, values in array are [x,y,z].
  20585. */
  20586. readonly angularVelocity: Nullable<Float32Array>;
  20587. /**
  20588. * The angularAcceleration of the device, values in array are [x,y,z].
  20589. */
  20590. readonly angularAcceleration: Nullable<Float32Array>;
  20591. }
  20592. /**
  20593. * Interface representing a pose controlled object in Babylon.
  20594. * A pose controlled object has both regular pose values as well as pose values
  20595. * from an external device such as a VR head mounted display
  20596. */
  20597. export interface PoseControlled {
  20598. /**
  20599. * The position of the object in babylon space.
  20600. */
  20601. position: Vector3;
  20602. /**
  20603. * The rotation quaternion of the object in babylon space.
  20604. */
  20605. rotationQuaternion: Quaternion;
  20606. /**
  20607. * The position of the device in babylon space.
  20608. */
  20609. devicePosition?: Vector3;
  20610. /**
  20611. * The rotation quaternion of the device in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The raw pose coming from the device.
  20616. */
  20617. rawPose: Nullable<DevicePose>;
  20618. /**
  20619. * The scale of the device to be used when translating from device space to babylon space.
  20620. */
  20621. deviceScaleFactor: number;
  20622. /**
  20623. * Updates the poseControlled values based on the input device pose.
  20624. * @param poseData the pose data to update the object with
  20625. */
  20626. updateFromDevice(poseData: DevicePose): void;
  20627. }
  20628. /**
  20629. * Set of options to customize the webVRCamera
  20630. */
  20631. export interface WebVROptions {
  20632. /**
  20633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20634. */
  20635. trackPosition?: boolean;
  20636. /**
  20637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20638. */
  20639. positionScale?: number;
  20640. /**
  20641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20642. */
  20643. displayName?: string;
  20644. /**
  20645. * Should the native controller meshes be initialized. (default: true)
  20646. */
  20647. controllerMeshes?: boolean;
  20648. /**
  20649. * Creating a default HemiLight only on controllers. (default: true)
  20650. */
  20651. defaultLightingOnControllers?: boolean;
  20652. /**
  20653. * If you don't want to use the default VR button of the helper. (default: false)
  20654. */
  20655. useCustomVRButton?: boolean;
  20656. /**
  20657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20658. */
  20659. customVRButton?: HTMLButtonElement;
  20660. /**
  20661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20662. */
  20663. rayLength?: number;
  20664. /**
  20665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20666. */
  20667. defaultHeight?: number;
  20668. /**
  20669. * If multiview should be used if availible (default: false)
  20670. */
  20671. useMultiview?: boolean;
  20672. }
  20673. /**
  20674. * This represents a WebVR camera.
  20675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20676. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20677. */
  20678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20679. private webVROptions;
  20680. /**
  20681. * @hidden
  20682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20683. */
  20684. _vrDevice: any;
  20685. /**
  20686. * The rawPose of the vrDevice.
  20687. */
  20688. rawPose: Nullable<DevicePose>;
  20689. private _onVREnabled;
  20690. private _specsVersion;
  20691. private _attached;
  20692. private _frameData;
  20693. protected _descendants: Array<Node>;
  20694. private _deviceRoomPosition;
  20695. /** @hidden */
  20696. _deviceRoomRotationQuaternion: Quaternion;
  20697. private _standingMatrix;
  20698. /**
  20699. * Represents device position in babylon space.
  20700. */
  20701. devicePosition: Vector3;
  20702. /**
  20703. * Represents device rotation in babylon space.
  20704. */
  20705. deviceRotationQuaternion: Quaternion;
  20706. /**
  20707. * The scale of the device to be used when translating from device space to babylon space.
  20708. */
  20709. deviceScaleFactor: number;
  20710. private _deviceToWorld;
  20711. private _worldToDevice;
  20712. /**
  20713. * References to the webVR controllers for the vrDevice.
  20714. */
  20715. controllers: Array<WebVRController>;
  20716. /**
  20717. * Emits an event when a controller is attached.
  20718. */
  20719. onControllersAttachedObservable: Observable<WebVRController[]>;
  20720. /**
  20721. * Emits an event when a controller's mesh has been loaded;
  20722. */
  20723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20724. /**
  20725. * Emits an event when the HMD's pose has been updated.
  20726. */
  20727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20728. private _poseSet;
  20729. /**
  20730. * If the rig cameras be used as parent instead of this camera.
  20731. */
  20732. rigParenting: boolean;
  20733. private _lightOnControllers;
  20734. private _defaultHeight?;
  20735. /**
  20736. * Instantiates a WebVRFreeCamera.
  20737. * @param name The name of the WebVRFreeCamera
  20738. * @param position The starting anchor position for the camera
  20739. * @param scene The scene the camera belongs to
  20740. * @param webVROptions a set of customizable options for the webVRCamera
  20741. */
  20742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20743. /**
  20744. * Gets the device distance from the ground in meters.
  20745. * @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.
  20746. */
  20747. deviceDistanceToRoomGround(): number;
  20748. /**
  20749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20751. */
  20752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20753. /**
  20754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20755. * @returns A promise with a boolean set to if the standing matrix is supported.
  20756. */
  20757. useStandingMatrixAsync(): Promise<boolean>;
  20758. /**
  20759. * Disposes the camera
  20760. */
  20761. dispose(): void;
  20762. /**
  20763. * Gets a vrController by name.
  20764. * @param name The name of the controller to retreive
  20765. * @returns the controller matching the name specified or null if not found
  20766. */
  20767. getControllerByName(name: string): Nullable<WebVRController>;
  20768. private _leftController;
  20769. /**
  20770. * The controller corresponding to the users left hand.
  20771. */
  20772. get leftController(): Nullable<WebVRController>;
  20773. private _rightController;
  20774. /**
  20775. * The controller corresponding to the users right hand.
  20776. */
  20777. get rightController(): Nullable<WebVRController>;
  20778. /**
  20779. * Casts a ray forward from the vrCamera's gaze.
  20780. * @param length Length of the ray (default: 100)
  20781. * @returns the ray corresponding to the gaze
  20782. */
  20783. getForwardRay(length?: number): Ray;
  20784. /**
  20785. * @hidden
  20786. * Updates the camera based on device's frame data
  20787. */
  20788. _checkInputs(): void;
  20789. /**
  20790. * Updates the poseControlled values based on the input device pose.
  20791. * @param poseData Pose coming from the device
  20792. */
  20793. updateFromDevice(poseData: DevicePose): void;
  20794. private _htmlElementAttached;
  20795. private _detachIfAttached;
  20796. /**
  20797. * WebVR's attach control will start broadcasting frames to the device.
  20798. * Note that in certain browsers (chrome for example) this function must be called
  20799. * within a user-interaction callback. Example:
  20800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20801. *
  20802. * @param element html element to attach the vrDevice to
  20803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20804. */
  20805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20806. /**
  20807. * Detaches the camera from the html element and disables VR
  20808. *
  20809. * @param element html element to detach from
  20810. */
  20811. detachControl(element: HTMLElement): void;
  20812. /**
  20813. * @returns the name of this class
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Calls resetPose on the vrDisplay
  20818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20819. */
  20820. resetToCurrentRotation(): void;
  20821. /**
  20822. * @hidden
  20823. * Updates the rig cameras (left and right eye)
  20824. */
  20825. _updateRigCameras(): void;
  20826. private _workingVector;
  20827. private _oneVector;
  20828. private _workingMatrix;
  20829. private updateCacheCalled;
  20830. private _correctPositionIfNotTrackPosition;
  20831. /**
  20832. * @hidden
  20833. * Updates the cached values of the camera
  20834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20835. */
  20836. _updateCache(ignoreParentClass?: boolean): void;
  20837. /**
  20838. * @hidden
  20839. * Get current device position in babylon world
  20840. */
  20841. _computeDevicePosition(): void;
  20842. /**
  20843. * Updates the current device position and rotation in the babylon world
  20844. */
  20845. update(): void;
  20846. /**
  20847. * @hidden
  20848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20849. * @returns an identity matrix
  20850. */
  20851. _getViewMatrix(): Matrix;
  20852. private _tmpMatrix;
  20853. /**
  20854. * This function is called by the two RIG cameras.
  20855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20856. * @hidden
  20857. */
  20858. _getWebVRViewMatrix(): Matrix;
  20859. /** @hidden */
  20860. _getWebVRProjectionMatrix(): Matrix;
  20861. private _onGamepadConnectedObserver;
  20862. private _onGamepadDisconnectedObserver;
  20863. private _updateCacheWhenTrackingDisabledObserver;
  20864. /**
  20865. * Initializes the controllers and their meshes
  20866. */
  20867. initControllers(): void;
  20868. }
  20869. }
  20870. declare module "babylonjs/Materials/materialHelper" {
  20871. import { Nullable } from "babylonjs/types";
  20872. import { Scene } from "babylonjs/scene";
  20873. import { Engine } from "babylonjs/Engines/engine";
  20874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20875. import { Light } from "babylonjs/Lights/light";
  20876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20877. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20879. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20881. /**
  20882. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20883. *
  20884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20885. *
  20886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20887. */
  20888. export class MaterialHelper {
  20889. /**
  20890. * Bind the current view position to an effect.
  20891. * @param effect The effect to be bound
  20892. * @param scene The scene the eyes position is used from
  20893. * @param variableName name of the shader variable that will hold the eye position
  20894. */
  20895. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20896. /**
  20897. * Helps preparing the defines values about the UVs in used in the effect.
  20898. * UVs are shared as much as we can accross channels in the shaders.
  20899. * @param texture The texture we are preparing the UVs for
  20900. * @param defines The defines to update
  20901. * @param key The channel key "diffuse", "specular"... used in the shader
  20902. */
  20903. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20904. /**
  20905. * Binds a texture matrix value to its corrsponding uniform
  20906. * @param texture The texture to bind the matrix for
  20907. * @param uniformBuffer The uniform buffer receivin the data
  20908. * @param key The channel key "diffuse", "specular"... used in the shader
  20909. */
  20910. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20911. /**
  20912. * Gets the current status of the fog (should it be enabled?)
  20913. * @param mesh defines the mesh to evaluate for fog support
  20914. * @param scene defines the hosting scene
  20915. * @returns true if fog must be enabled
  20916. */
  20917. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20918. /**
  20919. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20920. * @param mesh defines the current mesh
  20921. * @param scene defines the current scene
  20922. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20923. * @param pointsCloud defines if point cloud rendering has to be turned on
  20924. * @param fogEnabled defines if fog has to be turned on
  20925. * @param alphaTest defines if alpha testing has to be turned on
  20926. * @param defines defines the current list of defines
  20927. */
  20928. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20929. /**
  20930. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20931. * @param scene defines the current scene
  20932. * @param engine defines the current engine
  20933. * @param defines specifies the list of active defines
  20934. * @param useInstances defines if instances have to be turned on
  20935. * @param useClipPlane defines if clip plane have to be turned on
  20936. * @param useInstances defines if instances have to be turned on
  20937. * @param useThinInstances defines if thin instances have to be turned on
  20938. */
  20939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20940. /**
  20941. * Prepares the defines for bones
  20942. * @param mesh The mesh containing the geometry data we will draw
  20943. * @param defines The defines to update
  20944. */
  20945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20946. /**
  20947. * Prepares the defines for morph targets
  20948. * @param mesh The mesh containing the geometry data we will draw
  20949. * @param defines The defines to update
  20950. */
  20951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20952. /**
  20953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20954. * @param mesh The mesh containing the geometry data we will draw
  20955. * @param defines The defines to update
  20956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20957. * @param useBones Precise whether bones should be used or not (override mesh info)
  20958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20960. * @returns false if defines are considered not dirty and have not been checked
  20961. */
  20962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20963. /**
  20964. * Prepares the defines related to multiview
  20965. * @param scene The scene we are intending to draw
  20966. * @param defines The defines to update
  20967. */
  20968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20969. /**
  20970. * Prepares the defines related to the prepass
  20971. * @param scene The scene we are intending to draw
  20972. * @param defines The defines to update
  20973. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20974. */
  20975. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20976. /**
  20977. * Prepares the defines related to the light information passed in parameter
  20978. * @param scene The scene we are intending to draw
  20979. * @param mesh The mesh the effect is compiling for
  20980. * @param light The light the effect is compiling for
  20981. * @param lightIndex The index of the light
  20982. * @param defines The defines to update
  20983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20984. * @param state Defines the current state regarding what is needed (normals, etc...)
  20985. */
  20986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20987. needNormals: boolean;
  20988. needRebuild: boolean;
  20989. shadowEnabled: boolean;
  20990. specularEnabled: boolean;
  20991. lightmapMode: boolean;
  20992. }): void;
  20993. /**
  20994. * Prepares the defines related to the light information passed in parameter
  20995. * @param scene The scene we are intending to draw
  20996. * @param mesh The mesh the effect is compiling for
  20997. * @param defines The defines to update
  20998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21001. * @returns true if normals will be required for the rest of the effect
  21002. */
  21003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21004. /**
  21005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21006. * @param lightIndex defines the light index
  21007. * @param uniformsList The uniform list
  21008. * @param samplersList The sampler list
  21009. * @param projectedLightTexture defines if projected texture must be used
  21010. * @param uniformBuffersList defines an optional list of uniform buffers
  21011. */
  21012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21013. /**
  21014. * Prepares the uniforms and samplers list to be used in the effect
  21015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21016. * @param samplersList The sampler list
  21017. * @param defines The defines helping in the list generation
  21018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21019. */
  21020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21021. /**
  21022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21023. * @param defines The defines to update while falling back
  21024. * @param fallbacks The authorized effect fallbacks
  21025. * @param maxSimultaneousLights The maximum number of lights allowed
  21026. * @param rank the current rank of the Effect
  21027. * @returns The newly affected rank
  21028. */
  21029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21030. private static _TmpMorphInfluencers;
  21031. /**
  21032. * Prepares the list of attributes required for morph targets according to the effect defines.
  21033. * @param attribs The current list of supported attribs
  21034. * @param mesh The mesh to prepare the morph targets attributes for
  21035. * @param influencers The number of influencers
  21036. */
  21037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21038. /**
  21039. * Prepares the list of attributes required for morph targets according to the effect defines.
  21040. * @param attribs The current list of supported attribs
  21041. * @param mesh The mesh to prepare the morph targets attributes for
  21042. * @param defines The current Defines of the effect
  21043. */
  21044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the list of attributes required for bones according to the effect defines.
  21047. * @param attribs The current list of supported attribs
  21048. * @param mesh The mesh to prepare the bones attributes for
  21049. * @param defines The current Defines of the effect
  21050. * @param fallbacks The current efffect fallback strategy
  21051. */
  21052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21053. /**
  21054. * Check and prepare the list of attributes required for instances according to the effect defines.
  21055. * @param attribs The current list of supported attribs
  21056. * @param defines The current MaterialDefines of the effect
  21057. */
  21058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21059. /**
  21060. * Add the list of attributes required for instances to the attribs array.
  21061. * @param attribs The current list of supported attribs
  21062. */
  21063. static PushAttributesForInstances(attribs: string[]): void;
  21064. /**
  21065. * Binds the light information to the effect.
  21066. * @param light The light containing the generator
  21067. * @param effect The effect we are binding the data to
  21068. * @param lightIndex The light index in the effect used to render
  21069. */
  21070. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21071. /**
  21072. * Binds the lights information from the scene to the effect for the given mesh.
  21073. * @param light Light to bind
  21074. * @param lightIndex Light index
  21075. * @param scene The scene where the light belongs to
  21076. * @param effect The effect we are binding the data to
  21077. * @param useSpecular Defines if specular is supported
  21078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21079. */
  21080. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21081. /**
  21082. * Binds the lights information from the scene to the effect for the given mesh.
  21083. * @param scene The scene the lights belongs to
  21084. * @param mesh The mesh we are binding the information to render
  21085. * @param effect The effect we are binding the data to
  21086. * @param defines The generated defines for the effect
  21087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21089. */
  21090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21091. private static _tempFogColor;
  21092. /**
  21093. * Binds the fog information from the scene to the effect for the given mesh.
  21094. * @param scene The scene the lights belongs to
  21095. * @param mesh The mesh we are binding the information to render
  21096. * @param effect The effect we are binding the data to
  21097. * @param linearSpace Defines if the fog effect is applied in linear space
  21098. */
  21099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21100. /**
  21101. * Binds the bones information from the mesh to the effect.
  21102. * @param mesh The mesh we are binding the information to render
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21106. /**
  21107. * Binds the morph targets information from the mesh to the effect.
  21108. * @param abstractMesh The mesh we are binding the information to render
  21109. * @param effect The effect we are binding the data to
  21110. */
  21111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21112. /**
  21113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21114. * @param defines The generated defines used in the effect
  21115. * @param effect The effect we are binding the data to
  21116. * @param scene The scene we are willing to render with logarithmic scale for
  21117. */
  21118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21119. /**
  21120. * Binds the clip plane information from the scene to the effect.
  21121. * @param scene The scene the clip plane information are extracted from
  21122. * @param effect The effect we are binding the data to
  21123. */
  21124. static BindClipPlane(effect: Effect, scene: Scene): void;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21130. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Effect } from "babylonjs/Materials/effect";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { Scene } from "babylonjs/scene";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21137. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21138. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21139. import { Observable } from "babylonjs/Misc/observable";
  21140. /**
  21141. * Block used to expose an input value
  21142. */
  21143. export class InputBlock extends NodeMaterialBlock {
  21144. private _mode;
  21145. private _associatedVariableName;
  21146. private _storedValue;
  21147. private _valueCallback;
  21148. private _type;
  21149. private _animationType;
  21150. /** Gets or set a value used to limit the range of float values */
  21151. min: number;
  21152. /** Gets or set a value used to limit the range of float values */
  21153. max: number;
  21154. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21155. isBoolean: boolean;
  21156. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21157. matrixMode: number;
  21158. /** @hidden */
  21159. _systemValue: Nullable<NodeMaterialSystemValues>;
  21160. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21161. isConstant: boolean;
  21162. /** Gets or sets the group to use to display this block in the Inspector */
  21163. groupInInspector: string;
  21164. /** Gets an observable raised when the value is changed */
  21165. onValueChangedObservable: Observable<InputBlock>;
  21166. /**
  21167. * Gets or sets the connection point type (default is float)
  21168. */
  21169. get type(): NodeMaterialBlockConnectionPointTypes;
  21170. /**
  21171. * Creates a new InputBlock
  21172. * @param name defines the block name
  21173. * @param target defines the target of that block (Vertex by default)
  21174. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21175. */
  21176. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21177. /**
  21178. * Validates if a name is a reserve word.
  21179. * @param newName the new name to be given to the node.
  21180. * @returns false if the name is a reserve word, else true.
  21181. */
  21182. validateBlockName(newName: string): boolean;
  21183. /**
  21184. * Gets the output component
  21185. */
  21186. get output(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Set the source of this connection point to a vertex attribute
  21189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21190. * @returns the current connection point
  21191. */
  21192. setAsAttribute(attributeName?: string): InputBlock;
  21193. /**
  21194. * Set the source of this connection point to a system value
  21195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21196. * @returns the current connection point
  21197. */
  21198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21199. /**
  21200. * Gets or sets the value of that point.
  21201. * Please note that this value will be ignored if valueCallback is defined
  21202. */
  21203. get value(): any;
  21204. set value(value: any);
  21205. /**
  21206. * Gets or sets a callback used to get the value of that point.
  21207. * Please note that setting this value will force the connection point to ignore the value property
  21208. */
  21209. get valueCallback(): () => any;
  21210. set valueCallback(value: () => any);
  21211. /**
  21212. * Gets or sets the associated variable name in the shader
  21213. */
  21214. get associatedVariableName(): string;
  21215. set associatedVariableName(value: string);
  21216. /** Gets or sets the type of animation applied to the input */
  21217. get animationType(): AnimatedInputBlockTypes;
  21218. set animationType(value: AnimatedInputBlockTypes);
  21219. /**
  21220. * Gets a boolean indicating that this connection point not defined yet
  21221. */
  21222. get isUndefined(): boolean;
  21223. /**
  21224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21225. * In this case the connection point name must be the name of the uniform to use.
  21226. * Can only be set on inputs
  21227. */
  21228. get isUniform(): boolean;
  21229. set isUniform(value: boolean);
  21230. /**
  21231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21232. * In this case the connection point name must be the name of the attribute to use
  21233. * Can only be set on inputs
  21234. */
  21235. get isAttribute(): boolean;
  21236. set isAttribute(value: boolean);
  21237. /**
  21238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21239. * Can only be set on exit points
  21240. */
  21241. get isVarying(): boolean;
  21242. set isVarying(value: boolean);
  21243. /**
  21244. * Gets a boolean indicating that the current connection point is a system value
  21245. */
  21246. get isSystemValue(): boolean;
  21247. /**
  21248. * Gets or sets the current well known value or null if not defined as a system value
  21249. */
  21250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Animate the input if animationType !== None
  21259. * @param scene defines the rendering scene
  21260. */
  21261. animate(scene: Scene): void;
  21262. private _emitDefine;
  21263. initialize(state: NodeMaterialBuildState): void;
  21264. /**
  21265. * Set the input block to its default value (based on its type)
  21266. */
  21267. setDefaultValue(): void;
  21268. private _emitConstant;
  21269. /** @hidden */
  21270. get _noContextSwitch(): boolean;
  21271. private _emit;
  21272. /** @hidden */
  21273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21274. /** @hidden */
  21275. _transmit(effect: Effect, scene: Scene): void;
  21276. protected _buildBlock(state: NodeMaterialBuildState): void;
  21277. protected _dumpPropertiesCode(): string;
  21278. dispose(): void;
  21279. serialize(): any;
  21280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21281. }
  21282. }
  21283. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21284. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21286. import { Nullable } from "babylonjs/types";
  21287. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21290. /**
  21291. * Enum used to define the compatibility state between two connection points
  21292. */
  21293. export enum NodeMaterialConnectionPointCompatibilityStates {
  21294. /** Points are compatibles */
  21295. Compatible = 0,
  21296. /** Points are incompatible because of their types */
  21297. TypeIncompatible = 1,
  21298. /** Points are incompatible because of their targets (vertex vs fragment) */
  21299. TargetIncompatible = 2
  21300. }
  21301. /**
  21302. * Defines the direction of a connection point
  21303. */
  21304. export enum NodeMaterialConnectionPointDirection {
  21305. /** Input */
  21306. Input = 0,
  21307. /** Output */
  21308. Output = 1
  21309. }
  21310. /**
  21311. * Defines a connection point for a block
  21312. */
  21313. export class NodeMaterialConnectionPoint {
  21314. /** @hidden */
  21315. _ownerBlock: NodeMaterialBlock;
  21316. /** @hidden */
  21317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21318. private _endpoints;
  21319. private _associatedVariableName;
  21320. private _direction;
  21321. /** @hidden */
  21322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21323. /** @hidden */
  21324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21325. private _type;
  21326. /** @hidden */
  21327. _enforceAssociatedVariableName: boolean;
  21328. /** Gets the direction of the point */
  21329. get direction(): NodeMaterialConnectionPointDirection;
  21330. /** Indicates that this connection point needs dual validation before being connected to another point */
  21331. needDualDirectionValidation: boolean;
  21332. /**
  21333. * Gets or sets the additional types supported by this connection point
  21334. */
  21335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21336. /**
  21337. * Gets or sets the additional types excluded by this connection point
  21338. */
  21339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21340. /**
  21341. * Observable triggered when this point is connected
  21342. */
  21343. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21344. /**
  21345. * Gets or sets the associated variable name in the shader
  21346. */
  21347. get associatedVariableName(): string;
  21348. set associatedVariableName(value: string);
  21349. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21350. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21351. /**
  21352. * Gets or sets the connection point type (default is float)
  21353. */
  21354. get type(): NodeMaterialBlockConnectionPointTypes;
  21355. set type(value: NodeMaterialBlockConnectionPointTypes);
  21356. /**
  21357. * Gets or sets the connection point name
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the connection point name
  21362. */
  21363. displayName: string;
  21364. /**
  21365. * Gets or sets a boolean indicating that this connection point can be omitted
  21366. */
  21367. isOptional: boolean;
  21368. /**
  21369. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21370. */
  21371. isExposedOnFrame: boolean;
  21372. /**
  21373. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21374. */
  21375. define: string;
  21376. /** @hidden */
  21377. _prioritizeVertex: boolean;
  21378. private _target;
  21379. /** Gets or sets the target of that connection point */
  21380. get target(): NodeMaterialBlockTargets;
  21381. set target(value: NodeMaterialBlockTargets);
  21382. /**
  21383. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21384. */
  21385. get isConnected(): boolean;
  21386. /**
  21387. * Gets a boolean indicating that the current point is connected to an input block
  21388. */
  21389. get isConnectedToInputBlock(): boolean;
  21390. /**
  21391. * Gets a the connected input block (if any)
  21392. */
  21393. get connectInputBlock(): Nullable<InputBlock>;
  21394. /** Get the other side of the connection (if any) */
  21395. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21396. /** Get the block that owns this connection point */
  21397. get ownerBlock(): NodeMaterialBlock;
  21398. /** Get the block connected on the other side of this connection (if any) */
  21399. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21400. /** Get the block connected on the endpoints of this connection (if any) */
  21401. get connectedBlocks(): Array<NodeMaterialBlock>;
  21402. /** Gets the list of connected endpoints */
  21403. get endpoints(): NodeMaterialConnectionPoint[];
  21404. /** Gets a boolean indicating if that output point is connected to at least one input */
  21405. get hasEndpoints(): boolean;
  21406. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21407. get isConnectedInVertexShader(): boolean;
  21408. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21409. get isConnectedInFragmentShader(): boolean;
  21410. /**
  21411. * Creates a block suitable to be used as an input for this input point.
  21412. * If null is returned, a block based on the point type will be created.
  21413. * @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
  21414. */
  21415. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21416. /**
  21417. * Creates a new connection point
  21418. * @param name defines the connection point name
  21419. * @param ownerBlock defines the block hosting this connection point
  21420. * @param direction defines the direction of the connection point
  21421. */
  21422. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21423. /**
  21424. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21425. * @returns the class name
  21426. */
  21427. getClassName(): string;
  21428. /**
  21429. * Gets a boolean indicating if the current point can be connected to another point
  21430. * @param connectionPoint defines the other connection point
  21431. * @returns a boolean
  21432. */
  21433. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21434. /**
  21435. * Gets a number indicating if the current point can be connected to another point
  21436. * @param connectionPoint defines the other connection point
  21437. * @returns a number defining the compatibility state
  21438. */
  21439. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21440. /**
  21441. * Connect this point to another connection point
  21442. * @param connectionPoint defines the other connection point
  21443. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21444. * @returns the current connection point
  21445. */
  21446. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21447. /**
  21448. * Disconnect this point from one of his endpoint
  21449. * @param endpoint defines the other connection point
  21450. * @returns the current connection point
  21451. */
  21452. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21453. /**
  21454. * Serializes this point in a JSON representation
  21455. * @param isInput defines if the connection point is an input (default is true)
  21456. * @returns the serialized point object
  21457. */
  21458. serialize(isInput?: boolean): any;
  21459. /**
  21460. * Release resources
  21461. */
  21462. dispose(): void;
  21463. }
  21464. }
  21465. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21466. /**
  21467. * Enum used to define the material modes
  21468. */
  21469. export enum NodeMaterialModes {
  21470. /** Regular material */
  21471. Material = 0,
  21472. /** For post process */
  21473. PostProcess = 1,
  21474. /** For particle system */
  21475. Particle = 2,
  21476. /** For procedural texture */
  21477. ProceduralTexture = 3
  21478. }
  21479. }
  21480. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21483. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21486. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21487. import { Effect } from "babylonjs/Materials/effect";
  21488. import { Mesh } from "babylonjs/Meshes/mesh";
  21489. import { Nullable } from "babylonjs/types";
  21490. import { Texture } from "babylonjs/Materials/Textures/texture";
  21491. import { Scene } from "babylonjs/scene";
  21492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21493. /**
  21494. * Block used to read a texture from a sampler
  21495. */
  21496. export class TextureBlock extends NodeMaterialBlock {
  21497. private _defineName;
  21498. private _linearDefineName;
  21499. private _gammaDefineName;
  21500. private _tempTextureRead;
  21501. private _samplerName;
  21502. private _transformedUVName;
  21503. private _textureTransformName;
  21504. private _textureInfoName;
  21505. private _mainUVName;
  21506. private _mainUVDefineName;
  21507. private _fragmentOnly;
  21508. /**
  21509. * Gets or sets the texture associated with the node
  21510. */
  21511. texture: Nullable<Texture>;
  21512. /**
  21513. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21514. */
  21515. convertToGammaSpace: boolean;
  21516. /**
  21517. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21518. */
  21519. convertToLinearSpace: boolean;
  21520. /**
  21521. * Create a new TextureBlock
  21522. * @param name defines the block name
  21523. */
  21524. constructor(name: string, fragmentOnly?: boolean);
  21525. /**
  21526. * Gets the current class name
  21527. * @returns the class name
  21528. */
  21529. getClassName(): string;
  21530. /**
  21531. * Gets the uv input component
  21532. */
  21533. get uv(): NodeMaterialConnectionPoint;
  21534. /**
  21535. * Gets the rgba output component
  21536. */
  21537. get rgba(): NodeMaterialConnectionPoint;
  21538. /**
  21539. * Gets the rgb output component
  21540. */
  21541. get rgb(): NodeMaterialConnectionPoint;
  21542. /**
  21543. * Gets the r output component
  21544. */
  21545. get r(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the g output component
  21548. */
  21549. get g(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the b output component
  21552. */
  21553. get b(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the a output component
  21556. */
  21557. get a(): NodeMaterialConnectionPoint;
  21558. get target(): NodeMaterialBlockTargets;
  21559. autoConfigure(material: NodeMaterial): void;
  21560. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21562. isReady(): boolean;
  21563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21564. private get _isMixed();
  21565. private _injectVertexCode;
  21566. private _writeTextureRead;
  21567. private _writeOutput;
  21568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21569. protected _dumpPropertiesCode(): string;
  21570. serialize(): any;
  21571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21572. }
  21573. }
  21574. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21575. /** @hidden */
  21576. export var reflectionFunction: {
  21577. name: string;
  21578. shader: string;
  21579. };
  21580. }
  21581. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21587. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21588. import { Effect } from "babylonjs/Materials/effect";
  21589. import { Mesh } from "babylonjs/Meshes/mesh";
  21590. import { Nullable } from "babylonjs/types";
  21591. import { Scene } from "babylonjs/scene";
  21592. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21593. /**
  21594. * Base block used to read a reflection texture from a sampler
  21595. */
  21596. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21597. /** @hidden */
  21598. _define3DName: string;
  21599. /** @hidden */
  21600. _defineCubicName: string;
  21601. /** @hidden */
  21602. _defineExplicitName: string;
  21603. /** @hidden */
  21604. _defineProjectionName: string;
  21605. /** @hidden */
  21606. _defineLocalCubicName: string;
  21607. /** @hidden */
  21608. _defineSphericalName: string;
  21609. /** @hidden */
  21610. _definePlanarName: string;
  21611. /** @hidden */
  21612. _defineEquirectangularName: string;
  21613. /** @hidden */
  21614. _defineMirroredEquirectangularFixedName: string;
  21615. /** @hidden */
  21616. _defineEquirectangularFixedName: string;
  21617. /** @hidden */
  21618. _defineSkyboxName: string;
  21619. /** @hidden */
  21620. _defineOppositeZ: string;
  21621. /** @hidden */
  21622. _cubeSamplerName: string;
  21623. /** @hidden */
  21624. _2DSamplerName: string;
  21625. protected _positionUVWName: string;
  21626. protected _directionWName: string;
  21627. protected _reflectionVectorName: string;
  21628. /** @hidden */
  21629. _reflectionCoordsName: string;
  21630. /** @hidden */
  21631. _reflectionMatrixName: string;
  21632. protected _reflectionColorName: string;
  21633. /**
  21634. * Gets or sets the texture associated with the node
  21635. */
  21636. texture: Nullable<BaseTexture>;
  21637. /**
  21638. * Create a new ReflectionTextureBaseBlock
  21639. * @param name defines the block name
  21640. */
  21641. constructor(name: string);
  21642. /**
  21643. * Gets the current class name
  21644. * @returns the class name
  21645. */
  21646. getClassName(): string;
  21647. /**
  21648. * Gets the world position input component
  21649. */
  21650. abstract get position(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the world position input component
  21653. */
  21654. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the world normal input component
  21657. */
  21658. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the world input component
  21661. */
  21662. abstract get world(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the camera (or eye) position component
  21665. */
  21666. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the view input component
  21669. */
  21670. abstract get view(): NodeMaterialConnectionPoint;
  21671. protected _getTexture(): Nullable<BaseTexture>;
  21672. autoConfigure(material: NodeMaterial): void;
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21674. isReady(): boolean;
  21675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21676. /**
  21677. * Gets the code to inject in the vertex shader
  21678. * @param state current state of the node material building
  21679. * @returns the shader code
  21680. */
  21681. handleVertexSide(state: NodeMaterialBuildState): string;
  21682. /**
  21683. * Handles the inits for the fragment code path
  21684. * @param state node material build state
  21685. */
  21686. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21687. /**
  21688. * Generates the reflection coords code for the fragment code path
  21689. * @param worldNormalVarName name of the world normal variable
  21690. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21691. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21692. * @returns the shader code
  21693. */
  21694. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21695. /**
  21696. * Generates the reflection color code for the fragment code path
  21697. * @param lodVarName name of the lod variable
  21698. * @param swizzleLookupTexture swizzle to use for the final color variable
  21699. * @returns the shader code
  21700. */
  21701. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21702. /**
  21703. * Generates the code corresponding to the connected output points
  21704. * @param state node material build state
  21705. * @param varName name of the variable to output
  21706. * @returns the shader code
  21707. */
  21708. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21709. protected _buildBlock(state: NodeMaterialBuildState): this;
  21710. protected _dumpPropertiesCode(): string;
  21711. serialize(): any;
  21712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21713. }
  21714. }
  21715. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21717. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21718. import { Nullable } from "babylonjs/types";
  21719. /**
  21720. * Defines a connection point to be used for points with a custom object type
  21721. */
  21722. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21723. private _blockType;
  21724. private _blockName;
  21725. private _nameForCheking?;
  21726. /**
  21727. * Creates a new connection point
  21728. * @param name defines the connection point name
  21729. * @param ownerBlock defines the block hosting this connection point
  21730. * @param direction defines the direction of the connection point
  21731. */
  21732. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21733. /**
  21734. * Gets a number indicating if the current point can be connected to another point
  21735. * @param connectionPoint defines the other connection point
  21736. * @returns a number defining the compatibility state
  21737. */
  21738. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21739. /**
  21740. * Creates a block suitable to be used as an input for this input point.
  21741. * If null is returned, a block based on the point type will be created.
  21742. * @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
  21743. */
  21744. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21745. }
  21746. }
  21747. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21748. /**
  21749. * Enum defining the type of properties that can be edited in the property pages in the NME
  21750. */
  21751. export enum PropertyTypeForEdition {
  21752. /** property is a boolean */
  21753. Boolean = 0,
  21754. /** property is a float */
  21755. Float = 1,
  21756. /** property is a Vector2 */
  21757. Vector2 = 2,
  21758. /** property is a list of values */
  21759. List = 3
  21760. }
  21761. /**
  21762. * Interface that defines an option in a variable of type list
  21763. */
  21764. export interface IEditablePropertyListOption {
  21765. /** label of the option */
  21766. "label": string;
  21767. /** value of the option */
  21768. "value": number;
  21769. }
  21770. /**
  21771. * Interface that defines the options available for an editable property
  21772. */
  21773. export interface IEditablePropertyOption {
  21774. /** min value */
  21775. "min"?: number;
  21776. /** max value */
  21777. "max"?: number;
  21778. /** notifiers: indicates which actions to take when the property is changed */
  21779. "notifiers"?: {
  21780. /** the material should be rebuilt */
  21781. "rebuild"?: boolean;
  21782. /** the preview should be updated */
  21783. "update"?: boolean;
  21784. };
  21785. /** list of the options for a variable of type list */
  21786. "options"?: IEditablePropertyListOption[];
  21787. }
  21788. /**
  21789. * Interface that describes an editable property
  21790. */
  21791. export interface IPropertyDescriptionForEdition {
  21792. /** name of the property */
  21793. "propertyName": string;
  21794. /** display name of the property */
  21795. "displayName": string;
  21796. /** type of the property */
  21797. "type": PropertyTypeForEdition;
  21798. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21799. "groupName": string;
  21800. /** options for the property */
  21801. "options": IEditablePropertyOption;
  21802. }
  21803. /**
  21804. * Decorator that flags a property in a node material block as being editable
  21805. */
  21806. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21807. }
  21808. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21811. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21813. import { Nullable } from "babylonjs/types";
  21814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21817. import { Effect } from "babylonjs/Materials/effect";
  21818. import { Scene } from "babylonjs/scene";
  21819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21820. /**
  21821. * Block used to implement the refraction part of the sub surface module of the PBR material
  21822. */
  21823. export class RefractionBlock extends NodeMaterialBlock {
  21824. /** @hidden */
  21825. _define3DName: string;
  21826. /** @hidden */
  21827. _refractionMatrixName: string;
  21828. /** @hidden */
  21829. _defineLODRefractionAlpha: string;
  21830. /** @hidden */
  21831. _defineLinearSpecularRefraction: string;
  21832. /** @hidden */
  21833. _defineOppositeZ: string;
  21834. /** @hidden */
  21835. _cubeSamplerName: string;
  21836. /** @hidden */
  21837. _2DSamplerName: string;
  21838. /** @hidden */
  21839. _vRefractionMicrosurfaceInfosName: string;
  21840. /** @hidden */
  21841. _vRefractionInfosName: string;
  21842. private _scene;
  21843. /**
  21844. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21845. * Materials half opaque for instance using refraction could benefit from this control.
  21846. */
  21847. linkRefractionWithTransparency: boolean;
  21848. /**
  21849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21850. */
  21851. invertRefractionY: boolean;
  21852. /**
  21853. * Gets or sets the texture associated with the node
  21854. */
  21855. texture: Nullable<BaseTexture>;
  21856. /**
  21857. * Create a new RefractionBlock
  21858. * @param name defines the block name
  21859. */
  21860. constructor(name: string);
  21861. /**
  21862. * Gets the current class name
  21863. * @returns the class name
  21864. */
  21865. getClassName(): string;
  21866. /**
  21867. * Gets the intensity input component
  21868. */
  21869. get intensity(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the index of refraction input component
  21872. */
  21873. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the tint at distance input component
  21876. */
  21877. get tintAtDistance(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the view input component
  21880. */
  21881. get view(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the refraction object output component
  21884. */
  21885. get refraction(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Returns true if the block has a texture
  21888. */
  21889. get hasTexture(): boolean;
  21890. protected _getTexture(): Nullable<BaseTexture>;
  21891. autoConfigure(material: NodeMaterial): void;
  21892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21893. isReady(): boolean;
  21894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21895. /**
  21896. * Gets the main code of the block (fragment side)
  21897. * @param state current state of the node material building
  21898. * @returns the shader code
  21899. */
  21900. getCode(state: NodeMaterialBuildState): string;
  21901. protected _buildBlock(state: NodeMaterialBuildState): this;
  21902. protected _dumpPropertiesCode(): string;
  21903. serialize(): any;
  21904. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21905. }
  21906. }
  21907. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21910. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21913. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21915. import { Nullable } from "babylonjs/types";
  21916. import { Scene } from "babylonjs/scene";
  21917. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21918. /**
  21919. * Base block used as input for post process
  21920. */
  21921. export class CurrentScreenBlock extends NodeMaterialBlock {
  21922. private _samplerName;
  21923. private _linearDefineName;
  21924. private _gammaDefineName;
  21925. private _mainUVName;
  21926. private _tempTextureRead;
  21927. /**
  21928. * Gets or sets the texture associated with the node
  21929. */
  21930. texture: Nullable<BaseTexture>;
  21931. /**
  21932. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21933. */
  21934. convertToGammaSpace: boolean;
  21935. /**
  21936. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21937. */
  21938. convertToLinearSpace: boolean;
  21939. /**
  21940. * Create a new CurrentScreenBlock
  21941. * @param name defines the block name
  21942. */
  21943. constructor(name: string);
  21944. /**
  21945. * Gets the current class name
  21946. * @returns the class name
  21947. */
  21948. getClassName(): string;
  21949. /**
  21950. * Gets the uv input component
  21951. */
  21952. get uv(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Gets the rgba output component
  21955. */
  21956. get rgba(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the rgb output component
  21959. */
  21960. get rgb(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the r output component
  21963. */
  21964. get r(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the g output component
  21967. */
  21968. get g(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the b output component
  21971. */
  21972. get b(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the a output component
  21975. */
  21976. get a(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Initialize the block and prepare the context for build
  21979. * @param state defines the state that will be used for the build
  21980. */
  21981. initialize(state: NodeMaterialBuildState): void;
  21982. get target(): NodeMaterialBlockTargets;
  21983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21984. isReady(): boolean;
  21985. private _injectVertexCode;
  21986. private _writeTextureRead;
  21987. private _writeOutput;
  21988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21989. serialize(): any;
  21990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21991. }
  21992. }
  21993. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21998. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22000. import { Nullable } from "babylonjs/types";
  22001. import { Scene } from "babylonjs/scene";
  22002. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22003. /**
  22004. * Base block used for the particle texture
  22005. */
  22006. export class ParticleTextureBlock extends NodeMaterialBlock {
  22007. private _samplerName;
  22008. private _linearDefineName;
  22009. private _gammaDefineName;
  22010. private _tempTextureRead;
  22011. /**
  22012. * Gets or sets the texture associated with the node
  22013. */
  22014. texture: Nullable<BaseTexture>;
  22015. /**
  22016. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22017. */
  22018. convertToGammaSpace: boolean;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22021. */
  22022. convertToLinearSpace: boolean;
  22023. /**
  22024. * Create a new ParticleTextureBlock
  22025. * @param name defines the block name
  22026. */
  22027. constructor(name: string);
  22028. /**
  22029. * Gets the current class name
  22030. * @returns the class name
  22031. */
  22032. getClassName(): string;
  22033. /**
  22034. * Gets the uv input component
  22035. */
  22036. get uv(): NodeMaterialConnectionPoint;
  22037. /**
  22038. * Gets the rgba output component
  22039. */
  22040. get rgba(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgb output component
  22043. */
  22044. get rgb(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the r output component
  22047. */
  22048. get r(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the g output component
  22051. */
  22052. get g(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the b output component
  22055. */
  22056. get b(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the a output component
  22059. */
  22060. get a(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Initialize the block and prepare the context for build
  22063. * @param state defines the state that will be used for the build
  22064. */
  22065. initialize(state: NodeMaterialBuildState): void;
  22066. autoConfigure(material: NodeMaterial): void;
  22067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22068. isReady(): boolean;
  22069. private _writeOutput;
  22070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22071. serialize(): any;
  22072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22073. }
  22074. }
  22075. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22078. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22079. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22080. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22081. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22082. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22083. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22084. import { Scene } from "babylonjs/scene";
  22085. /**
  22086. * Class used to store shared data between 2 NodeMaterialBuildState
  22087. */
  22088. export class NodeMaterialBuildStateSharedData {
  22089. /**
  22090. * Gets the list of emitted varyings
  22091. */
  22092. temps: string[];
  22093. /**
  22094. * Gets the list of emitted varyings
  22095. */
  22096. varyings: string[];
  22097. /**
  22098. * Gets the varying declaration string
  22099. */
  22100. varyingDeclaration: string;
  22101. /**
  22102. * Input blocks
  22103. */
  22104. inputBlocks: InputBlock[];
  22105. /**
  22106. * Input blocks
  22107. */
  22108. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22109. /**
  22110. * Bindable blocks (Blocks that need to set data to the effect)
  22111. */
  22112. bindableBlocks: NodeMaterialBlock[];
  22113. /**
  22114. * List of blocks that can provide a compilation fallback
  22115. */
  22116. blocksWithFallbacks: NodeMaterialBlock[];
  22117. /**
  22118. * List of blocks that can provide a define update
  22119. */
  22120. blocksWithDefines: NodeMaterialBlock[];
  22121. /**
  22122. * List of blocks that can provide a repeatable content
  22123. */
  22124. repeatableContentBlocks: NodeMaterialBlock[];
  22125. /**
  22126. * List of blocks that can provide a dynamic list of uniforms
  22127. */
  22128. dynamicUniformBlocks: NodeMaterialBlock[];
  22129. /**
  22130. * List of blocks that can block the isReady function for the material
  22131. */
  22132. blockingBlocks: NodeMaterialBlock[];
  22133. /**
  22134. * Gets the list of animated inputs
  22135. */
  22136. animatedInputs: InputBlock[];
  22137. /**
  22138. * Build Id used to avoid multiple recompilations
  22139. */
  22140. buildId: number;
  22141. /** List of emitted variables */
  22142. variableNames: {
  22143. [key: string]: number;
  22144. };
  22145. /** List of emitted defines */
  22146. defineNames: {
  22147. [key: string]: number;
  22148. };
  22149. /** Should emit comments? */
  22150. emitComments: boolean;
  22151. /** Emit build activity */
  22152. verbose: boolean;
  22153. /** Gets or sets the hosting scene */
  22154. scene: Scene;
  22155. /**
  22156. * Gets the compilation hints emitted at compilation time
  22157. */
  22158. hints: {
  22159. needWorldViewMatrix: boolean;
  22160. needWorldViewProjectionMatrix: boolean;
  22161. needAlphaBlending: boolean;
  22162. needAlphaTesting: boolean;
  22163. };
  22164. /**
  22165. * List of compilation checks
  22166. */
  22167. checks: {
  22168. emitVertex: boolean;
  22169. emitFragment: boolean;
  22170. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22171. };
  22172. /**
  22173. * Is vertex program allowed to be empty?
  22174. */
  22175. allowEmptyVertexProgram: boolean;
  22176. /** Creates a new shared data */
  22177. constructor();
  22178. /**
  22179. * Emits console errors and exceptions if there is a failing check
  22180. */
  22181. emitErrors(): void;
  22182. }
  22183. }
  22184. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22185. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22187. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22188. /**
  22189. * Class used to store node based material build state
  22190. */
  22191. export class NodeMaterialBuildState {
  22192. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22193. supportUniformBuffers: boolean;
  22194. /**
  22195. * Gets the list of emitted attributes
  22196. */
  22197. attributes: string[];
  22198. /**
  22199. * Gets the list of emitted uniforms
  22200. */
  22201. uniforms: string[];
  22202. /**
  22203. * Gets the list of emitted constants
  22204. */
  22205. constants: string[];
  22206. /**
  22207. * Gets the list of emitted samplers
  22208. */
  22209. samplers: string[];
  22210. /**
  22211. * Gets the list of emitted functions
  22212. */
  22213. functions: {
  22214. [key: string]: string;
  22215. };
  22216. /**
  22217. * Gets the list of emitted extensions
  22218. */
  22219. extensions: {
  22220. [key: string]: string;
  22221. };
  22222. /**
  22223. * Gets the target of the compilation state
  22224. */
  22225. target: NodeMaterialBlockTargets;
  22226. /**
  22227. * Gets the list of emitted counters
  22228. */
  22229. counters: {
  22230. [key: string]: number;
  22231. };
  22232. /**
  22233. * Shared data between multiple NodeMaterialBuildState instances
  22234. */
  22235. sharedData: NodeMaterialBuildStateSharedData;
  22236. /** @hidden */
  22237. _vertexState: NodeMaterialBuildState;
  22238. /** @hidden */
  22239. _attributeDeclaration: string;
  22240. /** @hidden */
  22241. _uniformDeclaration: string;
  22242. /** @hidden */
  22243. _constantDeclaration: string;
  22244. /** @hidden */
  22245. _samplerDeclaration: string;
  22246. /** @hidden */
  22247. _varyingTransfer: string;
  22248. /** @hidden */
  22249. _injectAtEnd: string;
  22250. private _repeatableContentAnchorIndex;
  22251. /** @hidden */
  22252. _builtCompilationString: string;
  22253. /**
  22254. * Gets the emitted compilation strings
  22255. */
  22256. compilationString: string;
  22257. /**
  22258. * Finalize the compilation strings
  22259. * @param state defines the current compilation state
  22260. */
  22261. finalize(state: NodeMaterialBuildState): void;
  22262. /** @hidden */
  22263. get _repeatableContentAnchor(): string;
  22264. /** @hidden */
  22265. _getFreeVariableName(prefix: string): string;
  22266. /** @hidden */
  22267. _getFreeDefineName(prefix: string): string;
  22268. /** @hidden */
  22269. _excludeVariableName(name: string): void;
  22270. /** @hidden */
  22271. _emit2DSampler(name: string): void;
  22272. /** @hidden */
  22273. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22274. /** @hidden */
  22275. _emitExtension(name: string, extension: string, define?: string): void;
  22276. /** @hidden */
  22277. _emitFunction(name: string, code: string, comments: string): void;
  22278. /** @hidden */
  22279. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22280. replaceStrings?: {
  22281. search: RegExp;
  22282. replace: string;
  22283. }[];
  22284. repeatKey?: string;
  22285. }): string;
  22286. /** @hidden */
  22287. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22288. repeatKey?: string;
  22289. removeAttributes?: boolean;
  22290. removeUniforms?: boolean;
  22291. removeVaryings?: boolean;
  22292. removeIfDef?: boolean;
  22293. replaceStrings?: {
  22294. search: RegExp;
  22295. replace: string;
  22296. }[];
  22297. }, storeKey?: string): void;
  22298. /** @hidden */
  22299. _registerTempVariable(name: string): boolean;
  22300. /** @hidden */
  22301. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22302. /** @hidden */
  22303. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22304. /** @hidden */
  22305. _emitFloat(value: number): string;
  22306. }
  22307. }
  22308. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22309. /**
  22310. * Helper class used to generate session unique ID
  22311. */
  22312. export class UniqueIdGenerator {
  22313. private static _UniqueIdCounter;
  22314. /**
  22315. * Gets an unique (relatively to the current scene) Id
  22316. */
  22317. static get UniqueId(): number;
  22318. }
  22319. }
  22320. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22321. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22323. import { Nullable } from "babylonjs/types";
  22324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22325. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22326. import { Effect } from "babylonjs/Materials/effect";
  22327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22328. import { Mesh } from "babylonjs/Meshes/mesh";
  22329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22330. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22331. import { Scene } from "babylonjs/scene";
  22332. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22333. /**
  22334. * Defines a block that can be used inside a node based material
  22335. */
  22336. export class NodeMaterialBlock {
  22337. private _buildId;
  22338. private _buildTarget;
  22339. private _target;
  22340. private _isFinalMerger;
  22341. private _isInput;
  22342. private _name;
  22343. protected _isUnique: boolean;
  22344. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22345. inputsAreExclusive: boolean;
  22346. /** @hidden */
  22347. _codeVariableName: string;
  22348. /** @hidden */
  22349. _inputs: NodeMaterialConnectionPoint[];
  22350. /** @hidden */
  22351. _outputs: NodeMaterialConnectionPoint[];
  22352. /** @hidden */
  22353. _preparationId: number;
  22354. /**
  22355. * Gets the name of the block
  22356. */
  22357. get name(): string;
  22358. /**
  22359. * Sets the name of the block. Will check if the name is valid.
  22360. */
  22361. set name(newName: string);
  22362. /**
  22363. * Gets or sets the unique id of the node
  22364. */
  22365. uniqueId: number;
  22366. /**
  22367. * Gets or sets the comments associated with this block
  22368. */
  22369. comments: string;
  22370. /**
  22371. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22372. */
  22373. get isUnique(): boolean;
  22374. /**
  22375. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22376. */
  22377. get isFinalMerger(): boolean;
  22378. /**
  22379. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22380. */
  22381. get isInput(): boolean;
  22382. /**
  22383. * Gets or sets the build Id
  22384. */
  22385. get buildId(): number;
  22386. set buildId(value: number);
  22387. /**
  22388. * Gets or sets the target of the block
  22389. */
  22390. get target(): NodeMaterialBlockTargets;
  22391. set target(value: NodeMaterialBlockTargets);
  22392. /**
  22393. * Gets the list of input points
  22394. */
  22395. get inputs(): NodeMaterialConnectionPoint[];
  22396. /** Gets the list of output points */
  22397. get outputs(): NodeMaterialConnectionPoint[];
  22398. /**
  22399. * Find an input by its name
  22400. * @param name defines the name of the input to look for
  22401. * @returns the input or null if not found
  22402. */
  22403. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22404. /**
  22405. * Find an output by its name
  22406. * @param name defines the name of the outputto look for
  22407. * @returns the output or null if not found
  22408. */
  22409. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22410. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22411. visibleInInspector: boolean;
  22412. /**
  22413. * Creates a new NodeMaterialBlock
  22414. * @param name defines the block name
  22415. * @param target defines the target of that block (Vertex by default)
  22416. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22417. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22418. */
  22419. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22420. /**
  22421. * Initialize the block and prepare the context for build
  22422. * @param state defines the state that will be used for the build
  22423. */
  22424. initialize(state: NodeMaterialBuildState): void;
  22425. /**
  22426. * Bind data to effect. Will only be called for blocks with isBindable === true
  22427. * @param effect defines the effect to bind data to
  22428. * @param nodeMaterial defines the hosting NodeMaterial
  22429. * @param mesh defines the mesh that will be rendered
  22430. * @param subMesh defines the submesh that will be rendered
  22431. */
  22432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22433. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22434. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22435. protected _writeFloat(value: number): string;
  22436. /**
  22437. * Gets the current class name e.g. "NodeMaterialBlock"
  22438. * @returns the class name
  22439. */
  22440. getClassName(): string;
  22441. /**
  22442. * Register a new input. Must be called inside a block constructor
  22443. * @param name defines the connection point name
  22444. * @param type defines the connection point type
  22445. * @param isOptional defines a boolean indicating that this input can be omitted
  22446. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22447. * @param point an already created connection point. If not provided, create a new one
  22448. * @returns the current block
  22449. */
  22450. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22451. /**
  22452. * Register a new output. Must be called inside a block constructor
  22453. * @param name defines the connection point name
  22454. * @param type defines the connection point type
  22455. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22456. * @param point an already created connection point. If not provided, create a new one
  22457. * @returns the current block
  22458. */
  22459. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22460. /**
  22461. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22462. * @param forOutput defines an optional connection point to check compatibility with
  22463. * @returns the first available input or null
  22464. */
  22465. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22466. /**
  22467. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22468. * @param forBlock defines an optional block to check compatibility with
  22469. * @returns the first available input or null
  22470. */
  22471. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22472. /**
  22473. * Gets the sibling of the given output
  22474. * @param current defines the current output
  22475. * @returns the next output in the list or null
  22476. */
  22477. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22478. /**
  22479. * Connect current block with another block
  22480. * @param other defines the block to connect with
  22481. * @param options define the various options to help pick the right connections
  22482. * @returns the current block
  22483. */
  22484. connectTo(other: NodeMaterialBlock, options?: {
  22485. input?: string;
  22486. output?: string;
  22487. outputSwizzle?: string;
  22488. }): this | undefined;
  22489. protected _buildBlock(state: NodeMaterialBuildState): void;
  22490. /**
  22491. * Add uniforms, samplers and uniform buffers at compilation time
  22492. * @param state defines the state to update
  22493. * @param nodeMaterial defines the node material requesting the update
  22494. * @param defines defines the material defines to update
  22495. * @param uniformBuffers defines the list of uniform buffer names
  22496. */
  22497. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22498. /**
  22499. * Add potential fallbacks if shader compilation fails
  22500. * @param mesh defines the mesh to be rendered
  22501. * @param fallbacks defines the current prioritized list of fallbacks
  22502. */
  22503. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22504. /**
  22505. * Initialize defines for shader compilation
  22506. * @param mesh defines the mesh to be rendered
  22507. * @param nodeMaterial defines the node material requesting the update
  22508. * @param defines defines the material defines to update
  22509. * @param useInstances specifies that instances should be used
  22510. */
  22511. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22512. /**
  22513. * Update defines for shader compilation
  22514. * @param mesh defines the mesh to be rendered
  22515. * @param nodeMaterial defines the node material requesting the update
  22516. * @param defines defines the material defines to update
  22517. * @param useInstances specifies that instances should be used
  22518. * @param subMesh defines which submesh to render
  22519. */
  22520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22521. /**
  22522. * Lets the block try to connect some inputs automatically
  22523. * @param material defines the hosting NodeMaterial
  22524. */
  22525. autoConfigure(material: NodeMaterial): void;
  22526. /**
  22527. * Function called when a block is declared as repeatable content generator
  22528. * @param vertexShaderState defines the current compilation state for the vertex shader
  22529. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22530. * @param mesh defines the mesh to be rendered
  22531. * @param defines defines the material defines to update
  22532. */
  22533. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22534. /**
  22535. * Checks if the block is ready
  22536. * @param mesh defines the mesh to be rendered
  22537. * @param nodeMaterial defines the node material requesting the update
  22538. * @param defines defines the material defines to update
  22539. * @param useInstances specifies that instances should be used
  22540. * @returns true if the block is ready
  22541. */
  22542. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22543. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22544. private _processBuild;
  22545. /**
  22546. * Validates the new name for the block node.
  22547. * @param newName the new name to be given to the node.
  22548. * @returns false if the name is a reserve word, else true.
  22549. */
  22550. validateBlockName(newName: string): boolean;
  22551. /**
  22552. * Compile the current node and generate the shader code
  22553. * @param state defines the current compilation state (uniforms, samplers, current string)
  22554. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22555. * @returns true if already built
  22556. */
  22557. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22558. protected _inputRename(name: string): string;
  22559. protected _outputRename(name: string): string;
  22560. protected _dumpPropertiesCode(): string;
  22561. /** @hidden */
  22562. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22563. /** @hidden */
  22564. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22565. /**
  22566. * Clone the current block to a new identical block
  22567. * @param scene defines the hosting scene
  22568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22569. * @returns a copy of the current block
  22570. */
  22571. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22572. /**
  22573. * Serializes this block in a JSON representation
  22574. * @returns the serialized block object
  22575. */
  22576. serialize(): any;
  22577. /** @hidden */
  22578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22579. private _deserializePortDisplayNamesAndExposedOnFrame;
  22580. /**
  22581. * Release resources
  22582. */
  22583. dispose(): void;
  22584. }
  22585. }
  22586. declare module "babylonjs/Materials/pushMaterial" {
  22587. import { Nullable } from "babylonjs/types";
  22588. import { Scene } from "babylonjs/scene";
  22589. import { Matrix } from "babylonjs/Maths/math.vector";
  22590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22591. import { Mesh } from "babylonjs/Meshes/mesh";
  22592. import { Material } from "babylonjs/Materials/material";
  22593. import { Effect } from "babylonjs/Materials/effect";
  22594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22595. /**
  22596. * Base class of materials working in push mode in babylon JS
  22597. * @hidden
  22598. */
  22599. export class PushMaterial extends Material {
  22600. protected _activeEffect: Effect;
  22601. protected _normalMatrix: Matrix;
  22602. constructor(name: string, scene: Scene);
  22603. getEffect(): Effect;
  22604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22605. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22606. /**
  22607. * Binds the given world matrix to the active effect
  22608. *
  22609. * @param world the matrix to bind
  22610. */
  22611. bindOnlyWorldMatrix(world: Matrix): void;
  22612. /**
  22613. * Binds the given normal matrix to the active effect
  22614. *
  22615. * @param normalMatrix the matrix to bind
  22616. */
  22617. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22618. bind(world: Matrix, mesh?: Mesh): void;
  22619. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22620. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22621. }
  22622. }
  22623. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22625. /**
  22626. * Root class for all node material optimizers
  22627. */
  22628. export class NodeMaterialOptimizer {
  22629. /**
  22630. * Function used to optimize a NodeMaterial graph
  22631. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22632. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22633. */
  22634. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22635. }
  22636. }
  22637. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22641. import { Scene } from "babylonjs/scene";
  22642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22644. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22645. /**
  22646. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22647. */
  22648. export class TransformBlock extends NodeMaterialBlock {
  22649. /**
  22650. * Defines the value to use to complement W value to transform it to a Vector4
  22651. */
  22652. complementW: number;
  22653. /**
  22654. * Defines the value to use to complement z value to transform it to a Vector4
  22655. */
  22656. complementZ: number;
  22657. /**
  22658. * Creates a new TransformBlock
  22659. * @param name defines the block name
  22660. */
  22661. constructor(name: string);
  22662. /**
  22663. * Gets the current class name
  22664. * @returns the class name
  22665. */
  22666. getClassName(): string;
  22667. /**
  22668. * Gets the vector input
  22669. */
  22670. get vector(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the output component
  22673. */
  22674. get output(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the xyz output component
  22677. */
  22678. get xyz(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the matrix transform input
  22681. */
  22682. get transform(): NodeMaterialConnectionPoint;
  22683. protected _buildBlock(state: NodeMaterialBuildState): this;
  22684. /**
  22685. * Update defines for shader compilation
  22686. * @param mesh defines the mesh to be rendered
  22687. * @param nodeMaterial defines the node material requesting the update
  22688. * @param defines defines the material defines to update
  22689. * @param useInstances specifies that instances should be used
  22690. * @param subMesh defines which submesh to render
  22691. */
  22692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22693. serialize(): any;
  22694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22695. protected _dumpPropertiesCode(): string;
  22696. }
  22697. }
  22698. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22702. /**
  22703. * Block used to output the vertex position
  22704. */
  22705. export class VertexOutputBlock extends NodeMaterialBlock {
  22706. /**
  22707. * Creates a new VertexOutputBlock
  22708. * @param name defines the block name
  22709. */
  22710. constructor(name: string);
  22711. /**
  22712. * Gets the current class name
  22713. * @returns the class name
  22714. */
  22715. getClassName(): string;
  22716. /**
  22717. * Gets the vector input component
  22718. */
  22719. get vector(): NodeMaterialConnectionPoint;
  22720. protected _buildBlock(state: NodeMaterialBuildState): this;
  22721. }
  22722. }
  22723. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22727. /**
  22728. * Block used to output the final color
  22729. */
  22730. export class FragmentOutputBlock extends NodeMaterialBlock {
  22731. /**
  22732. * Create a new FragmentOutputBlock
  22733. * @param name defines the block name
  22734. */
  22735. constructor(name: string);
  22736. /**
  22737. * Gets the current class name
  22738. * @returns the class name
  22739. */
  22740. getClassName(): string;
  22741. /**
  22742. * Gets the rgba input component
  22743. */
  22744. get rgba(): NodeMaterialConnectionPoint;
  22745. /**
  22746. * Gets the rgb input component
  22747. */
  22748. get rgb(): NodeMaterialConnectionPoint;
  22749. /**
  22750. * Gets the a input component
  22751. */
  22752. get a(): NodeMaterialConnectionPoint;
  22753. protected _buildBlock(state: NodeMaterialBuildState): this;
  22754. }
  22755. }
  22756. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22760. /**
  22761. * Block used for the particle ramp gradient section
  22762. */
  22763. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22764. /**
  22765. * Create a new ParticleRampGradientBlock
  22766. * @param name defines the block name
  22767. */
  22768. constructor(name: string);
  22769. /**
  22770. * Gets the current class name
  22771. * @returns the class name
  22772. */
  22773. getClassName(): string;
  22774. /**
  22775. * Gets the color input component
  22776. */
  22777. get color(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the rampColor output component
  22780. */
  22781. get rampColor(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Initialize the block and prepare the context for build
  22784. * @param state defines the state that will be used for the build
  22785. */
  22786. initialize(state: NodeMaterialBuildState): void;
  22787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22788. }
  22789. }
  22790. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22794. /**
  22795. * Block used for the particle blend multiply section
  22796. */
  22797. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22798. /**
  22799. * Create a new ParticleBlendMultiplyBlock
  22800. * @param name defines the block name
  22801. */
  22802. constructor(name: string);
  22803. /**
  22804. * Gets the current class name
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Gets the color input component
  22810. */
  22811. get color(): NodeMaterialConnectionPoint;
  22812. /**
  22813. * Gets the alphaTexture input component
  22814. */
  22815. get alphaTexture(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the alphaColor input component
  22818. */
  22819. get alphaColor(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the blendColor output component
  22822. */
  22823. get blendColor(): NodeMaterialConnectionPoint;
  22824. /**
  22825. * Initialize the block and prepare the context for build
  22826. * @param state defines the state that will be used for the build
  22827. */
  22828. initialize(state: NodeMaterialBuildState): void;
  22829. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22830. }
  22831. }
  22832. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22836. /**
  22837. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22838. */
  22839. export class VectorMergerBlock extends NodeMaterialBlock {
  22840. /**
  22841. * Create a new VectorMergerBlock
  22842. * @param name defines the block name
  22843. */
  22844. constructor(name: string);
  22845. /**
  22846. * Gets the current class name
  22847. * @returns the class name
  22848. */
  22849. getClassName(): string;
  22850. /**
  22851. * Gets the xyz component (input)
  22852. */
  22853. get xyzIn(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the xy component (input)
  22856. */
  22857. get xyIn(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the x component (input)
  22860. */
  22861. get x(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the y component (input)
  22864. */
  22865. get y(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the z component (input)
  22868. */
  22869. get z(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the w component (input)
  22872. */
  22873. get w(): NodeMaterialConnectionPoint;
  22874. /**
  22875. * Gets the xyzw component (output)
  22876. */
  22877. get xyzw(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the xyz component (output)
  22880. */
  22881. get xyzOut(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the xy component (output)
  22884. */
  22885. get xyOut(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the xy component (output)
  22888. * @deprecated Please use xyOut instead.
  22889. */
  22890. get xy(): NodeMaterialConnectionPoint;
  22891. /**
  22892. * Gets the xyz component (output)
  22893. * @deprecated Please use xyzOut instead.
  22894. */
  22895. get xyz(): NodeMaterialConnectionPoint;
  22896. protected _buildBlock(state: NodeMaterialBuildState): this;
  22897. }
  22898. }
  22899. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22903. import { Vector2 } from "babylonjs/Maths/math.vector";
  22904. import { Scene } from "babylonjs/scene";
  22905. /**
  22906. * Block used to remap a float from a range to a new one
  22907. */
  22908. export class RemapBlock extends NodeMaterialBlock {
  22909. /**
  22910. * Gets or sets the source range
  22911. */
  22912. sourceRange: Vector2;
  22913. /**
  22914. * Gets or sets the target range
  22915. */
  22916. targetRange: Vector2;
  22917. /**
  22918. * Creates a new RemapBlock
  22919. * @param name defines the block name
  22920. */
  22921. constructor(name: string);
  22922. /**
  22923. * Gets the current class name
  22924. * @returns the class name
  22925. */
  22926. getClassName(): string;
  22927. /**
  22928. * Gets the input component
  22929. */
  22930. get input(): NodeMaterialConnectionPoint;
  22931. /**
  22932. * Gets the source min input component
  22933. */
  22934. get sourceMin(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the source max input component
  22937. */
  22938. get sourceMax(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the target min input component
  22941. */
  22942. get targetMin(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the target max input component
  22945. */
  22946. get targetMax(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the output component
  22949. */
  22950. get output(): NodeMaterialConnectionPoint;
  22951. protected _buildBlock(state: NodeMaterialBuildState): this;
  22952. protected _dumpPropertiesCode(): string;
  22953. serialize(): any;
  22954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22955. }
  22956. }
  22957. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22961. /**
  22962. * Block used to multiply 2 values
  22963. */
  22964. export class MultiplyBlock extends NodeMaterialBlock {
  22965. /**
  22966. * Creates a new MultiplyBlock
  22967. * @param name defines the block name
  22968. */
  22969. constructor(name: string);
  22970. /**
  22971. * Gets the current class name
  22972. * @returns the class name
  22973. */
  22974. getClassName(): string;
  22975. /**
  22976. * Gets the left operand input component
  22977. */
  22978. get left(): NodeMaterialConnectionPoint;
  22979. /**
  22980. * Gets the right operand input component
  22981. */
  22982. get right(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the output component
  22985. */
  22986. get output(): NodeMaterialConnectionPoint;
  22987. protected _buildBlock(state: NodeMaterialBuildState): this;
  22988. }
  22989. }
  22990. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22994. /**
  22995. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22996. */
  22997. export class ColorSplitterBlock extends NodeMaterialBlock {
  22998. /**
  22999. * Create a new ColorSplitterBlock
  23000. * @param name defines the block name
  23001. */
  23002. constructor(name: string);
  23003. /**
  23004. * Gets the current class name
  23005. * @returns the class name
  23006. */
  23007. getClassName(): string;
  23008. /**
  23009. * Gets the rgba component (input)
  23010. */
  23011. get rgba(): NodeMaterialConnectionPoint;
  23012. /**
  23013. * Gets the rgb component (input)
  23014. */
  23015. get rgbIn(): NodeMaterialConnectionPoint;
  23016. /**
  23017. * Gets the rgb component (output)
  23018. */
  23019. get rgbOut(): NodeMaterialConnectionPoint;
  23020. /**
  23021. * Gets the r component (output)
  23022. */
  23023. get r(): NodeMaterialConnectionPoint;
  23024. /**
  23025. * Gets the g component (output)
  23026. */
  23027. get g(): NodeMaterialConnectionPoint;
  23028. /**
  23029. * Gets the b component (output)
  23030. */
  23031. get b(): NodeMaterialConnectionPoint;
  23032. /**
  23033. * Gets the a component (output)
  23034. */
  23035. get a(): NodeMaterialConnectionPoint;
  23036. protected _inputRename(name: string): string;
  23037. protected _outputRename(name: string): string;
  23038. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23039. }
  23040. }
  23041. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23045. import { Scene } from "babylonjs/scene";
  23046. /**
  23047. * Operations supported by the Trigonometry block
  23048. */
  23049. export enum TrigonometryBlockOperations {
  23050. /** Cos */
  23051. Cos = 0,
  23052. /** Sin */
  23053. Sin = 1,
  23054. /** Abs */
  23055. Abs = 2,
  23056. /** Exp */
  23057. Exp = 3,
  23058. /** Exp2 */
  23059. Exp2 = 4,
  23060. /** Round */
  23061. Round = 5,
  23062. /** Floor */
  23063. Floor = 6,
  23064. /** Ceiling */
  23065. Ceiling = 7,
  23066. /** Square root */
  23067. Sqrt = 8,
  23068. /** Log */
  23069. Log = 9,
  23070. /** Tangent */
  23071. Tan = 10,
  23072. /** Arc tangent */
  23073. ArcTan = 11,
  23074. /** Arc cosinus */
  23075. ArcCos = 12,
  23076. /** Arc sinus */
  23077. ArcSin = 13,
  23078. /** Fraction */
  23079. Fract = 14,
  23080. /** Sign */
  23081. Sign = 15,
  23082. /** To radians (from degrees) */
  23083. Radians = 16,
  23084. /** To degrees (from radians) */
  23085. Degrees = 17
  23086. }
  23087. /**
  23088. * Block used to apply trigonometry operation to floats
  23089. */
  23090. export class TrigonometryBlock extends NodeMaterialBlock {
  23091. /**
  23092. * Gets or sets the operation applied by the block
  23093. */
  23094. operation: TrigonometryBlockOperations;
  23095. /**
  23096. * Creates a new TrigonometryBlock
  23097. * @param name defines the block name
  23098. */
  23099. constructor(name: string);
  23100. /**
  23101. * Gets the current class name
  23102. * @returns the class name
  23103. */
  23104. getClassName(): string;
  23105. /**
  23106. * Gets the input component
  23107. */
  23108. get input(): NodeMaterialConnectionPoint;
  23109. /**
  23110. * Gets the output component
  23111. */
  23112. get output(): NodeMaterialConnectionPoint;
  23113. protected _buildBlock(state: NodeMaterialBuildState): this;
  23114. serialize(): any;
  23115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23116. protected _dumpPropertiesCode(): string;
  23117. }
  23118. }
  23119. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23121. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23122. import { Scene } from "babylonjs/scene";
  23123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23124. import { Matrix } from "babylonjs/Maths/math.vector";
  23125. import { Mesh } from "babylonjs/Meshes/mesh";
  23126. import { Engine } from "babylonjs/Engines/engine";
  23127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23128. import { Observable } from "babylonjs/Misc/observable";
  23129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23130. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23131. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23132. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23133. import { Nullable } from "babylonjs/types";
  23134. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23135. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23136. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23137. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23138. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23139. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23140. import { Effect } from "babylonjs/Materials/effect";
  23141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23142. import { Camera } from "babylonjs/Cameras/camera";
  23143. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23145. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23146. /**
  23147. * Interface used to configure the node material editor
  23148. */
  23149. export interface INodeMaterialEditorOptions {
  23150. /** Define the URl to load node editor script */
  23151. editorURL?: string;
  23152. }
  23153. /** @hidden */
  23154. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23155. NORMAL: boolean;
  23156. TANGENT: boolean;
  23157. UV1: boolean;
  23158. /** BONES */
  23159. NUM_BONE_INFLUENCERS: number;
  23160. BonesPerMesh: number;
  23161. BONETEXTURE: boolean;
  23162. /** MORPH TARGETS */
  23163. MORPHTARGETS: boolean;
  23164. MORPHTARGETS_NORMAL: boolean;
  23165. MORPHTARGETS_TANGENT: boolean;
  23166. MORPHTARGETS_UV: boolean;
  23167. NUM_MORPH_INFLUENCERS: number;
  23168. /** IMAGE PROCESSING */
  23169. IMAGEPROCESSING: boolean;
  23170. VIGNETTE: boolean;
  23171. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23172. VIGNETTEBLENDMODEOPAQUE: boolean;
  23173. TONEMAPPING: boolean;
  23174. TONEMAPPING_ACES: boolean;
  23175. CONTRAST: boolean;
  23176. EXPOSURE: boolean;
  23177. COLORCURVES: boolean;
  23178. COLORGRADING: boolean;
  23179. COLORGRADING3D: boolean;
  23180. SAMPLER3DGREENDEPTH: boolean;
  23181. SAMPLER3DBGRMAP: boolean;
  23182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23183. /** MISC. */
  23184. BUMPDIRECTUV: number;
  23185. constructor();
  23186. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23187. }
  23188. /**
  23189. * Class used to configure NodeMaterial
  23190. */
  23191. export interface INodeMaterialOptions {
  23192. /**
  23193. * Defines if blocks should emit comments
  23194. */
  23195. emitComments: boolean;
  23196. }
  23197. /**
  23198. * Class used to create a node based material built by assembling shader blocks
  23199. */
  23200. export class NodeMaterial extends PushMaterial {
  23201. private static _BuildIdGenerator;
  23202. private _options;
  23203. private _vertexCompilationState;
  23204. private _fragmentCompilationState;
  23205. private _sharedData;
  23206. private _buildId;
  23207. private _buildWasSuccessful;
  23208. private _cachedWorldViewMatrix;
  23209. private _cachedWorldViewProjectionMatrix;
  23210. private _optimizers;
  23211. private _animationFrame;
  23212. /** Define the Url to load node editor script */
  23213. static EditorURL: string;
  23214. /** Define the Url to load snippets */
  23215. static SnippetUrl: string;
  23216. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23217. static IgnoreTexturesAtLoadTime: boolean;
  23218. private BJSNODEMATERIALEDITOR;
  23219. /** Get the inspector from bundle or global */
  23220. private _getGlobalNodeMaterialEditor;
  23221. /**
  23222. * Snippet ID if the material was created from the snippet server
  23223. */
  23224. snippetId: string;
  23225. /**
  23226. * Gets or sets data used by visual editor
  23227. * @see https://nme.babylonjs.com
  23228. */
  23229. editorData: any;
  23230. /**
  23231. * 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)
  23232. */
  23233. ignoreAlpha: boolean;
  23234. /**
  23235. * Defines the maximum number of lights that can be used in the material
  23236. */
  23237. maxSimultaneousLights: number;
  23238. /**
  23239. * Observable raised when the material is built
  23240. */
  23241. onBuildObservable: Observable<NodeMaterial>;
  23242. /**
  23243. * Gets or sets the root nodes of the material vertex shader
  23244. */
  23245. _vertexOutputNodes: NodeMaterialBlock[];
  23246. /**
  23247. * Gets or sets the root nodes of the material fragment (pixel) shader
  23248. */
  23249. _fragmentOutputNodes: NodeMaterialBlock[];
  23250. /** Gets or sets options to control the node material overall behavior */
  23251. get options(): INodeMaterialOptions;
  23252. set options(options: INodeMaterialOptions);
  23253. /**
  23254. * Default configuration related to image processing available in the standard Material.
  23255. */
  23256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23257. /**
  23258. * Gets the image processing configuration used either in this material.
  23259. */
  23260. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23261. /**
  23262. * Sets the Default image processing configuration used either in the this material.
  23263. *
  23264. * If sets to null, the scene one is in use.
  23265. */
  23266. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23267. /**
  23268. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23269. */
  23270. attachedBlocks: NodeMaterialBlock[];
  23271. /**
  23272. * Specifies the mode of the node material
  23273. * @hidden
  23274. */
  23275. _mode: NodeMaterialModes;
  23276. /**
  23277. * Gets the mode property
  23278. */
  23279. get mode(): NodeMaterialModes;
  23280. /**
  23281. * Create a new node based material
  23282. * @param name defines the material name
  23283. * @param scene defines the hosting scene
  23284. * @param options defines creation option
  23285. */
  23286. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23287. /**
  23288. * Gets the current class name of the material e.g. "NodeMaterial"
  23289. * @returns the class name
  23290. */
  23291. getClassName(): string;
  23292. /**
  23293. * Keep track of the image processing observer to allow dispose and replace.
  23294. */
  23295. private _imageProcessingObserver;
  23296. /**
  23297. * Attaches a new image processing configuration to the Standard Material.
  23298. * @param configuration
  23299. */
  23300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23301. /**
  23302. * Get a block by its name
  23303. * @param name defines the name of the block to retrieve
  23304. * @returns the required block or null if not found
  23305. */
  23306. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23307. /**
  23308. * Get a block by its name
  23309. * @param predicate defines the predicate used to find the good candidate
  23310. * @returns the required block or null if not found
  23311. */
  23312. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23313. /**
  23314. * Get an input block by its name
  23315. * @param predicate defines the predicate used to find the good candidate
  23316. * @returns the required input block or null if not found
  23317. */
  23318. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23319. /**
  23320. * Gets the list of input blocks attached to this material
  23321. * @returns an array of InputBlocks
  23322. */
  23323. getInputBlocks(): InputBlock[];
  23324. /**
  23325. * Adds a new optimizer to the list of optimizers
  23326. * @param optimizer defines the optimizers to add
  23327. * @returns the current material
  23328. */
  23329. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23330. /**
  23331. * Remove an optimizer from the list of optimizers
  23332. * @param optimizer defines the optimizers to remove
  23333. * @returns the current material
  23334. */
  23335. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23336. /**
  23337. * Add a new block to the list of output nodes
  23338. * @param node defines the node to add
  23339. * @returns the current material
  23340. */
  23341. addOutputNode(node: NodeMaterialBlock): this;
  23342. /**
  23343. * Remove a block from the list of root nodes
  23344. * @param node defines the node to remove
  23345. * @returns the current material
  23346. */
  23347. removeOutputNode(node: NodeMaterialBlock): this;
  23348. private _addVertexOutputNode;
  23349. private _removeVertexOutputNode;
  23350. private _addFragmentOutputNode;
  23351. private _removeFragmentOutputNode;
  23352. /**
  23353. * Specifies if the material will require alpha blending
  23354. * @returns a boolean specifying if alpha blending is needed
  23355. */
  23356. needAlphaBlending(): boolean;
  23357. /**
  23358. * Specifies if this material should be rendered in alpha test mode
  23359. * @returns a boolean specifying if an alpha test is needed.
  23360. */
  23361. needAlphaTesting(): boolean;
  23362. private _initializeBlock;
  23363. private _resetDualBlocks;
  23364. /**
  23365. * Remove a block from the current node material
  23366. * @param block defines the block to remove
  23367. */
  23368. removeBlock(block: NodeMaterialBlock): void;
  23369. /**
  23370. * Build the material and generates the inner effect
  23371. * @param verbose defines if the build should log activity
  23372. */
  23373. build(verbose?: boolean): void;
  23374. /**
  23375. * Runs an otpimization phase to try to improve the shader code
  23376. */
  23377. optimize(): void;
  23378. private _prepareDefinesForAttributes;
  23379. /**
  23380. * Create a post process from the material
  23381. * @param camera The camera to apply the render pass to.
  23382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23384. * @param engine The engine which the post process will be applied. (default: current engine)
  23385. * @param reusable If the post process can be reused on the same frame. (default: false)
  23386. * @param textureType Type of textures used when performing the post process. (default: 0)
  23387. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23388. * @returns the post process created
  23389. */
  23390. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23391. /**
  23392. * Create the post process effect from the material
  23393. * @param postProcess The post process to create the effect for
  23394. */
  23395. createEffectForPostProcess(postProcess: PostProcess): void;
  23396. private _createEffectForPostProcess;
  23397. /**
  23398. * Create a new procedural texture based on this node material
  23399. * @param size defines the size of the texture
  23400. * @param scene defines the hosting scene
  23401. * @returns the new procedural texture attached to this node material
  23402. */
  23403. createProceduralTexture(size: number | {
  23404. width: number;
  23405. height: number;
  23406. layers?: number;
  23407. }, scene: Scene): Nullable<ProceduralTexture>;
  23408. private _createEffectForParticles;
  23409. private _checkInternals;
  23410. /**
  23411. * Create the effect to be used as the custom effect for a particle system
  23412. * @param particleSystem Particle system to create the effect for
  23413. * @param onCompiled defines a function to call when the effect creation is successful
  23414. * @param onError defines a function to call when the effect creation has failed
  23415. */
  23416. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23417. private _processDefines;
  23418. /**
  23419. * Get if the submesh is ready to be used and all its information available.
  23420. * Child classes can use it to update shaders
  23421. * @param mesh defines the mesh to check
  23422. * @param subMesh defines which submesh to check
  23423. * @param useInstances specifies that instances should be used
  23424. * @returns a boolean indicating that the submesh is ready or not
  23425. */
  23426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23427. /**
  23428. * Get a string representing the shaders built by the current node graph
  23429. */
  23430. get compiledShaders(): string;
  23431. /**
  23432. * Binds the world matrix to the material
  23433. * @param world defines the world transformation matrix
  23434. */
  23435. bindOnlyWorldMatrix(world: Matrix): void;
  23436. /**
  23437. * Binds the submesh to this material by preparing the effect and shader to draw
  23438. * @param world defines the world transformation matrix
  23439. * @param mesh defines the mesh containing the submesh
  23440. * @param subMesh defines the submesh to bind the material to
  23441. */
  23442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23443. /**
  23444. * Gets the active textures from the material
  23445. * @returns an array of textures
  23446. */
  23447. getActiveTextures(): BaseTexture[];
  23448. /**
  23449. * Gets the list of texture blocks
  23450. * @returns an array of texture blocks
  23451. */
  23452. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23453. /**
  23454. * Specifies if the material uses a texture
  23455. * @param texture defines the texture to check against the material
  23456. * @returns a boolean specifying if the material uses the texture
  23457. */
  23458. hasTexture(texture: BaseTexture): boolean;
  23459. /**
  23460. * Disposes the material
  23461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23464. */
  23465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23466. /** Creates the node editor window. */
  23467. private _createNodeEditor;
  23468. /**
  23469. * Launch the node material editor
  23470. * @param config Define the configuration of the editor
  23471. * @return a promise fulfilled when the node editor is visible
  23472. */
  23473. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23474. /**
  23475. * Clear the current material
  23476. */
  23477. clear(): void;
  23478. /**
  23479. * Clear the current material and set it to a default state
  23480. */
  23481. setToDefault(): void;
  23482. /**
  23483. * Clear the current material and set it to a default state for post process
  23484. */
  23485. setToDefaultPostProcess(): void;
  23486. /**
  23487. * Clear the current material and set it to a default state for procedural texture
  23488. */
  23489. setToDefaultProceduralTexture(): void;
  23490. /**
  23491. * Clear the current material and set it to a default state for particle
  23492. */
  23493. setToDefaultParticle(): void;
  23494. /**
  23495. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23496. * @param url defines the url to load from
  23497. * @returns a promise that will fullfil when the material is fully loaded
  23498. */
  23499. loadAsync(url: string): Promise<void>;
  23500. private _gatherBlocks;
  23501. /**
  23502. * Generate a string containing the code declaration required to create an equivalent of this material
  23503. * @returns a string
  23504. */
  23505. generateCode(): string;
  23506. /**
  23507. * Serializes this material in a JSON representation
  23508. * @returns the serialized material object
  23509. */
  23510. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23511. private _restoreConnections;
  23512. /**
  23513. * Clear the current graph and load a new one from a serialization object
  23514. * @param source defines the JSON representation of the material
  23515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23516. * @param merge defines whether or not the source must be merged or replace the current content
  23517. */
  23518. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23519. /**
  23520. * Makes a duplicate of the current material.
  23521. * @param name - name to use for the new material.
  23522. */
  23523. clone(name: string): NodeMaterial;
  23524. /**
  23525. * Creates a node material from parsed material data
  23526. * @param source defines the JSON representation of the material
  23527. * @param scene defines the hosting scene
  23528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23529. * @returns a new node material
  23530. */
  23531. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23532. /**
  23533. * Creates a node material from a snippet saved in a remote file
  23534. * @param name defines the name of the material to create
  23535. * @param url defines the url to load from
  23536. * @param scene defines the hosting scene
  23537. * @returns a promise that will resolve to the new node material
  23538. */
  23539. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23540. /**
  23541. * Creates a node material from a snippet saved by the node material editor
  23542. * @param snippetId defines the snippet to load
  23543. * @param scene defines the hosting scene
  23544. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23545. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23546. * @returns a promise that will resolve to the new node material
  23547. */
  23548. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23549. /**
  23550. * Creates a new node material set to default basic configuration
  23551. * @param name defines the name of the material
  23552. * @param scene defines the hosting scene
  23553. * @returns a new NodeMaterial
  23554. */
  23555. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23556. }
  23557. }
  23558. declare module "babylonjs/PostProcesses/postProcess" {
  23559. import { Nullable } from "babylonjs/types";
  23560. import { SmartArray } from "babylonjs/Misc/smartArray";
  23561. import { Observable } from "babylonjs/Misc/observable";
  23562. import { Vector2 } from "babylonjs/Maths/math.vector";
  23563. import { Camera } from "babylonjs/Cameras/camera";
  23564. import { Effect } from "babylonjs/Materials/effect";
  23565. import "babylonjs/Shaders/postprocess.vertex";
  23566. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23567. import { Engine } from "babylonjs/Engines/engine";
  23568. import { Color4 } from "babylonjs/Maths/math.color";
  23569. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23570. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23571. import { Scene } from "babylonjs/scene";
  23572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23573. /**
  23574. * Size options for a post process
  23575. */
  23576. export type PostProcessOptions = {
  23577. width: number;
  23578. height: number;
  23579. };
  23580. /**
  23581. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23583. */
  23584. export class PostProcess {
  23585. /**
  23586. * Gets or sets the unique id of the post process
  23587. */
  23588. uniqueId: number;
  23589. /** Name of the PostProcess. */
  23590. name: string;
  23591. /**
  23592. * Width of the texture to apply the post process on
  23593. */
  23594. width: number;
  23595. /**
  23596. * Height of the texture to apply the post process on
  23597. */
  23598. height: number;
  23599. /**
  23600. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23601. */
  23602. nodeMaterialSource: Nullable<NodeMaterial>;
  23603. /**
  23604. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23605. * @hidden
  23606. */
  23607. _outputTexture: Nullable<InternalTexture>;
  23608. /**
  23609. * Sampling mode used by the shader
  23610. * See https://doc.babylonjs.com/classes/3.1/texture
  23611. */
  23612. renderTargetSamplingMode: number;
  23613. /**
  23614. * Clear color to use when screen clearing
  23615. */
  23616. clearColor: Color4;
  23617. /**
  23618. * If the buffer needs to be cleared before applying the post process. (default: true)
  23619. * Should be set to false if shader will overwrite all previous pixels.
  23620. */
  23621. autoClear: boolean;
  23622. /**
  23623. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23624. */
  23625. alphaMode: number;
  23626. /**
  23627. * Sets the setAlphaBlendConstants of the babylon engine
  23628. */
  23629. alphaConstants: Color4;
  23630. /**
  23631. * Animations to be used for the post processing
  23632. */
  23633. animations: import("babylonjs/Animations/animation").Animation[];
  23634. /**
  23635. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23636. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23637. */
  23638. enablePixelPerfectMode: boolean;
  23639. /**
  23640. * Force the postprocess to be applied without taking in account viewport
  23641. */
  23642. forceFullscreenViewport: boolean;
  23643. /**
  23644. * List of inspectable custom properties (used by the Inspector)
  23645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23646. */
  23647. inspectableCustomProperties: IInspectable[];
  23648. /**
  23649. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23650. *
  23651. * | Value | Type | Description |
  23652. * | ----- | ----------------------------------- | ----------- |
  23653. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23654. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23655. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23656. *
  23657. */
  23658. scaleMode: number;
  23659. /**
  23660. * Force textures to be a power of two (default: false)
  23661. */
  23662. alwaysForcePOT: boolean;
  23663. private _samples;
  23664. /**
  23665. * Number of sample textures (default: 1)
  23666. */
  23667. get samples(): number;
  23668. set samples(n: number);
  23669. /**
  23670. * Modify the scale of the post process to be the same as the viewport (default: false)
  23671. */
  23672. adaptScaleToCurrentViewport: boolean;
  23673. private _camera;
  23674. protected _scene: Scene;
  23675. private _engine;
  23676. private _options;
  23677. private _reusable;
  23678. private _textureType;
  23679. private _textureFormat;
  23680. /**
  23681. * Smart array of input and output textures for the post process.
  23682. * @hidden
  23683. */
  23684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23685. /**
  23686. * The index in _textures that corresponds to the output texture.
  23687. * @hidden
  23688. */
  23689. _currentRenderTextureInd: number;
  23690. private _effect;
  23691. private _samplers;
  23692. private _fragmentUrl;
  23693. private _vertexUrl;
  23694. private _parameters;
  23695. private _scaleRatio;
  23696. protected _indexParameters: any;
  23697. private _shareOutputWithPostProcess;
  23698. private _texelSize;
  23699. private _forcedOutputTexture;
  23700. /**
  23701. * Returns the fragment url or shader name used in the post process.
  23702. * @returns the fragment url or name in the shader store.
  23703. */
  23704. getEffectName(): string;
  23705. /**
  23706. * An event triggered when the postprocess is activated.
  23707. */
  23708. onActivateObservable: Observable<Camera>;
  23709. private _onActivateObserver;
  23710. /**
  23711. * A function that is added to the onActivateObservable
  23712. */
  23713. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23714. /**
  23715. * An event triggered when the postprocess changes its size.
  23716. */
  23717. onSizeChangedObservable: Observable<PostProcess>;
  23718. private _onSizeChangedObserver;
  23719. /**
  23720. * A function that is added to the onSizeChangedObservable
  23721. */
  23722. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23723. /**
  23724. * An event triggered when the postprocess applies its effect.
  23725. */
  23726. onApplyObservable: Observable<Effect>;
  23727. private _onApplyObserver;
  23728. /**
  23729. * A function that is added to the onApplyObservable
  23730. */
  23731. set onApply(callback: (effect: Effect) => void);
  23732. /**
  23733. * An event triggered before rendering the postprocess
  23734. */
  23735. onBeforeRenderObservable: Observable<Effect>;
  23736. private _onBeforeRenderObserver;
  23737. /**
  23738. * A function that is added to the onBeforeRenderObservable
  23739. */
  23740. set onBeforeRender(callback: (effect: Effect) => void);
  23741. /**
  23742. * An event triggered after rendering the postprocess
  23743. */
  23744. onAfterRenderObservable: Observable<Effect>;
  23745. private _onAfterRenderObserver;
  23746. /**
  23747. * A function that is added to the onAfterRenderObservable
  23748. */
  23749. set onAfterRender(callback: (efect: Effect) => void);
  23750. /**
  23751. * 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
  23752. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23753. */
  23754. get inputTexture(): InternalTexture;
  23755. set inputTexture(value: InternalTexture);
  23756. /**
  23757. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23758. * the only way to unset it is to use this function to restore its internal state
  23759. */
  23760. restoreDefaultInputTexture(): void;
  23761. /**
  23762. * Gets the camera which post process is applied to.
  23763. * @returns The camera the post process is applied to.
  23764. */
  23765. getCamera(): Camera;
  23766. /**
  23767. * Gets the texel size of the postprocess.
  23768. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23769. */
  23770. get texelSize(): Vector2;
  23771. /**
  23772. * Creates a new instance PostProcess
  23773. * @param name The name of the PostProcess.
  23774. * @param fragmentUrl The url of the fragment shader to be used.
  23775. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23776. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23777. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23778. * @param camera The camera to apply the render pass to.
  23779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23780. * @param engine The engine which the post process will be applied. (default: current engine)
  23781. * @param reusable If the post process can be reused on the same frame. (default: false)
  23782. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23783. * @param textureType Type of textures used when performing the post process. (default: 0)
  23784. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23785. * @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
  23786. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23787. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23788. */
  23789. 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);
  23790. /**
  23791. * Gets a string identifying the name of the class
  23792. * @returns "PostProcess" string
  23793. */
  23794. getClassName(): string;
  23795. /**
  23796. * Gets the engine which this post process belongs to.
  23797. * @returns The engine the post process was enabled with.
  23798. */
  23799. getEngine(): Engine;
  23800. /**
  23801. * The effect that is created when initializing the post process.
  23802. * @returns The created effect corresponding the the postprocess.
  23803. */
  23804. getEffect(): Effect;
  23805. /**
  23806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23807. * @param postProcess The post process to share the output with.
  23808. * @returns This post process.
  23809. */
  23810. shareOutputWith(postProcess: PostProcess): PostProcess;
  23811. /**
  23812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23814. */
  23815. useOwnOutput(): void;
  23816. /**
  23817. * Updates the effect with the current post process compile time values and recompiles the shader.
  23818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23821. * @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
  23822. * @param onCompiled Called when the shader has been compiled.
  23823. * @param onError Called if there is an error when compiling a shader.
  23824. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23825. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23826. */
  23827. 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;
  23828. /**
  23829. * The post process is reusable if it can be used multiple times within one frame.
  23830. * @returns If the post process is reusable
  23831. */
  23832. isReusable(): boolean;
  23833. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23834. markTextureDirty(): void;
  23835. /**
  23836. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23837. * 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.
  23838. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23839. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23840. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23841. * @returns The target texture that was bound to be written to.
  23842. */
  23843. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23844. /**
  23845. * If the post process is supported.
  23846. */
  23847. get isSupported(): boolean;
  23848. /**
  23849. * The aspect ratio of the output texture.
  23850. */
  23851. get aspectRatio(): number;
  23852. /**
  23853. * Get a value indicating if the post-process is ready to be used
  23854. * @returns true if the post-process is ready (shader is compiled)
  23855. */
  23856. isReady(): boolean;
  23857. /**
  23858. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23859. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23860. */
  23861. apply(): Nullable<Effect>;
  23862. private _disposeTextures;
  23863. /**
  23864. * Disposes the post process.
  23865. * @param camera The camera to dispose the post process on.
  23866. */
  23867. dispose(camera?: Camera): void;
  23868. /**
  23869. * Serializes the particle system to a JSON object
  23870. * @returns the JSON object
  23871. */
  23872. serialize(): any;
  23873. /**
  23874. * Creates a material from parsed material data
  23875. * @param parsedPostProcess defines parsed post process data
  23876. * @param scene defines the hosting scene
  23877. * @param rootUrl defines the root URL to use to load textures
  23878. * @returns a new post process
  23879. */
  23880. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23881. }
  23882. }
  23883. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23884. /** @hidden */
  23885. export var kernelBlurVaryingDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23891. /** @hidden */
  23892. export var kernelBlurFragment: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23898. /** @hidden */
  23899. export var kernelBlurFragment2: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23905. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23906. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23907. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23909. /** @hidden */
  23910. export var kernelBlurPixelShader: {
  23911. name: string;
  23912. shader: string;
  23913. };
  23914. }
  23915. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23916. /** @hidden */
  23917. export var kernelBlurVertex: {
  23918. name: string;
  23919. shader: string;
  23920. };
  23921. }
  23922. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23923. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23925. /** @hidden */
  23926. export var kernelBlurVertexShader: {
  23927. name: string;
  23928. shader: string;
  23929. };
  23930. }
  23931. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23932. import { Vector2 } from "babylonjs/Maths/math.vector";
  23933. import { Nullable } from "babylonjs/types";
  23934. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23935. import { Camera } from "babylonjs/Cameras/camera";
  23936. import { Effect } from "babylonjs/Materials/effect";
  23937. import { Engine } from "babylonjs/Engines/engine";
  23938. import "babylonjs/Shaders/kernelBlur.fragment";
  23939. import "babylonjs/Shaders/kernelBlur.vertex";
  23940. import { Scene } from "babylonjs/scene";
  23941. /**
  23942. * The Blur Post Process which blurs an image based on a kernel and direction.
  23943. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23944. */
  23945. export class BlurPostProcess extends PostProcess {
  23946. private blockCompilation;
  23947. protected _kernel: number;
  23948. protected _idealKernel: number;
  23949. protected _packedFloat: boolean;
  23950. private _staticDefines;
  23951. /** The direction in which to blur the image. */
  23952. direction: Vector2;
  23953. /**
  23954. * Sets the length in pixels of the blur sample region
  23955. */
  23956. set kernel(v: number);
  23957. /**
  23958. * Gets the length in pixels of the blur sample region
  23959. */
  23960. get kernel(): number;
  23961. /**
  23962. * Sets wether or not the blur needs to unpack/repack floats
  23963. */
  23964. set packedFloat(v: boolean);
  23965. /**
  23966. * Gets wether or not the blur is unpacking/repacking floats
  23967. */
  23968. get packedFloat(): boolean;
  23969. /**
  23970. * Gets a string identifying the name of the class
  23971. * @returns "BlurPostProcess" string
  23972. */
  23973. getClassName(): string;
  23974. /**
  23975. * Creates a new instance BlurPostProcess
  23976. * @param name The name of the effect.
  23977. * @param direction The direction in which to blur the image.
  23978. * @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.
  23979. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23980. * @param camera The camera to apply the render pass to.
  23981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23982. * @param engine The engine which the post process will be applied. (default: current engine)
  23983. * @param reusable If the post process can be reused on the same frame. (default: false)
  23984. * @param textureType Type of textures used when performing the post process. (default: 0)
  23985. * @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)
  23986. */
  23987. 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);
  23988. /**
  23989. * Updates the effect with the current post process compile time values and recompiles the shader.
  23990. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23991. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23992. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23993. * @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
  23994. * @param onCompiled Called when the shader has been compiled.
  23995. * @param onError Called if there is an error when compiling a shader.
  23996. */
  23997. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23998. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23999. /**
  24000. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24001. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24002. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24003. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24004. * The gaps between physical kernels are compensated for in the weighting of the samples
  24005. * @param idealKernel Ideal blur kernel.
  24006. * @return Nearest best kernel.
  24007. */
  24008. protected _nearestBestKernel(idealKernel: number): number;
  24009. /**
  24010. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24011. * @param x The point on the Gaussian distribution to sample.
  24012. * @return the value of the Gaussian function at x.
  24013. */
  24014. protected _gaussianWeight(x: number): number;
  24015. /**
  24016. * Generates a string that can be used as a floating point number in GLSL.
  24017. * @param x Value to print.
  24018. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24019. * @return GLSL float string.
  24020. */
  24021. protected _glslFloat(x: number, decimalFigures?: number): string;
  24022. /** @hidden */
  24023. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24024. }
  24025. }
  24026. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24027. import { Scene } from "babylonjs/scene";
  24028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24029. import { Plane } from "babylonjs/Maths/math.plane";
  24030. /**
  24031. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24032. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24033. * You can then easily use it as a reflectionTexture on a flat surface.
  24034. * In case the surface is not a plane, please consider relying on reflection probes.
  24035. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24036. */
  24037. export class MirrorTexture extends RenderTargetTexture {
  24038. private scene;
  24039. /**
  24040. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24041. * 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.
  24042. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24043. */
  24044. mirrorPlane: Plane;
  24045. /**
  24046. * Define the blur ratio used to blur the reflection if needed.
  24047. */
  24048. set blurRatio(value: number);
  24049. get blurRatio(): number;
  24050. /**
  24051. * Define the adaptive blur kernel used to blur the reflection if needed.
  24052. * This will autocompute the closest best match for the `blurKernel`
  24053. */
  24054. set adaptiveBlurKernel(value: number);
  24055. /**
  24056. * Define the blur kernel used to blur the reflection if needed.
  24057. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24058. */
  24059. set blurKernel(value: number);
  24060. /**
  24061. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24063. */
  24064. set blurKernelX(value: number);
  24065. get blurKernelX(): number;
  24066. /**
  24067. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24069. */
  24070. set blurKernelY(value: number);
  24071. get blurKernelY(): number;
  24072. private _autoComputeBlurKernel;
  24073. protected _onRatioRescale(): void;
  24074. private _updateGammaSpace;
  24075. private _imageProcessingConfigChangeObserver;
  24076. private _transformMatrix;
  24077. private _mirrorMatrix;
  24078. private _savedViewMatrix;
  24079. private _blurX;
  24080. private _blurY;
  24081. private _adaptiveBlurKernel;
  24082. private _blurKernelX;
  24083. private _blurKernelY;
  24084. private _blurRatio;
  24085. /**
  24086. * Instantiates a Mirror Texture.
  24087. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24088. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24089. * You can then easily use it as a reflectionTexture on a flat surface.
  24090. * In case the surface is not a plane, please consider relying on reflection probes.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24092. * @param name
  24093. * @param size
  24094. * @param scene
  24095. * @param generateMipMaps
  24096. * @param type
  24097. * @param samplingMode
  24098. * @param generateDepthBuffer
  24099. */
  24100. constructor(name: string, size: number | {
  24101. width: number;
  24102. height: number;
  24103. } | {
  24104. ratio: number;
  24105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24106. private _preparePostProcesses;
  24107. /**
  24108. * Clone the mirror texture.
  24109. * @returns the cloned texture
  24110. */
  24111. clone(): MirrorTexture;
  24112. /**
  24113. * Serialize the texture to a JSON representation you could use in Parse later on
  24114. * @returns the serialized JSON representation
  24115. */
  24116. serialize(): any;
  24117. /**
  24118. * Dispose the texture and release its associated resources.
  24119. */
  24120. dispose(): void;
  24121. }
  24122. }
  24123. declare module "babylonjs/Materials/Textures/texture" {
  24124. import { Observable } from "babylonjs/Misc/observable";
  24125. import { Nullable } from "babylonjs/types";
  24126. import { Matrix } from "babylonjs/Maths/math.vector";
  24127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24128. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24130. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24131. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24133. import { Scene } from "babylonjs/scene";
  24134. /**
  24135. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24136. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24137. */
  24138. export class Texture extends BaseTexture {
  24139. /**
  24140. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24141. */
  24142. static SerializeBuffers: boolean;
  24143. /** @hidden */
  24144. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24145. /** @hidden */
  24146. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24147. /** @hidden */
  24148. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24149. /** nearest is mag = nearest and min = nearest and mip = linear */
  24150. static readonly NEAREST_SAMPLINGMODE: number;
  24151. /** nearest is mag = nearest and min = nearest and mip = linear */
  24152. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24154. static readonly BILINEAR_SAMPLINGMODE: number;
  24155. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24156. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24157. /** Trilinear is mag = linear and min = linear and mip = linear */
  24158. static readonly TRILINEAR_SAMPLINGMODE: number;
  24159. /** Trilinear is mag = linear and min = linear and mip = linear */
  24160. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24161. /** mag = nearest and min = nearest and mip = nearest */
  24162. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24163. /** mag = nearest and min = linear and mip = nearest */
  24164. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24165. /** mag = nearest and min = linear and mip = linear */
  24166. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24167. /** mag = nearest and min = linear and mip = none */
  24168. static readonly NEAREST_LINEAR: number;
  24169. /** mag = nearest and min = nearest and mip = none */
  24170. static readonly NEAREST_NEAREST: number;
  24171. /** mag = linear and min = nearest and mip = nearest */
  24172. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24173. /** mag = linear and min = nearest and mip = linear */
  24174. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24175. /** mag = linear and min = linear and mip = none */
  24176. static readonly LINEAR_LINEAR: number;
  24177. /** mag = linear and min = nearest and mip = none */
  24178. static readonly LINEAR_NEAREST: number;
  24179. /** Explicit coordinates mode */
  24180. static readonly EXPLICIT_MODE: number;
  24181. /** Spherical coordinates mode */
  24182. static readonly SPHERICAL_MODE: number;
  24183. /** Planar coordinates mode */
  24184. static readonly PLANAR_MODE: number;
  24185. /** Cubic coordinates mode */
  24186. static readonly CUBIC_MODE: number;
  24187. /** Projection coordinates mode */
  24188. static readonly PROJECTION_MODE: number;
  24189. /** Inverse Cubic coordinates mode */
  24190. static readonly SKYBOX_MODE: number;
  24191. /** Inverse Cubic coordinates mode */
  24192. static readonly INVCUBIC_MODE: number;
  24193. /** Equirectangular coordinates mode */
  24194. static readonly EQUIRECTANGULAR_MODE: number;
  24195. /** Equirectangular Fixed coordinates mode */
  24196. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24197. /** Equirectangular Fixed Mirrored coordinates mode */
  24198. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24199. /** Texture is not repeating outside of 0..1 UVs */
  24200. static readonly CLAMP_ADDRESSMODE: number;
  24201. /** Texture is repeating outside of 0..1 UVs */
  24202. static readonly WRAP_ADDRESSMODE: number;
  24203. /** Texture is repeating and mirrored */
  24204. static readonly MIRROR_ADDRESSMODE: number;
  24205. /**
  24206. * 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
  24207. */
  24208. static UseSerializedUrlIfAny: boolean;
  24209. /**
  24210. * Define the url of the texture.
  24211. */
  24212. url: Nullable<string>;
  24213. /**
  24214. * Define an offset on the texture to offset the u coordinates of the UVs
  24215. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24216. */
  24217. uOffset: number;
  24218. /**
  24219. * Define an offset on the texture to offset the v coordinates of the UVs
  24220. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24221. */
  24222. vOffset: number;
  24223. /**
  24224. * Define an offset on the texture to scale the u coordinates of the UVs
  24225. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24226. */
  24227. uScale: number;
  24228. /**
  24229. * Define an offset on the texture to scale the v coordinates of the UVs
  24230. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24231. */
  24232. vScale: number;
  24233. /**
  24234. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24235. * @see https://doc.babylonjs.com/how_to/more_materials
  24236. */
  24237. uAng: number;
  24238. /**
  24239. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24240. * @see https://doc.babylonjs.com/how_to/more_materials
  24241. */
  24242. vAng: number;
  24243. /**
  24244. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24245. * @see https://doc.babylonjs.com/how_to/more_materials
  24246. */
  24247. wAng: number;
  24248. /**
  24249. * Defines the center of rotation (U)
  24250. */
  24251. uRotationCenter: number;
  24252. /**
  24253. * Defines the center of rotation (V)
  24254. */
  24255. vRotationCenter: number;
  24256. /**
  24257. * Defines the center of rotation (W)
  24258. */
  24259. wRotationCenter: number;
  24260. /**
  24261. * Are mip maps generated for this texture or not.
  24262. */
  24263. get noMipmap(): boolean;
  24264. /**
  24265. * List of inspectable custom properties (used by the Inspector)
  24266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24267. */
  24268. inspectableCustomProperties: Nullable<IInspectable[]>;
  24269. private _noMipmap;
  24270. /** @hidden */
  24271. _invertY: boolean;
  24272. private _rowGenerationMatrix;
  24273. private _cachedTextureMatrix;
  24274. private _projectionModeMatrix;
  24275. private _t0;
  24276. private _t1;
  24277. private _t2;
  24278. private _cachedUOffset;
  24279. private _cachedVOffset;
  24280. private _cachedUScale;
  24281. private _cachedVScale;
  24282. private _cachedUAng;
  24283. private _cachedVAng;
  24284. private _cachedWAng;
  24285. private _cachedProjectionMatrixId;
  24286. private _cachedCoordinatesMode;
  24287. /** @hidden */
  24288. protected _initialSamplingMode: number;
  24289. /** @hidden */
  24290. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24291. private _deleteBuffer;
  24292. protected _format: Nullable<number>;
  24293. private _delayedOnLoad;
  24294. private _delayedOnError;
  24295. private _mimeType?;
  24296. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24297. get mimeType(): string | undefined;
  24298. /**
  24299. * Observable triggered once the texture has been loaded.
  24300. */
  24301. onLoadObservable: Observable<Texture>;
  24302. protected _isBlocking: boolean;
  24303. /**
  24304. * Is the texture preventing material to render while loading.
  24305. * If false, a default texture will be used instead of the loading one during the preparation step.
  24306. */
  24307. set isBlocking(value: boolean);
  24308. get isBlocking(): boolean;
  24309. /**
  24310. * Get the current sampling mode associated with the texture.
  24311. */
  24312. get samplingMode(): number;
  24313. /**
  24314. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24315. */
  24316. get invertY(): boolean;
  24317. /**
  24318. * Instantiates a new texture.
  24319. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24320. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24321. * @param url defines the url of the picture to load as a texture
  24322. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24323. * @param noMipmap defines if the texture will require mip maps or not
  24324. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24325. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24326. * @param onLoad defines a callback triggered when the texture has been loaded
  24327. * @param onError defines a callback triggered when an error occurred during the loading session
  24328. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24329. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24330. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24331. * @param mimeType defines an optional mime type information
  24332. */
  24333. 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);
  24334. /**
  24335. * Update the url (and optional buffer) of this texture if url was null during construction.
  24336. * @param url the url of the texture
  24337. * @param buffer the buffer of the texture (defaults to null)
  24338. * @param onLoad callback called when the texture is loaded (defaults to null)
  24339. */
  24340. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24341. /**
  24342. * Finish the loading sequence of a texture flagged as delayed load.
  24343. * @hidden
  24344. */
  24345. delayLoad(): void;
  24346. private _prepareRowForTextureGeneration;
  24347. /**
  24348. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24349. * @returns the transform matrix of the texture.
  24350. */
  24351. getTextureMatrix(uBase?: number): Matrix;
  24352. /**
  24353. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24354. * @returns The reflection texture transform
  24355. */
  24356. getReflectionTextureMatrix(): Matrix;
  24357. /**
  24358. * Clones the texture.
  24359. * @returns the cloned texture
  24360. */
  24361. clone(): Texture;
  24362. /**
  24363. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24364. * @returns The JSON representation of the texture
  24365. */
  24366. serialize(): any;
  24367. /**
  24368. * Get the current class name of the texture useful for serialization or dynamic coding.
  24369. * @returns "Texture"
  24370. */
  24371. getClassName(): string;
  24372. /**
  24373. * Dispose the texture and release its associated resources.
  24374. */
  24375. dispose(): void;
  24376. /**
  24377. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24378. * @param parsedTexture Define the JSON representation of the texture
  24379. * @param scene Define the scene the parsed texture should be instantiated in
  24380. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24381. * @returns The parsed texture if successful
  24382. */
  24383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24384. /**
  24385. * Creates a texture from its base 64 representation.
  24386. * @param data Define the base64 payload without the data: prefix
  24387. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24388. * @param scene Define the scene the texture should belong to
  24389. * @param noMipmap Forces the texture to not create mip map information if true
  24390. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24391. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24392. * @param onLoad define a callback triggered when the texture has been loaded
  24393. * @param onError define a callback triggered when an error occurred during the loading session
  24394. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24395. * @returns the created texture
  24396. */
  24397. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24398. /**
  24399. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24400. * @param data Define the base64 payload without the data: prefix
  24401. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24402. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24403. * @param scene Define the scene the texture should belong to
  24404. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24405. * @param noMipmap Forces the texture to not create mip map information if true
  24406. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24407. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24408. * @param onLoad define a callback triggered when the texture has been loaded
  24409. * @param onError define a callback triggered when an error occurred during the loading session
  24410. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24411. * @returns the created texture
  24412. */
  24413. 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;
  24414. }
  24415. }
  24416. declare module "babylonjs/PostProcesses/postProcessManager" {
  24417. import { Nullable } from "babylonjs/types";
  24418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24420. import { Scene } from "babylonjs/scene";
  24421. /**
  24422. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24423. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24424. */
  24425. export class PostProcessManager {
  24426. private _scene;
  24427. private _indexBuffer;
  24428. private _vertexBuffers;
  24429. /**
  24430. * Creates a new instance PostProcess
  24431. * @param scene The scene that the post process is associated with.
  24432. */
  24433. constructor(scene: Scene);
  24434. private _prepareBuffers;
  24435. private _buildIndexBuffer;
  24436. /**
  24437. * Rebuilds the vertex buffers of the manager.
  24438. * @hidden
  24439. */
  24440. _rebuild(): void;
  24441. /**
  24442. * Prepares a frame to be run through a post process.
  24443. * @param sourceTexture The input texture to the post procesess. (default: null)
  24444. * @param postProcesses An array of post processes to be run. (default: null)
  24445. * @returns True if the post processes were able to be run.
  24446. * @hidden
  24447. */
  24448. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24449. /**
  24450. * Manually render a set of post processes to a texture.
  24451. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24452. * @param postProcesses An array of post processes to be run.
  24453. * @param targetTexture The target texture to render to.
  24454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24455. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24456. * @param lodLevel defines which lod of the texture to render to
  24457. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24458. */
  24459. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24460. /**
  24461. * Finalize the result of the output of the postprocesses.
  24462. * @param doNotPresent If true the result will not be displayed to the screen.
  24463. * @param targetTexture The target texture to render to.
  24464. * @param faceIndex The index of the face to bind the target texture to.
  24465. * @param postProcesses The array of post processes to render.
  24466. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24467. * @hidden
  24468. */
  24469. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24470. /**
  24471. * Disposes of the post process manager.
  24472. */
  24473. dispose(): void;
  24474. }
  24475. }
  24476. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24477. import { Observable } from "babylonjs/Misc/observable";
  24478. import { SmartArray } from "babylonjs/Misc/smartArray";
  24479. import { Nullable, Immutable } from "babylonjs/types";
  24480. import { Camera } from "babylonjs/Cameras/camera";
  24481. import { Scene } from "babylonjs/scene";
  24482. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24483. import { Color4 } from "babylonjs/Maths/math.color";
  24484. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24488. import { Texture } from "babylonjs/Materials/Textures/texture";
  24489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24490. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24491. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24492. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24493. import { Engine } from "babylonjs/Engines/engine";
  24494. /**
  24495. * This Helps creating a texture that will be created from a camera in your scene.
  24496. * It is basically a dynamic texture that could be used to create special effects for instance.
  24497. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24498. */
  24499. export class RenderTargetTexture extends Texture {
  24500. /**
  24501. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24502. */
  24503. static readonly REFRESHRATE_RENDER_ONCE: number;
  24504. /**
  24505. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24506. */
  24507. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24508. /**
  24509. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24510. * the central point of your effect and can save a lot of performances.
  24511. */
  24512. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24513. /**
  24514. * Use this predicate to dynamically define the list of mesh you want to render.
  24515. * If set, the renderList property will be overwritten.
  24516. */
  24517. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24518. private _renderList;
  24519. /**
  24520. * Use this list to define the list of mesh you want to render.
  24521. */
  24522. get renderList(): Nullable<Array<AbstractMesh>>;
  24523. set renderList(value: Nullable<Array<AbstractMesh>>);
  24524. /**
  24525. * Use this function to overload the renderList array at rendering time.
  24526. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24527. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24528. * the cube (if the RTT is a cube, else layerOrFace=0).
  24529. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24530. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24531. * hold dummy elements!
  24532. */
  24533. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24534. private _hookArray;
  24535. /**
  24536. * Define if particles should be rendered in your texture.
  24537. */
  24538. renderParticles: boolean;
  24539. /**
  24540. * Define if sprites should be rendered in your texture.
  24541. */
  24542. renderSprites: boolean;
  24543. /**
  24544. * Define the camera used to render the texture.
  24545. */
  24546. activeCamera: Nullable<Camera>;
  24547. /**
  24548. * Override the mesh isReady function with your own one.
  24549. */
  24550. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24551. /**
  24552. * Override the render function of the texture with your own one.
  24553. */
  24554. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24555. /**
  24556. * Define if camera post processes should be use while rendering the texture.
  24557. */
  24558. useCameraPostProcesses: boolean;
  24559. /**
  24560. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24561. */
  24562. ignoreCameraViewport: boolean;
  24563. private _postProcessManager;
  24564. private _postProcesses;
  24565. private _resizeObserver;
  24566. /**
  24567. * An event triggered when the texture is unbind.
  24568. */
  24569. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24570. /**
  24571. * An event triggered when the texture is unbind.
  24572. */
  24573. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24574. private _onAfterUnbindObserver;
  24575. /**
  24576. * Set a after unbind callback in the texture.
  24577. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24578. */
  24579. set onAfterUnbind(callback: () => void);
  24580. /**
  24581. * An event triggered before rendering the texture
  24582. */
  24583. onBeforeRenderObservable: Observable<number>;
  24584. private _onBeforeRenderObserver;
  24585. /**
  24586. * Set a before render callback in the texture.
  24587. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24588. */
  24589. set onBeforeRender(callback: (faceIndex: number) => void);
  24590. /**
  24591. * An event triggered after rendering the texture
  24592. */
  24593. onAfterRenderObservable: Observable<number>;
  24594. private _onAfterRenderObserver;
  24595. /**
  24596. * Set a after render callback in the texture.
  24597. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24598. */
  24599. set onAfterRender(callback: (faceIndex: number) => void);
  24600. /**
  24601. * An event triggered after the texture clear
  24602. */
  24603. onClearObservable: Observable<Engine>;
  24604. private _onClearObserver;
  24605. /**
  24606. * Set a clear callback in the texture.
  24607. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24608. */
  24609. set onClear(callback: (Engine: Engine) => void);
  24610. /**
  24611. * An event triggered when the texture is resized.
  24612. */
  24613. onResizeObservable: Observable<RenderTargetTexture>;
  24614. /**
  24615. * Define the clear color of the Render Target if it should be different from the scene.
  24616. */
  24617. clearColor: Color4;
  24618. protected _size: number | {
  24619. width: number;
  24620. height: number;
  24621. layers?: number;
  24622. };
  24623. protected _initialSizeParameter: number | {
  24624. width: number;
  24625. height: number;
  24626. } | {
  24627. ratio: number;
  24628. };
  24629. protected _sizeRatio: Nullable<number>;
  24630. /** @hidden */
  24631. _generateMipMaps: boolean;
  24632. protected _renderingManager: RenderingManager;
  24633. /** @hidden */
  24634. _waitingRenderList?: string[];
  24635. protected _doNotChangeAspectRatio: boolean;
  24636. protected _currentRefreshId: number;
  24637. protected _refreshRate: number;
  24638. protected _textureMatrix: Matrix;
  24639. protected _samples: number;
  24640. protected _renderTargetOptions: RenderTargetCreationOptions;
  24641. /**
  24642. * Gets render target creation options that were used.
  24643. */
  24644. get renderTargetOptions(): RenderTargetCreationOptions;
  24645. protected _onRatioRescale(): void;
  24646. /**
  24647. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24648. * It must define where the camera used to render the texture is set
  24649. */
  24650. boundingBoxPosition: Vector3;
  24651. private _boundingBoxSize;
  24652. /**
  24653. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24654. * When defined, the cubemap will switch to local mode
  24655. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24656. * @example https://www.babylonjs-playground.com/#RNASML
  24657. */
  24658. set boundingBoxSize(value: Vector3);
  24659. get boundingBoxSize(): Vector3;
  24660. /**
  24661. * In case the RTT has been created with a depth texture, get the associated
  24662. * depth texture.
  24663. * Otherwise, return null.
  24664. */
  24665. get depthStencilTexture(): Nullable<InternalTexture>;
  24666. /**
  24667. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24668. * or used a shadow, depth texture...
  24669. * @param name The friendly name of the texture
  24670. * @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)
  24671. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24672. * @param generateMipMaps True if mip maps need to be generated after render.
  24673. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24674. * @param type The type of the buffer in the RTT (int, half float, float...)
  24675. * @param isCube True if a cube texture needs to be created
  24676. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24677. * @param generateDepthBuffer True to generate a depth buffer
  24678. * @param generateStencilBuffer True to generate a stencil buffer
  24679. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24680. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24681. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24682. */
  24683. constructor(name: string, size: number | {
  24684. width: number;
  24685. height: number;
  24686. layers?: number;
  24687. } | {
  24688. ratio: number;
  24689. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24690. /**
  24691. * Creates a depth stencil texture.
  24692. * This is only available in WebGL 2 or with the depth texture extension available.
  24693. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24694. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24695. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24696. */
  24697. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24698. private _processSizeParameter;
  24699. /**
  24700. * Define the number of samples to use in case of MSAA.
  24701. * It defaults to one meaning no MSAA has been enabled.
  24702. */
  24703. get samples(): number;
  24704. set samples(value: number);
  24705. /**
  24706. * Resets the refresh counter of the texture and start bak from scratch.
  24707. * Could be useful to regenerate the texture if it is setup to render only once.
  24708. */
  24709. resetRefreshCounter(): void;
  24710. /**
  24711. * Define the refresh rate of the texture or the rendering frequency.
  24712. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24713. */
  24714. get refreshRate(): number;
  24715. set refreshRate(value: number);
  24716. /**
  24717. * Adds a post process to the render target rendering passes.
  24718. * @param postProcess define the post process to add
  24719. */
  24720. addPostProcess(postProcess: PostProcess): void;
  24721. /**
  24722. * Clear all the post processes attached to the render target
  24723. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24724. */
  24725. clearPostProcesses(dispose?: boolean): void;
  24726. /**
  24727. * Remove one of the post process from the list of attached post processes to the texture
  24728. * @param postProcess define the post process to remove from the list
  24729. */
  24730. removePostProcess(postProcess: PostProcess): void;
  24731. /** @hidden */
  24732. _shouldRender(): boolean;
  24733. /**
  24734. * Gets the actual render size of the texture.
  24735. * @returns the width of the render size
  24736. */
  24737. getRenderSize(): number;
  24738. /**
  24739. * Gets the actual render width of the texture.
  24740. * @returns the width of the render size
  24741. */
  24742. getRenderWidth(): number;
  24743. /**
  24744. * Gets the actual render height of the texture.
  24745. * @returns the height of the render size
  24746. */
  24747. getRenderHeight(): number;
  24748. /**
  24749. * Gets the actual number of layers of the texture.
  24750. * @returns the number of layers
  24751. */
  24752. getRenderLayers(): number;
  24753. /**
  24754. * Get if the texture can be rescaled or not.
  24755. */
  24756. get canRescale(): boolean;
  24757. /**
  24758. * Resize the texture using a ratio.
  24759. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24760. */
  24761. scale(ratio: number): void;
  24762. /**
  24763. * Get the texture reflection matrix used to rotate/transform the reflection.
  24764. * @returns the reflection matrix
  24765. */
  24766. getReflectionTextureMatrix(): Matrix;
  24767. /**
  24768. * Resize the texture to a new desired size.
  24769. * Be carrefull as it will recreate all the data in the new texture.
  24770. * @param size Define the new size. It can be:
  24771. * - a number for squared texture,
  24772. * - an object containing { width: number, height: number }
  24773. * - or an object containing a ratio { ratio: number }
  24774. */
  24775. resize(size: number | {
  24776. width: number;
  24777. height: number;
  24778. } | {
  24779. ratio: number;
  24780. }): void;
  24781. private _defaultRenderListPrepared;
  24782. /**
  24783. * Renders all the objects from the render list into the texture.
  24784. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24785. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24786. */
  24787. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24788. private _bestReflectionRenderTargetDimension;
  24789. private _prepareRenderingManager;
  24790. /**
  24791. * @hidden
  24792. * @param faceIndex face index to bind to if this is a cubetexture
  24793. * @param layer defines the index of the texture to bind in the array
  24794. */
  24795. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24797. private renderToTarget;
  24798. /**
  24799. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24800. * This allowed control for front to back rendering or reversly depending of the special needs.
  24801. *
  24802. * @param renderingGroupId The rendering group id corresponding to its index
  24803. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24804. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24805. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24806. */
  24807. 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;
  24808. /**
  24809. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24810. *
  24811. * @param renderingGroupId The rendering group id corresponding to its index
  24812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24813. */
  24814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24815. /**
  24816. * Clones the texture.
  24817. * @returns the cloned texture
  24818. */
  24819. clone(): RenderTargetTexture;
  24820. /**
  24821. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24822. * @returns The JSON representation of the texture
  24823. */
  24824. serialize(): any;
  24825. /**
  24826. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24827. */
  24828. disposeFramebufferObjects(): void;
  24829. /**
  24830. * Dispose the texture and release its associated resources.
  24831. */
  24832. dispose(): void;
  24833. /** @hidden */
  24834. _rebuild(): void;
  24835. /**
  24836. * Clear the info related to rendering groups preventing retention point in material dispose.
  24837. */
  24838. freeRenderingGroups(): void;
  24839. /**
  24840. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24841. * @returns the view count
  24842. */
  24843. getViewCount(): number;
  24844. }
  24845. }
  24846. declare module "babylonjs/Misc/guid" {
  24847. /**
  24848. * Class used to manipulate GUIDs
  24849. */
  24850. export class GUID {
  24851. /**
  24852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24853. * Be aware Math.random() could cause collisions, but:
  24854. * "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"
  24855. * @returns a pseudo random id
  24856. */
  24857. static RandomId(): string;
  24858. }
  24859. }
  24860. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24861. import { Nullable } from "babylonjs/types";
  24862. import { Scene } from "babylonjs/scene";
  24863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24864. import { Material } from "babylonjs/Materials/material";
  24865. import { Effect } from "babylonjs/Materials/effect";
  24866. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24867. /**
  24868. * Options to be used when creating a shadow depth material
  24869. */
  24870. export interface IIOptionShadowDepthMaterial {
  24871. /** Variables in the vertex shader code that need to have their names remapped.
  24872. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24873. * "var_name" should be either: worldPos or vNormalW
  24874. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24875. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24876. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24877. */
  24878. remappedVariables?: string[];
  24879. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24880. standalone?: boolean;
  24881. }
  24882. /**
  24883. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24884. */
  24885. export class ShadowDepthWrapper {
  24886. private _scene;
  24887. private _options?;
  24888. private _baseMaterial;
  24889. private _onEffectCreatedObserver;
  24890. private _subMeshToEffect;
  24891. private _subMeshToDepthEffect;
  24892. private _meshes;
  24893. /** @hidden */
  24894. _matriceNames: any;
  24895. /** Gets the standalone status of the wrapper */
  24896. get standalone(): boolean;
  24897. /** Gets the base material the wrapper is built upon */
  24898. get baseMaterial(): Material;
  24899. /**
  24900. * Instantiate a new shadow depth wrapper.
  24901. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24902. * generate the shadow depth map. For more information, please refer to the documentation:
  24903. * https://doc.babylonjs.com/babylon101/shadows
  24904. * @param baseMaterial Material to wrap
  24905. * @param scene Define the scene the material belongs to
  24906. * @param options Options used to create the wrapper
  24907. */
  24908. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24909. /**
  24910. * Gets the effect to use to generate the depth map
  24911. * @param subMesh subMesh to get the effect for
  24912. * @param shadowGenerator shadow generator to get the effect for
  24913. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24914. */
  24915. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24916. /**
  24917. * Specifies that the submesh is ready to be used for depth rendering
  24918. * @param subMesh submesh to check
  24919. * @param defines the list of defines to take into account when checking the effect
  24920. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24921. * @param useInstances specifies that instances should be used
  24922. * @returns a boolean indicating that the submesh is ready or not
  24923. */
  24924. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24925. /**
  24926. * Disposes the resources
  24927. */
  24928. dispose(): void;
  24929. private _makeEffect;
  24930. }
  24931. }
  24932. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24934. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24935. import { Nullable } from "babylonjs/types";
  24936. module "babylonjs/Engines/thinEngine" {
  24937. interface ThinEngine {
  24938. /**
  24939. * Unbind a list of render target textures from the webGL context
  24940. * This is used only when drawBuffer extension or webGL2 are active
  24941. * @param textures defines the render target textures to unbind
  24942. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24943. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24944. */
  24945. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24946. /**
  24947. * Create a multi render target texture
  24948. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24949. * @param size defines the size of the texture
  24950. * @param options defines the creation options
  24951. * @returns the cube texture as an InternalTexture
  24952. */
  24953. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24954. /**
  24955. * Update the sample count for a given multiple render target texture
  24956. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24957. * @param textures defines the textures to update
  24958. * @param samples defines the sample count to set
  24959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24960. */
  24961. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24962. /**
  24963. * Select a subsets of attachments to draw to.
  24964. * @param attachments gl attachments
  24965. */
  24966. bindAttachments(attachments: number[]): void;
  24967. }
  24968. }
  24969. }
  24970. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24971. import { Scene } from "babylonjs/scene";
  24972. import { Engine } from "babylonjs/Engines/engine";
  24973. import { Texture } from "babylonjs/Materials/Textures/texture";
  24974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24975. import "babylonjs/Engines/Extensions/engine.multiRender";
  24976. /**
  24977. * Creation options of the multi render target texture.
  24978. */
  24979. export interface IMultiRenderTargetOptions {
  24980. /**
  24981. * Define if the texture needs to create mip maps after render.
  24982. */
  24983. generateMipMaps?: boolean;
  24984. /**
  24985. * Define the types of all the draw buffers we want to create
  24986. */
  24987. types?: number[];
  24988. /**
  24989. * Define the sampling modes of all the draw buffers we want to create
  24990. */
  24991. samplingModes?: number[];
  24992. /**
  24993. * Define if a depth buffer is required
  24994. */
  24995. generateDepthBuffer?: boolean;
  24996. /**
  24997. * Define if a stencil buffer is required
  24998. */
  24999. generateStencilBuffer?: boolean;
  25000. /**
  25001. * Define if a depth texture is required instead of a depth buffer
  25002. */
  25003. generateDepthTexture?: boolean;
  25004. /**
  25005. * Define the number of desired draw buffers
  25006. */
  25007. textureCount?: number;
  25008. /**
  25009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25010. */
  25011. doNotChangeAspectRatio?: boolean;
  25012. /**
  25013. * Define the default type of the buffers we are creating
  25014. */
  25015. defaultType?: number;
  25016. }
  25017. /**
  25018. * A multi render target, like a render target provides the ability to render to a texture.
  25019. * Unlike the render target, it can render to several draw buffers in one draw.
  25020. * This is specially interesting in deferred rendering or for any effects requiring more than
  25021. * just one color from a single pass.
  25022. */
  25023. export class MultiRenderTarget extends RenderTargetTexture {
  25024. private _internalTextures;
  25025. private _textures;
  25026. private _multiRenderTargetOptions;
  25027. private _count;
  25028. /**
  25029. * Get if draw buffers are currently supported by the used hardware and browser.
  25030. */
  25031. get isSupported(): boolean;
  25032. /**
  25033. * Get the list of textures generated by the multi render target.
  25034. */
  25035. get textures(): Texture[];
  25036. /**
  25037. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25038. */
  25039. get count(): number;
  25040. /**
  25041. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25042. */
  25043. get depthTexture(): Texture;
  25044. /**
  25045. * Set the wrapping mode on U of all the textures we are rendering to.
  25046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25047. */
  25048. set wrapU(wrap: number);
  25049. /**
  25050. * Set the wrapping mode on V of all the textures we are rendering to.
  25051. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25052. */
  25053. set wrapV(wrap: number);
  25054. /**
  25055. * Instantiate a new multi render target texture.
  25056. * A multi render target, like a render target provides the ability to render to a texture.
  25057. * Unlike the render target, it can render to several draw buffers in one draw.
  25058. * This is specially interesting in deferred rendering or for any effects requiring more than
  25059. * just one color from a single pass.
  25060. * @param name Define the name of the texture
  25061. * @param size Define the size of the buffers to render to
  25062. * @param count Define the number of target we are rendering into
  25063. * @param scene Define the scene the texture belongs to
  25064. * @param options Define the options used to create the multi render target
  25065. */
  25066. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25067. private _initTypes;
  25068. /** @hidden */
  25069. _rebuild(forceFullRebuild?: boolean): void;
  25070. private _createInternalTextures;
  25071. private _createTextures;
  25072. /**
  25073. * Define the number of samples used if MSAA is enabled.
  25074. */
  25075. get samples(): number;
  25076. set samples(value: number);
  25077. /**
  25078. * Resize all the textures in the multi render target.
  25079. * Be careful as it will recreate all the data in the new texture.
  25080. * @param size Define the new size
  25081. */
  25082. resize(size: any): void;
  25083. /**
  25084. * Changes the number of render targets in this MRT
  25085. * Be careful as it will recreate all the data in the new texture.
  25086. * @param count new texture count
  25087. * @param options Specifies texture types and sampling modes for new textures
  25088. */
  25089. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25090. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25091. /**
  25092. * Dispose the render targets and their associated resources
  25093. */
  25094. dispose(): void;
  25095. /**
  25096. * Release all the underlying texture used as draw buffers.
  25097. */
  25098. releaseInternalTextures(): void;
  25099. }
  25100. }
  25101. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25102. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25104. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25105. /** @hidden */
  25106. export var imageProcessingPixelShader: {
  25107. name: string;
  25108. shader: string;
  25109. };
  25110. }
  25111. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25112. import { Nullable } from "babylonjs/types";
  25113. import { Color4 } from "babylonjs/Maths/math.color";
  25114. import { Camera } from "babylonjs/Cameras/camera";
  25115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25116. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25117. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25119. import { Engine } from "babylonjs/Engines/engine";
  25120. import "babylonjs/Shaders/imageProcessing.fragment";
  25121. import "babylonjs/Shaders/postprocess.vertex";
  25122. /**
  25123. * ImageProcessingPostProcess
  25124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25125. */
  25126. export class ImageProcessingPostProcess extends PostProcess {
  25127. /**
  25128. * Default configuration related to image processing available in the PBR Material.
  25129. */
  25130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25131. /**
  25132. * Gets the image processing configuration used either in this material.
  25133. */
  25134. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25135. /**
  25136. * Sets the Default image processing configuration used either in the this material.
  25137. *
  25138. * If sets to null, the scene one is in use.
  25139. */
  25140. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25141. /**
  25142. * Keep track of the image processing observer to allow dispose and replace.
  25143. */
  25144. private _imageProcessingObserver;
  25145. /**
  25146. * Attaches a new image processing configuration to the PBR Material.
  25147. * @param configuration
  25148. */
  25149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25150. /**
  25151. * If the post process is supported.
  25152. */
  25153. get isSupported(): boolean;
  25154. /**
  25155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25156. */
  25157. get colorCurves(): Nullable<ColorCurves>;
  25158. /**
  25159. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25160. */
  25161. set colorCurves(value: Nullable<ColorCurves>);
  25162. /**
  25163. * Gets wether the color curves effect is enabled.
  25164. */
  25165. get colorCurvesEnabled(): boolean;
  25166. /**
  25167. * Sets wether the color curves effect is enabled.
  25168. */
  25169. set colorCurvesEnabled(value: boolean);
  25170. /**
  25171. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25172. */
  25173. get colorGradingTexture(): Nullable<BaseTexture>;
  25174. /**
  25175. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25176. */
  25177. set colorGradingTexture(value: Nullable<BaseTexture>);
  25178. /**
  25179. * Gets wether the color grading effect is enabled.
  25180. */
  25181. get colorGradingEnabled(): boolean;
  25182. /**
  25183. * Gets wether the color grading effect is enabled.
  25184. */
  25185. set colorGradingEnabled(value: boolean);
  25186. /**
  25187. * Gets exposure used in the effect.
  25188. */
  25189. get exposure(): number;
  25190. /**
  25191. * Sets exposure used in the effect.
  25192. */
  25193. set exposure(value: number);
  25194. /**
  25195. * Gets wether tonemapping is enabled or not.
  25196. */
  25197. get toneMappingEnabled(): boolean;
  25198. /**
  25199. * Sets wether tonemapping is enabled or not
  25200. */
  25201. set toneMappingEnabled(value: boolean);
  25202. /**
  25203. * Gets the type of tone mapping effect.
  25204. */
  25205. get toneMappingType(): number;
  25206. /**
  25207. * Sets the type of tone mapping effect.
  25208. */
  25209. set toneMappingType(value: number);
  25210. /**
  25211. * Gets contrast used in the effect.
  25212. */
  25213. get contrast(): number;
  25214. /**
  25215. * Sets contrast used in the effect.
  25216. */
  25217. set contrast(value: number);
  25218. /**
  25219. * Gets Vignette stretch size.
  25220. */
  25221. get vignetteStretch(): number;
  25222. /**
  25223. * Sets Vignette stretch size.
  25224. */
  25225. set vignetteStretch(value: number);
  25226. /**
  25227. * Gets Vignette centre X Offset.
  25228. */
  25229. get vignetteCentreX(): number;
  25230. /**
  25231. * Sets Vignette centre X Offset.
  25232. */
  25233. set vignetteCentreX(value: number);
  25234. /**
  25235. * Gets Vignette centre Y Offset.
  25236. */
  25237. get vignetteCentreY(): number;
  25238. /**
  25239. * Sets Vignette centre Y Offset.
  25240. */
  25241. set vignetteCentreY(value: number);
  25242. /**
  25243. * Gets Vignette weight or intensity of the vignette effect.
  25244. */
  25245. get vignetteWeight(): number;
  25246. /**
  25247. * Sets Vignette weight or intensity of the vignette effect.
  25248. */
  25249. set vignetteWeight(value: number);
  25250. /**
  25251. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25252. * if vignetteEnabled is set to true.
  25253. */
  25254. get vignetteColor(): Color4;
  25255. /**
  25256. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25257. * if vignetteEnabled is set to true.
  25258. */
  25259. set vignetteColor(value: Color4);
  25260. /**
  25261. * Gets Camera field of view used by the Vignette effect.
  25262. */
  25263. get vignetteCameraFov(): number;
  25264. /**
  25265. * Sets Camera field of view used by the Vignette effect.
  25266. */
  25267. set vignetteCameraFov(value: number);
  25268. /**
  25269. * Gets the vignette blend mode allowing different kind of effect.
  25270. */
  25271. get vignetteBlendMode(): number;
  25272. /**
  25273. * Sets the vignette blend mode allowing different kind of effect.
  25274. */
  25275. set vignetteBlendMode(value: number);
  25276. /**
  25277. * Gets wether the vignette effect is enabled.
  25278. */
  25279. get vignetteEnabled(): boolean;
  25280. /**
  25281. * Sets wether the vignette effect is enabled.
  25282. */
  25283. set vignetteEnabled(value: boolean);
  25284. private _fromLinearSpace;
  25285. /**
  25286. * Gets wether the input of the processing is in Gamma or Linear Space.
  25287. */
  25288. get fromLinearSpace(): boolean;
  25289. /**
  25290. * Sets wether the input of the processing is in Gamma or Linear Space.
  25291. */
  25292. set fromLinearSpace(value: boolean);
  25293. /**
  25294. * Defines cache preventing GC.
  25295. */
  25296. private _defines;
  25297. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25298. /**
  25299. * "ImageProcessingPostProcess"
  25300. * @returns "ImageProcessingPostProcess"
  25301. */
  25302. getClassName(): string;
  25303. /**
  25304. * @hidden
  25305. */
  25306. _updateParameters(): void;
  25307. dispose(camera?: Camera): void;
  25308. }
  25309. }
  25310. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25311. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25312. /**
  25313. * Interface for defining prepass effects in the prepass post-process pipeline
  25314. */
  25315. export interface PrePassEffectConfiguration {
  25316. /**
  25317. * Name of the effect
  25318. */
  25319. name: string;
  25320. /**
  25321. * Post process to attach for this effect
  25322. */
  25323. postProcess?: PostProcess;
  25324. /**
  25325. * Textures required in the MRT
  25326. */
  25327. texturesRequired: number[];
  25328. /**
  25329. * Is the effect enabled
  25330. */
  25331. enabled: boolean;
  25332. /**
  25333. * Disposes the effect configuration
  25334. */
  25335. dispose(): void;
  25336. /**
  25337. * Creates the associated post process
  25338. */
  25339. createPostProcess?: () => PostProcess;
  25340. }
  25341. }
  25342. declare module "babylonjs/Rendering/prePassRenderer" {
  25343. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25344. import { Scene } from "babylonjs/scene";
  25345. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25346. import { Effect } from "babylonjs/Materials/effect";
  25347. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25348. /**
  25349. * Renders a pre pass of the scene
  25350. * This means every mesh in the scene will be rendered to a render target texture
  25351. * And then this texture will be composited to the rendering canvas with post processes
  25352. * It is necessary for effects like subsurface scattering or deferred shading
  25353. */
  25354. export class PrePassRenderer {
  25355. /** @hidden */
  25356. static _SceneComponentInitialization: (scene: Scene) => void;
  25357. private _textureFormats;
  25358. private _textureIndices;
  25359. private _scene;
  25360. private _engine;
  25361. private _isDirty;
  25362. /**
  25363. * Number of textures in the multi render target texture where the scene is directly rendered
  25364. */
  25365. mrtCount: number;
  25366. /**
  25367. * The render target where the scene is directly rendered
  25368. */
  25369. prePassRT: MultiRenderTarget;
  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 prepass effects
  25381. */
  25382. private _effectConfigurations;
  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 _mrtFormats;
  25392. private _mrtLayout;
  25393. private _enabled;
  25394. /**
  25395. * Indicates if the prepass is enabled
  25396. */
  25397. get enabled(): boolean;
  25398. /**
  25399. * How many samples are used for MSAA of the scene render target
  25400. */
  25401. get samples(): number;
  25402. set samples(n: number);
  25403. /**
  25404. * Instanciates a prepass renderer
  25405. * @param scene The scene
  25406. */
  25407. constructor(scene: Scene);
  25408. private _initializeAttachments;
  25409. private _createCompositionEffect;
  25410. /**
  25411. * Indicates if rendering a prepass is supported
  25412. */
  25413. get isSupported(): boolean;
  25414. /**
  25415. * Sets the proper output textures to draw in the engine.
  25416. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25417. */
  25418. bindAttachmentsForEffect(effect: Effect): void;
  25419. /**
  25420. * @hidden
  25421. */
  25422. _beforeCameraDraw(): void;
  25423. /**
  25424. * @hidden
  25425. */
  25426. _afterCameraDraw(): void;
  25427. private _checkRTSize;
  25428. private _bindFrameBuffer;
  25429. /**
  25430. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25431. */
  25432. clear(): void;
  25433. private _setState;
  25434. private _checkTextureType;
  25435. /**
  25436. * Adds an effect configuration to the prepass.
  25437. * If an effect has already been added, it won't add it twice and will return the configuration
  25438. * already present.
  25439. * @param cfg the effect configuration
  25440. * @return the effect configuration now used by the prepass
  25441. */
  25442. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25443. /**
  25444. * Returns the index of a texture in the multi render target texture array.
  25445. * @param type Texture type
  25446. * @return The index
  25447. */
  25448. getIndex(type: number): number;
  25449. private _enable;
  25450. private _disable;
  25451. private _resetLayout;
  25452. private _resetPostProcessChain;
  25453. private _bindPostProcessChain;
  25454. /**
  25455. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25456. */
  25457. markAsDirty(): void;
  25458. /**
  25459. * Enables a texture on the MultiRenderTarget for prepass
  25460. */
  25461. private _enableTextures;
  25462. private _update;
  25463. /**
  25464. * Disposes the prepass renderer.
  25465. */
  25466. dispose(): void;
  25467. }
  25468. }
  25469. declare module "babylonjs/Materials/material" {
  25470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25471. import { SmartArray } from "babylonjs/Misc/smartArray";
  25472. import { Observable } from "babylonjs/Misc/observable";
  25473. import { Nullable } from "babylonjs/types";
  25474. import { Scene } from "babylonjs/scene";
  25475. import { Matrix } from "babylonjs/Maths/math.vector";
  25476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25479. import { Effect } from "babylonjs/Materials/effect";
  25480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25482. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25483. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25484. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25485. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25486. import { Mesh } from "babylonjs/Meshes/mesh";
  25487. import { Animation } from "babylonjs/Animations/animation";
  25488. /**
  25489. * Options for compiling materials.
  25490. */
  25491. export interface IMaterialCompilationOptions {
  25492. /**
  25493. * Defines whether clip planes are enabled.
  25494. */
  25495. clipPlane: boolean;
  25496. /**
  25497. * Defines whether instances are enabled.
  25498. */
  25499. useInstances: boolean;
  25500. }
  25501. /**
  25502. * Options passed when calling customShaderNameResolve
  25503. */
  25504. export interface ICustomShaderNameResolveOptions {
  25505. /**
  25506. * 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
  25507. */
  25508. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25509. }
  25510. /**
  25511. * Base class for the main features of a material in Babylon.js
  25512. */
  25513. export class Material implements IAnimatable {
  25514. /**
  25515. * Returns the triangle fill mode
  25516. */
  25517. static readonly TriangleFillMode: number;
  25518. /**
  25519. * Returns the wireframe mode
  25520. */
  25521. static readonly WireFrameFillMode: number;
  25522. /**
  25523. * Returns the point fill mode
  25524. */
  25525. static readonly PointFillMode: number;
  25526. /**
  25527. * Returns the point list draw mode
  25528. */
  25529. static readonly PointListDrawMode: number;
  25530. /**
  25531. * Returns the line list draw mode
  25532. */
  25533. static readonly LineListDrawMode: number;
  25534. /**
  25535. * Returns the line loop draw mode
  25536. */
  25537. static readonly LineLoopDrawMode: number;
  25538. /**
  25539. * Returns the line strip draw mode
  25540. */
  25541. static readonly LineStripDrawMode: number;
  25542. /**
  25543. * Returns the triangle strip draw mode
  25544. */
  25545. static readonly TriangleStripDrawMode: number;
  25546. /**
  25547. * Returns the triangle fan draw mode
  25548. */
  25549. static readonly TriangleFanDrawMode: number;
  25550. /**
  25551. * Stores the clock-wise side orientation
  25552. */
  25553. static readonly ClockWiseSideOrientation: number;
  25554. /**
  25555. * Stores the counter clock-wise side orientation
  25556. */
  25557. static readonly CounterClockWiseSideOrientation: number;
  25558. /**
  25559. * The dirty texture flag value
  25560. */
  25561. static readonly TextureDirtyFlag: number;
  25562. /**
  25563. * The dirty light flag value
  25564. */
  25565. static readonly LightDirtyFlag: number;
  25566. /**
  25567. * The dirty fresnel flag value
  25568. */
  25569. static readonly FresnelDirtyFlag: number;
  25570. /**
  25571. * The dirty attribute flag value
  25572. */
  25573. static readonly AttributesDirtyFlag: number;
  25574. /**
  25575. * The dirty misc flag value
  25576. */
  25577. static readonly MiscDirtyFlag: number;
  25578. /**
  25579. * The all dirty flag value
  25580. */
  25581. static readonly AllDirtyFlag: number;
  25582. /**
  25583. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25584. */
  25585. static readonly MATERIAL_OPAQUE: number;
  25586. /**
  25587. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25588. */
  25589. static readonly MATERIAL_ALPHATEST: number;
  25590. /**
  25591. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25592. */
  25593. static readonly MATERIAL_ALPHABLEND: number;
  25594. /**
  25595. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25596. * They are also discarded below the alpha cutoff threshold to improve performances.
  25597. */
  25598. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25599. /**
  25600. * The Whiteout method is used to blend normals.
  25601. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25602. */
  25603. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25604. /**
  25605. * The Reoriented Normal Mapping method is used to blend normals.
  25606. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25607. */
  25608. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25609. /**
  25610. * Custom callback helping to override the default shader used in the material.
  25611. */
  25612. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25613. /**
  25614. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25615. */
  25616. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25617. /**
  25618. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25619. * This means that the material can keep using a previous shader while a new one is being compiled.
  25620. * This is mostly used when shader parallel compilation is supported (true by default)
  25621. */
  25622. allowShaderHotSwapping: boolean;
  25623. /**
  25624. * The ID of the material
  25625. */
  25626. id: string;
  25627. /**
  25628. * Gets or sets the unique id of the material
  25629. */
  25630. uniqueId: number;
  25631. /**
  25632. * The name of the material
  25633. */
  25634. name: string;
  25635. /**
  25636. * Gets or sets user defined metadata
  25637. */
  25638. metadata: any;
  25639. /**
  25640. * For internal use only. Please do not use.
  25641. */
  25642. reservedDataStore: any;
  25643. /**
  25644. * Specifies if the ready state should be checked on each call
  25645. */
  25646. checkReadyOnEveryCall: boolean;
  25647. /**
  25648. * Specifies if the ready state should be checked once
  25649. */
  25650. checkReadyOnlyOnce: boolean;
  25651. /**
  25652. * The state of the material
  25653. */
  25654. state: string;
  25655. /**
  25656. * If the material can be rendered to several textures with MRT extension
  25657. */
  25658. get canRenderToMRT(): boolean;
  25659. /**
  25660. * The alpha value of the material
  25661. */
  25662. protected _alpha: number;
  25663. /**
  25664. * List of inspectable custom properties (used by the Inspector)
  25665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25666. */
  25667. inspectableCustomProperties: IInspectable[];
  25668. /**
  25669. * Sets the alpha value of the material
  25670. */
  25671. set alpha(value: number);
  25672. /**
  25673. * Gets the alpha value of the material
  25674. */
  25675. get alpha(): number;
  25676. /**
  25677. * Specifies if back face culling is enabled
  25678. */
  25679. protected _backFaceCulling: boolean;
  25680. /**
  25681. * Sets the back-face culling state
  25682. */
  25683. set backFaceCulling(value: boolean);
  25684. /**
  25685. * Gets the back-face culling state
  25686. */
  25687. get backFaceCulling(): boolean;
  25688. /**
  25689. * Stores the value for side orientation
  25690. */
  25691. sideOrientation: number;
  25692. /**
  25693. * Callback triggered when the material is compiled
  25694. */
  25695. onCompiled: Nullable<(effect: Effect) => void>;
  25696. /**
  25697. * Callback triggered when an error occurs
  25698. */
  25699. onError: Nullable<(effect: Effect, errors: string) => void>;
  25700. /**
  25701. * Callback triggered to get the render target textures
  25702. */
  25703. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25704. /**
  25705. * Gets a boolean indicating that current material needs to register RTT
  25706. */
  25707. get hasRenderTargetTextures(): boolean;
  25708. /**
  25709. * Specifies if the material should be serialized
  25710. */
  25711. doNotSerialize: boolean;
  25712. /**
  25713. * @hidden
  25714. */
  25715. _storeEffectOnSubMeshes: boolean;
  25716. /**
  25717. * Stores the animations for the material
  25718. */
  25719. animations: Nullable<Array<Animation>>;
  25720. /**
  25721. * An event triggered when the material is disposed
  25722. */
  25723. onDisposeObservable: Observable<Material>;
  25724. /**
  25725. * An observer which watches for dispose events
  25726. */
  25727. private _onDisposeObserver;
  25728. private _onUnBindObservable;
  25729. /**
  25730. * Called during a dispose event
  25731. */
  25732. set onDispose(callback: () => void);
  25733. private _onBindObservable;
  25734. /**
  25735. * An event triggered when the material is bound
  25736. */
  25737. get onBindObservable(): Observable<AbstractMesh>;
  25738. /**
  25739. * An observer which watches for bind events
  25740. */
  25741. private _onBindObserver;
  25742. /**
  25743. * Called during a bind event
  25744. */
  25745. set onBind(callback: (Mesh: AbstractMesh) => void);
  25746. /**
  25747. * An event triggered when the material is unbound
  25748. */
  25749. get onUnBindObservable(): Observable<Material>;
  25750. protected _onEffectCreatedObservable: Nullable<Observable<{
  25751. effect: Effect;
  25752. subMesh: Nullable<SubMesh>;
  25753. }>>;
  25754. /**
  25755. * An event triggered when the effect is (re)created
  25756. */
  25757. get onEffectCreatedObservable(): Observable<{
  25758. effect: Effect;
  25759. subMesh: Nullable<SubMesh>;
  25760. }>;
  25761. /**
  25762. * Stores the value of the alpha mode
  25763. */
  25764. private _alphaMode;
  25765. /**
  25766. * Sets the value of the alpha mode.
  25767. *
  25768. * | Value | Type | Description |
  25769. * | --- | --- | --- |
  25770. * | 0 | ALPHA_DISABLE | |
  25771. * | 1 | ALPHA_ADD | |
  25772. * | 2 | ALPHA_COMBINE | |
  25773. * | 3 | ALPHA_SUBTRACT | |
  25774. * | 4 | ALPHA_MULTIPLY | |
  25775. * | 5 | ALPHA_MAXIMIZED | |
  25776. * | 6 | ALPHA_ONEONE | |
  25777. * | 7 | ALPHA_PREMULTIPLIED | |
  25778. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25779. * | 9 | ALPHA_INTERPOLATE | |
  25780. * | 10 | ALPHA_SCREENMODE | |
  25781. *
  25782. */
  25783. set alphaMode(value: number);
  25784. /**
  25785. * Gets the value of the alpha mode
  25786. */
  25787. get alphaMode(): number;
  25788. /**
  25789. * Stores the state of the need depth pre-pass value
  25790. */
  25791. private _needDepthPrePass;
  25792. /**
  25793. * Sets the need depth pre-pass value
  25794. */
  25795. set needDepthPrePass(value: boolean);
  25796. /**
  25797. * Gets the depth pre-pass value
  25798. */
  25799. get needDepthPrePass(): boolean;
  25800. /**
  25801. * Specifies if depth writing should be disabled
  25802. */
  25803. disableDepthWrite: boolean;
  25804. /**
  25805. * Specifies if color writing should be disabled
  25806. */
  25807. disableColorWrite: boolean;
  25808. /**
  25809. * Specifies if depth writing should be forced
  25810. */
  25811. forceDepthWrite: boolean;
  25812. /**
  25813. * Specifies the depth function that should be used. 0 means the default engine function
  25814. */
  25815. depthFunction: number;
  25816. /**
  25817. * Specifies if there should be a separate pass for culling
  25818. */
  25819. separateCullingPass: boolean;
  25820. /**
  25821. * Stores the state specifing if fog should be enabled
  25822. */
  25823. private _fogEnabled;
  25824. /**
  25825. * Sets the state for enabling fog
  25826. */
  25827. set fogEnabled(value: boolean);
  25828. /**
  25829. * Gets the value of the fog enabled state
  25830. */
  25831. get fogEnabled(): boolean;
  25832. /**
  25833. * Stores the size of points
  25834. */
  25835. pointSize: number;
  25836. /**
  25837. * Stores the z offset value
  25838. */
  25839. zOffset: number;
  25840. get wireframe(): boolean;
  25841. /**
  25842. * Sets the state of wireframe mode
  25843. */
  25844. set wireframe(value: boolean);
  25845. /**
  25846. * Gets the value specifying if point clouds are enabled
  25847. */
  25848. get pointsCloud(): boolean;
  25849. /**
  25850. * Sets the state of point cloud mode
  25851. */
  25852. set pointsCloud(value: boolean);
  25853. /**
  25854. * Gets the material fill mode
  25855. */
  25856. get fillMode(): number;
  25857. /**
  25858. * Sets the material fill mode
  25859. */
  25860. set fillMode(value: number);
  25861. /**
  25862. * @hidden
  25863. * Stores the effects for the material
  25864. */
  25865. _effect: Nullable<Effect>;
  25866. /**
  25867. * Specifies if uniform buffers should be used
  25868. */
  25869. private _useUBO;
  25870. /**
  25871. * Stores a reference to the scene
  25872. */
  25873. private _scene;
  25874. /**
  25875. * Stores the fill mode state
  25876. */
  25877. private _fillMode;
  25878. /**
  25879. * Specifies if the depth write state should be cached
  25880. */
  25881. private _cachedDepthWriteState;
  25882. /**
  25883. * Specifies if the color write state should be cached
  25884. */
  25885. private _cachedColorWriteState;
  25886. /**
  25887. * Specifies if the depth function state should be cached
  25888. */
  25889. private _cachedDepthFunctionState;
  25890. /**
  25891. * Stores the uniform buffer
  25892. */
  25893. protected _uniformBuffer: UniformBuffer;
  25894. /** @hidden */
  25895. _indexInSceneMaterialArray: number;
  25896. /** @hidden */
  25897. meshMap: Nullable<{
  25898. [id: string]: AbstractMesh | undefined;
  25899. }>;
  25900. /**
  25901. * Creates a material instance
  25902. * @param name defines the name of the material
  25903. * @param scene defines the scene to reference
  25904. * @param doNotAdd specifies if the material should be added to the scene
  25905. */
  25906. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25907. /**
  25908. * Returns a string representation of the current material
  25909. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25910. * @returns a string with material information
  25911. */
  25912. toString(fullDetails?: boolean): string;
  25913. /**
  25914. * Gets the class name of the material
  25915. * @returns a string with the class name of the material
  25916. */
  25917. getClassName(): string;
  25918. /**
  25919. * Specifies if updates for the material been locked
  25920. */
  25921. get isFrozen(): boolean;
  25922. /**
  25923. * Locks updates for the material
  25924. */
  25925. freeze(): void;
  25926. /**
  25927. * Unlocks updates for the material
  25928. */
  25929. unfreeze(): void;
  25930. /**
  25931. * Specifies if the material is ready to be used
  25932. * @param mesh defines the mesh to check
  25933. * @param useInstances specifies if instances should be used
  25934. * @returns a boolean indicating if the material is ready to be used
  25935. */
  25936. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25937. /**
  25938. * Specifies that the submesh is ready to be used
  25939. * @param mesh defines the mesh to check
  25940. * @param subMesh defines which submesh to check
  25941. * @param useInstances specifies that instances should be used
  25942. * @returns a boolean indicating that the submesh is ready or not
  25943. */
  25944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25945. /**
  25946. * Returns the material effect
  25947. * @returns the effect associated with the material
  25948. */
  25949. getEffect(): Nullable<Effect>;
  25950. /**
  25951. * Returns the current scene
  25952. * @returns a Scene
  25953. */
  25954. getScene(): Scene;
  25955. /**
  25956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25957. */
  25958. protected _forceAlphaTest: boolean;
  25959. /**
  25960. * The transparency mode of the material.
  25961. */
  25962. protected _transparencyMode: Nullable<number>;
  25963. /**
  25964. * Gets the current transparency mode.
  25965. */
  25966. get transparencyMode(): Nullable<number>;
  25967. /**
  25968. * Sets the transparency mode of the material.
  25969. *
  25970. * | Value | Type | Description |
  25971. * | ----- | ----------------------------------- | ----------- |
  25972. * | 0 | OPAQUE | |
  25973. * | 1 | ALPHATEST | |
  25974. * | 2 | ALPHABLEND | |
  25975. * | 3 | ALPHATESTANDBLEND | |
  25976. *
  25977. */
  25978. set transparencyMode(value: Nullable<number>);
  25979. /**
  25980. * Returns true if alpha blending should be disabled.
  25981. */
  25982. protected get _disableAlphaBlending(): boolean;
  25983. /**
  25984. * Specifies whether or not this material should be rendered in alpha blend mode.
  25985. * @returns a boolean specifying if alpha blending is needed
  25986. */
  25987. needAlphaBlending(): boolean;
  25988. /**
  25989. * Specifies if the mesh will require alpha blending
  25990. * @param mesh defines the mesh to check
  25991. * @returns a boolean specifying if alpha blending is needed for the mesh
  25992. */
  25993. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25994. /**
  25995. * Specifies whether or not this material should be rendered in alpha test mode.
  25996. * @returns a boolean specifying if an alpha test is needed.
  25997. */
  25998. needAlphaTesting(): boolean;
  25999. /**
  26000. * Specifies if material alpha testing should be turned on for the mesh
  26001. * @param mesh defines the mesh to check
  26002. */
  26003. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26004. /**
  26005. * Gets the texture used for the alpha test
  26006. * @returns the texture to use for alpha testing
  26007. */
  26008. getAlphaTestTexture(): Nullable<BaseTexture>;
  26009. /**
  26010. * Marks the material to indicate that it needs to be re-calculated
  26011. */
  26012. markDirty(): void;
  26013. /** @hidden */
  26014. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26015. /**
  26016. * Binds the material to the mesh
  26017. * @param world defines the world transformation matrix
  26018. * @param mesh defines the mesh to bind the material to
  26019. */
  26020. bind(world: Matrix, mesh?: Mesh): void;
  26021. /**
  26022. * Binds the submesh to the material
  26023. * @param world defines the world transformation matrix
  26024. * @param mesh defines the mesh containing the submesh
  26025. * @param subMesh defines the submesh to bind the material to
  26026. */
  26027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26028. /**
  26029. * Binds the world matrix to the material
  26030. * @param world defines the world transformation matrix
  26031. */
  26032. bindOnlyWorldMatrix(world: Matrix): void;
  26033. /**
  26034. * Binds the scene's uniform buffer to the effect.
  26035. * @param effect defines the effect to bind to the scene uniform buffer
  26036. * @param sceneUbo defines the uniform buffer storing scene data
  26037. */
  26038. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26039. /**
  26040. * Binds the view matrix to the effect
  26041. * @param effect defines the effect to bind the view matrix to
  26042. */
  26043. bindView(effect: Effect): void;
  26044. /**
  26045. * Binds the view projection matrix to the effect
  26046. * @param effect defines the effect to bind the view projection matrix to
  26047. */
  26048. bindViewProjection(effect: Effect): void;
  26049. /**
  26050. * Processes to execute after binding the material to a mesh
  26051. * @param mesh defines the rendered mesh
  26052. */
  26053. protected _afterBind(mesh?: Mesh): void;
  26054. /**
  26055. * Unbinds the material from the mesh
  26056. */
  26057. unbind(): void;
  26058. /**
  26059. * Gets the active textures from the material
  26060. * @returns an array of textures
  26061. */
  26062. getActiveTextures(): BaseTexture[];
  26063. /**
  26064. * Specifies if the material uses a texture
  26065. * @param texture defines the texture to check against the material
  26066. * @returns a boolean specifying if the material uses the texture
  26067. */
  26068. hasTexture(texture: BaseTexture): boolean;
  26069. /**
  26070. * Makes a duplicate of the material, and gives it a new name
  26071. * @param name defines the new name for the duplicated material
  26072. * @returns the cloned material
  26073. */
  26074. clone(name: string): Nullable<Material>;
  26075. /**
  26076. * Gets the meshes bound to the material
  26077. * @returns an array of meshes bound to the material
  26078. */
  26079. getBindedMeshes(): AbstractMesh[];
  26080. /**
  26081. * Force shader compilation
  26082. * @param mesh defines the mesh associated with this material
  26083. * @param onCompiled defines a function to execute once the material is compiled
  26084. * @param options defines the options to configure the compilation
  26085. * @param onError defines a function to execute if the material fails compiling
  26086. */
  26087. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26088. /**
  26089. * Force shader compilation
  26090. * @param mesh defines the mesh that will use this material
  26091. * @param options defines additional options for compiling the shaders
  26092. * @returns a promise that resolves when the compilation completes
  26093. */
  26094. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26095. private static readonly _AllDirtyCallBack;
  26096. private static readonly _ImageProcessingDirtyCallBack;
  26097. private static readonly _TextureDirtyCallBack;
  26098. private static readonly _FresnelDirtyCallBack;
  26099. private static readonly _MiscDirtyCallBack;
  26100. private static readonly _LightsDirtyCallBack;
  26101. private static readonly _AttributeDirtyCallBack;
  26102. private static _FresnelAndMiscDirtyCallBack;
  26103. private static _TextureAndMiscDirtyCallBack;
  26104. private static readonly _DirtyCallbackArray;
  26105. private static readonly _RunDirtyCallBacks;
  26106. /**
  26107. * Marks a define in the material to indicate that it needs to be re-computed
  26108. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26109. */
  26110. markAsDirty(flag: number): void;
  26111. /**
  26112. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26113. * @param func defines a function which checks material defines against the submeshes
  26114. */
  26115. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26116. /**
  26117. * Indicates that the scene should check if the rendering now needs a prepass
  26118. */
  26119. protected _markScenePrePassDirty(): void;
  26120. /**
  26121. * Indicates that we need to re-calculated for all submeshes
  26122. */
  26123. protected _markAllSubMeshesAsAllDirty(): void;
  26124. /**
  26125. * Indicates that image processing needs to be re-calculated for all submeshes
  26126. */
  26127. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26128. /**
  26129. * Indicates that textures need to be re-calculated for all submeshes
  26130. */
  26131. protected _markAllSubMeshesAsTexturesDirty(): void;
  26132. /**
  26133. * Indicates that fresnel needs to be re-calculated for all submeshes
  26134. */
  26135. protected _markAllSubMeshesAsFresnelDirty(): void;
  26136. /**
  26137. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26138. */
  26139. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26140. /**
  26141. * Indicates that lights need to be re-calculated for all submeshes
  26142. */
  26143. protected _markAllSubMeshesAsLightsDirty(): void;
  26144. /**
  26145. * Indicates that attributes need to be re-calculated for all submeshes
  26146. */
  26147. protected _markAllSubMeshesAsAttributesDirty(): void;
  26148. /**
  26149. * Indicates that misc needs to be re-calculated for all submeshes
  26150. */
  26151. protected _markAllSubMeshesAsMiscDirty(): void;
  26152. /**
  26153. * Indicates that textures and misc need to be re-calculated for all submeshes
  26154. */
  26155. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26156. /**
  26157. * Sets the required values to the prepass renderer.
  26158. * @param prePassRenderer defines the prepass renderer to setup.
  26159. * @returns true if the pre pass is needed.
  26160. */
  26161. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26162. /**
  26163. * Disposes the material
  26164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26166. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26167. */
  26168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26169. /** @hidden */
  26170. private releaseVertexArrayObject;
  26171. /**
  26172. * Serializes this material
  26173. * @returns the serialized material object
  26174. */
  26175. serialize(): any;
  26176. /**
  26177. * Creates a material from parsed material data
  26178. * @param parsedMaterial defines parsed material data
  26179. * @param scene defines the hosting scene
  26180. * @param rootUrl defines the root URL to use to load textures
  26181. * @returns a new material
  26182. */
  26183. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26184. }
  26185. }
  26186. declare module "babylonjs/Materials/multiMaterial" {
  26187. import { Nullable } from "babylonjs/types";
  26188. import { Scene } from "babylonjs/scene";
  26189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26192. import { Material } from "babylonjs/Materials/material";
  26193. /**
  26194. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26195. * separate meshes. This can be use to improve performances.
  26196. * @see https://doc.babylonjs.com/how_to/multi_materials
  26197. */
  26198. export class MultiMaterial extends Material {
  26199. private _subMaterials;
  26200. /**
  26201. * Gets or Sets the list of Materials used within the multi material.
  26202. * They need to be ordered according to the submeshes order in the associated mesh
  26203. */
  26204. get subMaterials(): Nullable<Material>[];
  26205. set subMaterials(value: Nullable<Material>[]);
  26206. /**
  26207. * Function used to align with Node.getChildren()
  26208. * @returns the list of Materials used within the multi material
  26209. */
  26210. getChildren(): Nullable<Material>[];
  26211. /**
  26212. * Instantiates a new Multi Material
  26213. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26214. * separate meshes. This can be use to improve performances.
  26215. * @see https://doc.babylonjs.com/how_to/multi_materials
  26216. * @param name Define the name in the scene
  26217. * @param scene Define the scene the material belongs to
  26218. */
  26219. constructor(name: string, scene: Scene);
  26220. private _hookArray;
  26221. /**
  26222. * Get one of the submaterial by its index in the submaterials array
  26223. * @param index The index to look the sub material at
  26224. * @returns The Material if the index has been defined
  26225. */
  26226. getSubMaterial(index: number): Nullable<Material>;
  26227. /**
  26228. * Get the list of active textures for the whole sub materials list.
  26229. * @returns All the textures that will be used during the rendering
  26230. */
  26231. getActiveTextures(): BaseTexture[];
  26232. /**
  26233. * Gets the current class name of the material e.g. "MultiMaterial"
  26234. * Mainly use in serialization.
  26235. * @returns the class name
  26236. */
  26237. getClassName(): string;
  26238. /**
  26239. * Checks if the material is ready to render the requested sub mesh
  26240. * @param mesh Define the mesh the submesh belongs to
  26241. * @param subMesh Define the sub mesh to look readyness for
  26242. * @param useInstances Define whether or not the material is used with instances
  26243. * @returns true if ready, otherwise false
  26244. */
  26245. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26246. /**
  26247. * Clones the current material and its related sub materials
  26248. * @param name Define the name of the newly cloned material
  26249. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26250. * @returns the cloned material
  26251. */
  26252. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26253. /**
  26254. * Serializes the materials into a JSON representation.
  26255. * @returns the JSON representation
  26256. */
  26257. serialize(): any;
  26258. /**
  26259. * Dispose the material and release its associated resources
  26260. * @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)
  26261. * @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)
  26262. * @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)
  26263. */
  26264. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26265. /**
  26266. * Creates a MultiMaterial from parsed MultiMaterial data.
  26267. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26268. * @param scene defines the hosting scene
  26269. * @returns a new MultiMaterial
  26270. */
  26271. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26272. }
  26273. }
  26274. declare module "babylonjs/Meshes/subMesh" {
  26275. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26276. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26277. import { Engine } from "babylonjs/Engines/engine";
  26278. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26279. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26280. import { Effect } from "babylonjs/Materials/effect";
  26281. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26282. import { Plane } from "babylonjs/Maths/math.plane";
  26283. import { Collider } from "babylonjs/Collisions/collider";
  26284. import { Material } from "babylonjs/Materials/material";
  26285. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26287. import { Mesh } from "babylonjs/Meshes/mesh";
  26288. import { Ray } from "babylonjs/Culling/ray";
  26289. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26290. /**
  26291. * Defines a subdivision inside a mesh
  26292. */
  26293. export class SubMesh implements ICullable {
  26294. /** the material index to use */
  26295. materialIndex: number;
  26296. /** vertex index start */
  26297. verticesStart: number;
  26298. /** vertices count */
  26299. verticesCount: number;
  26300. /** index start */
  26301. indexStart: number;
  26302. /** indices count */
  26303. indexCount: number;
  26304. /** @hidden */
  26305. _materialDefines: Nullable<MaterialDefines>;
  26306. /** @hidden */
  26307. _materialEffect: Nullable<Effect>;
  26308. /** @hidden */
  26309. _effectOverride: Nullable<Effect>;
  26310. /**
  26311. * Gets material defines used by the effect associated to the sub mesh
  26312. */
  26313. get materialDefines(): Nullable<MaterialDefines>;
  26314. /**
  26315. * Sets material defines used by the effect associated to the sub mesh
  26316. */
  26317. set materialDefines(defines: Nullable<MaterialDefines>);
  26318. /**
  26319. * Gets associated effect
  26320. */
  26321. get effect(): Nullable<Effect>;
  26322. /**
  26323. * Sets associated effect (effect used to render this submesh)
  26324. * @param effect defines the effect to associate with
  26325. * @param defines defines the set of defines used to compile this effect
  26326. */
  26327. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26328. /** @hidden */
  26329. _linesIndexCount: number;
  26330. private _mesh;
  26331. private _renderingMesh;
  26332. private _boundingInfo;
  26333. private _linesIndexBuffer;
  26334. /** @hidden */
  26335. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26336. /** @hidden */
  26337. _trianglePlanes: Plane[];
  26338. /** @hidden */
  26339. _lastColliderTransformMatrix: Nullable<Matrix>;
  26340. /** @hidden */
  26341. _renderId: number;
  26342. /** @hidden */
  26343. _alphaIndex: number;
  26344. /** @hidden */
  26345. _distanceToCamera: number;
  26346. /** @hidden */
  26347. _id: number;
  26348. private _currentMaterial;
  26349. /**
  26350. * Add a new submesh to a mesh
  26351. * @param materialIndex defines the material index to use
  26352. * @param verticesStart defines vertex index start
  26353. * @param verticesCount defines vertices count
  26354. * @param indexStart defines index start
  26355. * @param indexCount defines indices count
  26356. * @param mesh defines the parent mesh
  26357. * @param renderingMesh defines an optional rendering mesh
  26358. * @param createBoundingBox defines if bounding box should be created for this submesh
  26359. * @returns the new submesh
  26360. */
  26361. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26362. /**
  26363. * Creates a new submesh
  26364. * @param materialIndex defines the material index to use
  26365. * @param verticesStart defines vertex index start
  26366. * @param verticesCount defines vertices count
  26367. * @param indexStart defines index start
  26368. * @param indexCount defines indices count
  26369. * @param mesh defines the parent mesh
  26370. * @param renderingMesh defines an optional rendering mesh
  26371. * @param createBoundingBox defines if bounding box should be created for this submesh
  26372. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26373. */
  26374. constructor(
  26375. /** the material index to use */
  26376. materialIndex: number,
  26377. /** vertex index start */
  26378. verticesStart: number,
  26379. /** vertices count */
  26380. verticesCount: number,
  26381. /** index start */
  26382. indexStart: number,
  26383. /** indices count */
  26384. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26385. /**
  26386. * Returns true if this submesh covers the entire parent mesh
  26387. * @ignorenaming
  26388. */
  26389. get IsGlobal(): boolean;
  26390. /**
  26391. * Returns the submesh BoudingInfo object
  26392. * @returns current bounding info (or mesh's one if the submesh is global)
  26393. */
  26394. getBoundingInfo(): BoundingInfo;
  26395. /**
  26396. * Sets the submesh BoundingInfo
  26397. * @param boundingInfo defines the new bounding info to use
  26398. * @returns the SubMesh
  26399. */
  26400. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26401. /**
  26402. * Returns the mesh of the current submesh
  26403. * @return the parent mesh
  26404. */
  26405. getMesh(): AbstractMesh;
  26406. /**
  26407. * Returns the rendering mesh of the submesh
  26408. * @returns the rendering mesh (could be different from parent mesh)
  26409. */
  26410. getRenderingMesh(): Mesh;
  26411. /**
  26412. * Returns the replacement mesh of the submesh
  26413. * @returns the replacement mesh (could be different from parent mesh)
  26414. */
  26415. getReplacementMesh(): Nullable<AbstractMesh>;
  26416. /**
  26417. * Returns the effective mesh of the submesh
  26418. * @returns the effective mesh (could be different from parent mesh)
  26419. */
  26420. getEffectiveMesh(): AbstractMesh;
  26421. /**
  26422. * Returns the submesh material
  26423. * @returns null or the current material
  26424. */
  26425. getMaterial(): Nullable<Material>;
  26426. private _IsMultiMaterial;
  26427. /**
  26428. * Sets a new updated BoundingInfo object to the submesh
  26429. * @param data defines an optional position array to use to determine the bounding info
  26430. * @returns the SubMesh
  26431. */
  26432. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26433. /** @hidden */
  26434. _checkCollision(collider: Collider): boolean;
  26435. /**
  26436. * Updates the submesh BoundingInfo
  26437. * @param world defines the world matrix to use to update the bounding info
  26438. * @returns the submesh
  26439. */
  26440. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26441. /**
  26442. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26443. * @param frustumPlanes defines the frustum planes
  26444. * @returns true if the submesh is intersecting with the frustum
  26445. */
  26446. isInFrustum(frustumPlanes: Plane[]): boolean;
  26447. /**
  26448. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26449. * @param frustumPlanes defines the frustum planes
  26450. * @returns true if the submesh is inside the frustum
  26451. */
  26452. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26453. /**
  26454. * Renders the submesh
  26455. * @param enableAlphaMode defines if alpha needs to be used
  26456. * @returns the submesh
  26457. */
  26458. render(enableAlphaMode: boolean): SubMesh;
  26459. /**
  26460. * @hidden
  26461. */
  26462. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26463. /**
  26464. * Checks if the submesh intersects with a ray
  26465. * @param ray defines the ray to test
  26466. * @returns true is the passed ray intersects the submesh bounding box
  26467. */
  26468. canIntersects(ray: Ray): boolean;
  26469. /**
  26470. * Intersects current submesh with a ray
  26471. * @param ray defines the ray to test
  26472. * @param positions defines mesh's positions array
  26473. * @param indices defines mesh's indices array
  26474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26476. * @returns intersection info or null if no intersection
  26477. */
  26478. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26479. /** @hidden */
  26480. private _intersectLines;
  26481. /** @hidden */
  26482. private _intersectUnIndexedLines;
  26483. /** @hidden */
  26484. private _intersectTriangles;
  26485. /** @hidden */
  26486. private _intersectUnIndexedTriangles;
  26487. /** @hidden */
  26488. _rebuild(): void;
  26489. /**
  26490. * Creates a new submesh from the passed mesh
  26491. * @param newMesh defines the new hosting mesh
  26492. * @param newRenderingMesh defines an optional rendering mesh
  26493. * @returns the new submesh
  26494. */
  26495. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26496. /**
  26497. * Release associated resources
  26498. */
  26499. dispose(): void;
  26500. /**
  26501. * Gets the class name
  26502. * @returns the string "SubMesh".
  26503. */
  26504. getClassName(): string;
  26505. /**
  26506. * Creates a new submesh from indices data
  26507. * @param materialIndex the index of the main mesh material
  26508. * @param startIndex the index where to start the copy in the mesh indices array
  26509. * @param indexCount the number of indices to copy then from the startIndex
  26510. * @param mesh the main mesh to create the submesh from
  26511. * @param renderingMesh the optional rendering mesh
  26512. * @returns a new submesh
  26513. */
  26514. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26515. }
  26516. }
  26517. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26518. /**
  26519. * Class used to represent data loading progression
  26520. */
  26521. export class SceneLoaderFlags {
  26522. private static _ForceFullSceneLoadingForIncremental;
  26523. private static _ShowLoadingScreen;
  26524. private static _CleanBoneMatrixWeights;
  26525. private static _loggingLevel;
  26526. /**
  26527. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26528. */
  26529. static get ForceFullSceneLoadingForIncremental(): boolean;
  26530. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26531. /**
  26532. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26533. */
  26534. static get ShowLoadingScreen(): boolean;
  26535. static set ShowLoadingScreen(value: boolean);
  26536. /**
  26537. * Defines the current logging level (while loading the scene)
  26538. * @ignorenaming
  26539. */
  26540. static get loggingLevel(): number;
  26541. static set loggingLevel(value: number);
  26542. /**
  26543. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26544. */
  26545. static get CleanBoneMatrixWeights(): boolean;
  26546. static set CleanBoneMatrixWeights(value: boolean);
  26547. }
  26548. }
  26549. declare module "babylonjs/Meshes/geometry" {
  26550. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26551. import { Scene } from "babylonjs/scene";
  26552. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26553. import { Engine } from "babylonjs/Engines/engine";
  26554. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26555. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26556. import { Effect } from "babylonjs/Materials/effect";
  26557. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26559. import { Mesh } from "babylonjs/Meshes/mesh";
  26560. /**
  26561. * Class used to store geometry data (vertex buffers + index buffer)
  26562. */
  26563. export class Geometry implements IGetSetVerticesData {
  26564. /**
  26565. * Gets or sets the ID of the geometry
  26566. */
  26567. id: string;
  26568. /**
  26569. * Gets or sets the unique ID of the geometry
  26570. */
  26571. uniqueId: number;
  26572. /**
  26573. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26574. */
  26575. delayLoadState: number;
  26576. /**
  26577. * Gets the file containing the data to load when running in delay load state
  26578. */
  26579. delayLoadingFile: Nullable<string>;
  26580. /**
  26581. * Callback called when the geometry is updated
  26582. */
  26583. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26584. private _scene;
  26585. private _engine;
  26586. private _meshes;
  26587. private _totalVertices;
  26588. /** @hidden */
  26589. _indices: IndicesArray;
  26590. /** @hidden */
  26591. _vertexBuffers: {
  26592. [key: string]: VertexBuffer;
  26593. };
  26594. private _isDisposed;
  26595. private _extend;
  26596. private _boundingBias;
  26597. /** @hidden */
  26598. _delayInfo: Array<string>;
  26599. private _indexBuffer;
  26600. private _indexBufferIsUpdatable;
  26601. /** @hidden */
  26602. _boundingInfo: Nullable<BoundingInfo>;
  26603. /** @hidden */
  26604. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26605. /** @hidden */
  26606. _softwareSkinningFrameId: number;
  26607. private _vertexArrayObjects;
  26608. private _updatable;
  26609. /** @hidden */
  26610. _positions: Nullable<Vector3[]>;
  26611. /**
  26612. * 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
  26613. */
  26614. get boundingBias(): Vector2;
  26615. /**
  26616. * 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
  26617. */
  26618. set boundingBias(value: Vector2);
  26619. /**
  26620. * Static function used to attach a new empty geometry to a mesh
  26621. * @param mesh defines the mesh to attach the geometry to
  26622. * @returns the new Geometry
  26623. */
  26624. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26625. /** Get the list of meshes using this geometry */
  26626. get meshes(): Mesh[];
  26627. /**
  26628. * 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
  26629. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26630. */
  26631. useBoundingInfoFromGeometry: boolean;
  26632. /**
  26633. * Creates a new geometry
  26634. * @param id defines the unique ID
  26635. * @param scene defines the hosting scene
  26636. * @param vertexData defines the VertexData used to get geometry data
  26637. * @param updatable defines if geometry must be updatable (false by default)
  26638. * @param mesh defines the mesh that will be associated with the geometry
  26639. */
  26640. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26641. /**
  26642. * Gets the current extend of the geometry
  26643. */
  26644. get extend(): {
  26645. minimum: Vector3;
  26646. maximum: Vector3;
  26647. };
  26648. /**
  26649. * Gets the hosting scene
  26650. * @returns the hosting Scene
  26651. */
  26652. getScene(): Scene;
  26653. /**
  26654. * Gets the hosting engine
  26655. * @returns the hosting Engine
  26656. */
  26657. getEngine(): Engine;
  26658. /**
  26659. * Defines if the geometry is ready to use
  26660. * @returns true if the geometry is ready to be used
  26661. */
  26662. isReady(): boolean;
  26663. /**
  26664. * Gets a value indicating that the geometry should not be serialized
  26665. */
  26666. get doNotSerialize(): boolean;
  26667. /** @hidden */
  26668. _rebuild(): void;
  26669. /**
  26670. * Affects all geometry data in one call
  26671. * @param vertexData defines the geometry data
  26672. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26673. */
  26674. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26675. /**
  26676. * Set specific vertex data
  26677. * @param kind defines the data kind (Position, normal, etc...)
  26678. * @param data defines the vertex data to use
  26679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26681. */
  26682. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26683. /**
  26684. * Removes a specific vertex data
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. */
  26687. removeVerticesData(kind: string): void;
  26688. /**
  26689. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26690. * @param buffer defines the vertex buffer to use
  26691. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26692. */
  26693. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26694. /**
  26695. * Update a specific vertex buffer
  26696. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26697. * It will do nothing if the buffer is not updatable
  26698. * @param kind defines the data kind (Position, normal, etc...)
  26699. * @param data defines the data to use
  26700. * @param offset defines the offset in the target buffer where to store the data
  26701. * @param useBytes set to true if the offset is in bytes
  26702. */
  26703. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26704. /**
  26705. * Update a specific vertex buffer
  26706. * This function will create a new buffer if the current one is not updatable
  26707. * @param kind defines the data kind (Position, normal, etc...)
  26708. * @param data defines the data to use
  26709. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26710. */
  26711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26712. private _updateBoundingInfo;
  26713. /** @hidden */
  26714. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26715. /**
  26716. * Gets total number of vertices
  26717. * @returns the total number of vertices
  26718. */
  26719. getTotalVertices(): number;
  26720. /**
  26721. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26722. * @param kind defines the data kind (Position, normal, etc...)
  26723. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26724. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26725. * @returns a float array containing vertex data
  26726. */
  26727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26728. /**
  26729. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26730. * @param kind defines the data kind (Position, normal, etc...)
  26731. * @returns true if the vertex buffer with the specified kind is updatable
  26732. */
  26733. isVertexBufferUpdatable(kind: string): boolean;
  26734. /**
  26735. * Gets a specific vertex buffer
  26736. * @param kind defines the data kind (Position, normal, etc...)
  26737. * @returns a VertexBuffer
  26738. */
  26739. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26740. /**
  26741. * Returns all vertex buffers
  26742. * @return an object holding all vertex buffers indexed by kind
  26743. */
  26744. getVertexBuffers(): Nullable<{
  26745. [key: string]: VertexBuffer;
  26746. }>;
  26747. /**
  26748. * Gets a boolean indicating if specific vertex buffer is present
  26749. * @param kind defines the data kind (Position, normal, etc...)
  26750. * @returns true if data is present
  26751. */
  26752. isVerticesDataPresent(kind: string): boolean;
  26753. /**
  26754. * Gets a list of all attached data kinds (Position, normal, etc...)
  26755. * @returns a list of string containing all kinds
  26756. */
  26757. getVerticesDataKinds(): string[];
  26758. /**
  26759. * Update index buffer
  26760. * @param indices defines the indices to store in the index buffer
  26761. * @param offset defines the offset in the target buffer where to store the data
  26762. * @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)
  26763. */
  26764. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26765. /**
  26766. * Creates a new index buffer
  26767. * @param indices defines the indices to store in the index buffer
  26768. * @param totalVertices defines the total number of vertices (could be null)
  26769. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26770. */
  26771. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26772. /**
  26773. * Return the total number of indices
  26774. * @returns the total number of indices
  26775. */
  26776. getTotalIndices(): number;
  26777. /**
  26778. * Gets the index buffer array
  26779. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26780. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26781. * @returns the index buffer array
  26782. */
  26783. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26784. /**
  26785. * Gets the index buffer
  26786. * @return the index buffer
  26787. */
  26788. getIndexBuffer(): Nullable<DataBuffer>;
  26789. /** @hidden */
  26790. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26791. /**
  26792. * Release the associated resources for a specific mesh
  26793. * @param mesh defines the source mesh
  26794. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26795. */
  26796. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26797. /**
  26798. * Apply current geometry to a given mesh
  26799. * @param mesh defines the mesh to apply geometry to
  26800. */
  26801. applyToMesh(mesh: Mesh): void;
  26802. private _updateExtend;
  26803. private _applyToMesh;
  26804. private notifyUpdate;
  26805. /**
  26806. * Load the geometry if it was flagged as delay loaded
  26807. * @param scene defines the hosting scene
  26808. * @param onLoaded defines a callback called when the geometry is loaded
  26809. */
  26810. load(scene: Scene, onLoaded?: () => void): void;
  26811. private _queueLoad;
  26812. /**
  26813. * Invert the geometry to move from a right handed system to a left handed one.
  26814. */
  26815. toLeftHanded(): void;
  26816. /** @hidden */
  26817. _resetPointsArrayCache(): void;
  26818. /** @hidden */
  26819. _generatePointsArray(): boolean;
  26820. /**
  26821. * Gets a value indicating if the geometry is disposed
  26822. * @returns true if the geometry was disposed
  26823. */
  26824. isDisposed(): boolean;
  26825. private _disposeVertexArrayObjects;
  26826. /**
  26827. * Free all associated resources
  26828. */
  26829. dispose(): void;
  26830. /**
  26831. * Clone the current geometry into a new geometry
  26832. * @param id defines the unique ID of the new geometry
  26833. * @returns a new geometry object
  26834. */
  26835. copy(id: string): Geometry;
  26836. /**
  26837. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26838. * @return a JSON representation of the current geometry data (without the vertices data)
  26839. */
  26840. serialize(): any;
  26841. private toNumberArray;
  26842. /**
  26843. * Serialize all vertices data into a JSON oject
  26844. * @returns a JSON representation of the current geometry data
  26845. */
  26846. serializeVerticeData(): any;
  26847. /**
  26848. * Extracts a clone of a mesh geometry
  26849. * @param mesh defines the source mesh
  26850. * @param id defines the unique ID of the new geometry object
  26851. * @returns the new geometry object
  26852. */
  26853. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26854. /**
  26855. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26857. * Be aware Math.random() could cause collisions, but:
  26858. * "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"
  26859. * @returns a string containing a new GUID
  26860. */
  26861. static RandomId(): string;
  26862. /** @hidden */
  26863. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26864. private static _CleanMatricesWeights;
  26865. /**
  26866. * Create a new geometry from persisted data (Using .babylon file format)
  26867. * @param parsedVertexData defines the persisted data
  26868. * @param scene defines the hosting scene
  26869. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26870. * @returns the new geometry object
  26871. */
  26872. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26873. }
  26874. }
  26875. declare module "babylonjs/Meshes/mesh.vertexData" {
  26876. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26877. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26878. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26879. import { Geometry } from "babylonjs/Meshes/geometry";
  26880. import { Mesh } from "babylonjs/Meshes/mesh";
  26881. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26882. /**
  26883. * Define an interface for all classes that will get and set the data on vertices
  26884. */
  26885. export interface IGetSetVerticesData {
  26886. /**
  26887. * Gets a boolean indicating if specific vertex data is present
  26888. * @param kind defines the vertex data kind to use
  26889. * @returns true is data kind is present
  26890. */
  26891. isVerticesDataPresent(kind: string): boolean;
  26892. /**
  26893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26894. * @param kind defines the data kind (Position, normal, etc...)
  26895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26897. * @returns a float array containing vertex data
  26898. */
  26899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26900. /**
  26901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26902. * @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.
  26903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26904. * @returns the indices array or an empty array if the mesh has no geometry
  26905. */
  26906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26907. /**
  26908. * Set specific vertex data
  26909. * @param kind defines the data kind (Position, normal, etc...)
  26910. * @param data defines the vertex data to use
  26911. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26912. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26913. */
  26914. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26915. /**
  26916. * Update a specific associated vertex buffer
  26917. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26918. * - VertexBuffer.PositionKind
  26919. * - VertexBuffer.UVKind
  26920. * - VertexBuffer.UV2Kind
  26921. * - VertexBuffer.UV3Kind
  26922. * - VertexBuffer.UV4Kind
  26923. * - VertexBuffer.UV5Kind
  26924. * - VertexBuffer.UV6Kind
  26925. * - VertexBuffer.ColorKind
  26926. * - VertexBuffer.MatricesIndicesKind
  26927. * - VertexBuffer.MatricesIndicesExtraKind
  26928. * - VertexBuffer.MatricesWeightsKind
  26929. * - VertexBuffer.MatricesWeightsExtraKind
  26930. * @param data defines the data source
  26931. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26932. * @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)
  26933. */
  26934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26935. /**
  26936. * Creates a new index buffer
  26937. * @param indices defines the indices to store in the index buffer
  26938. * @param totalVertices defines the total number of vertices (could be null)
  26939. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26940. */
  26941. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26942. }
  26943. /**
  26944. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26945. */
  26946. export class VertexData {
  26947. /**
  26948. * Mesh side orientation : usually the external or front surface
  26949. */
  26950. static readonly FRONTSIDE: number;
  26951. /**
  26952. * Mesh side orientation : usually the internal or back surface
  26953. */
  26954. static readonly BACKSIDE: number;
  26955. /**
  26956. * Mesh side orientation : both internal and external or front and back surfaces
  26957. */
  26958. static readonly DOUBLESIDE: number;
  26959. /**
  26960. * Mesh side orientation : by default, `FRONTSIDE`
  26961. */
  26962. static readonly DEFAULTSIDE: number;
  26963. /**
  26964. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26965. */
  26966. positions: Nullable<FloatArray>;
  26967. /**
  26968. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26969. */
  26970. normals: Nullable<FloatArray>;
  26971. /**
  26972. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26973. */
  26974. tangents: Nullable<FloatArray>;
  26975. /**
  26976. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26977. */
  26978. uvs: Nullable<FloatArray>;
  26979. /**
  26980. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26981. */
  26982. uvs2: Nullable<FloatArray>;
  26983. /**
  26984. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26985. */
  26986. uvs3: Nullable<FloatArray>;
  26987. /**
  26988. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26989. */
  26990. uvs4: Nullable<FloatArray>;
  26991. /**
  26992. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26993. */
  26994. uvs5: Nullable<FloatArray>;
  26995. /**
  26996. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26997. */
  26998. uvs6: Nullable<FloatArray>;
  26999. /**
  27000. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27001. */
  27002. colors: Nullable<FloatArray>;
  27003. /**
  27004. * 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).
  27005. */
  27006. matricesIndices: Nullable<FloatArray>;
  27007. /**
  27008. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27009. */
  27010. matricesWeights: Nullable<FloatArray>;
  27011. /**
  27012. * An array extending the number of possible indices
  27013. */
  27014. matricesIndicesExtra: Nullable<FloatArray>;
  27015. /**
  27016. * An array extending the number of possible weights when the number of indices is extended
  27017. */
  27018. matricesWeightsExtra: Nullable<FloatArray>;
  27019. /**
  27020. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27021. */
  27022. indices: Nullable<IndicesArray>;
  27023. /**
  27024. * Uses the passed data array to set the set the values for the specified kind of data
  27025. * @param data a linear array of floating numbers
  27026. * @param kind the type of data that is being set, eg positions, colors etc
  27027. */
  27028. set(data: FloatArray, kind: string): void;
  27029. /**
  27030. * Associates the vertexData to the passed Mesh.
  27031. * Sets it as updatable or not (default `false`)
  27032. * @param mesh the mesh the vertexData is applied to
  27033. * @param updatable when used and having the value true allows new data to update the vertexData
  27034. * @returns the VertexData
  27035. */
  27036. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27037. /**
  27038. * Associates the vertexData to the passed Geometry.
  27039. * Sets it as updatable or not (default `false`)
  27040. * @param geometry the geometry the vertexData is applied to
  27041. * @param updatable when used and having the value true allows new data to update the vertexData
  27042. * @returns VertexData
  27043. */
  27044. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27045. /**
  27046. * Updates the associated mesh
  27047. * @param mesh the mesh to be updated
  27048. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27049. * @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
  27050. * @returns VertexData
  27051. */
  27052. updateMesh(mesh: Mesh): VertexData;
  27053. /**
  27054. * Updates the associated geometry
  27055. * @param geometry the geometry to be updated
  27056. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27057. * @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
  27058. * @returns VertexData.
  27059. */
  27060. updateGeometry(geometry: Geometry): VertexData;
  27061. private _applyTo;
  27062. private _update;
  27063. /**
  27064. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27065. * @param matrix the transforming matrix
  27066. * @returns the VertexData
  27067. */
  27068. transform(matrix: Matrix): VertexData;
  27069. /**
  27070. * Merges the passed VertexData into the current one
  27071. * @param other the VertexData to be merged into the current one
  27072. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27073. * @returns the modified VertexData
  27074. */
  27075. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27076. private _mergeElement;
  27077. private _validate;
  27078. /**
  27079. * Serializes the VertexData
  27080. * @returns a serialized object
  27081. */
  27082. serialize(): any;
  27083. /**
  27084. * Extracts the vertexData from a mesh
  27085. * @param mesh the mesh from which to extract the VertexData
  27086. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27088. * @returns the object VertexData associated to the passed mesh
  27089. */
  27090. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27091. /**
  27092. * Extracts the vertexData from the geometry
  27093. * @param geometry the geometry from which to extract the VertexData
  27094. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27096. * @returns the object VertexData associated to the passed mesh
  27097. */
  27098. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27099. private static _ExtractFrom;
  27100. /**
  27101. * Creates the VertexData for a Ribbon
  27102. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27103. * * pathArray array of paths, each of which an array of successive Vector3
  27104. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27105. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27106. * * 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
  27107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27108. * * 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)
  27109. * * 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)
  27110. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27111. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27112. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27113. * @returns the VertexData of the ribbon
  27114. */
  27115. static CreateRibbon(options: {
  27116. pathArray: Vector3[][];
  27117. closeArray?: boolean;
  27118. closePath?: boolean;
  27119. offset?: number;
  27120. sideOrientation?: number;
  27121. frontUVs?: Vector4;
  27122. backUVs?: Vector4;
  27123. invertUV?: boolean;
  27124. uvs?: Vector2[];
  27125. colors?: Color4[];
  27126. }): VertexData;
  27127. /**
  27128. * Creates the VertexData for a box
  27129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27130. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27131. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27132. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27133. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  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. * * 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)
  27138. * * 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)
  27139. * @returns the VertexData of the box
  27140. */
  27141. static CreateBox(options: {
  27142. size?: number;
  27143. width?: number;
  27144. height?: number;
  27145. depth?: number;
  27146. faceUV?: Vector4[];
  27147. faceColors?: Color4[];
  27148. sideOrientation?: number;
  27149. frontUVs?: Vector4;
  27150. backUVs?: Vector4;
  27151. }): VertexData;
  27152. /**
  27153. * Creates the VertexData for a tiled box
  27154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27155. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27156. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27157. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27159. * @returns the VertexData of the box
  27160. */
  27161. static CreateTiledBox(options: {
  27162. pattern?: number;
  27163. width?: number;
  27164. height?: number;
  27165. depth?: number;
  27166. tileSize?: number;
  27167. tileWidth?: number;
  27168. tileHeight?: number;
  27169. alignHorizontal?: number;
  27170. alignVertical?: number;
  27171. faceUV?: Vector4[];
  27172. faceColors?: Color4[];
  27173. sideOrientation?: number;
  27174. }): VertexData;
  27175. /**
  27176. * Creates the VertexData for a tiled plane
  27177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27178. * * pattern a limited pattern arrangement depending on the number
  27179. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27180. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27181. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27183. * * 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)
  27184. * * 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)
  27185. * @returns the VertexData of the tiled plane
  27186. */
  27187. static CreateTiledPlane(options: {
  27188. pattern?: number;
  27189. tileSize?: number;
  27190. tileWidth?: number;
  27191. tileHeight?: number;
  27192. size?: number;
  27193. width?: number;
  27194. height?: number;
  27195. alignHorizontal?: number;
  27196. alignVertical?: number;
  27197. sideOrientation?: number;
  27198. frontUVs?: Vector4;
  27199. backUVs?: Vector4;
  27200. }): VertexData;
  27201. /**
  27202. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27204. * * segments sets the number of horizontal strips optional, default 32
  27205. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27206. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27207. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27208. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27209. * * 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
  27210. * * 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
  27211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27212. * * 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)
  27213. * * 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)
  27214. * @returns the VertexData of the ellipsoid
  27215. */
  27216. static CreateSphere(options: {
  27217. segments?: number;
  27218. diameter?: number;
  27219. diameterX?: number;
  27220. diameterY?: number;
  27221. diameterZ?: number;
  27222. arc?: number;
  27223. slice?: number;
  27224. sideOrientation?: number;
  27225. frontUVs?: Vector4;
  27226. backUVs?: Vector4;
  27227. }): VertexData;
  27228. /**
  27229. * Creates the VertexData for a cylinder, cone or prism
  27230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27231. * * height sets the height (y direction) of the cylinder, optional, default 2
  27232. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27233. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27234. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27235. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27236. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27237. * * 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
  27238. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27239. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27240. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27241. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27243. * * 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)
  27244. * * 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)
  27245. * @returns the VertexData of the cylinder, cone or prism
  27246. */
  27247. static CreateCylinder(options: {
  27248. height?: number;
  27249. diameterTop?: number;
  27250. diameterBottom?: number;
  27251. diameter?: number;
  27252. tessellation?: number;
  27253. subdivisions?: number;
  27254. arc?: number;
  27255. faceColors?: Color4[];
  27256. faceUV?: Vector4[];
  27257. hasRings?: boolean;
  27258. enclose?: boolean;
  27259. sideOrientation?: number;
  27260. frontUVs?: Vector4;
  27261. backUVs?: Vector4;
  27262. }): VertexData;
  27263. /**
  27264. * Creates the VertexData for a torus
  27265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27266. * * diameter the diameter of the torus, optional default 1
  27267. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27268. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27270. * * 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)
  27271. * * 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)
  27272. * @returns the VertexData of the torus
  27273. */
  27274. static CreateTorus(options: {
  27275. diameter?: number;
  27276. thickness?: number;
  27277. tessellation?: number;
  27278. sideOrientation?: number;
  27279. frontUVs?: Vector4;
  27280. backUVs?: Vector4;
  27281. }): VertexData;
  27282. /**
  27283. * Creates the VertexData of the LineSystem
  27284. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27285. * - lines an array of lines, each line being an array of successive Vector3
  27286. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27287. * @returns the VertexData of the LineSystem
  27288. */
  27289. static CreateLineSystem(options: {
  27290. lines: Vector3[][];
  27291. colors?: Nullable<Color4[][]>;
  27292. }): VertexData;
  27293. /**
  27294. * Create the VertexData for a DashedLines
  27295. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27296. * - points an array successive Vector3
  27297. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27298. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27299. * - dashNb the intended total number of dashes, optional, default 200
  27300. * @returns the VertexData for the DashedLines
  27301. */
  27302. static CreateDashedLines(options: {
  27303. points: Vector3[];
  27304. dashSize?: number;
  27305. gapSize?: number;
  27306. dashNb?: number;
  27307. }): VertexData;
  27308. /**
  27309. * Creates the VertexData for a Ground
  27310. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27311. * - width the width (x direction) of the ground, optional, default 1
  27312. * - height the height (z direction) of the ground, optional, default 1
  27313. * - subdivisions the number of subdivisions per side, optional, default 1
  27314. * @returns the VertexData of the Ground
  27315. */
  27316. static CreateGround(options: {
  27317. width?: number;
  27318. height?: number;
  27319. subdivisions?: number;
  27320. subdivisionsX?: number;
  27321. subdivisionsY?: number;
  27322. }): VertexData;
  27323. /**
  27324. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27325. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27326. * * xmin the ground minimum X coordinate, optional, default -1
  27327. * * zmin the ground minimum Z coordinate, optional, default -1
  27328. * * xmax the ground maximum X coordinate, optional, default 1
  27329. * * zmax the ground maximum Z coordinate, optional, default 1
  27330. * * 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}
  27331. * * 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}
  27332. * @returns the VertexData of the TiledGround
  27333. */
  27334. static CreateTiledGround(options: {
  27335. xmin: number;
  27336. zmin: number;
  27337. xmax: number;
  27338. zmax: number;
  27339. subdivisions?: {
  27340. w: number;
  27341. h: number;
  27342. };
  27343. precision?: {
  27344. w: number;
  27345. h: number;
  27346. };
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData of the Ground designed from a heightmap
  27350. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27351. * * width the width (x direction) of the ground
  27352. * * height the height (z direction) of the ground
  27353. * * subdivisions the number of subdivisions per side
  27354. * * minHeight the minimum altitude on the ground, optional, default 0
  27355. * * maxHeight the maximum altitude on the ground, optional default 1
  27356. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27357. * * buffer the array holding the image color data
  27358. * * bufferWidth the width of image
  27359. * * bufferHeight the height of image
  27360. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27361. * @returns the VertexData of the Ground designed from a heightmap
  27362. */
  27363. static CreateGroundFromHeightMap(options: {
  27364. width: number;
  27365. height: number;
  27366. subdivisions: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. colorFilter: Color3;
  27370. buffer: Uint8Array;
  27371. bufferWidth: number;
  27372. bufferHeight: number;
  27373. alphaFilter: number;
  27374. }): VertexData;
  27375. /**
  27376. * Creates the VertexData for a Plane
  27377. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27378. * * size sets the width and height of the plane to the value of size, optional default 1
  27379. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27380. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27382. * * 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)
  27383. * * 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)
  27384. * @returns the VertexData of the box
  27385. */
  27386. static CreatePlane(options: {
  27387. size?: number;
  27388. width?: number;
  27389. height?: number;
  27390. sideOrientation?: number;
  27391. frontUVs?: Vector4;
  27392. backUVs?: Vector4;
  27393. }): VertexData;
  27394. /**
  27395. * Creates the VertexData of the Disc or regular Polygon
  27396. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27397. * * radius the radius of the disc, optional default 0.5
  27398. * * tessellation the number of polygon sides, optional, default 64
  27399. * * 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
  27400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27401. * * 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)
  27402. * * 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)
  27403. * @returns the VertexData of the box
  27404. */
  27405. static CreateDisc(options: {
  27406. radius?: number;
  27407. tessellation?: number;
  27408. arc?: number;
  27409. sideOrientation?: number;
  27410. frontUVs?: Vector4;
  27411. backUVs?: Vector4;
  27412. }): VertexData;
  27413. /**
  27414. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27415. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27416. * @param polygon a mesh built from polygonTriangulation.build()
  27417. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27418. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27419. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27420. * @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)
  27421. * @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)
  27422. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27423. * @returns the VertexData of the Polygon
  27424. */
  27425. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27426. /**
  27427. * Creates the VertexData of the IcoSphere
  27428. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27429. * * radius the radius of the IcoSphere, optional default 1
  27430. * * radiusX allows stretching in the x direction, optional, default radius
  27431. * * radiusY allows stretching in the y direction, optional, default radius
  27432. * * radiusZ allows stretching in the z direction, optional, default radius
  27433. * * flat when true creates a flat shaded mesh, optional, default true
  27434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27436. * * 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)
  27437. * * 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)
  27438. * @returns the VertexData of the IcoSphere
  27439. */
  27440. static CreateIcoSphere(options: {
  27441. radius?: number;
  27442. radiusX?: number;
  27443. radiusY?: number;
  27444. radiusZ?: number;
  27445. flat?: boolean;
  27446. subdivisions?: number;
  27447. sideOrientation?: number;
  27448. frontUVs?: Vector4;
  27449. backUVs?: Vector4;
  27450. }): VertexData;
  27451. /**
  27452. * Creates the VertexData for a Polyhedron
  27453. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27454. * * type provided types are:
  27455. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27456. * * 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)
  27457. * * size the size of the IcoSphere, optional default 1
  27458. * * sizeX allows stretching in the x direction, optional, default size
  27459. * * sizeY allows stretching in the y direction, optional, default size
  27460. * * sizeZ allows stretching in the z direction, optional, default size
  27461. * * 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
  27462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27463. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27464. * * flat when true creates a flat shaded mesh, optional, default true
  27465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27467. * * 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)
  27468. * * 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)
  27469. * @returns the VertexData of the Polyhedron
  27470. */
  27471. static CreatePolyhedron(options: {
  27472. type?: number;
  27473. size?: number;
  27474. sizeX?: number;
  27475. sizeY?: number;
  27476. sizeZ?: number;
  27477. custom?: any;
  27478. faceUV?: Vector4[];
  27479. faceColors?: Color4[];
  27480. flat?: boolean;
  27481. sideOrientation?: number;
  27482. frontUVs?: Vector4;
  27483. backUVs?: Vector4;
  27484. }): VertexData;
  27485. /**
  27486. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27487. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27488. * @returns the VertexData of the Capsule
  27489. */
  27490. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27491. /**
  27492. * Creates the VertexData for a TorusKnot
  27493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27494. * * radius the radius of the torus knot, optional, default 2
  27495. * * tube the thickness of the tube, optional, default 0.5
  27496. * * radialSegments the number of sides on each tube segments, optional, default 32
  27497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27498. * * p the number of windings around the z axis, optional, default 2
  27499. * * q the number of windings around the x axis, optional, default 3
  27500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27501. * * 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)
  27502. * * 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)
  27503. * @returns the VertexData of the Torus Knot
  27504. */
  27505. static CreateTorusKnot(options: {
  27506. radius?: number;
  27507. tube?: number;
  27508. radialSegments?: number;
  27509. tubularSegments?: number;
  27510. p?: number;
  27511. q?: number;
  27512. sideOrientation?: number;
  27513. frontUVs?: Vector4;
  27514. backUVs?: Vector4;
  27515. }): VertexData;
  27516. /**
  27517. * Compute normals for given positions and indices
  27518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27522. * * facetNormals : optional array of facet normals (vector3)
  27523. * * facetPositions : optional array of facet positions (vector3)
  27524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27526. * * bInfo : optional bounding info, required for facetPartitioning computation
  27527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27529. * * useRightHandedSystem: optional boolean to for right handed system computation
  27530. * * depthSort : optional boolean to enable the facet depth sort computation
  27531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27533. */
  27534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27535. facetNormals?: any;
  27536. facetPositions?: any;
  27537. facetPartitioning?: any;
  27538. ratio?: number;
  27539. bInfo?: any;
  27540. bbSize?: Vector3;
  27541. subDiv?: any;
  27542. useRightHandedSystem?: boolean;
  27543. depthSort?: boolean;
  27544. distanceTo?: Vector3;
  27545. depthSortedFacets?: any;
  27546. }): void;
  27547. /** @hidden */
  27548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27549. /**
  27550. * Applies VertexData created from the imported parameters to the geometry
  27551. * @param parsedVertexData the parsed data from an imported file
  27552. * @param geometry the geometry to apply the VertexData to
  27553. */
  27554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27555. }
  27556. }
  27557. declare module "babylonjs/Morph/morphTarget" {
  27558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27559. import { Observable } from "babylonjs/Misc/observable";
  27560. import { Nullable, FloatArray } from "babylonjs/types";
  27561. import { Scene } from "babylonjs/scene";
  27562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27563. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27564. /**
  27565. * Defines a target to use with MorphTargetManager
  27566. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27567. */
  27568. export class MorphTarget implements IAnimatable {
  27569. /** defines the name of the target */
  27570. name: string;
  27571. /**
  27572. * Gets or sets the list of animations
  27573. */
  27574. animations: import("babylonjs/Animations/animation").Animation[];
  27575. private _scene;
  27576. private _positions;
  27577. private _normals;
  27578. private _tangents;
  27579. private _uvs;
  27580. private _influence;
  27581. private _uniqueId;
  27582. /**
  27583. * Observable raised when the influence changes
  27584. */
  27585. onInfluenceChanged: Observable<boolean>;
  27586. /** @hidden */
  27587. _onDataLayoutChanged: Observable<void>;
  27588. /**
  27589. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27590. */
  27591. get influence(): number;
  27592. set influence(influence: number);
  27593. /**
  27594. * Gets or sets the id of the morph Target
  27595. */
  27596. id: string;
  27597. private _animationPropertiesOverride;
  27598. /**
  27599. * Gets or sets the animation properties override
  27600. */
  27601. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27602. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27603. /**
  27604. * Creates a new MorphTarget
  27605. * @param name defines the name of the target
  27606. * @param influence defines the influence to use
  27607. * @param scene defines the scene the morphtarget belongs to
  27608. */
  27609. constructor(
  27610. /** defines the name of the target */
  27611. name: string, influence?: number, scene?: Nullable<Scene>);
  27612. /**
  27613. * Gets the unique ID of this manager
  27614. */
  27615. get uniqueId(): number;
  27616. /**
  27617. * Gets a boolean defining if the target contains position data
  27618. */
  27619. get hasPositions(): boolean;
  27620. /**
  27621. * Gets a boolean defining if the target contains normal data
  27622. */
  27623. get hasNormals(): boolean;
  27624. /**
  27625. * Gets a boolean defining if the target contains tangent data
  27626. */
  27627. get hasTangents(): boolean;
  27628. /**
  27629. * Gets a boolean defining if the target contains texture coordinates data
  27630. */
  27631. get hasUVs(): boolean;
  27632. /**
  27633. * Affects position data to this target
  27634. * @param data defines the position data to use
  27635. */
  27636. setPositions(data: Nullable<FloatArray>): void;
  27637. /**
  27638. * Gets the position data stored in this target
  27639. * @returns a FloatArray containing the position data (or null if not present)
  27640. */
  27641. getPositions(): Nullable<FloatArray>;
  27642. /**
  27643. * Affects normal data to this target
  27644. * @param data defines the normal data to use
  27645. */
  27646. setNormals(data: Nullable<FloatArray>): void;
  27647. /**
  27648. * Gets the normal data stored in this target
  27649. * @returns a FloatArray containing the normal data (or null if not present)
  27650. */
  27651. getNormals(): Nullable<FloatArray>;
  27652. /**
  27653. * Affects tangent data to this target
  27654. * @param data defines the tangent data to use
  27655. */
  27656. setTangents(data: Nullable<FloatArray>): void;
  27657. /**
  27658. * Gets the tangent data stored in this target
  27659. * @returns a FloatArray containing the tangent data (or null if not present)
  27660. */
  27661. getTangents(): Nullable<FloatArray>;
  27662. /**
  27663. * Affects texture coordinates data to this target
  27664. * @param data defines the texture coordinates data to use
  27665. */
  27666. setUVs(data: Nullable<FloatArray>): void;
  27667. /**
  27668. * Gets the texture coordinates data stored in this target
  27669. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27670. */
  27671. getUVs(): Nullable<FloatArray>;
  27672. /**
  27673. * Clone the current target
  27674. * @returns a new MorphTarget
  27675. */
  27676. clone(): MorphTarget;
  27677. /**
  27678. * Serializes the current target into a Serialization object
  27679. * @returns the serialized object
  27680. */
  27681. serialize(): any;
  27682. /**
  27683. * Returns the string "MorphTarget"
  27684. * @returns "MorphTarget"
  27685. */
  27686. getClassName(): string;
  27687. /**
  27688. * Creates a new target from serialized data
  27689. * @param serializationObject defines the serialized data to use
  27690. * @returns a new MorphTarget
  27691. */
  27692. static Parse(serializationObject: any): MorphTarget;
  27693. /**
  27694. * Creates a MorphTarget from mesh data
  27695. * @param mesh defines the source mesh
  27696. * @param name defines the name to use for the new target
  27697. * @param influence defines the influence to attach to the target
  27698. * @returns a new MorphTarget
  27699. */
  27700. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27701. }
  27702. }
  27703. declare module "babylonjs/Morph/morphTargetManager" {
  27704. import { Nullable } from "babylonjs/types";
  27705. import { Scene } from "babylonjs/scene";
  27706. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27707. /**
  27708. * This class is used to deform meshes using morphing between different targets
  27709. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27710. */
  27711. export class MorphTargetManager {
  27712. private _targets;
  27713. private _targetInfluenceChangedObservers;
  27714. private _targetDataLayoutChangedObservers;
  27715. private _activeTargets;
  27716. private _scene;
  27717. private _influences;
  27718. private _supportsNormals;
  27719. private _supportsTangents;
  27720. private _supportsUVs;
  27721. private _vertexCount;
  27722. private _uniqueId;
  27723. private _tempInfluences;
  27724. /**
  27725. * Gets or sets a boolean indicating if normals must be morphed
  27726. */
  27727. enableNormalMorphing: boolean;
  27728. /**
  27729. * Gets or sets a boolean indicating if tangents must be morphed
  27730. */
  27731. enableTangentMorphing: boolean;
  27732. /**
  27733. * Gets or sets a boolean indicating if UV must be morphed
  27734. */
  27735. enableUVMorphing: boolean;
  27736. /**
  27737. * Creates a new MorphTargetManager
  27738. * @param scene defines the current scene
  27739. */
  27740. constructor(scene?: Nullable<Scene>);
  27741. /**
  27742. * Gets the unique ID of this manager
  27743. */
  27744. get uniqueId(): number;
  27745. /**
  27746. * Gets the number of vertices handled by this manager
  27747. */
  27748. get vertexCount(): number;
  27749. /**
  27750. * Gets a boolean indicating if this manager supports morphing of normals
  27751. */
  27752. get supportsNormals(): boolean;
  27753. /**
  27754. * Gets a boolean indicating if this manager supports morphing of tangents
  27755. */
  27756. get supportsTangents(): boolean;
  27757. /**
  27758. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27759. */
  27760. get supportsUVs(): boolean;
  27761. /**
  27762. * Gets the number of targets stored in this manager
  27763. */
  27764. get numTargets(): number;
  27765. /**
  27766. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27767. */
  27768. get numInfluencers(): number;
  27769. /**
  27770. * Gets the list of influences (one per target)
  27771. */
  27772. get influences(): Float32Array;
  27773. /**
  27774. * Gets the active target at specified index. An active target is a target with an influence > 0
  27775. * @param index defines the index to check
  27776. * @returns the requested target
  27777. */
  27778. getActiveTarget(index: number): MorphTarget;
  27779. /**
  27780. * Gets the target at specified index
  27781. * @param index defines the index to check
  27782. * @returns the requested target
  27783. */
  27784. getTarget(index: number): MorphTarget;
  27785. /**
  27786. * Add a new target to this manager
  27787. * @param target defines the target to add
  27788. */
  27789. addTarget(target: MorphTarget): void;
  27790. /**
  27791. * Removes a target from the manager
  27792. * @param target defines the target to remove
  27793. */
  27794. removeTarget(target: MorphTarget): void;
  27795. /**
  27796. * Clone the current manager
  27797. * @returns a new MorphTargetManager
  27798. */
  27799. clone(): MorphTargetManager;
  27800. /**
  27801. * Serializes the current manager into a Serialization object
  27802. * @returns the serialized object
  27803. */
  27804. serialize(): any;
  27805. private _syncActiveTargets;
  27806. /**
  27807. * Syncrhonize the targets with all the meshes using this morph target manager
  27808. */
  27809. synchronize(): void;
  27810. /**
  27811. * Creates a new MorphTargetManager from serialized data
  27812. * @param serializationObject defines the serialized data
  27813. * @param scene defines the hosting scene
  27814. * @returns the new MorphTargetManager
  27815. */
  27816. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27817. }
  27818. }
  27819. declare module "babylonjs/Meshes/meshLODLevel" {
  27820. import { Mesh } from "babylonjs/Meshes/mesh";
  27821. import { Nullable } from "babylonjs/types";
  27822. /**
  27823. * Class used to represent a specific level of detail of a mesh
  27824. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27825. */
  27826. export class MeshLODLevel {
  27827. /** Defines the distance where this level should start being displayed */
  27828. distance: number;
  27829. /** Defines the mesh to use to render this level */
  27830. mesh: Nullable<Mesh>;
  27831. /**
  27832. * Creates a new LOD level
  27833. * @param distance defines the distance where this level should star being displayed
  27834. * @param mesh defines the mesh to use to render this level
  27835. */
  27836. constructor(
  27837. /** Defines the distance where this level should start being displayed */
  27838. distance: number,
  27839. /** Defines the mesh to use to render this level */
  27840. mesh: Nullable<Mesh>);
  27841. }
  27842. }
  27843. declare module "babylonjs/Misc/canvasGenerator" {
  27844. /**
  27845. * Helper class used to generate a canvas to manipulate images
  27846. */
  27847. export class CanvasGenerator {
  27848. /**
  27849. * Create a new canvas (or offscreen canvas depending on the context)
  27850. * @param width defines the expected width
  27851. * @param height defines the expected height
  27852. * @return a new canvas or offscreen canvas
  27853. */
  27854. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27855. }
  27856. }
  27857. declare module "babylonjs/Meshes/groundMesh" {
  27858. import { Scene } from "babylonjs/scene";
  27859. import { Vector3 } from "babylonjs/Maths/math.vector";
  27860. import { Mesh } from "babylonjs/Meshes/mesh";
  27861. /**
  27862. * Mesh representing the gorund
  27863. */
  27864. export class GroundMesh extends Mesh {
  27865. /** If octree should be generated */
  27866. generateOctree: boolean;
  27867. private _heightQuads;
  27868. /** @hidden */
  27869. _subdivisionsX: number;
  27870. /** @hidden */
  27871. _subdivisionsY: number;
  27872. /** @hidden */
  27873. _width: number;
  27874. /** @hidden */
  27875. _height: number;
  27876. /** @hidden */
  27877. _minX: number;
  27878. /** @hidden */
  27879. _maxX: number;
  27880. /** @hidden */
  27881. _minZ: number;
  27882. /** @hidden */
  27883. _maxZ: number;
  27884. constructor(name: string, scene: Scene);
  27885. /**
  27886. * "GroundMesh"
  27887. * @returns "GroundMesh"
  27888. */
  27889. getClassName(): string;
  27890. /**
  27891. * The minimum of x and y subdivisions
  27892. */
  27893. get subdivisions(): number;
  27894. /**
  27895. * X subdivisions
  27896. */
  27897. get subdivisionsX(): number;
  27898. /**
  27899. * Y subdivisions
  27900. */
  27901. get subdivisionsY(): number;
  27902. /**
  27903. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27905. * @param chunksCount the number of subdivisions for x and y
  27906. * @param octreeBlocksSize (Default: 32)
  27907. */
  27908. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27909. /**
  27910. * Returns a height (y) value in the Worl system :
  27911. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27912. * @param x x coordinate
  27913. * @param z z coordinate
  27914. * @returns the ground y position if (x, z) are outside the ground surface.
  27915. */
  27916. getHeightAtCoordinates(x: number, z: number): number;
  27917. /**
  27918. * Returns a normalized vector (Vector3) orthogonal to the ground
  27919. * at the ground coordinates (x, z) expressed in the World system.
  27920. * @param x x coordinate
  27921. * @param z z coordinate
  27922. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27923. */
  27924. getNormalAtCoordinates(x: number, z: number): Vector3;
  27925. /**
  27926. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27927. * at the ground coordinates (x, z) expressed in the World system.
  27928. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27929. * @param x x coordinate
  27930. * @param z z coordinate
  27931. * @param ref vector to store the result
  27932. * @returns the GroundMesh.
  27933. */
  27934. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27935. /**
  27936. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27937. * if the ground has been updated.
  27938. * This can be used in the render loop.
  27939. * @returns the GroundMesh.
  27940. */
  27941. updateCoordinateHeights(): GroundMesh;
  27942. private _getFacetAt;
  27943. private _initHeightQuads;
  27944. private _computeHeightQuads;
  27945. /**
  27946. * Serializes this ground mesh
  27947. * @param serializationObject object to write serialization to
  27948. */
  27949. serialize(serializationObject: any): void;
  27950. /**
  27951. * Parses a serialized ground mesh
  27952. * @param parsedMesh the serialized mesh
  27953. * @param scene the scene to create the ground mesh in
  27954. * @returns the created ground mesh
  27955. */
  27956. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27957. }
  27958. }
  27959. declare module "babylonjs/Physics/physicsJoint" {
  27960. import { Vector3 } from "babylonjs/Maths/math.vector";
  27961. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27962. /**
  27963. * Interface for Physics-Joint data
  27964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27965. */
  27966. export interface PhysicsJointData {
  27967. /**
  27968. * The main pivot of the joint
  27969. */
  27970. mainPivot?: Vector3;
  27971. /**
  27972. * The connected pivot of the joint
  27973. */
  27974. connectedPivot?: Vector3;
  27975. /**
  27976. * The main axis of the joint
  27977. */
  27978. mainAxis?: Vector3;
  27979. /**
  27980. * The connected axis of the joint
  27981. */
  27982. connectedAxis?: Vector3;
  27983. /**
  27984. * The collision of the joint
  27985. */
  27986. collision?: boolean;
  27987. /**
  27988. * Native Oimo/Cannon/Energy data
  27989. */
  27990. nativeParams?: any;
  27991. }
  27992. /**
  27993. * This is a holder class for the physics joint created by the physics plugin
  27994. * It holds a set of functions to control the underlying joint
  27995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27996. */
  27997. export class PhysicsJoint {
  27998. /**
  27999. * The type of the physics joint
  28000. */
  28001. type: number;
  28002. /**
  28003. * The data for the physics joint
  28004. */
  28005. jointData: PhysicsJointData;
  28006. private _physicsJoint;
  28007. protected _physicsPlugin: IPhysicsEnginePlugin;
  28008. /**
  28009. * Initializes the physics joint
  28010. * @param type The type of the physics joint
  28011. * @param jointData The data for the physics joint
  28012. */
  28013. constructor(
  28014. /**
  28015. * The type of the physics joint
  28016. */
  28017. type: number,
  28018. /**
  28019. * The data for the physics joint
  28020. */
  28021. jointData: PhysicsJointData);
  28022. /**
  28023. * Gets the physics joint
  28024. */
  28025. get physicsJoint(): any;
  28026. /**
  28027. * Sets the physics joint
  28028. */
  28029. set physicsJoint(newJoint: any);
  28030. /**
  28031. * Sets the physics plugin
  28032. */
  28033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28034. /**
  28035. * Execute a function that is physics-plugin specific.
  28036. * @param {Function} func the function that will be executed.
  28037. * It accepts two parameters: the physics world and the physics joint
  28038. */
  28039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28040. /**
  28041. * Distance-Joint type
  28042. */
  28043. static DistanceJoint: number;
  28044. /**
  28045. * Hinge-Joint type
  28046. */
  28047. static HingeJoint: number;
  28048. /**
  28049. * Ball-and-Socket joint type
  28050. */
  28051. static BallAndSocketJoint: number;
  28052. /**
  28053. * Wheel-Joint type
  28054. */
  28055. static WheelJoint: number;
  28056. /**
  28057. * Slider-Joint type
  28058. */
  28059. static SliderJoint: number;
  28060. /**
  28061. * Prismatic-Joint type
  28062. */
  28063. static PrismaticJoint: number;
  28064. /**
  28065. * Universal-Joint type
  28066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28067. */
  28068. static UniversalJoint: number;
  28069. /**
  28070. * Hinge-Joint 2 type
  28071. */
  28072. static Hinge2Joint: number;
  28073. /**
  28074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28075. */
  28076. static PointToPointJoint: number;
  28077. /**
  28078. * Spring-Joint type
  28079. */
  28080. static SpringJoint: number;
  28081. /**
  28082. * Lock-Joint type
  28083. */
  28084. static LockJoint: number;
  28085. }
  28086. /**
  28087. * A class representing a physics distance joint
  28088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28089. */
  28090. export class DistanceJoint extends PhysicsJoint {
  28091. /**
  28092. *
  28093. * @param jointData The data for the Distance-Joint
  28094. */
  28095. constructor(jointData: DistanceJointData);
  28096. /**
  28097. * Update the predefined distance.
  28098. * @param maxDistance The maximum preferred distance
  28099. * @param minDistance The minimum preferred distance
  28100. */
  28101. updateDistance(maxDistance: number, minDistance?: number): void;
  28102. }
  28103. /**
  28104. * Represents a Motor-Enabled Joint
  28105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28106. */
  28107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28108. /**
  28109. * Initializes the Motor-Enabled Joint
  28110. * @param type The type of the joint
  28111. * @param jointData The physica joint data for the joint
  28112. */
  28113. constructor(type: number, jointData: PhysicsJointData);
  28114. /**
  28115. * Set the motor values.
  28116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28117. * @param force the force to apply
  28118. * @param maxForce max force for this motor.
  28119. */
  28120. setMotor(force?: number, maxForce?: number): void;
  28121. /**
  28122. * Set the motor's limits.
  28123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28124. * @param upperLimit The upper limit of the motor
  28125. * @param lowerLimit The lower limit of the motor
  28126. */
  28127. setLimit(upperLimit: number, lowerLimit?: number): void;
  28128. }
  28129. /**
  28130. * This class represents a single physics Hinge-Joint
  28131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28132. */
  28133. export class HingeJoint extends MotorEnabledJoint {
  28134. /**
  28135. * Initializes the Hinge-Joint
  28136. * @param jointData The joint data for the Hinge-Joint
  28137. */
  28138. constructor(jointData: PhysicsJointData);
  28139. /**
  28140. * Set the motor values.
  28141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28142. * @param {number} force the force to apply
  28143. * @param {number} maxForce max force for this motor.
  28144. */
  28145. setMotor(force?: number, maxForce?: number): void;
  28146. /**
  28147. * Set the motor's limits.
  28148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28149. * @param upperLimit The upper limit of the motor
  28150. * @param lowerLimit The lower limit of the motor
  28151. */
  28152. setLimit(upperLimit: number, lowerLimit?: number): void;
  28153. }
  28154. /**
  28155. * This class represents a dual hinge physics joint (same as wheel joint)
  28156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28157. */
  28158. export class Hinge2Joint extends MotorEnabledJoint {
  28159. /**
  28160. * Initializes the Hinge2-Joint
  28161. * @param jointData The joint data for the Hinge2-Joint
  28162. */
  28163. constructor(jointData: PhysicsJointData);
  28164. /**
  28165. * Set the motor values.
  28166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28167. * @param {number} targetSpeed the speed the motor is to reach
  28168. * @param {number} maxForce max force for this motor.
  28169. * @param {motorIndex} the motor's index, 0 or 1.
  28170. */
  28171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28172. /**
  28173. * Set the motor limits.
  28174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28175. * @param {number} upperLimit the upper limit
  28176. * @param {number} lowerLimit lower limit
  28177. * @param {motorIndex} the motor's index, 0 or 1.
  28178. */
  28179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28180. }
  28181. /**
  28182. * Interface for a motor enabled joint
  28183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28184. */
  28185. export interface IMotorEnabledJoint {
  28186. /**
  28187. * Physics joint
  28188. */
  28189. physicsJoint: any;
  28190. /**
  28191. * Sets the motor of the motor-enabled joint
  28192. * @param force The force of the motor
  28193. * @param maxForce The maximum force of the motor
  28194. * @param motorIndex The index of the motor
  28195. */
  28196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28197. /**
  28198. * Sets the limit of the motor
  28199. * @param upperLimit The upper limit of the motor
  28200. * @param lowerLimit The lower limit of the motor
  28201. * @param motorIndex The index of the motor
  28202. */
  28203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28204. }
  28205. /**
  28206. * Joint data for a Distance-Joint
  28207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28208. */
  28209. export interface DistanceJointData extends PhysicsJointData {
  28210. /**
  28211. * Max distance the 2 joint objects can be apart
  28212. */
  28213. maxDistance: number;
  28214. }
  28215. /**
  28216. * Joint data from a spring joint
  28217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28218. */
  28219. export interface SpringJointData extends PhysicsJointData {
  28220. /**
  28221. * Length of the spring
  28222. */
  28223. length: number;
  28224. /**
  28225. * Stiffness of the spring
  28226. */
  28227. stiffness: number;
  28228. /**
  28229. * Damping of the spring
  28230. */
  28231. damping: number;
  28232. /** this callback will be called when applying the force to the impostors. */
  28233. forceApplicationCallback: () => void;
  28234. }
  28235. }
  28236. declare module "babylonjs/Physics/physicsRaycastResult" {
  28237. import { Vector3 } from "babylonjs/Maths/math.vector";
  28238. /**
  28239. * Holds the data for the raycast result
  28240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28241. */
  28242. export class PhysicsRaycastResult {
  28243. private _hasHit;
  28244. private _hitDistance;
  28245. private _hitNormalWorld;
  28246. private _hitPointWorld;
  28247. private _rayFromWorld;
  28248. private _rayToWorld;
  28249. /**
  28250. * Gets if there was a hit
  28251. */
  28252. get hasHit(): boolean;
  28253. /**
  28254. * Gets the distance from the hit
  28255. */
  28256. get hitDistance(): number;
  28257. /**
  28258. * Gets the hit normal/direction in the world
  28259. */
  28260. get hitNormalWorld(): Vector3;
  28261. /**
  28262. * Gets the hit point in the world
  28263. */
  28264. get hitPointWorld(): Vector3;
  28265. /**
  28266. * Gets the ray "start point" of the ray in the world
  28267. */
  28268. get rayFromWorld(): Vector3;
  28269. /**
  28270. * Gets the ray "end point" of the ray in the world
  28271. */
  28272. get rayToWorld(): Vector3;
  28273. /**
  28274. * Sets the hit data (normal & point in world space)
  28275. * @param hitNormalWorld defines the normal in world space
  28276. * @param hitPointWorld defines the point in world space
  28277. */
  28278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28279. /**
  28280. * Sets the distance from the start point to the hit point
  28281. * @param distance
  28282. */
  28283. setHitDistance(distance: number): void;
  28284. /**
  28285. * Calculates the distance manually
  28286. */
  28287. calculateHitDistance(): void;
  28288. /**
  28289. * Resets all the values to default
  28290. * @param from The from point on world space
  28291. * @param to The to point on world space
  28292. */
  28293. reset(from?: Vector3, to?: Vector3): void;
  28294. }
  28295. /**
  28296. * Interface for the size containing width and height
  28297. */
  28298. interface IXYZ {
  28299. /**
  28300. * X
  28301. */
  28302. x: number;
  28303. /**
  28304. * Y
  28305. */
  28306. y: number;
  28307. /**
  28308. * Z
  28309. */
  28310. z: number;
  28311. }
  28312. }
  28313. declare module "babylonjs/Physics/IPhysicsEngine" {
  28314. import { Nullable } from "babylonjs/types";
  28315. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28317. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28319. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28320. /**
  28321. * Interface used to describe a physics joint
  28322. */
  28323. export interface PhysicsImpostorJoint {
  28324. /** Defines the main impostor to which the joint is linked */
  28325. mainImpostor: PhysicsImpostor;
  28326. /** Defines the impostor that is connected to the main impostor using this joint */
  28327. connectedImpostor: PhysicsImpostor;
  28328. /** Defines the joint itself */
  28329. joint: PhysicsJoint;
  28330. }
  28331. /** @hidden */
  28332. export interface IPhysicsEnginePlugin {
  28333. world: any;
  28334. name: string;
  28335. setGravity(gravity: Vector3): void;
  28336. setTimeStep(timeStep: number): void;
  28337. getTimeStep(): number;
  28338. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28339. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28342. removePhysicsBody(impostor: PhysicsImpostor): void;
  28343. generateJoint(joint: PhysicsImpostorJoint): void;
  28344. removeJoint(joint: PhysicsImpostorJoint): void;
  28345. isSupported(): boolean;
  28346. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28347. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28348. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28349. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28350. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28351. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28352. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28353. getBodyMass(impostor: PhysicsImpostor): number;
  28354. getBodyFriction(impostor: PhysicsImpostor): number;
  28355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28356. getBodyRestitution(impostor: PhysicsImpostor): number;
  28357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28358. getBodyPressure?(impostor: PhysicsImpostor): number;
  28359. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28360. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28361. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28362. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28363. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28364. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28365. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28366. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28367. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28368. sleepBody(impostor: PhysicsImpostor): void;
  28369. wakeUpBody(impostor: PhysicsImpostor): void;
  28370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28372. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28374. getRadius(impostor: PhysicsImpostor): number;
  28375. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28377. dispose(): void;
  28378. }
  28379. /**
  28380. * Interface used to define a physics engine
  28381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28382. */
  28383. export interface IPhysicsEngine {
  28384. /**
  28385. * Gets the gravity vector used by the simulation
  28386. */
  28387. gravity: Vector3;
  28388. /**
  28389. * Sets the gravity vector used by the simulation
  28390. * @param gravity defines the gravity vector to use
  28391. */
  28392. setGravity(gravity: Vector3): void;
  28393. /**
  28394. * Set the time step of the physics engine.
  28395. * Default is 1/60.
  28396. * To slow it down, enter 1/600 for example.
  28397. * To speed it up, 1/30
  28398. * @param newTimeStep the new timestep to apply to this world.
  28399. */
  28400. setTimeStep(newTimeStep: number): void;
  28401. /**
  28402. * Get the time step of the physics engine.
  28403. * @returns the current time step
  28404. */
  28405. getTimeStep(): number;
  28406. /**
  28407. * Set the sub time step of the physics engine.
  28408. * Default is 0 meaning there is no sub steps
  28409. * To increase physics resolution precision, set a small value (like 1 ms)
  28410. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28411. */
  28412. setSubTimeStep(subTimeStep: number): void;
  28413. /**
  28414. * Get the sub time step of the physics engine.
  28415. * @returns the current sub time step
  28416. */
  28417. getSubTimeStep(): number;
  28418. /**
  28419. * Release all resources
  28420. */
  28421. dispose(): void;
  28422. /**
  28423. * Gets the name of the current physics plugin
  28424. * @returns the name of the plugin
  28425. */
  28426. getPhysicsPluginName(): string;
  28427. /**
  28428. * Adding a new impostor for the impostor tracking.
  28429. * This will be done by the impostor itself.
  28430. * @param impostor the impostor to add
  28431. */
  28432. addImpostor(impostor: PhysicsImpostor): void;
  28433. /**
  28434. * Remove an impostor from the engine.
  28435. * This impostor and its mesh will not longer be updated by the physics engine.
  28436. * @param impostor the impostor to remove
  28437. */
  28438. removeImpostor(impostor: PhysicsImpostor): void;
  28439. /**
  28440. * Add a joint to the physics engine
  28441. * @param mainImpostor defines the main impostor to which the joint is added.
  28442. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28443. * @param joint defines the joint that will connect both impostors.
  28444. */
  28445. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28446. /**
  28447. * Removes a joint from the simulation
  28448. * @param mainImpostor defines the impostor used with the joint
  28449. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28450. * @param joint defines the joint to remove
  28451. */
  28452. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28453. /**
  28454. * Gets the current plugin used to run the simulation
  28455. * @returns current plugin
  28456. */
  28457. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28458. /**
  28459. * Gets the list of physic impostors
  28460. * @returns an array of PhysicsImpostor
  28461. */
  28462. getImpostors(): Array<PhysicsImpostor>;
  28463. /**
  28464. * Gets the impostor for a physics enabled object
  28465. * @param object defines the object impersonated by the impostor
  28466. * @returns the PhysicsImpostor or null if not found
  28467. */
  28468. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28469. /**
  28470. * Gets the impostor for a physics body object
  28471. * @param body defines physics body used by the impostor
  28472. * @returns the PhysicsImpostor or null if not found
  28473. */
  28474. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28475. /**
  28476. * Does a raycast in the physics world
  28477. * @param from when should the ray start?
  28478. * @param to when should the ray end?
  28479. * @returns PhysicsRaycastResult
  28480. */
  28481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28482. /**
  28483. * Called by the scene. No need to call it.
  28484. * @param delta defines the timespam between frames
  28485. */
  28486. _step(delta: number): void;
  28487. }
  28488. }
  28489. declare module "babylonjs/Physics/physicsImpostor" {
  28490. import { Nullable, IndicesArray } from "babylonjs/types";
  28491. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28494. import { Scene } from "babylonjs/scene";
  28495. import { Bone } from "babylonjs/Bones/bone";
  28496. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28497. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28498. import { Space } from "babylonjs/Maths/math.axis";
  28499. /**
  28500. * The interface for the physics imposter parameters
  28501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28502. */
  28503. export interface PhysicsImpostorParameters {
  28504. /**
  28505. * The mass of the physics imposter
  28506. */
  28507. mass: number;
  28508. /**
  28509. * The friction of the physics imposter
  28510. */
  28511. friction?: number;
  28512. /**
  28513. * The coefficient of restitution of the physics imposter
  28514. */
  28515. restitution?: number;
  28516. /**
  28517. * The native options of the physics imposter
  28518. */
  28519. nativeOptions?: any;
  28520. /**
  28521. * Specifies if the parent should be ignored
  28522. */
  28523. ignoreParent?: boolean;
  28524. /**
  28525. * Specifies if bi-directional transformations should be disabled
  28526. */
  28527. disableBidirectionalTransformation?: boolean;
  28528. /**
  28529. * The pressure inside the physics imposter, soft object only
  28530. */
  28531. pressure?: number;
  28532. /**
  28533. * The stiffness the physics imposter, soft object only
  28534. */
  28535. stiffness?: number;
  28536. /**
  28537. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28538. */
  28539. velocityIterations?: number;
  28540. /**
  28541. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28542. */
  28543. positionIterations?: number;
  28544. /**
  28545. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28546. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28547. * Add to fix multiple points
  28548. */
  28549. fixedPoints?: number;
  28550. /**
  28551. * The collision margin around a soft object
  28552. */
  28553. margin?: number;
  28554. /**
  28555. * The collision margin around a soft object
  28556. */
  28557. damping?: number;
  28558. /**
  28559. * The path for a rope based on an extrusion
  28560. */
  28561. path?: any;
  28562. /**
  28563. * The shape of an extrusion used for a rope based on an extrusion
  28564. */
  28565. shape?: any;
  28566. }
  28567. /**
  28568. * Interface for a physics-enabled object
  28569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28570. */
  28571. export interface IPhysicsEnabledObject {
  28572. /**
  28573. * The position of the physics-enabled object
  28574. */
  28575. position: Vector3;
  28576. /**
  28577. * The rotation of the physics-enabled object
  28578. */
  28579. rotationQuaternion: Nullable<Quaternion>;
  28580. /**
  28581. * The scale of the physics-enabled object
  28582. */
  28583. scaling: Vector3;
  28584. /**
  28585. * The rotation of the physics-enabled object
  28586. */
  28587. rotation?: Vector3;
  28588. /**
  28589. * The parent of the physics-enabled object
  28590. */
  28591. parent?: any;
  28592. /**
  28593. * The bounding info of the physics-enabled object
  28594. * @returns The bounding info of the physics-enabled object
  28595. */
  28596. getBoundingInfo(): BoundingInfo;
  28597. /**
  28598. * Computes the world matrix
  28599. * @param force Specifies if the world matrix should be computed by force
  28600. * @returns A world matrix
  28601. */
  28602. computeWorldMatrix(force: boolean): Matrix;
  28603. /**
  28604. * Gets the world matrix
  28605. * @returns A world matrix
  28606. */
  28607. getWorldMatrix?(): Matrix;
  28608. /**
  28609. * Gets the child meshes
  28610. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28611. * @returns An array of abstract meshes
  28612. */
  28613. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28614. /**
  28615. * Gets the vertex data
  28616. * @param kind The type of vertex data
  28617. * @returns A nullable array of numbers, or a float32 array
  28618. */
  28619. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28620. /**
  28621. * Gets the indices from the mesh
  28622. * @returns A nullable array of index arrays
  28623. */
  28624. getIndices?(): Nullable<IndicesArray>;
  28625. /**
  28626. * Gets the scene from the mesh
  28627. * @returns the indices array or null
  28628. */
  28629. getScene?(): Scene;
  28630. /**
  28631. * Gets the absolute position from the mesh
  28632. * @returns the absolute position
  28633. */
  28634. getAbsolutePosition(): Vector3;
  28635. /**
  28636. * Gets the absolute pivot point from the mesh
  28637. * @returns the absolute pivot point
  28638. */
  28639. getAbsolutePivotPoint(): Vector3;
  28640. /**
  28641. * Rotates the mesh
  28642. * @param axis The axis of rotation
  28643. * @param amount The amount of rotation
  28644. * @param space The space of the rotation
  28645. * @returns The rotation transform node
  28646. */
  28647. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28648. /**
  28649. * Translates the mesh
  28650. * @param axis The axis of translation
  28651. * @param distance The distance of translation
  28652. * @param space The space of the translation
  28653. * @returns The transform node
  28654. */
  28655. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28656. /**
  28657. * Sets the absolute position of the mesh
  28658. * @param absolutePosition The absolute position of the mesh
  28659. * @returns The transform node
  28660. */
  28661. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28662. /**
  28663. * Gets the class name of the mesh
  28664. * @returns The class name
  28665. */
  28666. getClassName(): string;
  28667. }
  28668. /**
  28669. * Represents a physics imposter
  28670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28671. */
  28672. export class PhysicsImpostor {
  28673. /**
  28674. * The physics-enabled object used as the physics imposter
  28675. */
  28676. object: IPhysicsEnabledObject;
  28677. /**
  28678. * The type of the physics imposter
  28679. */
  28680. type: number;
  28681. private _options;
  28682. private _scene?;
  28683. /**
  28684. * The default object size of the imposter
  28685. */
  28686. static DEFAULT_OBJECT_SIZE: Vector3;
  28687. /**
  28688. * The identity quaternion of the imposter
  28689. */
  28690. static IDENTITY_QUATERNION: Quaternion;
  28691. /** @hidden */
  28692. _pluginData: any;
  28693. private _physicsEngine;
  28694. private _physicsBody;
  28695. private _bodyUpdateRequired;
  28696. private _onBeforePhysicsStepCallbacks;
  28697. private _onAfterPhysicsStepCallbacks;
  28698. /** @hidden */
  28699. _onPhysicsCollideCallbacks: Array<{
  28700. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28701. otherImpostors: Array<PhysicsImpostor>;
  28702. }>;
  28703. private _deltaPosition;
  28704. private _deltaRotation;
  28705. private _deltaRotationConjugated;
  28706. /** @hidden */
  28707. _isFromLine: boolean;
  28708. private _parent;
  28709. private _isDisposed;
  28710. private static _tmpVecs;
  28711. private static _tmpQuat;
  28712. /**
  28713. * Specifies if the physics imposter is disposed
  28714. */
  28715. get isDisposed(): boolean;
  28716. /**
  28717. * Gets the mass of the physics imposter
  28718. */
  28719. get mass(): number;
  28720. set mass(value: number);
  28721. /**
  28722. * Gets the coefficient of friction
  28723. */
  28724. get friction(): number;
  28725. /**
  28726. * Sets the coefficient of friction
  28727. */
  28728. set friction(value: number);
  28729. /**
  28730. * Gets the coefficient of restitution
  28731. */
  28732. get restitution(): number;
  28733. /**
  28734. * Sets the coefficient of restitution
  28735. */
  28736. set restitution(value: number);
  28737. /**
  28738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28739. */
  28740. get pressure(): number;
  28741. /**
  28742. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28743. */
  28744. set pressure(value: number);
  28745. /**
  28746. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28747. */
  28748. get stiffness(): number;
  28749. /**
  28750. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28751. */
  28752. set stiffness(value: number);
  28753. /**
  28754. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28755. */
  28756. get velocityIterations(): number;
  28757. /**
  28758. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28759. */
  28760. set velocityIterations(value: number);
  28761. /**
  28762. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28763. */
  28764. get positionIterations(): number;
  28765. /**
  28766. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28767. */
  28768. set positionIterations(value: number);
  28769. /**
  28770. * The unique id of the physics imposter
  28771. * set by the physics engine when adding this impostor to the array
  28772. */
  28773. uniqueId: number;
  28774. /**
  28775. * @hidden
  28776. */
  28777. soft: boolean;
  28778. /**
  28779. * @hidden
  28780. */
  28781. segments: number;
  28782. private _joints;
  28783. /**
  28784. * Initializes the physics imposter
  28785. * @param object The physics-enabled object used as the physics imposter
  28786. * @param type The type of the physics imposter
  28787. * @param _options The options for the physics imposter
  28788. * @param _scene The Babylon scene
  28789. */
  28790. constructor(
  28791. /**
  28792. * The physics-enabled object used as the physics imposter
  28793. */
  28794. object: IPhysicsEnabledObject,
  28795. /**
  28796. * The type of the physics imposter
  28797. */
  28798. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28799. /**
  28800. * This function will completly initialize this impostor.
  28801. * It will create a new body - but only if this mesh has no parent.
  28802. * If it has, this impostor will not be used other than to define the impostor
  28803. * of the child mesh.
  28804. * @hidden
  28805. */
  28806. _init(): void;
  28807. private _getPhysicsParent;
  28808. /**
  28809. * Should a new body be generated.
  28810. * @returns boolean specifying if body initialization is required
  28811. */
  28812. isBodyInitRequired(): boolean;
  28813. /**
  28814. * Sets the updated scaling
  28815. * @param updated Specifies if the scaling is updated
  28816. */
  28817. setScalingUpdated(): void;
  28818. /**
  28819. * Force a regeneration of this or the parent's impostor's body.
  28820. * Use under cautious - This will remove all joints already implemented.
  28821. */
  28822. forceUpdate(): void;
  28823. /**
  28824. * Gets the body that holds this impostor. Either its own, or its parent.
  28825. */
  28826. get physicsBody(): any;
  28827. /**
  28828. * Get the parent of the physics imposter
  28829. * @returns Physics imposter or null
  28830. */
  28831. get parent(): Nullable<PhysicsImpostor>;
  28832. /**
  28833. * Sets the parent of the physics imposter
  28834. */
  28835. set parent(value: Nullable<PhysicsImpostor>);
  28836. /**
  28837. * Set the physics body. Used mainly by the physics engine/plugin
  28838. */
  28839. set physicsBody(physicsBody: any);
  28840. /**
  28841. * Resets the update flags
  28842. */
  28843. resetUpdateFlags(): void;
  28844. /**
  28845. * Gets the object extend size
  28846. * @returns the object extend size
  28847. */
  28848. getObjectExtendSize(): Vector3;
  28849. /**
  28850. * Gets the object center
  28851. * @returns The object center
  28852. */
  28853. getObjectCenter(): Vector3;
  28854. /**
  28855. * Get a specific parameter from the options parameters
  28856. * @param paramName The object parameter name
  28857. * @returns The object parameter
  28858. */
  28859. getParam(paramName: string): any;
  28860. /**
  28861. * Sets a specific parameter in the options given to the physics plugin
  28862. * @param paramName The parameter name
  28863. * @param value The value of the parameter
  28864. */
  28865. setParam(paramName: string, value: number): void;
  28866. /**
  28867. * Specifically change the body's mass option. Won't recreate the physics body object
  28868. * @param mass The mass of the physics imposter
  28869. */
  28870. setMass(mass: number): void;
  28871. /**
  28872. * Gets the linear velocity
  28873. * @returns linear velocity or null
  28874. */
  28875. getLinearVelocity(): Nullable<Vector3>;
  28876. /**
  28877. * Sets the linear velocity
  28878. * @param velocity linear velocity or null
  28879. */
  28880. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28881. /**
  28882. * Gets the angular velocity
  28883. * @returns angular velocity or null
  28884. */
  28885. getAngularVelocity(): Nullable<Vector3>;
  28886. /**
  28887. * Sets the angular velocity
  28888. * @param velocity The velocity or null
  28889. */
  28890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28891. /**
  28892. * Execute a function with the physics plugin native code
  28893. * Provide a function the will have two variables - the world object and the physics body object
  28894. * @param func The function to execute with the physics plugin native code
  28895. */
  28896. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28897. /**
  28898. * Register a function that will be executed before the physics world is stepping forward
  28899. * @param func The function to execute before the physics world is stepped forward
  28900. */
  28901. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28902. /**
  28903. * Unregister a function that will be executed before the physics world is stepping forward
  28904. * @param func The function to execute before the physics world is stepped forward
  28905. */
  28906. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28907. /**
  28908. * Register a function that will be executed after the physics step
  28909. * @param func The function to execute after physics step
  28910. */
  28911. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28912. /**
  28913. * Unregisters a function that will be executed after the physics step
  28914. * @param func The function to execute after physics step
  28915. */
  28916. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28917. /**
  28918. * register a function that will be executed when this impostor collides against a different body
  28919. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28920. * @param func Callback that is executed on collision
  28921. */
  28922. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28923. /**
  28924. * Unregisters the physics imposter on contact
  28925. * @param collideAgainst The physics object to collide against
  28926. * @param func Callback to execute on collision
  28927. */
  28928. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28929. private _tmpQuat;
  28930. private _tmpQuat2;
  28931. /**
  28932. * Get the parent rotation
  28933. * @returns The parent rotation
  28934. */
  28935. getParentsRotation(): Quaternion;
  28936. /**
  28937. * this function is executed by the physics engine.
  28938. */
  28939. beforeStep: () => void;
  28940. /**
  28941. * this function is executed by the physics engine
  28942. */
  28943. afterStep: () => void;
  28944. /**
  28945. * Legacy collision detection event support
  28946. */
  28947. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28948. /**
  28949. * event and body object due to cannon's event-based architecture.
  28950. */
  28951. onCollide: (e: {
  28952. body: any;
  28953. }) => void;
  28954. /**
  28955. * Apply a force
  28956. * @param force The force to apply
  28957. * @param contactPoint The contact point for the force
  28958. * @returns The physics imposter
  28959. */
  28960. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28961. /**
  28962. * Apply an impulse
  28963. * @param force The impulse force
  28964. * @param contactPoint The contact point for the impulse force
  28965. * @returns The physics imposter
  28966. */
  28967. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28968. /**
  28969. * A help function to create a joint
  28970. * @param otherImpostor A physics imposter used to create a joint
  28971. * @param jointType The type of joint
  28972. * @param jointData The data for the joint
  28973. * @returns The physics imposter
  28974. */
  28975. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28976. /**
  28977. * Add a joint to this impostor with a different impostor
  28978. * @param otherImpostor A physics imposter used to add a joint
  28979. * @param joint The joint to add
  28980. * @returns The physics imposter
  28981. */
  28982. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28983. /**
  28984. * Add an anchor to a cloth impostor
  28985. * @param otherImpostor rigid impostor to anchor to
  28986. * @param width ratio across width from 0 to 1
  28987. * @param height ratio up height from 0 to 1
  28988. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28989. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28990. * @returns impostor the soft imposter
  28991. */
  28992. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28993. /**
  28994. * Add a hook to a rope impostor
  28995. * @param otherImpostor rigid impostor to anchor to
  28996. * @param length ratio across rope from 0 to 1
  28997. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28998. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28999. * @returns impostor the rope imposter
  29000. */
  29001. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29002. /**
  29003. * Will keep this body still, in a sleep mode.
  29004. * @returns the physics imposter
  29005. */
  29006. sleep(): PhysicsImpostor;
  29007. /**
  29008. * Wake the body up.
  29009. * @returns The physics imposter
  29010. */
  29011. wakeUp(): PhysicsImpostor;
  29012. /**
  29013. * Clones the physics imposter
  29014. * @param newObject The physics imposter clones to this physics-enabled object
  29015. * @returns A nullable physics imposter
  29016. */
  29017. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29018. /**
  29019. * Disposes the physics imposter
  29020. */
  29021. dispose(): void;
  29022. /**
  29023. * Sets the delta position
  29024. * @param position The delta position amount
  29025. */
  29026. setDeltaPosition(position: Vector3): void;
  29027. /**
  29028. * Sets the delta rotation
  29029. * @param rotation The delta rotation amount
  29030. */
  29031. setDeltaRotation(rotation: Quaternion): void;
  29032. /**
  29033. * Gets the box size of the physics imposter and stores the result in the input parameter
  29034. * @param result Stores the box size
  29035. * @returns The physics imposter
  29036. */
  29037. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29038. /**
  29039. * Gets the radius of the physics imposter
  29040. * @returns Radius of the physics imposter
  29041. */
  29042. getRadius(): number;
  29043. /**
  29044. * Sync a bone with this impostor
  29045. * @param bone The bone to sync to the impostor.
  29046. * @param boneMesh The mesh that the bone is influencing.
  29047. * @param jointPivot The pivot of the joint / bone in local space.
  29048. * @param distToJoint Optional distance from the impostor to the joint.
  29049. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29050. */
  29051. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29052. /**
  29053. * Sync impostor to a bone
  29054. * @param bone The bone that the impostor will be synced to.
  29055. * @param boneMesh The mesh that the bone is influencing.
  29056. * @param jointPivot The pivot of the joint / bone in local space.
  29057. * @param distToJoint Optional distance from the impostor to the joint.
  29058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29059. * @param boneAxis Optional vector3 axis the bone is aligned with
  29060. */
  29061. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29062. /**
  29063. * No-Imposter type
  29064. */
  29065. static NoImpostor: number;
  29066. /**
  29067. * Sphere-Imposter type
  29068. */
  29069. static SphereImpostor: number;
  29070. /**
  29071. * Box-Imposter type
  29072. */
  29073. static BoxImpostor: number;
  29074. /**
  29075. * Plane-Imposter type
  29076. */
  29077. static PlaneImpostor: number;
  29078. /**
  29079. * Mesh-imposter type
  29080. */
  29081. static MeshImpostor: number;
  29082. /**
  29083. * Capsule-Impostor type (Ammo.js plugin only)
  29084. */
  29085. static CapsuleImpostor: number;
  29086. /**
  29087. * Cylinder-Imposter type
  29088. */
  29089. static CylinderImpostor: number;
  29090. /**
  29091. * Particle-Imposter type
  29092. */
  29093. static ParticleImpostor: number;
  29094. /**
  29095. * Heightmap-Imposter type
  29096. */
  29097. static HeightmapImpostor: number;
  29098. /**
  29099. * ConvexHull-Impostor type (Ammo.js plugin only)
  29100. */
  29101. static ConvexHullImpostor: number;
  29102. /**
  29103. * Custom-Imposter type (Ammo.js plugin only)
  29104. */
  29105. static CustomImpostor: number;
  29106. /**
  29107. * Rope-Imposter type
  29108. */
  29109. static RopeImpostor: number;
  29110. /**
  29111. * Cloth-Imposter type
  29112. */
  29113. static ClothImpostor: number;
  29114. /**
  29115. * Softbody-Imposter type
  29116. */
  29117. static SoftbodyImpostor: number;
  29118. }
  29119. }
  29120. declare module "babylonjs/Meshes/mesh" {
  29121. import { Observable } from "babylonjs/Misc/observable";
  29122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29123. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29124. import { Camera } from "babylonjs/Cameras/camera";
  29125. import { Scene } from "babylonjs/scene";
  29126. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29127. import { Color4 } from "babylonjs/Maths/math.color";
  29128. import { Engine } from "babylonjs/Engines/engine";
  29129. import { Node } from "babylonjs/node";
  29130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29131. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29132. import { Buffer } from "babylonjs/Meshes/buffer";
  29133. import { Geometry } from "babylonjs/Meshes/geometry";
  29134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29136. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29137. import { Effect } from "babylonjs/Materials/effect";
  29138. import { Material } from "babylonjs/Materials/material";
  29139. import { Skeleton } from "babylonjs/Bones/skeleton";
  29140. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29141. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29142. import { Path3D } from "babylonjs/Maths/math.path";
  29143. import { Plane } from "babylonjs/Maths/math.plane";
  29144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29145. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29146. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29147. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29148. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29149. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29150. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29151. /**
  29152. * @hidden
  29153. **/
  29154. export class _CreationDataStorage {
  29155. closePath?: boolean;
  29156. closeArray?: boolean;
  29157. idx: number[];
  29158. dashSize: number;
  29159. gapSize: number;
  29160. path3D: Path3D;
  29161. pathArray: Vector3[][];
  29162. arc: number;
  29163. radius: number;
  29164. cap: number;
  29165. tessellation: number;
  29166. }
  29167. /**
  29168. * @hidden
  29169. **/
  29170. class _InstanceDataStorage {
  29171. visibleInstances: any;
  29172. batchCache: _InstancesBatch;
  29173. instancesBufferSize: number;
  29174. instancesBuffer: Nullable<Buffer>;
  29175. instancesData: Float32Array;
  29176. overridenInstanceCount: number;
  29177. isFrozen: boolean;
  29178. previousBatch: Nullable<_InstancesBatch>;
  29179. hardwareInstancedRendering: boolean;
  29180. sideOrientation: number;
  29181. manualUpdate: boolean;
  29182. previousRenderId: number;
  29183. }
  29184. /**
  29185. * @hidden
  29186. **/
  29187. export class _InstancesBatch {
  29188. mustReturn: boolean;
  29189. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29190. renderSelf: boolean[];
  29191. hardwareInstancedRendering: boolean[];
  29192. }
  29193. /**
  29194. * @hidden
  29195. **/
  29196. class _ThinInstanceDataStorage {
  29197. instancesCount: number;
  29198. matrixBuffer: Nullable<Buffer>;
  29199. matrixBufferSize: number;
  29200. matrixData: Nullable<Float32Array>;
  29201. boundingVectors: Array<Vector3>;
  29202. worldMatrices: Nullable<Matrix[]>;
  29203. }
  29204. /**
  29205. * Class used to represent renderable models
  29206. */
  29207. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29208. /**
  29209. * Mesh side orientation : usually the external or front surface
  29210. */
  29211. static readonly FRONTSIDE: number;
  29212. /**
  29213. * Mesh side orientation : usually the internal or back surface
  29214. */
  29215. static readonly BACKSIDE: number;
  29216. /**
  29217. * Mesh side orientation : both internal and external or front and back surfaces
  29218. */
  29219. static readonly DOUBLESIDE: number;
  29220. /**
  29221. * Mesh side orientation : by default, `FRONTSIDE`
  29222. */
  29223. static readonly DEFAULTSIDE: number;
  29224. /**
  29225. * Mesh cap setting : no cap
  29226. */
  29227. static readonly NO_CAP: number;
  29228. /**
  29229. * Mesh cap setting : one cap at the beginning of the mesh
  29230. */
  29231. static readonly CAP_START: number;
  29232. /**
  29233. * Mesh cap setting : one cap at the end of the mesh
  29234. */
  29235. static readonly CAP_END: number;
  29236. /**
  29237. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29238. */
  29239. static readonly CAP_ALL: number;
  29240. /**
  29241. * Mesh pattern setting : no flip or rotate
  29242. */
  29243. static readonly NO_FLIP: number;
  29244. /**
  29245. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29246. */
  29247. static readonly FLIP_TILE: number;
  29248. /**
  29249. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29250. */
  29251. static readonly ROTATE_TILE: number;
  29252. /**
  29253. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29254. */
  29255. static readonly FLIP_ROW: number;
  29256. /**
  29257. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29258. */
  29259. static readonly ROTATE_ROW: number;
  29260. /**
  29261. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29262. */
  29263. static readonly FLIP_N_ROTATE_TILE: number;
  29264. /**
  29265. * Mesh pattern setting : rotate pattern and rotate
  29266. */
  29267. static readonly FLIP_N_ROTATE_ROW: number;
  29268. /**
  29269. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29270. */
  29271. static readonly CENTER: number;
  29272. /**
  29273. * Mesh tile positioning : part tiles on left
  29274. */
  29275. static readonly LEFT: number;
  29276. /**
  29277. * Mesh tile positioning : part tiles on right
  29278. */
  29279. static readonly RIGHT: number;
  29280. /**
  29281. * Mesh tile positioning : part tiles on top
  29282. */
  29283. static readonly TOP: number;
  29284. /**
  29285. * Mesh tile positioning : part tiles on bottom
  29286. */
  29287. static readonly BOTTOM: number;
  29288. /**
  29289. * Gets the default side orientation.
  29290. * @param orientation the orientation to value to attempt to get
  29291. * @returns the default orientation
  29292. * @hidden
  29293. */
  29294. static _GetDefaultSideOrientation(orientation?: number): number;
  29295. private _internalMeshDataInfo;
  29296. get computeBonesUsingShaders(): boolean;
  29297. set computeBonesUsingShaders(value: boolean);
  29298. /**
  29299. * An event triggered before rendering the mesh
  29300. */
  29301. get onBeforeRenderObservable(): Observable<Mesh>;
  29302. /**
  29303. * An event triggered before binding the mesh
  29304. */
  29305. get onBeforeBindObservable(): Observable<Mesh>;
  29306. /**
  29307. * An event triggered after rendering the mesh
  29308. */
  29309. get onAfterRenderObservable(): Observable<Mesh>;
  29310. /**
  29311. * An event triggered before drawing the mesh
  29312. */
  29313. get onBeforeDrawObservable(): Observable<Mesh>;
  29314. private _onBeforeDrawObserver;
  29315. /**
  29316. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29317. */
  29318. set onBeforeDraw(callback: () => void);
  29319. get hasInstances(): boolean;
  29320. get hasThinInstances(): boolean;
  29321. /**
  29322. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29323. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29324. */
  29325. delayLoadState: number;
  29326. /**
  29327. * Gets the list of instances created from this mesh
  29328. * it is not supposed to be modified manually.
  29329. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29331. */
  29332. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29333. /**
  29334. * Gets the file containing delay loading data for this mesh
  29335. */
  29336. delayLoadingFile: string;
  29337. /** @hidden */
  29338. _binaryInfo: any;
  29339. /**
  29340. * User defined function used to change how LOD level selection is done
  29341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29342. */
  29343. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29344. /**
  29345. * Gets or sets the morph target manager
  29346. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29347. */
  29348. get morphTargetManager(): Nullable<MorphTargetManager>;
  29349. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29350. /** @hidden */
  29351. _creationDataStorage: Nullable<_CreationDataStorage>;
  29352. /** @hidden */
  29353. _geometry: Nullable<Geometry>;
  29354. /** @hidden */
  29355. _delayInfo: Array<string>;
  29356. /** @hidden */
  29357. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29358. /** @hidden */
  29359. _instanceDataStorage: _InstanceDataStorage;
  29360. /** @hidden */
  29361. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29362. private _effectiveMaterial;
  29363. /** @hidden */
  29364. _shouldGenerateFlatShading: boolean;
  29365. /** @hidden */
  29366. _originalBuilderSideOrientation: number;
  29367. /**
  29368. * Use this property to change the original side orientation defined at construction time
  29369. */
  29370. overrideMaterialSideOrientation: Nullable<number>;
  29371. /**
  29372. * Gets the source mesh (the one used to clone this one from)
  29373. */
  29374. get source(): Nullable<Mesh>;
  29375. /**
  29376. * Gets the list of clones of this mesh
  29377. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29378. * Note that useClonedMeshMap=true is the default setting
  29379. */
  29380. get cloneMeshMap(): Nullable<{
  29381. [id: string]: Mesh | undefined;
  29382. }>;
  29383. /**
  29384. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29385. */
  29386. get isUnIndexed(): boolean;
  29387. set isUnIndexed(value: boolean);
  29388. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29389. get worldMatrixInstancedBuffer(): Float32Array;
  29390. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29391. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29392. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29393. /**
  29394. * @constructor
  29395. * @param name The value used by scene.getMeshByName() to do a lookup.
  29396. * @param scene The scene to add this mesh to.
  29397. * @param parent The parent of this mesh, if it has one
  29398. * @param source An optional Mesh from which geometry is shared, cloned.
  29399. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29400. * When false, achieved by calling a clone(), also passing False.
  29401. * This will make creation of children, recursive.
  29402. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29403. */
  29404. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29405. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29406. doNotInstantiate: boolean;
  29407. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29408. /**
  29409. * Gets the class name
  29410. * @returns the string "Mesh".
  29411. */
  29412. getClassName(): string;
  29413. /** @hidden */
  29414. get _isMesh(): boolean;
  29415. /**
  29416. * Returns a description of this mesh
  29417. * @param fullDetails define if full details about this mesh must be used
  29418. * @returns a descriptive string representing this mesh
  29419. */
  29420. toString(fullDetails?: boolean): string;
  29421. /** @hidden */
  29422. _unBindEffect(): void;
  29423. /**
  29424. * Gets a boolean indicating if this mesh has LOD
  29425. */
  29426. get hasLODLevels(): boolean;
  29427. /**
  29428. * Gets the list of MeshLODLevel associated with the current mesh
  29429. * @returns an array of MeshLODLevel
  29430. */
  29431. getLODLevels(): MeshLODLevel[];
  29432. private _sortLODLevels;
  29433. /**
  29434. * Add a mesh as LOD level triggered at the given distance.
  29435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29436. * @param distance The distance from the center of the object to show this level
  29437. * @param mesh The mesh to be added as LOD level (can be null)
  29438. * @return This mesh (for chaining)
  29439. */
  29440. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29441. /**
  29442. * Returns the LOD level mesh at the passed distance or null if not found.
  29443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29444. * @param distance The distance from the center of the object to show this level
  29445. * @returns a Mesh or `null`
  29446. */
  29447. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29448. /**
  29449. * Remove a mesh from the LOD array
  29450. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29451. * @param mesh defines the mesh to be removed
  29452. * @return This mesh (for chaining)
  29453. */
  29454. removeLODLevel(mesh: Mesh): Mesh;
  29455. /**
  29456. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29457. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29458. * @param camera defines the camera to use to compute distance
  29459. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29460. * @return This mesh (for chaining)
  29461. */
  29462. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29463. /**
  29464. * Gets the mesh internal Geometry object
  29465. */
  29466. get geometry(): Nullable<Geometry>;
  29467. /**
  29468. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29469. * @returns the total number of vertices
  29470. */
  29471. getTotalVertices(): number;
  29472. /**
  29473. * Returns the content of an associated vertex buffer
  29474. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29475. * - VertexBuffer.PositionKind
  29476. * - VertexBuffer.UVKind
  29477. * - VertexBuffer.UV2Kind
  29478. * - VertexBuffer.UV3Kind
  29479. * - VertexBuffer.UV4Kind
  29480. * - VertexBuffer.UV5Kind
  29481. * - VertexBuffer.UV6Kind
  29482. * - VertexBuffer.ColorKind
  29483. * - VertexBuffer.MatricesIndicesKind
  29484. * - VertexBuffer.MatricesIndicesExtraKind
  29485. * - VertexBuffer.MatricesWeightsKind
  29486. * - VertexBuffer.MatricesWeightsExtraKind
  29487. * @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
  29488. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29489. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29490. */
  29491. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29492. /**
  29493. * Returns the mesh VertexBuffer object from the requested `kind`
  29494. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29495. * - VertexBuffer.PositionKind
  29496. * - VertexBuffer.NormalKind
  29497. * - VertexBuffer.UVKind
  29498. * - VertexBuffer.UV2Kind
  29499. * - VertexBuffer.UV3Kind
  29500. * - VertexBuffer.UV4Kind
  29501. * - VertexBuffer.UV5Kind
  29502. * - VertexBuffer.UV6Kind
  29503. * - VertexBuffer.ColorKind
  29504. * - VertexBuffer.MatricesIndicesKind
  29505. * - VertexBuffer.MatricesIndicesExtraKind
  29506. * - VertexBuffer.MatricesWeightsKind
  29507. * - VertexBuffer.MatricesWeightsExtraKind
  29508. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29509. */
  29510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29511. /**
  29512. * Tests if a specific vertex buffer is associated with this mesh
  29513. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29514. * - VertexBuffer.PositionKind
  29515. * - VertexBuffer.NormalKind
  29516. * - VertexBuffer.UVKind
  29517. * - VertexBuffer.UV2Kind
  29518. * - VertexBuffer.UV3Kind
  29519. * - VertexBuffer.UV4Kind
  29520. * - VertexBuffer.UV5Kind
  29521. * - VertexBuffer.UV6Kind
  29522. * - VertexBuffer.ColorKind
  29523. * - VertexBuffer.MatricesIndicesKind
  29524. * - VertexBuffer.MatricesIndicesExtraKind
  29525. * - VertexBuffer.MatricesWeightsKind
  29526. * - VertexBuffer.MatricesWeightsExtraKind
  29527. * @returns a boolean
  29528. */
  29529. isVerticesDataPresent(kind: string): boolean;
  29530. /**
  29531. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29532. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29533. * - VertexBuffer.PositionKind
  29534. * - VertexBuffer.UVKind
  29535. * - VertexBuffer.UV2Kind
  29536. * - VertexBuffer.UV3Kind
  29537. * - VertexBuffer.UV4Kind
  29538. * - VertexBuffer.UV5Kind
  29539. * - VertexBuffer.UV6Kind
  29540. * - VertexBuffer.ColorKind
  29541. * - VertexBuffer.MatricesIndicesKind
  29542. * - VertexBuffer.MatricesIndicesExtraKind
  29543. * - VertexBuffer.MatricesWeightsKind
  29544. * - VertexBuffer.MatricesWeightsExtraKind
  29545. * @returns a boolean
  29546. */
  29547. isVertexBufferUpdatable(kind: string): boolean;
  29548. /**
  29549. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29550. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29551. * - VertexBuffer.PositionKind
  29552. * - VertexBuffer.NormalKind
  29553. * - VertexBuffer.UVKind
  29554. * - VertexBuffer.UV2Kind
  29555. * - VertexBuffer.UV3Kind
  29556. * - VertexBuffer.UV4Kind
  29557. * - VertexBuffer.UV5Kind
  29558. * - VertexBuffer.UV6Kind
  29559. * - VertexBuffer.ColorKind
  29560. * - VertexBuffer.MatricesIndicesKind
  29561. * - VertexBuffer.MatricesIndicesExtraKind
  29562. * - VertexBuffer.MatricesWeightsKind
  29563. * - VertexBuffer.MatricesWeightsExtraKind
  29564. * @returns an array of strings
  29565. */
  29566. getVerticesDataKinds(): string[];
  29567. /**
  29568. * Returns a positive integer : the total number of indices in this mesh geometry.
  29569. * @returns the numner of indices or zero if the mesh has no geometry.
  29570. */
  29571. getTotalIndices(): number;
  29572. /**
  29573. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29574. * @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.
  29575. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29576. * @returns the indices array or an empty array if the mesh has no geometry
  29577. */
  29578. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29579. get isBlocked(): boolean;
  29580. /**
  29581. * Determine if the current mesh is ready to be rendered
  29582. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29583. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29584. * @returns true if all associated assets are ready (material, textures, shaders)
  29585. */
  29586. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29587. /**
  29588. * 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.
  29589. */
  29590. get areNormalsFrozen(): boolean;
  29591. /**
  29592. * 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.
  29593. * @returns the current mesh
  29594. */
  29595. freezeNormals(): Mesh;
  29596. /**
  29597. * 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
  29598. * @returns the current mesh
  29599. */
  29600. unfreezeNormals(): Mesh;
  29601. /**
  29602. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29603. */
  29604. set overridenInstanceCount(count: number);
  29605. /** @hidden */
  29606. _preActivate(): Mesh;
  29607. /** @hidden */
  29608. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29609. /** @hidden */
  29610. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29611. protected _afterComputeWorldMatrix(): void;
  29612. /** @hidden */
  29613. _postActivate(): void;
  29614. /**
  29615. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29616. * This means the mesh underlying bounding box and sphere are recomputed.
  29617. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29618. * @returns the current mesh
  29619. */
  29620. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29621. /** @hidden */
  29622. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29623. /**
  29624. * This function will subdivide the mesh into multiple submeshes
  29625. * @param count defines the expected number of submeshes
  29626. */
  29627. subdivide(count: number): void;
  29628. /**
  29629. * Copy a FloatArray into a specific associated vertex buffer
  29630. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29631. * - VertexBuffer.PositionKind
  29632. * - VertexBuffer.UVKind
  29633. * - VertexBuffer.UV2Kind
  29634. * - VertexBuffer.UV3Kind
  29635. * - VertexBuffer.UV4Kind
  29636. * - VertexBuffer.UV5Kind
  29637. * - VertexBuffer.UV6Kind
  29638. * - VertexBuffer.ColorKind
  29639. * - VertexBuffer.MatricesIndicesKind
  29640. * - VertexBuffer.MatricesIndicesExtraKind
  29641. * - VertexBuffer.MatricesWeightsKind
  29642. * - VertexBuffer.MatricesWeightsExtraKind
  29643. * @param data defines the data source
  29644. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29645. * @param stride defines the data stride size (can be null)
  29646. * @returns the current mesh
  29647. */
  29648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29649. /**
  29650. * Delete a vertex buffer associated with this mesh
  29651. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29652. * - VertexBuffer.PositionKind
  29653. * - VertexBuffer.UVKind
  29654. * - VertexBuffer.UV2Kind
  29655. * - VertexBuffer.UV3Kind
  29656. * - VertexBuffer.UV4Kind
  29657. * - VertexBuffer.UV5Kind
  29658. * - VertexBuffer.UV6Kind
  29659. * - VertexBuffer.ColorKind
  29660. * - VertexBuffer.MatricesIndicesKind
  29661. * - VertexBuffer.MatricesIndicesExtraKind
  29662. * - VertexBuffer.MatricesWeightsKind
  29663. * - VertexBuffer.MatricesWeightsExtraKind
  29664. */
  29665. removeVerticesData(kind: string): void;
  29666. /**
  29667. * Flags an associated vertex buffer as updatable
  29668. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29669. * - VertexBuffer.PositionKind
  29670. * - VertexBuffer.UVKind
  29671. * - VertexBuffer.UV2Kind
  29672. * - VertexBuffer.UV3Kind
  29673. * - VertexBuffer.UV4Kind
  29674. * - VertexBuffer.UV5Kind
  29675. * - VertexBuffer.UV6Kind
  29676. * - VertexBuffer.ColorKind
  29677. * - VertexBuffer.MatricesIndicesKind
  29678. * - VertexBuffer.MatricesIndicesExtraKind
  29679. * - VertexBuffer.MatricesWeightsKind
  29680. * - VertexBuffer.MatricesWeightsExtraKind
  29681. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29682. */
  29683. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29684. /**
  29685. * Sets the mesh global Vertex Buffer
  29686. * @param buffer defines the buffer to use
  29687. * @returns the current mesh
  29688. */
  29689. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29690. /**
  29691. * Update a specific associated vertex buffer
  29692. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29693. * - VertexBuffer.PositionKind
  29694. * - VertexBuffer.UVKind
  29695. * - VertexBuffer.UV2Kind
  29696. * - VertexBuffer.UV3Kind
  29697. * - VertexBuffer.UV4Kind
  29698. * - VertexBuffer.UV5Kind
  29699. * - VertexBuffer.UV6Kind
  29700. * - VertexBuffer.ColorKind
  29701. * - VertexBuffer.MatricesIndicesKind
  29702. * - VertexBuffer.MatricesIndicesExtraKind
  29703. * - VertexBuffer.MatricesWeightsKind
  29704. * - VertexBuffer.MatricesWeightsExtraKind
  29705. * @param data defines the data source
  29706. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29707. * @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)
  29708. * @returns the current mesh
  29709. */
  29710. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29711. /**
  29712. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29713. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29714. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29715. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29716. * @returns the current mesh
  29717. */
  29718. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29719. /**
  29720. * Creates a un-shared specific occurence of the geometry for the mesh.
  29721. * @returns the current mesh
  29722. */
  29723. makeGeometryUnique(): Mesh;
  29724. /**
  29725. * Set the index buffer of this mesh
  29726. * @param indices defines the source data
  29727. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29728. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29729. * @returns the current mesh
  29730. */
  29731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29732. /**
  29733. * Update the current index buffer
  29734. * @param indices defines the source data
  29735. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29736. * @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)
  29737. * @returns the current mesh
  29738. */
  29739. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29740. /**
  29741. * Invert the geometry to move from a right handed system to a left handed one.
  29742. * @returns the current mesh
  29743. */
  29744. toLeftHanded(): Mesh;
  29745. /** @hidden */
  29746. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29747. /** @hidden */
  29748. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29749. /**
  29750. * Registers for this mesh a javascript function called just before the rendering process
  29751. * @param func defines the function to call before rendering this mesh
  29752. * @returns the current mesh
  29753. */
  29754. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29755. /**
  29756. * Disposes a previously registered javascript function called before the rendering
  29757. * @param func defines the function to remove
  29758. * @returns the current mesh
  29759. */
  29760. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29761. /**
  29762. * Registers for this mesh a javascript function called just after the rendering is complete
  29763. * @param func defines the function to call after rendering this mesh
  29764. * @returns the current mesh
  29765. */
  29766. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29767. /**
  29768. * Disposes a previously registered javascript function called after the rendering.
  29769. * @param func defines the function to remove
  29770. * @returns the current mesh
  29771. */
  29772. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29773. /** @hidden */
  29774. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29775. /** @hidden */
  29776. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29777. /** @hidden */
  29778. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29779. /** @hidden */
  29780. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29781. /** @hidden */
  29782. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29783. /** @hidden */
  29784. _rebuild(): void;
  29785. /** @hidden */
  29786. _freeze(): void;
  29787. /** @hidden */
  29788. _unFreeze(): void;
  29789. /**
  29790. * 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
  29791. * @param subMesh defines the subMesh to render
  29792. * @param enableAlphaMode defines if alpha mode can be changed
  29793. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29794. * @returns the current mesh
  29795. */
  29796. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29797. private _onBeforeDraw;
  29798. /**
  29799. * Renormalize the mesh and patch it up if there are no weights
  29800. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29801. * However in the case of zero weights then we set just a single influence to 1.
  29802. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29803. */
  29804. cleanMatrixWeights(): void;
  29805. private normalizeSkinFourWeights;
  29806. private normalizeSkinWeightsAndExtra;
  29807. /**
  29808. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29809. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29810. * the user know there was an issue with importing the mesh
  29811. * @returns a validation object with skinned, valid and report string
  29812. */
  29813. validateSkinning(): {
  29814. skinned: boolean;
  29815. valid: boolean;
  29816. report: string;
  29817. };
  29818. /** @hidden */
  29819. _checkDelayState(): Mesh;
  29820. private _queueLoad;
  29821. /**
  29822. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29823. * A mesh is in the frustum if its bounding box intersects the frustum
  29824. * @param frustumPlanes defines the frustum to test
  29825. * @returns true if the mesh is in the frustum planes
  29826. */
  29827. isInFrustum(frustumPlanes: Plane[]): boolean;
  29828. /**
  29829. * Sets the mesh material by the material or multiMaterial `id` property
  29830. * @param id is a string identifying the material or the multiMaterial
  29831. * @returns the current mesh
  29832. */
  29833. setMaterialByID(id: string): Mesh;
  29834. /**
  29835. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29836. * @returns an array of IAnimatable
  29837. */
  29838. getAnimatables(): IAnimatable[];
  29839. /**
  29840. * Modifies the mesh geometry according to the passed transformation matrix.
  29841. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29842. * The mesh normals are modified using the same transformation.
  29843. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29844. * @param transform defines the transform matrix to use
  29845. * @see https://doc.babylonjs.com/resources/baking_transformations
  29846. * @returns the current mesh
  29847. */
  29848. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29849. /**
  29850. * Modifies the mesh geometry according to its own current World Matrix.
  29851. * The mesh World Matrix is then reset.
  29852. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29853. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29854. * @see https://doc.babylonjs.com/resources/baking_transformations
  29855. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29856. * @returns the current mesh
  29857. */
  29858. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29859. /** @hidden */
  29860. get _positions(): Nullable<Vector3[]>;
  29861. /** @hidden */
  29862. _resetPointsArrayCache(): Mesh;
  29863. /** @hidden */
  29864. _generatePointsArray(): boolean;
  29865. /**
  29866. * Returns a new Mesh object generated from the current mesh properties.
  29867. * This method must not get confused with createInstance()
  29868. * @param name is a string, the name given to the new mesh
  29869. * @param newParent can be any Node object (default `null`)
  29870. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29871. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29872. * @returns a new mesh
  29873. */
  29874. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29875. /**
  29876. * Releases resources associated with this mesh.
  29877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29879. */
  29880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29881. /** @hidden */
  29882. _disposeInstanceSpecificData(): void;
  29883. /** @hidden */
  29884. _disposeThinInstanceSpecificData(): void;
  29885. /**
  29886. * Modifies the mesh geometry according to a displacement map.
  29887. * 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.
  29888. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29889. * @param url is a string, the URL from the image file is to be downloaded.
  29890. * @param minHeight is the lower limit of the displacement.
  29891. * @param maxHeight is the upper limit of the displacement.
  29892. * @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.
  29893. * @param uvOffset is an optional vector2 used to offset UV.
  29894. * @param uvScale is an optional vector2 used to scale UV.
  29895. * @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.
  29896. * @returns the Mesh.
  29897. */
  29898. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29899. /**
  29900. * Modifies the mesh geometry according to a displacementMap buffer.
  29901. * 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.
  29902. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29903. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29904. * @param heightMapWidth is the width of the buffer image.
  29905. * @param heightMapHeight is the height of the buffer image.
  29906. * @param minHeight is the lower limit of the displacement.
  29907. * @param maxHeight is the upper limit of the displacement.
  29908. * @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.
  29909. * @param uvOffset is an optional vector2 used to offset UV.
  29910. * @param uvScale is an optional vector2 used to scale UV.
  29911. * @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.
  29912. * @returns the Mesh.
  29913. */
  29914. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29915. /**
  29916. * Modify the mesh to get a flat shading rendering.
  29917. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29918. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29919. * @returns current mesh
  29920. */
  29921. convertToFlatShadedMesh(): Mesh;
  29922. /**
  29923. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29924. * In other words, more vertices, no more indices and a single bigger VBO.
  29925. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29926. * @returns current mesh
  29927. */
  29928. convertToUnIndexedMesh(): Mesh;
  29929. /**
  29930. * Inverses facet orientations.
  29931. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29932. * @param flipNormals will also inverts the normals
  29933. * @returns current mesh
  29934. */
  29935. flipFaces(flipNormals?: boolean): Mesh;
  29936. /**
  29937. * Increase the number of facets and hence vertices in a mesh
  29938. * Vertex normals are interpolated from existing vertex normals
  29939. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29940. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29941. */
  29942. increaseVertices(numberPerEdge: number): void;
  29943. /**
  29944. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29945. * This will undo any application of covertToFlatShadedMesh
  29946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29947. */
  29948. forceSharedVertices(): void;
  29949. /** @hidden */
  29950. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29951. /** @hidden */
  29952. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29953. /**
  29954. * Creates a new InstancedMesh object from the mesh model.
  29955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29956. * @param name defines the name of the new instance
  29957. * @returns a new InstancedMesh
  29958. */
  29959. createInstance(name: string): InstancedMesh;
  29960. /**
  29961. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29962. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29963. * @returns the current mesh
  29964. */
  29965. synchronizeInstances(): Mesh;
  29966. /**
  29967. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29968. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29969. * This should be used together with the simplification to avoid disappearing triangles.
  29970. * @param successCallback an optional success callback to be called after the optimization finished.
  29971. * @returns the current mesh
  29972. */
  29973. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29974. /**
  29975. * Serialize current mesh
  29976. * @param serializationObject defines the object which will receive the serialization data
  29977. */
  29978. serialize(serializationObject: any): void;
  29979. /** @hidden */
  29980. _syncGeometryWithMorphTargetManager(): void;
  29981. /** @hidden */
  29982. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29983. /**
  29984. * Returns a new Mesh object parsed from the source provided.
  29985. * @param parsedMesh is the source
  29986. * @param scene defines the hosting scene
  29987. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29988. * @returns a new Mesh
  29989. */
  29990. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29991. /**
  29992. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29994. * @param name defines the name of the mesh to create
  29995. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29996. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29997. * @param closePath creates a seam between the first and the last points of each path of the path array
  29998. * @param offset is taken in account only if the `pathArray` is containing a single path
  29999. * @param scene defines the hosting scene
  30000. * @param updatable defines if the mesh must be flagged as updatable
  30001. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30002. * @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)
  30003. * @returns a new Mesh
  30004. */
  30005. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30006. /**
  30007. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30008. * @param name defines the name of the mesh to create
  30009. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30010. * @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
  30011. * @param scene defines the hosting scene
  30012. * @param updatable defines if the mesh must be flagged as updatable
  30013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30014. * @returns a new Mesh
  30015. */
  30016. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30017. /**
  30018. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30019. * @param name defines the name of the mesh to create
  30020. * @param size sets the size (float) of each box side (default 1)
  30021. * @param scene defines the hosting scene
  30022. * @param updatable defines if the mesh must be flagged as updatable
  30023. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30024. * @returns a new Mesh
  30025. */
  30026. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30027. /**
  30028. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30029. * @param name defines the name of the mesh to create
  30030. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30031. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30038. /**
  30039. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30042. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30043. * @param scene defines the hosting scene
  30044. * @returns a new Mesh
  30045. */
  30046. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30047. /**
  30048. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30049. * @param name defines the name of the mesh to create
  30050. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30051. * @param diameterTop set the top cap diameter (floats, default 1)
  30052. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30053. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30054. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30055. * @param scene defines the hosting scene
  30056. * @param updatable defines if the mesh must be flagged as updatable
  30057. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30058. * @returns a new Mesh
  30059. */
  30060. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30061. /**
  30062. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30063. * @param name defines the name of the mesh to create
  30064. * @param diameter sets the diameter size (float) of the torus (default 1)
  30065. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30066. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30067. * @param scene defines the hosting scene
  30068. * @param updatable defines if the mesh must be flagged as updatable
  30069. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30070. * @returns a new Mesh
  30071. */
  30072. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30073. /**
  30074. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30075. * @param name defines the name of the mesh to create
  30076. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30077. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30078. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30079. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30080. * @param p the number of windings on X axis (positive integers, default 2)
  30081. * @param q the number of windings on Y axis (positive integers, default 3)
  30082. * @param scene defines the hosting scene
  30083. * @param updatable defines if the mesh must be flagged as updatable
  30084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30085. * @returns a new Mesh
  30086. */
  30087. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30088. /**
  30089. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30090. * @param name defines the name of the mesh to create
  30091. * @param points is an array successive Vector3
  30092. * @param scene defines the hosting scene
  30093. * @param updatable defines if the mesh must be flagged as updatable
  30094. * @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).
  30095. * @returns a new Mesh
  30096. */
  30097. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30098. /**
  30099. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30100. * @param name defines the name of the mesh to create
  30101. * @param points is an array successive Vector3
  30102. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30103. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30104. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30105. * @param scene defines the hosting scene
  30106. * @param updatable defines if the mesh must be flagged as updatable
  30107. * @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)
  30108. * @returns a new Mesh
  30109. */
  30110. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30111. /**
  30112. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30114. * 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.
  30115. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30117. * Remember you can only change the shape positions, not their number when updating a polygon.
  30118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30119. * @param name defines the name of the mesh to create
  30120. * @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
  30121. * @param scene defines the hosting scene
  30122. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30123. * @param updatable defines if the mesh must be flagged as updatable
  30124. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30125. * @param earcutInjection can be used to inject your own earcut reference
  30126. * @returns a new Mesh
  30127. */
  30128. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30129. /**
  30130. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30132. * @param name defines the name of the mesh to create
  30133. * @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
  30134. * @param depth defines the height of extrusion
  30135. * @param scene defines the hosting scene
  30136. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30137. * @param updatable defines if the mesh must be flagged as updatable
  30138. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30139. * @param earcutInjection can be used to inject your own earcut reference
  30140. * @returns a new Mesh
  30141. */
  30142. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30143. /**
  30144. * Creates an extruded shape mesh.
  30145. * 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
  30146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30148. * @param name defines the name of the mesh to create
  30149. * @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
  30150. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30151. * @param scale is the value to scale the shape
  30152. * @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
  30153. * @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
  30154. * @param scene defines the hosting scene
  30155. * @param updatable defines if the mesh must be flagged as updatable
  30156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30157. * @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)
  30158. * @returns a new Mesh
  30159. */
  30160. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30161. /**
  30162. * Creates an custom extruded shape mesh.
  30163. * The custom extrusion is a parametric shape.
  30164. * It has no predefined shape. Its final shape will depend on the input parameters.
  30165. * Please consider using the same method from the MeshBuilder class instead
  30166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30167. * @param name defines the name of the mesh to create
  30168. * @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
  30169. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30170. * @param scaleFunction is a custom Javascript function called on each path point
  30171. * @param rotationFunction is a custom Javascript function called on each path point
  30172. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30173. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30174. * @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
  30175. * @param scene defines the hosting scene
  30176. * @param updatable defines if the mesh must be flagged as updatable
  30177. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30178. * @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)
  30179. * @returns a new Mesh
  30180. */
  30181. 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;
  30182. /**
  30183. * Creates lathe mesh.
  30184. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  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 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
  30188. * @param radius is the radius value of the lathe
  30189. * @param tessellation is the side number of the lathe.
  30190. * @param scene defines the hosting scene
  30191. * @param updatable defines if the mesh must be flagged as updatable
  30192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30193. * @returns a new Mesh
  30194. */
  30195. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30196. /**
  30197. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30198. * @param name defines the name of the mesh to create
  30199. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30200. * @param scene defines the hosting scene
  30201. * @param updatable defines if the mesh must be flagged as updatable
  30202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30203. * @returns a new Mesh
  30204. */
  30205. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30206. /**
  30207. * Creates a ground mesh.
  30208. * Please consider using the same method from the MeshBuilder class instead
  30209. * @param name defines the name of the mesh to create
  30210. * @param width set the width of the ground
  30211. * @param height set the height of the ground
  30212. * @param subdivisions sets the number of subdivisions per side
  30213. * @param scene defines the hosting scene
  30214. * @param updatable defines if the mesh must be flagged as updatable
  30215. * @returns a new Mesh
  30216. */
  30217. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30218. /**
  30219. * Creates a tiled ground mesh.
  30220. * Please consider using the same method from the MeshBuilder class instead
  30221. * @param name defines the name of the mesh to create
  30222. * @param xmin set the ground minimum X coordinate
  30223. * @param zmin set the ground minimum Y coordinate
  30224. * @param xmax set the ground maximum X coordinate
  30225. * @param zmax set the ground maximum Z coordinate
  30226. * @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
  30227. * @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
  30228. * @param scene defines the hosting scene
  30229. * @param updatable defines if the mesh must be flagged as updatable
  30230. * @returns a new Mesh
  30231. */
  30232. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30233. w: number;
  30234. h: number;
  30235. }, precision: {
  30236. w: number;
  30237. h: number;
  30238. }, scene: Scene, updatable?: boolean): Mesh;
  30239. /**
  30240. * Creates a ground mesh from a height map.
  30241. * Please consider using the same method from the MeshBuilder class instead
  30242. * @see https://doc.babylonjs.com/babylon101/height_map
  30243. * @param name defines the name of the mesh to create
  30244. * @param url sets the URL of the height map image resource
  30245. * @param width set the ground width size
  30246. * @param height set the ground height size
  30247. * @param subdivisions sets the number of subdivision per side
  30248. * @param minHeight is the minimum altitude on the ground
  30249. * @param maxHeight is the maximum altitude on the ground
  30250. * @param scene defines the hosting scene
  30251. * @param updatable defines if the mesh must be flagged as updatable
  30252. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30253. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30254. * @returns a new Mesh
  30255. */
  30256. 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;
  30257. /**
  30258. * Creates a tube mesh.
  30259. * The tube is a parametric shape.
  30260. * It has no predefined shape. Its final shape will depend on the input parameters.
  30261. * Please consider using the same method from the MeshBuilder class instead
  30262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30263. * @param name defines the name of the mesh to create
  30264. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30265. * @param radius sets the tube radius size
  30266. * @param tessellation is the number of sides on the tubular surface
  30267. * @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
  30268. * @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
  30269. * @param scene defines the hosting scene
  30270. * @param updatable defines if the mesh must be flagged as updatable
  30271. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30272. * @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)
  30273. * @returns a new Mesh
  30274. */
  30275. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30276. (i: number, distance: number): number;
  30277. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30278. /**
  30279. * Creates a polyhedron mesh.
  30280. * Please consider using the same method from the MeshBuilder class instead.
  30281. * * 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
  30282. * * The parameter `size` (positive float, default 1) sets the polygon size
  30283. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30284. * * 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`
  30285. * * 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
  30286. * * 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)`)
  30287. * * 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
  30288. * * 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
  30289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30292. * @param name defines the name of the mesh to create
  30293. * @param options defines the options used to create the mesh
  30294. * @param scene defines the hosting scene
  30295. * @returns a new Mesh
  30296. */
  30297. static CreatePolyhedron(name: string, options: {
  30298. type?: number;
  30299. size?: number;
  30300. sizeX?: number;
  30301. sizeY?: number;
  30302. sizeZ?: number;
  30303. custom?: any;
  30304. faceUV?: Vector4[];
  30305. faceColors?: Color4[];
  30306. updatable?: boolean;
  30307. sideOrientation?: number;
  30308. }, scene: Scene): Mesh;
  30309. /**
  30310. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30311. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30312. * * 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`)
  30313. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30314. * * 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
  30315. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30318. * @param name defines the name of the mesh
  30319. * @param options defines the options used to create the mesh
  30320. * @param scene defines the hosting scene
  30321. * @returns a new Mesh
  30322. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30323. */
  30324. static CreateIcoSphere(name: string, options: {
  30325. radius?: number;
  30326. flat?: boolean;
  30327. subdivisions?: number;
  30328. sideOrientation?: number;
  30329. updatable?: boolean;
  30330. }, scene: Scene): Mesh;
  30331. /**
  30332. * Creates a decal mesh.
  30333. * Please consider using the same method from the MeshBuilder class instead.
  30334. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30335. * @param name defines the name of the mesh
  30336. * @param sourceMesh defines the mesh receiving the decal
  30337. * @param position sets the position of the decal in world coordinates
  30338. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30339. * @param size sets the decal scaling
  30340. * @param angle sets the angle to rotate the decal
  30341. * @returns a new Mesh
  30342. */
  30343. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30344. /** Creates a Capsule Mesh
  30345. * @param name defines the name of the mesh.
  30346. * @param options the constructors options used to shape the mesh.
  30347. * @param scene defines the scene the mesh is scoped to.
  30348. * @returns the capsule mesh
  30349. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30350. */
  30351. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30352. /**
  30353. * Prepare internal position array for software CPU skinning
  30354. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30355. */
  30356. setPositionsForCPUSkinning(): Float32Array;
  30357. /**
  30358. * Prepare internal normal array for software CPU skinning
  30359. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30360. */
  30361. setNormalsForCPUSkinning(): Float32Array;
  30362. /**
  30363. * Updates the vertex buffer by applying transformation from the bones
  30364. * @param skeleton defines the skeleton to apply to current mesh
  30365. * @returns the current mesh
  30366. */
  30367. applySkeleton(skeleton: Skeleton): Mesh;
  30368. /**
  30369. * 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
  30370. * @param meshes defines the list of meshes to scan
  30371. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30372. */
  30373. static MinMax(meshes: AbstractMesh[]): {
  30374. min: Vector3;
  30375. max: Vector3;
  30376. };
  30377. /**
  30378. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30379. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30380. * @returns a vector3
  30381. */
  30382. static Center(meshesOrMinMaxVector: {
  30383. min: Vector3;
  30384. max: Vector3;
  30385. } | AbstractMesh[]): Vector3;
  30386. /**
  30387. * Merge the array of meshes into a single mesh for performance reasons.
  30388. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30389. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30390. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30391. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30392. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30393. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30394. * @returns a new mesh
  30395. */
  30396. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30397. /** @hidden */
  30398. addInstance(instance: InstancedMesh): void;
  30399. /** @hidden */
  30400. removeInstance(instance: InstancedMesh): void;
  30401. }
  30402. }
  30403. declare module "babylonjs/Cameras/camera" {
  30404. import { SmartArray } from "babylonjs/Misc/smartArray";
  30405. import { Observable } from "babylonjs/Misc/observable";
  30406. import { Nullable } from "babylonjs/types";
  30407. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30408. import { Scene } from "babylonjs/scene";
  30409. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30410. import { Node } from "babylonjs/node";
  30411. import { Mesh } from "babylonjs/Meshes/mesh";
  30412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30413. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30414. import { Viewport } from "babylonjs/Maths/math.viewport";
  30415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30416. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30418. import { Ray } from "babylonjs/Culling/ray";
  30419. /**
  30420. * This is the base class of all the camera used in the application.
  30421. * @see https://doc.babylonjs.com/features/cameras
  30422. */
  30423. export class Camera extends Node {
  30424. /** @hidden */
  30425. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30426. /**
  30427. * This is the default projection mode used by the cameras.
  30428. * It helps recreating a feeling of perspective and better appreciate depth.
  30429. * This is the best way to simulate real life cameras.
  30430. */
  30431. static readonly PERSPECTIVE_CAMERA: number;
  30432. /**
  30433. * This helps creating camera with an orthographic mode.
  30434. * 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.
  30435. */
  30436. static readonly ORTHOGRAPHIC_CAMERA: number;
  30437. /**
  30438. * This is the default FOV mode for perspective cameras.
  30439. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30440. */
  30441. static readonly FOVMODE_VERTICAL_FIXED: number;
  30442. /**
  30443. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30446. /**
  30447. * This specifies ther is no need for a camera rig.
  30448. * Basically only one eye is rendered corresponding to the camera.
  30449. */
  30450. static readonly RIG_MODE_NONE: number;
  30451. /**
  30452. * Simulates a camera Rig with one blue eye and one red eye.
  30453. * This can be use with 3d blue and red glasses.
  30454. */
  30455. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30456. /**
  30457. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered over under each other.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30468. /**
  30469. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30470. */
  30471. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30472. /**
  30473. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30474. */
  30475. static readonly RIG_MODE_VR: number;
  30476. /**
  30477. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30478. */
  30479. static readonly RIG_MODE_WEBVR: number;
  30480. /**
  30481. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30482. */
  30483. static readonly RIG_MODE_CUSTOM: number;
  30484. /**
  30485. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30486. */
  30487. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30488. /**
  30489. * Define the input manager associated with the camera.
  30490. */
  30491. inputs: CameraInputsManager<Camera>;
  30492. /** @hidden */
  30493. _position: Vector3;
  30494. /**
  30495. * Define the current local position of the camera in the scene
  30496. */
  30497. get position(): Vector3;
  30498. set position(newPosition: Vector3);
  30499. protected _upVector: Vector3;
  30500. /**
  30501. * The vector the camera should consider as up.
  30502. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30503. */
  30504. set upVector(vec: Vector3);
  30505. get upVector(): Vector3;
  30506. /**
  30507. * Define the current limit on the left side for an orthographic camera
  30508. * In scene unit
  30509. */
  30510. orthoLeft: Nullable<number>;
  30511. /**
  30512. * Define the current limit on the right side for an orthographic camera
  30513. * In scene unit
  30514. */
  30515. orthoRight: Nullable<number>;
  30516. /**
  30517. * Define the current limit on the bottom side for an orthographic camera
  30518. * In scene unit
  30519. */
  30520. orthoBottom: Nullable<number>;
  30521. /**
  30522. * Define the current limit on the top side for an orthographic camera
  30523. * In scene unit
  30524. */
  30525. orthoTop: Nullable<number>;
  30526. /**
  30527. * Field Of View is set in Radians. (default is 0.8)
  30528. */
  30529. fov: number;
  30530. /**
  30531. * Define the minimum distance the camera can see from.
  30532. * This is important to note that the depth buffer are not infinite and the closer it starts
  30533. * the more your scene might encounter depth fighting issue.
  30534. */
  30535. minZ: number;
  30536. /**
  30537. * Define the maximum distance the camera can see to.
  30538. * This is important to note that the depth buffer are not infinite and the further it end
  30539. * the more your scene might encounter depth fighting issue.
  30540. */
  30541. maxZ: number;
  30542. /**
  30543. * Define the default inertia of the camera.
  30544. * This helps giving a smooth feeling to the camera movement.
  30545. */
  30546. inertia: number;
  30547. /**
  30548. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30549. */
  30550. mode: number;
  30551. /**
  30552. * Define whether the camera is intermediate.
  30553. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30554. */
  30555. isIntermediate: boolean;
  30556. /**
  30557. * Define the viewport of the camera.
  30558. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30559. */
  30560. viewport: Viewport;
  30561. /**
  30562. * Restricts the camera to viewing objects with the same layerMask.
  30563. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30564. */
  30565. layerMask: number;
  30566. /**
  30567. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30568. */
  30569. fovMode: number;
  30570. /**
  30571. * Rig mode of the camera.
  30572. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30573. * This is normally controlled byt the camera themselves as internal use.
  30574. */
  30575. cameraRigMode: number;
  30576. /**
  30577. * Defines the distance between both "eyes" in case of a RIG
  30578. */
  30579. interaxialDistance: number;
  30580. /**
  30581. * Defines if stereoscopic rendering is done side by side or over under.
  30582. */
  30583. isStereoscopicSideBySide: boolean;
  30584. /**
  30585. * 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
  30586. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30587. * else in the scene. (Eg. security camera)
  30588. *
  30589. * 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)
  30590. */
  30591. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30592. /**
  30593. * When set, the camera will render to this render target instead of the default canvas
  30594. *
  30595. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30596. */
  30597. outputRenderTarget: Nullable<RenderTargetTexture>;
  30598. /**
  30599. * Observable triggered when the camera view matrix has changed.
  30600. */
  30601. onViewMatrixChangedObservable: Observable<Camera>;
  30602. /**
  30603. * Observable triggered when the camera Projection matrix has changed.
  30604. */
  30605. onProjectionMatrixChangedObservable: Observable<Camera>;
  30606. /**
  30607. * Observable triggered when the inputs have been processed.
  30608. */
  30609. onAfterCheckInputsObservable: Observable<Camera>;
  30610. /**
  30611. * Observable triggered when reset has been called and applied to the camera.
  30612. */
  30613. onRestoreStateObservable: Observable<Camera>;
  30614. /**
  30615. * Is this camera a part of a rig system?
  30616. */
  30617. isRigCamera: boolean;
  30618. /**
  30619. * If isRigCamera set to true this will be set with the parent camera.
  30620. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30621. */
  30622. rigParent?: Camera;
  30623. /** @hidden */
  30624. _cameraRigParams: any;
  30625. /** @hidden */
  30626. _rigCameras: Camera[];
  30627. /** @hidden */
  30628. _rigPostProcess: Nullable<PostProcess>;
  30629. protected _webvrViewMatrix: Matrix;
  30630. /** @hidden */
  30631. _skipRendering: boolean;
  30632. /** @hidden */
  30633. _projectionMatrix: Matrix;
  30634. /** @hidden */
  30635. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30636. /** @hidden */
  30637. _activeMeshes: SmartArray<AbstractMesh>;
  30638. protected _globalPosition: Vector3;
  30639. /** @hidden */
  30640. _computedViewMatrix: Matrix;
  30641. private _doNotComputeProjectionMatrix;
  30642. private _transformMatrix;
  30643. private _frustumPlanes;
  30644. private _refreshFrustumPlanes;
  30645. private _storedFov;
  30646. private _stateStored;
  30647. /**
  30648. * Instantiates a new camera object.
  30649. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30650. * @see https://doc.babylonjs.com/features/cameras
  30651. * @param name Defines the name of the camera in the scene
  30652. * @param position Defines the position of the camera
  30653. * @param scene Defines the scene the camera belongs too
  30654. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30655. */
  30656. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30657. /**
  30658. * Store current camera state (fov, position, etc..)
  30659. * @returns the camera
  30660. */
  30661. storeState(): Camera;
  30662. /**
  30663. * Restores the camera state values if it has been stored. You must call storeState() first
  30664. */
  30665. protected _restoreStateValues(): boolean;
  30666. /**
  30667. * Restored camera state. You must call storeState() first.
  30668. * @returns true if restored and false otherwise
  30669. */
  30670. restoreState(): boolean;
  30671. /**
  30672. * Gets the class name of the camera.
  30673. * @returns the class name
  30674. */
  30675. getClassName(): string;
  30676. /** @hidden */
  30677. readonly _isCamera: boolean;
  30678. /**
  30679. * Gets a string representation of the camera useful for debug purpose.
  30680. * @param fullDetails Defines that a more verboe level of logging is required
  30681. * @returns the string representation
  30682. */
  30683. toString(fullDetails?: boolean): string;
  30684. /**
  30685. * Gets the current world space position of the camera.
  30686. */
  30687. get globalPosition(): Vector3;
  30688. /**
  30689. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30690. * @returns the active meshe list
  30691. */
  30692. getActiveMeshes(): SmartArray<AbstractMesh>;
  30693. /**
  30694. * Check whether a mesh is part of the current active mesh list of the camera
  30695. * @param mesh Defines the mesh to check
  30696. * @returns true if active, false otherwise
  30697. */
  30698. isActiveMesh(mesh: Mesh): boolean;
  30699. /**
  30700. * Is this camera ready to be used/rendered
  30701. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30702. * @return true if the camera is ready
  30703. */
  30704. isReady(completeCheck?: boolean): boolean;
  30705. /** @hidden */
  30706. _initCache(): void;
  30707. /** @hidden */
  30708. _updateCache(ignoreParentClass?: boolean): void;
  30709. /** @hidden */
  30710. _isSynchronized(): boolean;
  30711. /** @hidden */
  30712. _isSynchronizedViewMatrix(): boolean;
  30713. /** @hidden */
  30714. _isSynchronizedProjectionMatrix(): boolean;
  30715. /**
  30716. * Attach the input controls to a specific dom element to get the input from.
  30717. * @param element Defines the element the controls should be listened from
  30718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30719. */
  30720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30721. /**
  30722. * Detach the current controls from the specified dom element.
  30723. * @param element Defines the element to stop listening the inputs from
  30724. */
  30725. detachControl(element: HTMLElement): void;
  30726. /**
  30727. * Update the camera state according to the different inputs gathered during the frame.
  30728. */
  30729. update(): void;
  30730. /** @hidden */
  30731. _checkInputs(): void;
  30732. /** @hidden */
  30733. get rigCameras(): Camera[];
  30734. /**
  30735. * Gets the post process used by the rig cameras
  30736. */
  30737. get rigPostProcess(): Nullable<PostProcess>;
  30738. /**
  30739. * Internal, gets the first post proces.
  30740. * @returns the first post process to be run on this camera.
  30741. */
  30742. _getFirstPostProcess(): Nullable<PostProcess>;
  30743. private _cascadePostProcessesToRigCams;
  30744. /**
  30745. * Attach a post process to the camera.
  30746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30747. * @param postProcess The post process to attach to the camera
  30748. * @param insertAt The position of the post process in case several of them are in use in the scene
  30749. * @returns the position the post process has been inserted at
  30750. */
  30751. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30752. /**
  30753. * Detach a post process to the camera.
  30754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30755. * @param postProcess The post process to detach from the camera
  30756. */
  30757. detachPostProcess(postProcess: PostProcess): void;
  30758. /**
  30759. * Gets the current world matrix of the camera
  30760. */
  30761. getWorldMatrix(): Matrix;
  30762. /** @hidden */
  30763. _getViewMatrix(): Matrix;
  30764. /**
  30765. * Gets the current view matrix of the camera.
  30766. * @param force forces the camera to recompute the matrix without looking at the cached state
  30767. * @returns the view matrix
  30768. */
  30769. getViewMatrix(force?: boolean): Matrix;
  30770. /**
  30771. * Freeze the projection matrix.
  30772. * It will prevent the cache check of the camera projection compute and can speed up perf
  30773. * if no parameter of the camera are meant to change
  30774. * @param projection Defines manually a projection if necessary
  30775. */
  30776. freezeProjectionMatrix(projection?: Matrix): void;
  30777. /**
  30778. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30779. */
  30780. unfreezeProjectionMatrix(): void;
  30781. /**
  30782. * Gets the current projection matrix of the camera.
  30783. * @param force forces the camera to recompute the matrix without looking at the cached state
  30784. * @returns the projection matrix
  30785. */
  30786. getProjectionMatrix(force?: boolean): Matrix;
  30787. /**
  30788. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30789. * @returns a Matrix
  30790. */
  30791. getTransformationMatrix(): Matrix;
  30792. private _updateFrustumPlanes;
  30793. /**
  30794. * Checks if a cullable object (mesh...) is in the camera frustum
  30795. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30796. * @param target The object to check
  30797. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30798. * @returns true if the object is in frustum otherwise false
  30799. */
  30800. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30801. /**
  30802. * Checks if a cullable object (mesh...) is in the camera frustum
  30803. * Unlike isInFrustum this cheks the full bounding box
  30804. * @param target The object to check
  30805. * @returns true if the object is in frustum otherwise false
  30806. */
  30807. isCompletelyInFrustum(target: ICullable): boolean;
  30808. /**
  30809. * Gets a ray in the forward direction from the camera.
  30810. * @param length Defines the length of the ray to create
  30811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30812. * @param origin Defines the start point of the ray which defaults to the camera position
  30813. * @returns the forward ray
  30814. */
  30815. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30816. /**
  30817. * Gets a ray in the forward direction from the camera.
  30818. * @param refRay the ray to (re)use when setting the values
  30819. * @param length Defines the length of the ray to create
  30820. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30821. * @param origin Defines the start point of the ray which defaults to the camera position
  30822. * @returns the forward ray
  30823. */
  30824. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30825. /**
  30826. * Releases resources associated with this node.
  30827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30829. */
  30830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30831. /** @hidden */
  30832. _isLeftCamera: boolean;
  30833. /**
  30834. * Gets the left camera of a rig setup in case of Rigged Camera
  30835. */
  30836. get isLeftCamera(): boolean;
  30837. /** @hidden */
  30838. _isRightCamera: boolean;
  30839. /**
  30840. * Gets the right camera of a rig setup in case of Rigged Camera
  30841. */
  30842. get isRightCamera(): boolean;
  30843. /**
  30844. * Gets the left camera of a rig setup in case of Rigged Camera
  30845. */
  30846. get leftCamera(): Nullable<FreeCamera>;
  30847. /**
  30848. * Gets the right camera of a rig setup in case of Rigged Camera
  30849. */
  30850. get rightCamera(): Nullable<FreeCamera>;
  30851. /**
  30852. * Gets the left camera target of a rig setup in case of Rigged Camera
  30853. * @returns the target position
  30854. */
  30855. getLeftTarget(): Nullable<Vector3>;
  30856. /**
  30857. * Gets the right camera target of a rig setup in case of Rigged Camera
  30858. * @returns the target position
  30859. */
  30860. getRightTarget(): Nullable<Vector3>;
  30861. /**
  30862. * @hidden
  30863. */
  30864. setCameraRigMode(mode: number, rigParams: any): void;
  30865. /** @hidden */
  30866. static _setStereoscopicRigMode(camera: Camera): void;
  30867. /** @hidden */
  30868. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30869. /** @hidden */
  30870. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30871. /** @hidden */
  30872. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30873. /** @hidden */
  30874. _getVRProjectionMatrix(): Matrix;
  30875. protected _updateCameraRotationMatrix(): void;
  30876. protected _updateWebVRCameraRotationMatrix(): void;
  30877. /**
  30878. * This function MUST be overwritten by the different WebVR cameras available.
  30879. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30880. * @hidden
  30881. */
  30882. _getWebVRProjectionMatrix(): Matrix;
  30883. /**
  30884. * This function MUST be overwritten by the different WebVR cameras available.
  30885. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30886. * @hidden
  30887. */
  30888. _getWebVRViewMatrix(): Matrix;
  30889. /** @hidden */
  30890. setCameraRigParameter(name: string, value: any): void;
  30891. /**
  30892. * needs to be overridden by children so sub has required properties to be copied
  30893. * @hidden
  30894. */
  30895. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30896. /**
  30897. * May need to be overridden by children
  30898. * @hidden
  30899. */
  30900. _updateRigCameras(): void;
  30901. /** @hidden */
  30902. _setupInputs(): void;
  30903. /**
  30904. * Serialiaze the camera setup to a json represention
  30905. * @returns the JSON representation
  30906. */
  30907. serialize(): any;
  30908. /**
  30909. * Clones the current camera.
  30910. * @param name The cloned camera name
  30911. * @returns the cloned camera
  30912. */
  30913. clone(name: string): Camera;
  30914. /**
  30915. * Gets the direction of the camera relative to a given local axis.
  30916. * @param localAxis Defines the reference axis to provide a relative direction.
  30917. * @return the direction
  30918. */
  30919. getDirection(localAxis: Vector3): Vector3;
  30920. /**
  30921. * Returns the current camera absolute rotation
  30922. */
  30923. get absoluteRotation(): Quaternion;
  30924. /**
  30925. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30926. * @param localAxis Defines the reference axis to provide a relative direction.
  30927. * @param result Defines the vector to store the result in
  30928. */
  30929. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30930. /**
  30931. * Gets a camera constructor for a given camera type
  30932. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30933. * @param name The name of the camera the result will be able to instantiate
  30934. * @param scene The scene the result will construct the camera in
  30935. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30936. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30937. * @returns a factory method to construc the camera
  30938. */
  30939. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30940. /**
  30941. * Compute the world matrix of the camera.
  30942. * @returns the camera world matrix
  30943. */
  30944. computeWorldMatrix(): Matrix;
  30945. /**
  30946. * Parse a JSON and creates the camera from the parsed information
  30947. * @param parsedCamera The JSON to parse
  30948. * @param scene The scene to instantiate the camera in
  30949. * @returns the newly constructed camera
  30950. */
  30951. static Parse(parsedCamera: any, scene: Scene): Camera;
  30952. }
  30953. }
  30954. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30955. import { Nullable } from "babylonjs/types";
  30956. import { Scene } from "babylonjs/scene";
  30957. import { Vector4 } from "babylonjs/Maths/math.vector";
  30958. import { Mesh } from "babylonjs/Meshes/mesh";
  30959. /**
  30960. * Class containing static functions to help procedurally build meshes
  30961. */
  30962. export class DiscBuilder {
  30963. /**
  30964. * Creates a plane polygonal mesh. By default, this is a disc
  30965. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30966. * * 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
  30967. * * 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
  30968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30971. * @param name defines the name of the mesh
  30972. * @param options defines the options used to create the mesh
  30973. * @param scene defines the hosting scene
  30974. * @returns the plane polygonal mesh
  30975. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30976. */
  30977. static CreateDisc(name: string, options: {
  30978. radius?: number;
  30979. tessellation?: number;
  30980. arc?: number;
  30981. updatable?: boolean;
  30982. sideOrientation?: number;
  30983. frontUVs?: Vector4;
  30984. backUVs?: Vector4;
  30985. }, scene?: Nullable<Scene>): Mesh;
  30986. }
  30987. }
  30988. declare module "babylonjs/Materials/fresnelParameters" {
  30989. import { DeepImmutable } from "babylonjs/types";
  30990. import { Color3 } from "babylonjs/Maths/math.color";
  30991. /**
  30992. * Options to be used when creating a FresnelParameters.
  30993. */
  30994. export type IFresnelParametersCreationOptions = {
  30995. /**
  30996. * Define the color used on edges (grazing angle)
  30997. */
  30998. leftColor?: Color3;
  30999. /**
  31000. * Define the color used on center
  31001. */
  31002. rightColor?: Color3;
  31003. /**
  31004. * Define bias applied to computed fresnel term
  31005. */
  31006. bias?: number;
  31007. /**
  31008. * Defined the power exponent applied to fresnel term
  31009. */
  31010. power?: number;
  31011. /**
  31012. * Define if the fresnel effect is enable or not.
  31013. */
  31014. isEnabled?: boolean;
  31015. };
  31016. /**
  31017. * Serialized format for FresnelParameters.
  31018. */
  31019. export type IFresnelParametersSerialized = {
  31020. /**
  31021. * Define the color used on edges (grazing angle) [as an array]
  31022. */
  31023. leftColor: number[];
  31024. /**
  31025. * Define the color used on center [as an array]
  31026. */
  31027. rightColor: number[];
  31028. /**
  31029. * Define bias applied to computed fresnel term
  31030. */
  31031. bias: number;
  31032. /**
  31033. * Defined the power exponent applied to fresnel term
  31034. */
  31035. power?: number;
  31036. /**
  31037. * Define if the fresnel effect is enable or not.
  31038. */
  31039. isEnabled: boolean;
  31040. };
  31041. /**
  31042. * This represents all the required information to add a fresnel effect on a material:
  31043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31044. */
  31045. export class FresnelParameters {
  31046. private _isEnabled;
  31047. /**
  31048. * Define if the fresnel effect is enable or not.
  31049. */
  31050. get isEnabled(): boolean;
  31051. set isEnabled(value: boolean);
  31052. /**
  31053. * Define the color used on edges (grazing angle)
  31054. */
  31055. leftColor: Color3;
  31056. /**
  31057. * Define the color used on center
  31058. */
  31059. rightColor: Color3;
  31060. /**
  31061. * Define bias applied to computed fresnel term
  31062. */
  31063. bias: number;
  31064. /**
  31065. * Defined the power exponent applied to fresnel term
  31066. */
  31067. power: number;
  31068. /**
  31069. * Creates a new FresnelParameters object.
  31070. *
  31071. * @param options provide your own settings to optionally to override defaults
  31072. */
  31073. constructor(options?: IFresnelParametersCreationOptions);
  31074. /**
  31075. * Clones the current fresnel and its valuues
  31076. * @returns a clone fresnel configuration
  31077. */
  31078. clone(): FresnelParameters;
  31079. /**
  31080. * Determines equality between FresnelParameters objects
  31081. * @param otherFresnelParameters defines the second operand
  31082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31083. */
  31084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31085. /**
  31086. * Serializes the current fresnel parameters to a JSON representation.
  31087. * @return the JSON serialization
  31088. */
  31089. serialize(): IFresnelParametersSerialized;
  31090. /**
  31091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31092. * @param parsedFresnelParameters Define the JSON representation
  31093. * @returns the parsed parameters
  31094. */
  31095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31096. }
  31097. }
  31098. declare module "babylonjs/Materials/materialFlags" {
  31099. /**
  31100. * This groups all the flags used to control the materials channel.
  31101. */
  31102. export class MaterialFlags {
  31103. private static _DiffuseTextureEnabled;
  31104. /**
  31105. * Are diffuse textures enabled in the application.
  31106. */
  31107. static get DiffuseTextureEnabled(): boolean;
  31108. static set DiffuseTextureEnabled(value: boolean);
  31109. private static _DetailTextureEnabled;
  31110. /**
  31111. * Are detail textures enabled in the application.
  31112. */
  31113. static get DetailTextureEnabled(): boolean;
  31114. static set DetailTextureEnabled(value: boolean);
  31115. private static _AmbientTextureEnabled;
  31116. /**
  31117. * Are ambient textures enabled in the application.
  31118. */
  31119. static get AmbientTextureEnabled(): boolean;
  31120. static set AmbientTextureEnabled(value: boolean);
  31121. private static _OpacityTextureEnabled;
  31122. /**
  31123. * Are opacity textures enabled in the application.
  31124. */
  31125. static get OpacityTextureEnabled(): boolean;
  31126. static set OpacityTextureEnabled(value: boolean);
  31127. private static _ReflectionTextureEnabled;
  31128. /**
  31129. * Are reflection textures enabled in the application.
  31130. */
  31131. static get ReflectionTextureEnabled(): boolean;
  31132. static set ReflectionTextureEnabled(value: boolean);
  31133. private static _EmissiveTextureEnabled;
  31134. /**
  31135. * Are emissive textures enabled in the application.
  31136. */
  31137. static get EmissiveTextureEnabled(): boolean;
  31138. static set EmissiveTextureEnabled(value: boolean);
  31139. private static _SpecularTextureEnabled;
  31140. /**
  31141. * Are specular textures enabled in the application.
  31142. */
  31143. static get SpecularTextureEnabled(): boolean;
  31144. static set SpecularTextureEnabled(value: boolean);
  31145. private static _BumpTextureEnabled;
  31146. /**
  31147. * Are bump textures enabled in the application.
  31148. */
  31149. static get BumpTextureEnabled(): boolean;
  31150. static set BumpTextureEnabled(value: boolean);
  31151. private static _LightmapTextureEnabled;
  31152. /**
  31153. * Are lightmap textures enabled in the application.
  31154. */
  31155. static get LightmapTextureEnabled(): boolean;
  31156. static set LightmapTextureEnabled(value: boolean);
  31157. private static _RefractionTextureEnabled;
  31158. /**
  31159. * Are refraction textures enabled in the application.
  31160. */
  31161. static get RefractionTextureEnabled(): boolean;
  31162. static set RefractionTextureEnabled(value: boolean);
  31163. private static _ColorGradingTextureEnabled;
  31164. /**
  31165. * Are color grading textures enabled in the application.
  31166. */
  31167. static get ColorGradingTextureEnabled(): boolean;
  31168. static set ColorGradingTextureEnabled(value: boolean);
  31169. private static _FresnelEnabled;
  31170. /**
  31171. * Are fresnels enabled in the application.
  31172. */
  31173. static get FresnelEnabled(): boolean;
  31174. static set FresnelEnabled(value: boolean);
  31175. private static _ClearCoatTextureEnabled;
  31176. /**
  31177. * Are clear coat textures enabled in the application.
  31178. */
  31179. static get ClearCoatTextureEnabled(): boolean;
  31180. static set ClearCoatTextureEnabled(value: boolean);
  31181. private static _ClearCoatBumpTextureEnabled;
  31182. /**
  31183. * Are clear coat bump textures enabled in the application.
  31184. */
  31185. static get ClearCoatBumpTextureEnabled(): boolean;
  31186. static set ClearCoatBumpTextureEnabled(value: boolean);
  31187. private static _ClearCoatTintTextureEnabled;
  31188. /**
  31189. * Are clear coat tint textures enabled in the application.
  31190. */
  31191. static get ClearCoatTintTextureEnabled(): boolean;
  31192. static set ClearCoatTintTextureEnabled(value: boolean);
  31193. private static _SheenTextureEnabled;
  31194. /**
  31195. * Are sheen textures enabled in the application.
  31196. */
  31197. static get SheenTextureEnabled(): boolean;
  31198. static set SheenTextureEnabled(value: boolean);
  31199. private static _AnisotropicTextureEnabled;
  31200. /**
  31201. * Are anisotropic textures enabled in the application.
  31202. */
  31203. static get AnisotropicTextureEnabled(): boolean;
  31204. static set AnisotropicTextureEnabled(value: boolean);
  31205. private static _ThicknessTextureEnabled;
  31206. /**
  31207. * Are thickness textures enabled in the application.
  31208. */
  31209. static get ThicknessTextureEnabled(): boolean;
  31210. static set ThicknessTextureEnabled(value: boolean);
  31211. }
  31212. }
  31213. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31214. /** @hidden */
  31215. export var defaultFragmentDeclaration: {
  31216. name: string;
  31217. shader: string;
  31218. };
  31219. }
  31220. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31221. /** @hidden */
  31222. export var defaultUboDeclaration: {
  31223. name: string;
  31224. shader: string;
  31225. };
  31226. }
  31227. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31228. /** @hidden */
  31229. export var prePassDeclaration: {
  31230. name: string;
  31231. shader: string;
  31232. };
  31233. }
  31234. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31235. /** @hidden */
  31236. export var lightFragmentDeclaration: {
  31237. name: string;
  31238. shader: string;
  31239. };
  31240. }
  31241. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31242. /** @hidden */
  31243. export var lightUboDeclaration: {
  31244. name: string;
  31245. shader: string;
  31246. };
  31247. }
  31248. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31249. /** @hidden */
  31250. export var lightsFragmentFunctions: {
  31251. name: string;
  31252. shader: string;
  31253. };
  31254. }
  31255. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31256. /** @hidden */
  31257. export var shadowsFragmentFunctions: {
  31258. name: string;
  31259. shader: string;
  31260. };
  31261. }
  31262. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31263. /** @hidden */
  31264. export var fresnelFunction: {
  31265. name: string;
  31266. shader: string;
  31267. };
  31268. }
  31269. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31270. /** @hidden */
  31271. export var bumpFragmentMainFunctions: {
  31272. name: string;
  31273. shader: string;
  31274. };
  31275. }
  31276. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31277. /** @hidden */
  31278. export var bumpFragmentFunctions: {
  31279. name: string;
  31280. shader: string;
  31281. };
  31282. }
  31283. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31284. /** @hidden */
  31285. export var logDepthDeclaration: {
  31286. name: string;
  31287. shader: string;
  31288. };
  31289. }
  31290. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31291. /** @hidden */
  31292. export var bumpFragment: {
  31293. name: string;
  31294. shader: string;
  31295. };
  31296. }
  31297. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31298. /** @hidden */
  31299. export var depthPrePass: {
  31300. name: string;
  31301. shader: string;
  31302. };
  31303. }
  31304. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31305. /** @hidden */
  31306. export var lightFragment: {
  31307. name: string;
  31308. shader: string;
  31309. };
  31310. }
  31311. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31312. /** @hidden */
  31313. export var logDepthFragment: {
  31314. name: string;
  31315. shader: string;
  31316. };
  31317. }
  31318. declare module "babylonjs/Shaders/default.fragment" {
  31319. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31320. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31323. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31326. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31328. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31329. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31330. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31331. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31333. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31334. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31335. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31336. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31337. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31338. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31339. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31340. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31342. /** @hidden */
  31343. export var defaultPixelShader: {
  31344. name: string;
  31345. shader: string;
  31346. };
  31347. }
  31348. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31349. /** @hidden */
  31350. export var defaultVertexDeclaration: {
  31351. name: string;
  31352. shader: string;
  31353. };
  31354. }
  31355. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31356. /** @hidden */
  31357. export var bumpVertexDeclaration: {
  31358. name: string;
  31359. shader: string;
  31360. };
  31361. }
  31362. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31363. /** @hidden */
  31364. export var bumpVertex: {
  31365. name: string;
  31366. shader: string;
  31367. };
  31368. }
  31369. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31370. /** @hidden */
  31371. export var fogVertex: {
  31372. name: string;
  31373. shader: string;
  31374. };
  31375. }
  31376. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31377. /** @hidden */
  31378. export var shadowsVertex: {
  31379. name: string;
  31380. shader: string;
  31381. };
  31382. }
  31383. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31384. /** @hidden */
  31385. export var pointCloudVertex: {
  31386. name: string;
  31387. shader: string;
  31388. };
  31389. }
  31390. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31391. /** @hidden */
  31392. export var logDepthVertex: {
  31393. name: string;
  31394. shader: string;
  31395. };
  31396. }
  31397. declare module "babylonjs/Shaders/default.vertex" {
  31398. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31399. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31412. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31413. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31414. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31415. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31420. /** @hidden */
  31421. export var defaultVertexShader: {
  31422. name: string;
  31423. shader: string;
  31424. };
  31425. }
  31426. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31427. import { Nullable } from "babylonjs/types";
  31428. import { Scene } from "babylonjs/scene";
  31429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31431. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31432. /**
  31433. * @hidden
  31434. */
  31435. export interface IMaterialDetailMapDefines {
  31436. DETAIL: boolean;
  31437. DETAILDIRECTUV: number;
  31438. DETAIL_NORMALBLENDMETHOD: number;
  31439. /** @hidden */
  31440. _areTexturesDirty: boolean;
  31441. }
  31442. /**
  31443. * Define the code related to the detail map parameters of a material
  31444. *
  31445. * Inspired from:
  31446. * 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
  31447. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31448. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31449. */
  31450. export class DetailMapConfiguration {
  31451. private _texture;
  31452. /**
  31453. * The detail texture of the material.
  31454. */
  31455. texture: Nullable<BaseTexture>;
  31456. /**
  31457. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31458. * Bigger values mean stronger blending
  31459. */
  31460. diffuseBlendLevel: number;
  31461. /**
  31462. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31463. * Bigger values mean stronger blending. Only used with PBR materials
  31464. */
  31465. roughnessBlendLevel: number;
  31466. /**
  31467. * Defines how strong the bump effect from the detail map is
  31468. * Bigger values mean stronger effect
  31469. */
  31470. bumpLevel: number;
  31471. private _normalBlendMethod;
  31472. /**
  31473. * The method used to blend the bump and detail normals together
  31474. */
  31475. normalBlendMethod: number;
  31476. private _isEnabled;
  31477. /**
  31478. * Enable or disable the detail map on this material
  31479. */
  31480. isEnabled: boolean;
  31481. /** @hidden */
  31482. private _internalMarkAllSubMeshesAsTexturesDirty;
  31483. /** @hidden */
  31484. _markAllSubMeshesAsTexturesDirty(): void;
  31485. /**
  31486. * Instantiate a new detail map
  31487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31488. */
  31489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31490. /**
  31491. * Gets whether the submesh is ready to be used or not.
  31492. * @param defines the list of "defines" to update.
  31493. * @param scene defines the scene the material belongs to.
  31494. * @returns - boolean indicating that the submesh is ready or not.
  31495. */
  31496. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31497. /**
  31498. * Update the defines for detail map usage
  31499. * @param defines the list of "defines" to update.
  31500. * @param scene defines the scene the material belongs to.
  31501. */
  31502. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31503. /**
  31504. * Binds the material data.
  31505. * @param uniformBuffer defines the Uniform buffer to fill in.
  31506. * @param scene defines the scene the material belongs to.
  31507. * @param isFrozen defines whether the material is frozen or not.
  31508. */
  31509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31510. /**
  31511. * Checks to see if a texture is used in the material.
  31512. * @param texture - Base texture to use.
  31513. * @returns - Boolean specifying if a texture is used in the material.
  31514. */
  31515. hasTexture(texture: BaseTexture): boolean;
  31516. /**
  31517. * Returns an array of the actively used textures.
  31518. * @param activeTextures Array of BaseTextures
  31519. */
  31520. getActiveTextures(activeTextures: BaseTexture[]): void;
  31521. /**
  31522. * Returns the animatable textures.
  31523. * @param animatables Array of animatable textures.
  31524. */
  31525. getAnimatables(animatables: IAnimatable[]): void;
  31526. /**
  31527. * Disposes the resources of the material.
  31528. * @param forceDisposeTextures - Forces the disposal of all textures.
  31529. */
  31530. dispose(forceDisposeTextures?: boolean): void;
  31531. /**
  31532. * Get the current class name useful for serialization or dynamic coding.
  31533. * @returns "DetailMap"
  31534. */
  31535. getClassName(): string;
  31536. /**
  31537. * Add the required uniforms to the current list.
  31538. * @param uniforms defines the current uniform list.
  31539. */
  31540. static AddUniforms(uniforms: string[]): void;
  31541. /**
  31542. * Add the required samplers to the current list.
  31543. * @param samplers defines the current sampler list.
  31544. */
  31545. static AddSamplers(samplers: string[]): void;
  31546. /**
  31547. * Add the required uniforms to the current buffer.
  31548. * @param uniformBuffer defines the current uniform buffer.
  31549. */
  31550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31551. /**
  31552. * Makes a duplicate of the current instance into another one.
  31553. * @param detailMap define the instance where to copy the info
  31554. */
  31555. copyTo(detailMap: DetailMapConfiguration): void;
  31556. /**
  31557. * Serializes this detail map instance
  31558. * @returns - An object with the serialized instance.
  31559. */
  31560. serialize(): any;
  31561. /**
  31562. * Parses a detail map setting from a serialized object.
  31563. * @param source - Serialized object.
  31564. * @param scene Defines the scene we are parsing for
  31565. * @param rootUrl Defines the rootUrl to load from
  31566. */
  31567. parse(source: any, scene: Scene, rootUrl: string): void;
  31568. }
  31569. }
  31570. declare module "babylonjs/Materials/standardMaterial" {
  31571. import { SmartArray } from "babylonjs/Misc/smartArray";
  31572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31573. import { Nullable } from "babylonjs/types";
  31574. import { Scene } from "babylonjs/scene";
  31575. import { Matrix } from "babylonjs/Maths/math.vector";
  31576. import { Color3 } from "babylonjs/Maths/math.color";
  31577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31579. import { Mesh } from "babylonjs/Meshes/mesh";
  31580. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31581. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31582. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31583. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31584. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31587. import "babylonjs/Shaders/default.fragment";
  31588. import "babylonjs/Shaders/default.vertex";
  31589. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31590. /** @hidden */
  31591. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31592. MAINUV1: boolean;
  31593. MAINUV2: boolean;
  31594. DIFFUSE: boolean;
  31595. DIFFUSEDIRECTUV: number;
  31596. DETAIL: boolean;
  31597. DETAILDIRECTUV: number;
  31598. DETAIL_NORMALBLENDMETHOD: number;
  31599. AMBIENT: boolean;
  31600. AMBIENTDIRECTUV: number;
  31601. OPACITY: boolean;
  31602. OPACITYDIRECTUV: number;
  31603. OPACITYRGB: boolean;
  31604. REFLECTION: boolean;
  31605. EMISSIVE: boolean;
  31606. EMISSIVEDIRECTUV: number;
  31607. SPECULAR: boolean;
  31608. SPECULARDIRECTUV: number;
  31609. BUMP: boolean;
  31610. BUMPDIRECTUV: number;
  31611. PARALLAX: boolean;
  31612. PARALLAXOCCLUSION: boolean;
  31613. SPECULAROVERALPHA: boolean;
  31614. CLIPPLANE: boolean;
  31615. CLIPPLANE2: boolean;
  31616. CLIPPLANE3: boolean;
  31617. CLIPPLANE4: boolean;
  31618. CLIPPLANE5: boolean;
  31619. CLIPPLANE6: boolean;
  31620. ALPHATEST: boolean;
  31621. DEPTHPREPASS: boolean;
  31622. ALPHAFROMDIFFUSE: boolean;
  31623. POINTSIZE: boolean;
  31624. FOG: boolean;
  31625. SPECULARTERM: boolean;
  31626. DIFFUSEFRESNEL: boolean;
  31627. OPACITYFRESNEL: boolean;
  31628. REFLECTIONFRESNEL: boolean;
  31629. REFRACTIONFRESNEL: boolean;
  31630. EMISSIVEFRESNEL: boolean;
  31631. FRESNEL: boolean;
  31632. NORMAL: boolean;
  31633. UV1: boolean;
  31634. UV2: boolean;
  31635. VERTEXCOLOR: boolean;
  31636. VERTEXALPHA: boolean;
  31637. NUM_BONE_INFLUENCERS: number;
  31638. BonesPerMesh: number;
  31639. BONETEXTURE: boolean;
  31640. INSTANCES: boolean;
  31641. THIN_INSTANCES: boolean;
  31642. GLOSSINESS: boolean;
  31643. ROUGHNESS: boolean;
  31644. EMISSIVEASILLUMINATION: boolean;
  31645. LINKEMISSIVEWITHDIFFUSE: boolean;
  31646. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31647. LIGHTMAP: boolean;
  31648. LIGHTMAPDIRECTUV: number;
  31649. OBJECTSPACE_NORMALMAP: boolean;
  31650. USELIGHTMAPASSHADOWMAP: boolean;
  31651. REFLECTIONMAP_3D: boolean;
  31652. REFLECTIONMAP_SPHERICAL: boolean;
  31653. REFLECTIONMAP_PLANAR: boolean;
  31654. REFLECTIONMAP_CUBIC: boolean;
  31655. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31656. REFLECTIONMAP_PROJECTION: boolean;
  31657. REFLECTIONMAP_SKYBOX: boolean;
  31658. REFLECTIONMAP_EXPLICIT: boolean;
  31659. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31660. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31661. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31662. INVERTCUBICMAP: boolean;
  31663. LOGARITHMICDEPTH: boolean;
  31664. REFRACTION: boolean;
  31665. REFRACTIONMAP_3D: boolean;
  31666. REFLECTIONOVERALPHA: boolean;
  31667. TWOSIDEDLIGHTING: boolean;
  31668. SHADOWFLOAT: boolean;
  31669. MORPHTARGETS: boolean;
  31670. MORPHTARGETS_NORMAL: boolean;
  31671. MORPHTARGETS_TANGENT: boolean;
  31672. MORPHTARGETS_UV: boolean;
  31673. NUM_MORPH_INFLUENCERS: number;
  31674. NONUNIFORMSCALING: boolean;
  31675. PREMULTIPLYALPHA: boolean;
  31676. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31677. ALPHABLEND: boolean;
  31678. PREPASS: boolean;
  31679. PREPASS_IRRADIANCE: boolean;
  31680. PREPASS_IRRADIANCE_INDEX: number;
  31681. PREPASS_ALBEDO: boolean;
  31682. PREPASS_ALBEDO_INDEX: number;
  31683. PREPASS_DEPTHNORMAL: boolean;
  31684. PREPASS_DEPTHNORMAL_INDEX: number;
  31685. SCENE_MRT_COUNT: number;
  31686. RGBDLIGHTMAP: boolean;
  31687. RGBDREFLECTION: boolean;
  31688. RGBDREFRACTION: boolean;
  31689. IMAGEPROCESSING: boolean;
  31690. VIGNETTE: boolean;
  31691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31692. VIGNETTEBLENDMODEOPAQUE: boolean;
  31693. TONEMAPPING: boolean;
  31694. TONEMAPPING_ACES: boolean;
  31695. CONTRAST: boolean;
  31696. COLORCURVES: boolean;
  31697. COLORGRADING: boolean;
  31698. COLORGRADING3D: boolean;
  31699. SAMPLER3DGREENDEPTH: boolean;
  31700. SAMPLER3DBGRMAP: boolean;
  31701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31702. MULTIVIEW: boolean;
  31703. /**
  31704. * If the reflection texture on this material is in linear color space
  31705. * @hidden
  31706. */
  31707. IS_REFLECTION_LINEAR: boolean;
  31708. /**
  31709. * If the refraction texture on this material is in linear color space
  31710. * @hidden
  31711. */
  31712. IS_REFRACTION_LINEAR: boolean;
  31713. EXPOSURE: boolean;
  31714. constructor();
  31715. setReflectionMode(modeToEnable: string): void;
  31716. }
  31717. /**
  31718. * This is the default material used in Babylon. It is the best trade off between quality
  31719. * and performances.
  31720. * @see https://doc.babylonjs.com/babylon101/materials
  31721. */
  31722. export class StandardMaterial extends PushMaterial {
  31723. private _diffuseTexture;
  31724. /**
  31725. * The basic texture of the material as viewed under a light.
  31726. */
  31727. diffuseTexture: Nullable<BaseTexture>;
  31728. private _ambientTexture;
  31729. /**
  31730. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31731. */
  31732. ambientTexture: Nullable<BaseTexture>;
  31733. private _opacityTexture;
  31734. /**
  31735. * Define the transparency of the material from a texture.
  31736. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31737. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31738. */
  31739. opacityTexture: Nullable<BaseTexture>;
  31740. private _reflectionTexture;
  31741. /**
  31742. * Define the texture used to display the reflection.
  31743. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31744. */
  31745. reflectionTexture: Nullable<BaseTexture>;
  31746. private _emissiveTexture;
  31747. /**
  31748. * Define texture of the material as if self lit.
  31749. * This will be mixed in the final result even in the absence of light.
  31750. */
  31751. emissiveTexture: Nullable<BaseTexture>;
  31752. private _specularTexture;
  31753. /**
  31754. * Define how the color and intensity of the highlight given by the light in the material.
  31755. */
  31756. specularTexture: Nullable<BaseTexture>;
  31757. private _bumpTexture;
  31758. /**
  31759. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31760. * 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.
  31761. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31762. */
  31763. bumpTexture: Nullable<BaseTexture>;
  31764. private _lightmapTexture;
  31765. /**
  31766. * Complex lighting can be computationally expensive to compute at runtime.
  31767. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31768. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31769. */
  31770. lightmapTexture: Nullable<BaseTexture>;
  31771. private _refractionTexture;
  31772. /**
  31773. * Define the texture used to display the refraction.
  31774. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31775. */
  31776. refractionTexture: Nullable<BaseTexture>;
  31777. /**
  31778. * The color of the material lit by the environmental background lighting.
  31779. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31780. */
  31781. ambientColor: Color3;
  31782. /**
  31783. * The basic color of the material as viewed under a light.
  31784. */
  31785. diffuseColor: Color3;
  31786. /**
  31787. * Define how the color and intensity of the highlight given by the light in the material.
  31788. */
  31789. specularColor: Color3;
  31790. /**
  31791. * Define the color of the material as if self lit.
  31792. * This will be mixed in the final result even in the absence of light.
  31793. */
  31794. emissiveColor: Color3;
  31795. /**
  31796. * Defines how sharp are the highlights in the material.
  31797. * The bigger the value the sharper giving a more glossy feeling to the result.
  31798. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31799. */
  31800. specularPower: number;
  31801. private _useAlphaFromDiffuseTexture;
  31802. /**
  31803. * Does the transparency come from the diffuse texture alpha channel.
  31804. */
  31805. useAlphaFromDiffuseTexture: boolean;
  31806. private _useEmissiveAsIllumination;
  31807. /**
  31808. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31809. */
  31810. useEmissiveAsIllumination: boolean;
  31811. private _linkEmissiveWithDiffuse;
  31812. /**
  31813. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31814. * the emissive level when the final color is close to one.
  31815. */
  31816. linkEmissiveWithDiffuse: boolean;
  31817. private _useSpecularOverAlpha;
  31818. /**
  31819. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31820. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31821. */
  31822. useSpecularOverAlpha: boolean;
  31823. private _useReflectionOverAlpha;
  31824. /**
  31825. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31826. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31827. */
  31828. useReflectionOverAlpha: boolean;
  31829. private _disableLighting;
  31830. /**
  31831. * Does lights from the scene impacts this material.
  31832. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31833. */
  31834. disableLighting: boolean;
  31835. private _useObjectSpaceNormalMap;
  31836. /**
  31837. * Allows using an object space normal map (instead of tangent space).
  31838. */
  31839. useObjectSpaceNormalMap: boolean;
  31840. private _useParallax;
  31841. /**
  31842. * Is parallax enabled or not.
  31843. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31844. */
  31845. useParallax: boolean;
  31846. private _useParallaxOcclusion;
  31847. /**
  31848. * Is parallax occlusion enabled or not.
  31849. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31850. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31851. */
  31852. useParallaxOcclusion: boolean;
  31853. /**
  31854. * 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.
  31855. */
  31856. parallaxScaleBias: number;
  31857. private _roughness;
  31858. /**
  31859. * Helps to define how blurry the reflections should appears in the material.
  31860. */
  31861. roughness: number;
  31862. /**
  31863. * In case of refraction, define the value of the index of refraction.
  31864. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31865. */
  31866. indexOfRefraction: number;
  31867. /**
  31868. * Invert the refraction texture alongside the y axis.
  31869. * It can be useful with procedural textures or probe for instance.
  31870. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31871. */
  31872. invertRefractionY: boolean;
  31873. /**
  31874. * Defines the alpha limits in alpha test mode.
  31875. */
  31876. alphaCutOff: number;
  31877. private _useLightmapAsShadowmap;
  31878. /**
  31879. * In case of light mapping, define whether the map contains light or shadow informations.
  31880. */
  31881. useLightmapAsShadowmap: boolean;
  31882. private _diffuseFresnelParameters;
  31883. /**
  31884. * Define the diffuse fresnel parameters of the material.
  31885. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31886. */
  31887. diffuseFresnelParameters: FresnelParameters;
  31888. private _opacityFresnelParameters;
  31889. /**
  31890. * Define the opacity fresnel parameters of the material.
  31891. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31892. */
  31893. opacityFresnelParameters: FresnelParameters;
  31894. private _reflectionFresnelParameters;
  31895. /**
  31896. * Define the reflection fresnel parameters of the material.
  31897. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31898. */
  31899. reflectionFresnelParameters: FresnelParameters;
  31900. private _refractionFresnelParameters;
  31901. /**
  31902. * Define the refraction fresnel parameters of the material.
  31903. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31904. */
  31905. refractionFresnelParameters: FresnelParameters;
  31906. private _emissiveFresnelParameters;
  31907. /**
  31908. * Define the emissive fresnel parameters of the material.
  31909. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31910. */
  31911. emissiveFresnelParameters: FresnelParameters;
  31912. private _useReflectionFresnelFromSpecular;
  31913. /**
  31914. * If true automatically deducts the fresnels values from the material specularity.
  31915. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31916. */
  31917. useReflectionFresnelFromSpecular: boolean;
  31918. private _useGlossinessFromSpecularMapAlpha;
  31919. /**
  31920. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31921. */
  31922. useGlossinessFromSpecularMapAlpha: boolean;
  31923. private _maxSimultaneousLights;
  31924. /**
  31925. * Defines the maximum number of lights that can be used in the material
  31926. */
  31927. maxSimultaneousLights: number;
  31928. private _invertNormalMapX;
  31929. /**
  31930. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31931. */
  31932. invertNormalMapX: boolean;
  31933. private _invertNormalMapY;
  31934. /**
  31935. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31936. */
  31937. invertNormalMapY: boolean;
  31938. private _twoSidedLighting;
  31939. /**
  31940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31941. */
  31942. twoSidedLighting: boolean;
  31943. /**
  31944. * Default configuration related to image processing available in the standard Material.
  31945. */
  31946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31947. /**
  31948. * Gets the image processing configuration used either in this material.
  31949. */
  31950. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31951. /**
  31952. * Sets the Default image processing configuration used either in the this material.
  31953. *
  31954. * If sets to null, the scene one is in use.
  31955. */
  31956. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31957. /**
  31958. * Keep track of the image processing observer to allow dispose and replace.
  31959. */
  31960. private _imageProcessingObserver;
  31961. /**
  31962. * Attaches a new image processing configuration to the Standard Material.
  31963. * @param configuration
  31964. */
  31965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31966. /**
  31967. * Gets wether the color curves effect is enabled.
  31968. */
  31969. get cameraColorCurvesEnabled(): boolean;
  31970. /**
  31971. * Sets wether the color curves effect is enabled.
  31972. */
  31973. set cameraColorCurvesEnabled(value: boolean);
  31974. /**
  31975. * Gets wether the color grading effect is enabled.
  31976. */
  31977. get cameraColorGradingEnabled(): boolean;
  31978. /**
  31979. * Gets wether the color grading effect is enabled.
  31980. */
  31981. set cameraColorGradingEnabled(value: boolean);
  31982. /**
  31983. * Gets wether tonemapping is enabled or not.
  31984. */
  31985. get cameraToneMappingEnabled(): boolean;
  31986. /**
  31987. * Sets wether tonemapping is enabled or not
  31988. */
  31989. set cameraToneMappingEnabled(value: boolean);
  31990. /**
  31991. * The camera exposure used on this material.
  31992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31993. * This corresponds to a photographic exposure.
  31994. */
  31995. get cameraExposure(): number;
  31996. /**
  31997. * The camera exposure used on this material.
  31998. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31999. * This corresponds to a photographic exposure.
  32000. */
  32001. set cameraExposure(value: number);
  32002. /**
  32003. * Gets The camera contrast used on this material.
  32004. */
  32005. get cameraContrast(): number;
  32006. /**
  32007. * Sets The camera contrast used on this material.
  32008. */
  32009. set cameraContrast(value: number);
  32010. /**
  32011. * Gets the Color Grading 2D Lookup Texture.
  32012. */
  32013. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32014. /**
  32015. * Sets the Color Grading 2D Lookup Texture.
  32016. */
  32017. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32018. /**
  32019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32021. * 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;
  32022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32023. */
  32024. get cameraColorCurves(): Nullable<ColorCurves>;
  32025. /**
  32026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32028. * 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;
  32029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32030. */
  32031. set cameraColorCurves(value: Nullable<ColorCurves>);
  32032. /**
  32033. * Can this material render to several textures at once
  32034. */
  32035. get canRenderToMRT(): boolean;
  32036. /**
  32037. * Defines the detail map parameters for the material.
  32038. */
  32039. readonly detailMap: DetailMapConfiguration;
  32040. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32041. protected _worldViewProjectionMatrix: Matrix;
  32042. protected _globalAmbientColor: Color3;
  32043. protected _useLogarithmicDepth: boolean;
  32044. protected _rebuildInParallel: boolean;
  32045. /**
  32046. * Instantiates a new standard material.
  32047. * This is the default material used in Babylon. It is the best trade off between quality
  32048. * and performances.
  32049. * @see https://doc.babylonjs.com/babylon101/materials
  32050. * @param name Define the name of the material in the scene
  32051. * @param scene Define the scene the material belong to
  32052. */
  32053. constructor(name: string, scene: Scene);
  32054. /**
  32055. * Gets a boolean indicating that current material needs to register RTT
  32056. */
  32057. get hasRenderTargetTextures(): boolean;
  32058. /**
  32059. * Gets the current class name of the material e.g. "StandardMaterial"
  32060. * Mainly use in serialization.
  32061. * @returns the class name
  32062. */
  32063. getClassName(): string;
  32064. /**
  32065. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32066. * You can try switching to logarithmic depth.
  32067. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32068. */
  32069. get useLogarithmicDepth(): boolean;
  32070. set useLogarithmicDepth(value: boolean);
  32071. /**
  32072. * Specifies if the material will require alpha blending
  32073. * @returns a boolean specifying if alpha blending is needed
  32074. */
  32075. needAlphaBlending(): boolean;
  32076. /**
  32077. * Specifies if this material should be rendered in alpha test mode
  32078. * @returns a boolean specifying if an alpha test is needed.
  32079. */
  32080. needAlphaTesting(): boolean;
  32081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32082. /**
  32083. * Get the texture used for alpha test purpose.
  32084. * @returns the diffuse texture in case of the standard material.
  32085. */
  32086. getAlphaTestTexture(): Nullable<BaseTexture>;
  32087. /**
  32088. * Get if the submesh is ready to be used and all its information available.
  32089. * Child classes can use it to update shaders
  32090. * @param mesh defines the mesh to check
  32091. * @param subMesh defines which submesh to check
  32092. * @param useInstances specifies that instances should be used
  32093. * @returns a boolean indicating that the submesh is ready or not
  32094. */
  32095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32096. /**
  32097. * Builds the material UBO layouts.
  32098. * Used internally during the effect preparation.
  32099. */
  32100. buildUniformLayout(): void;
  32101. /**
  32102. * Unbinds the material from the mesh
  32103. */
  32104. unbind(): void;
  32105. /**
  32106. * Binds the submesh to this material by preparing the effect and shader to draw
  32107. * @param world defines the world transformation matrix
  32108. * @param mesh defines the mesh containing the submesh
  32109. * @param subMesh defines the submesh to bind the material to
  32110. */
  32111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32112. /**
  32113. * Get the list of animatables in the material.
  32114. * @returns the list of animatables object used in the material
  32115. */
  32116. getAnimatables(): IAnimatable[];
  32117. /**
  32118. * Gets the active textures from the material
  32119. * @returns an array of textures
  32120. */
  32121. getActiveTextures(): BaseTexture[];
  32122. /**
  32123. * Specifies if the material uses a texture
  32124. * @param texture defines the texture to check against the material
  32125. * @returns a boolean specifying if the material uses the texture
  32126. */
  32127. hasTexture(texture: BaseTexture): boolean;
  32128. /**
  32129. * Disposes the material
  32130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32132. */
  32133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32134. /**
  32135. * Makes a duplicate of the material, and gives it a new name
  32136. * @param name defines the new name for the duplicated material
  32137. * @returns the cloned material
  32138. */
  32139. clone(name: string): StandardMaterial;
  32140. /**
  32141. * Serializes this material in a JSON representation
  32142. * @returns the serialized material object
  32143. */
  32144. serialize(): any;
  32145. /**
  32146. * Creates a standard material from parsed material data
  32147. * @param source defines the JSON representation of the material
  32148. * @param scene defines the hosting scene
  32149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32150. * @returns a new standard material
  32151. */
  32152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32153. /**
  32154. * Are diffuse textures enabled in the application.
  32155. */
  32156. static get DiffuseTextureEnabled(): boolean;
  32157. static set DiffuseTextureEnabled(value: boolean);
  32158. /**
  32159. * Are detail textures enabled in the application.
  32160. */
  32161. static get DetailTextureEnabled(): boolean;
  32162. static set DetailTextureEnabled(value: boolean);
  32163. /**
  32164. * Are ambient textures enabled in the application.
  32165. */
  32166. static get AmbientTextureEnabled(): boolean;
  32167. static set AmbientTextureEnabled(value: boolean);
  32168. /**
  32169. * Are opacity textures enabled in the application.
  32170. */
  32171. static get OpacityTextureEnabled(): boolean;
  32172. static set OpacityTextureEnabled(value: boolean);
  32173. /**
  32174. * Are reflection textures enabled in the application.
  32175. */
  32176. static get ReflectionTextureEnabled(): boolean;
  32177. static set ReflectionTextureEnabled(value: boolean);
  32178. /**
  32179. * Are emissive textures enabled in the application.
  32180. */
  32181. static get EmissiveTextureEnabled(): boolean;
  32182. static set EmissiveTextureEnabled(value: boolean);
  32183. /**
  32184. * Are specular textures enabled in the application.
  32185. */
  32186. static get SpecularTextureEnabled(): boolean;
  32187. static set SpecularTextureEnabled(value: boolean);
  32188. /**
  32189. * Are bump textures enabled in the application.
  32190. */
  32191. static get BumpTextureEnabled(): boolean;
  32192. static set BumpTextureEnabled(value: boolean);
  32193. /**
  32194. * Are lightmap textures enabled in the application.
  32195. */
  32196. static get LightmapTextureEnabled(): boolean;
  32197. static set LightmapTextureEnabled(value: boolean);
  32198. /**
  32199. * Are refraction textures enabled in the application.
  32200. */
  32201. static get RefractionTextureEnabled(): boolean;
  32202. static set RefractionTextureEnabled(value: boolean);
  32203. /**
  32204. * Are color grading textures enabled in the application.
  32205. */
  32206. static get ColorGradingTextureEnabled(): boolean;
  32207. static set ColorGradingTextureEnabled(value: boolean);
  32208. /**
  32209. * Are fresnels enabled in the application.
  32210. */
  32211. static get FresnelEnabled(): boolean;
  32212. static set FresnelEnabled(value: boolean);
  32213. }
  32214. }
  32215. declare module "babylonjs/Particles/solidParticleSystem" {
  32216. import { Nullable } from "babylonjs/types";
  32217. import { Mesh } from "babylonjs/Meshes/mesh";
  32218. import { Scene, IDisposable } from "babylonjs/scene";
  32219. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32220. import { Material } from "babylonjs/Materials/material";
  32221. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32222. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32223. /**
  32224. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32225. *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.
  32226. * The SPS is also a particle system. It provides some methods to manage the particles.
  32227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32228. *
  32229. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32230. */
  32231. export class SolidParticleSystem implements IDisposable {
  32232. /**
  32233. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32234. * Example : var p = SPS.particles[i];
  32235. */
  32236. particles: SolidParticle[];
  32237. /**
  32238. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32239. */
  32240. nbParticles: number;
  32241. /**
  32242. * If the particles must ever face the camera (default false). Useful for planar particles.
  32243. */
  32244. billboard: boolean;
  32245. /**
  32246. * Recompute normals when adding a shape
  32247. */
  32248. recomputeNormals: boolean;
  32249. /**
  32250. * This a counter ofr your own usage. It's not set by any SPS functions.
  32251. */
  32252. counter: number;
  32253. /**
  32254. * The SPS name. This name is also given to the underlying mesh.
  32255. */
  32256. name: string;
  32257. /**
  32258. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32259. */
  32260. mesh: Mesh;
  32261. /**
  32262. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32263. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32264. */
  32265. vars: any;
  32266. /**
  32267. * This array is populated when the SPS is set as 'pickable'.
  32268. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32269. * Each element of this array is an object `{idx: int, faceId: int}`.
  32270. * `idx` is the picked particle index in the `SPS.particles` array
  32271. * `faceId` is the picked face index counted within this particle.
  32272. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32273. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32274. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32275. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32276. */
  32277. pickedParticles: {
  32278. idx: number;
  32279. faceId: number;
  32280. }[];
  32281. /**
  32282. * This array is populated when the SPS is set as 'pickable'
  32283. * Each key of this array is a submesh index.
  32284. * Each element of this array is a second array defined like this :
  32285. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32286. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32287. * `idx` is the picked particle index in the `SPS.particles` array
  32288. * `faceId` is the picked face index counted within this particle.
  32289. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32290. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32291. */
  32292. pickedBySubMesh: {
  32293. idx: number;
  32294. faceId: number;
  32295. }[][];
  32296. /**
  32297. * This array is populated when `enableDepthSort` is set to true.
  32298. * Each element of this array is an instance of the class DepthSortedParticle.
  32299. */
  32300. depthSortedParticles: DepthSortedParticle[];
  32301. /**
  32302. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32303. * @hidden
  32304. */
  32305. _bSphereOnly: boolean;
  32306. /**
  32307. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32308. * @hidden
  32309. */
  32310. _bSphereRadiusFactor: number;
  32311. private _scene;
  32312. private _positions;
  32313. private _indices;
  32314. private _normals;
  32315. private _colors;
  32316. private _uvs;
  32317. private _indices32;
  32318. private _positions32;
  32319. private _normals32;
  32320. private _fixedNormal32;
  32321. private _colors32;
  32322. private _uvs32;
  32323. private _index;
  32324. private _updatable;
  32325. private _pickable;
  32326. private _isVisibilityBoxLocked;
  32327. private _alwaysVisible;
  32328. private _depthSort;
  32329. private _expandable;
  32330. private _shapeCounter;
  32331. private _copy;
  32332. private _color;
  32333. private _computeParticleColor;
  32334. private _computeParticleTexture;
  32335. private _computeParticleRotation;
  32336. private _computeParticleVertex;
  32337. private _computeBoundingBox;
  32338. private _depthSortParticles;
  32339. private _camera;
  32340. private _mustUnrotateFixedNormals;
  32341. private _particlesIntersect;
  32342. private _needs32Bits;
  32343. private _isNotBuilt;
  32344. private _lastParticleId;
  32345. private _idxOfId;
  32346. private _multimaterialEnabled;
  32347. private _useModelMaterial;
  32348. private _indicesByMaterial;
  32349. private _materialIndexes;
  32350. private _depthSortFunction;
  32351. private _materialSortFunction;
  32352. private _materials;
  32353. private _multimaterial;
  32354. private _materialIndexesById;
  32355. private _defaultMaterial;
  32356. private _autoUpdateSubMeshes;
  32357. private _tmpVertex;
  32358. /**
  32359. * Creates a SPS (Solid Particle System) object.
  32360. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32361. * @param scene (Scene) is the scene in which the SPS is added.
  32362. * @param options defines the options of the sps e.g.
  32363. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32364. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32365. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32366. * * 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.
  32367. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32368. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32369. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32370. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32371. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32372. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32373. */
  32374. constructor(name: string, scene: Scene, options?: {
  32375. updatable?: boolean;
  32376. isPickable?: boolean;
  32377. enableDepthSort?: boolean;
  32378. particleIntersection?: boolean;
  32379. boundingSphereOnly?: boolean;
  32380. bSphereRadiusFactor?: number;
  32381. expandable?: boolean;
  32382. useModelMaterial?: boolean;
  32383. enableMultiMaterial?: boolean;
  32384. });
  32385. /**
  32386. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32387. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32388. * @returns the created mesh
  32389. */
  32390. buildMesh(): Mesh;
  32391. /**
  32392. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32393. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32394. * Thus the particles generated from `digest()` have their property `position` set yet.
  32395. * @param mesh ( Mesh ) is the mesh to be digested
  32396. * @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
  32397. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32398. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32399. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32400. * @returns the current SPS
  32401. */
  32402. digest(mesh: Mesh, options?: {
  32403. facetNb?: number;
  32404. number?: number;
  32405. delta?: number;
  32406. storage?: [];
  32407. }): SolidParticleSystem;
  32408. /**
  32409. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32410. * @hidden
  32411. */
  32412. private _unrotateFixedNormals;
  32413. /**
  32414. * Resets the temporary working copy particle
  32415. * @hidden
  32416. */
  32417. private _resetCopy;
  32418. /**
  32419. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32420. * @param p the current index in the positions array to be updated
  32421. * @param ind the current index in the indices array
  32422. * @param shape a Vector3 array, the shape geometry
  32423. * @param positions the positions array to be updated
  32424. * @param meshInd the shape indices array
  32425. * @param indices the indices array to be updated
  32426. * @param meshUV the shape uv array
  32427. * @param uvs the uv array to be updated
  32428. * @param meshCol the shape color array
  32429. * @param colors the color array to be updated
  32430. * @param meshNor the shape normals array
  32431. * @param normals the normals array to be updated
  32432. * @param idx the particle index
  32433. * @param idxInShape the particle index in its shape
  32434. * @param options the addShape() method passed options
  32435. * @model the particle model
  32436. * @hidden
  32437. */
  32438. private _meshBuilder;
  32439. /**
  32440. * Returns a shape Vector3 array from positions float array
  32441. * @param positions float array
  32442. * @returns a vector3 array
  32443. * @hidden
  32444. */
  32445. private _posToShape;
  32446. /**
  32447. * Returns a shapeUV array from a float uvs (array deep copy)
  32448. * @param uvs as a float array
  32449. * @returns a shapeUV array
  32450. * @hidden
  32451. */
  32452. private _uvsToShapeUV;
  32453. /**
  32454. * Adds a new particle object in the particles array
  32455. * @param idx particle index in particles array
  32456. * @param id particle id
  32457. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32458. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32459. * @param model particle ModelShape object
  32460. * @param shapeId model shape identifier
  32461. * @param idxInShape index of the particle in the current model
  32462. * @param bInfo model bounding info object
  32463. * @param storage target storage array, if any
  32464. * @hidden
  32465. */
  32466. private _addParticle;
  32467. /**
  32468. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32469. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32470. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32471. * @param nb (positive integer) the number of particles to be created from this model
  32472. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32473. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32474. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32475. * @returns the number of shapes in the system
  32476. */
  32477. addShape(mesh: Mesh, nb: number, options?: {
  32478. positionFunction?: any;
  32479. vertexFunction?: any;
  32480. storage?: [];
  32481. }): number;
  32482. /**
  32483. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32484. * @hidden
  32485. */
  32486. private _rebuildParticle;
  32487. /**
  32488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32489. * @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.
  32490. * @returns the SPS.
  32491. */
  32492. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32493. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32494. * Returns an array with the removed particles.
  32495. * 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.
  32496. * The SPS can't be empty so at least one particle needs to remain in place.
  32497. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32498. * @param start index of the first particle to remove
  32499. * @param end index of the last particle to remove (included)
  32500. * @returns an array populated with the removed particles
  32501. */
  32502. removeParticles(start: number, end: number): SolidParticle[];
  32503. /**
  32504. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32505. * @param solidParticleArray an array populated with Solid Particles objects
  32506. * @returns the SPS
  32507. */
  32508. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32509. /**
  32510. * Creates a new particle and modifies the SPS mesh geometry :
  32511. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32512. * - calls _addParticle() to populate the particle array
  32513. * factorized code from addShape() and insertParticlesFromArray()
  32514. * @param idx particle index in the particles array
  32515. * @param i particle index in its shape
  32516. * @param modelShape particle ModelShape object
  32517. * @param shape shape vertex array
  32518. * @param meshInd shape indices array
  32519. * @param meshUV shape uv array
  32520. * @param meshCol shape color array
  32521. * @param meshNor shape normals array
  32522. * @param bbInfo shape bounding info
  32523. * @param storage target particle storage
  32524. * @options addShape() passed options
  32525. * @hidden
  32526. */
  32527. private _insertNewParticle;
  32528. /**
  32529. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32530. * This method calls `updateParticle()` for each particle of the SPS.
  32531. * For an animated SPS, it is usually called within the render loop.
  32532. * 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.
  32533. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32534. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32535. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32536. * @returns the SPS.
  32537. */
  32538. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32539. /**
  32540. * Disposes the SPS.
  32541. */
  32542. dispose(): void;
  32543. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32544. * idx is the particle index in the SPS
  32545. * faceId is the picked face index counted within this particle.
  32546. * Returns null if the pickInfo can't identify a picked particle.
  32547. * @param pickingInfo (PickingInfo object)
  32548. * @returns {idx: number, faceId: number} or null
  32549. */
  32550. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32551. idx: number;
  32552. faceId: number;
  32553. }>;
  32554. /**
  32555. * Returns a SolidParticle object from its identifier : particle.id
  32556. * @param id (integer) the particle Id
  32557. * @returns the searched particle or null if not found in the SPS.
  32558. */
  32559. getParticleById(id: number): Nullable<SolidParticle>;
  32560. /**
  32561. * Returns a new array populated with the particles having the passed shapeId.
  32562. * @param shapeId (integer) the shape identifier
  32563. * @returns a new solid particle array
  32564. */
  32565. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32566. /**
  32567. * Populates the passed array "ref" with the particles having the passed shapeId.
  32568. * @param shapeId the shape identifier
  32569. * @returns the SPS
  32570. * @param ref
  32571. */
  32572. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32573. /**
  32574. * Computes the required SubMeshes according the materials assigned to the particles.
  32575. * @returns the solid particle system.
  32576. * Does nothing if called before the SPS mesh is built.
  32577. */
  32578. computeSubMeshes(): SolidParticleSystem;
  32579. /**
  32580. * Sorts the solid particles by material when MultiMaterial is enabled.
  32581. * Updates the indices32 array.
  32582. * Updates the indicesByMaterial array.
  32583. * Updates the mesh indices array.
  32584. * @returns the SPS
  32585. * @hidden
  32586. */
  32587. private _sortParticlesByMaterial;
  32588. /**
  32589. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32590. * @hidden
  32591. */
  32592. private _setMaterialIndexesById;
  32593. /**
  32594. * Returns an array with unique values of Materials from the passed array
  32595. * @param array the material array to be checked and filtered
  32596. * @hidden
  32597. */
  32598. private _filterUniqueMaterialId;
  32599. /**
  32600. * Sets a new Standard Material as _defaultMaterial if not already set.
  32601. * @hidden
  32602. */
  32603. private _setDefaultMaterial;
  32604. /**
  32605. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32606. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32607. * @returns the SPS.
  32608. */
  32609. refreshVisibleSize(): SolidParticleSystem;
  32610. /**
  32611. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32612. * @param size the size (float) of the visibility box
  32613. * note : this doesn't lock the SPS mesh bounding box.
  32614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32615. */
  32616. setVisibilityBox(size: number): void;
  32617. /**
  32618. * Gets whether the SPS as always visible or not
  32619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32620. */
  32621. get isAlwaysVisible(): boolean;
  32622. /**
  32623. * Sets the SPS as always visible or not
  32624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32625. */
  32626. set isAlwaysVisible(val: boolean);
  32627. /**
  32628. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32630. */
  32631. set isVisibilityBoxLocked(val: boolean);
  32632. /**
  32633. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32634. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32635. */
  32636. get isVisibilityBoxLocked(): boolean;
  32637. /**
  32638. * Tells to `setParticles()` to compute 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. set computeParticleRotation(val: boolean);
  32643. /**
  32644. * Tells to `setParticles()` to compute 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. set computeParticleColor(val: boolean);
  32649. set computeParticleTexture(val: boolean);
  32650. /**
  32651. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32652. * Default value : false. The SPS is faster when it's set to false.
  32653. * Note : the particle custom vertex positions aren't stored values.
  32654. */
  32655. set computeParticleVertex(val: boolean);
  32656. /**
  32657. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32658. */
  32659. set computeBoundingBox(val: boolean);
  32660. /**
  32661. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32662. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32663. * Default : `true`
  32664. */
  32665. set depthSortParticles(val: boolean);
  32666. /**
  32667. * Gets if `setParticles()` computes the particle rotations or not.
  32668. * Default value : true. The SPS is faster when it's set to false.
  32669. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32670. */
  32671. get computeParticleRotation(): boolean;
  32672. /**
  32673. * Gets if `setParticles()` computes the particle colors or not.
  32674. * Default value : true. The SPS is faster when it's set to false.
  32675. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32676. */
  32677. get computeParticleColor(): boolean;
  32678. /**
  32679. * Gets if `setParticles()` computes the particle textures or not.
  32680. * Default value : true. The SPS is faster when it's set to false.
  32681. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32682. */
  32683. get computeParticleTexture(): boolean;
  32684. /**
  32685. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32686. * Default value : false. The SPS is faster when it's set to false.
  32687. * Note : the particle custom vertex positions aren't stored values.
  32688. */
  32689. get computeParticleVertex(): boolean;
  32690. /**
  32691. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32692. */
  32693. get computeBoundingBox(): boolean;
  32694. /**
  32695. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32696. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32697. * Default : `true`
  32698. */
  32699. get depthSortParticles(): boolean;
  32700. /**
  32701. * Gets if the SPS is created as expandable at construction time.
  32702. * Default : `false`
  32703. */
  32704. get expandable(): boolean;
  32705. /**
  32706. * Gets if the SPS supports the Multi Materials
  32707. */
  32708. get multimaterialEnabled(): boolean;
  32709. /**
  32710. * Gets if the SPS uses the model materials for its own multimaterial.
  32711. */
  32712. get useModelMaterial(): boolean;
  32713. /**
  32714. * The SPS used material array.
  32715. */
  32716. get materials(): Material[];
  32717. /**
  32718. * Sets the SPS MultiMaterial from the passed materials.
  32719. * Note : the passed array is internally copied and not used then by reference.
  32720. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32721. */
  32722. setMultiMaterial(materials: Material[]): void;
  32723. /**
  32724. * The SPS computed multimaterial object
  32725. */
  32726. get multimaterial(): MultiMaterial;
  32727. set multimaterial(mm: MultiMaterial);
  32728. /**
  32729. * If the subMeshes must be updated on the next call to setParticles()
  32730. */
  32731. get autoUpdateSubMeshes(): boolean;
  32732. set autoUpdateSubMeshes(val: boolean);
  32733. /**
  32734. * This function does nothing. It may be overwritten to set all the particle first values.
  32735. * The SPS doesn't call this function, you may have to call it by your own.
  32736. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32737. */
  32738. initParticles(): void;
  32739. /**
  32740. * This function does nothing. It may be overwritten to recycle a particle.
  32741. * The SPS doesn't call this function, you may have to call it by your own.
  32742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32743. * @param particle The particle to recycle
  32744. * @returns the recycled particle
  32745. */
  32746. recycleParticle(particle: SolidParticle): SolidParticle;
  32747. /**
  32748. * Updates a particle : this function should be overwritten by the user.
  32749. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32750. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32751. * @example : just set a particle position or velocity and recycle conditions
  32752. * @param particle The particle to update
  32753. * @returns the updated particle
  32754. */
  32755. updateParticle(particle: SolidParticle): SolidParticle;
  32756. /**
  32757. * Updates a vertex of a particle : it can be overwritten by the user.
  32758. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32759. * @param particle the current particle
  32760. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32761. * @param pt the index of the current vertex in the particle shape
  32762. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32763. * @example : just set a vertex particle position or color
  32764. * @returns the sps
  32765. */
  32766. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32767. /**
  32768. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32769. * This does nothing and may be overwritten by the user.
  32770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param update the boolean update value actually passed to setParticles()
  32773. */
  32774. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32775. /**
  32776. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32777. * This will be passed three parameters.
  32778. * This does nothing and may be overwritten by the user.
  32779. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32780. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32781. * @param update the boolean update value actually passed to setParticles()
  32782. */
  32783. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32784. }
  32785. }
  32786. declare module "babylonjs/Particles/solidParticle" {
  32787. import { Nullable } from "babylonjs/types";
  32788. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32789. import { Color4 } from "babylonjs/Maths/math.color";
  32790. import { Mesh } from "babylonjs/Meshes/mesh";
  32791. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32792. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32793. import { Plane } from "babylonjs/Maths/math.plane";
  32794. import { Material } from "babylonjs/Materials/material";
  32795. /**
  32796. * Represents one particle of a solid particle system.
  32797. */
  32798. export class SolidParticle {
  32799. /**
  32800. * particle global index
  32801. */
  32802. idx: number;
  32803. /**
  32804. * particle identifier
  32805. */
  32806. id: number;
  32807. /**
  32808. * The color of the particle
  32809. */
  32810. color: Nullable<Color4>;
  32811. /**
  32812. * The world space position of the particle.
  32813. */
  32814. position: Vector3;
  32815. /**
  32816. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32817. */
  32818. rotation: Vector3;
  32819. /**
  32820. * The world space rotation quaternion of the particle.
  32821. */
  32822. rotationQuaternion: Nullable<Quaternion>;
  32823. /**
  32824. * The scaling of the particle.
  32825. */
  32826. scaling: Vector3;
  32827. /**
  32828. * The uvs of the particle.
  32829. */
  32830. uvs: Vector4;
  32831. /**
  32832. * The current speed of the particle.
  32833. */
  32834. velocity: Vector3;
  32835. /**
  32836. * The pivot point in the particle local space.
  32837. */
  32838. pivot: Vector3;
  32839. /**
  32840. * Must the particle be translated from its pivot point in its local space ?
  32841. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32842. * Default : false
  32843. */
  32844. translateFromPivot: boolean;
  32845. /**
  32846. * Is the particle active or not ?
  32847. */
  32848. alive: boolean;
  32849. /**
  32850. * Is the particle visible or not ?
  32851. */
  32852. isVisible: boolean;
  32853. /**
  32854. * Index of this particle in the global "positions" array (Internal use)
  32855. * @hidden
  32856. */
  32857. _pos: number;
  32858. /**
  32859. * @hidden Index of this particle in the global "indices" array (Internal use)
  32860. */
  32861. _ind: number;
  32862. /**
  32863. * @hidden ModelShape of this particle (Internal use)
  32864. */
  32865. _model: ModelShape;
  32866. /**
  32867. * ModelShape id of this particle
  32868. */
  32869. shapeId: number;
  32870. /**
  32871. * Index of the particle in its shape id
  32872. */
  32873. idxInShape: number;
  32874. /**
  32875. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32876. */
  32877. _modelBoundingInfo: BoundingInfo;
  32878. /**
  32879. * @hidden Particle BoundingInfo object (Internal use)
  32880. */
  32881. _boundingInfo: BoundingInfo;
  32882. /**
  32883. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32884. */
  32885. _sps: SolidParticleSystem;
  32886. /**
  32887. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32888. */
  32889. _stillInvisible: boolean;
  32890. /**
  32891. * @hidden Last computed particle rotation matrix
  32892. */
  32893. _rotationMatrix: number[];
  32894. /**
  32895. * Parent particle Id, if any.
  32896. * Default null.
  32897. */
  32898. parentId: Nullable<number>;
  32899. /**
  32900. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32901. */
  32902. materialIndex: Nullable<number>;
  32903. /**
  32904. * Custom object or properties.
  32905. */
  32906. props: Nullable<any>;
  32907. /**
  32908. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32909. * The possible values are :
  32910. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32911. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32912. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32914. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32915. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32916. * */
  32917. cullingStrategy: number;
  32918. /**
  32919. * @hidden Internal global position in the SPS.
  32920. */
  32921. _globalPosition: Vector3;
  32922. /**
  32923. * Creates a Solid Particle object.
  32924. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32925. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32926. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32927. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32928. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32929. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32930. * @param shapeId (integer) is the model shape identifier in the SPS.
  32931. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32932. * @param sps defines the sps it is associated to
  32933. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32934. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32935. */
  32936. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32937. /**
  32938. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32939. * @param target the particle target
  32940. * @returns the current particle
  32941. */
  32942. copyToRef(target: SolidParticle): SolidParticle;
  32943. /**
  32944. * Legacy support, changed scale to scaling
  32945. */
  32946. get scale(): Vector3;
  32947. /**
  32948. * Legacy support, changed scale to scaling
  32949. */
  32950. set scale(scale: Vector3);
  32951. /**
  32952. * Legacy support, changed quaternion to rotationQuaternion
  32953. */
  32954. get quaternion(): Nullable<Quaternion>;
  32955. /**
  32956. * Legacy support, changed quaternion to rotationQuaternion
  32957. */
  32958. set quaternion(q: Nullable<Quaternion>);
  32959. /**
  32960. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32961. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32962. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32963. * @returns true if it intersects
  32964. */
  32965. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32966. /**
  32967. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32968. * A particle is in the frustum if its bounding box intersects the frustum
  32969. * @param frustumPlanes defines the frustum to test
  32970. * @returns true if the particle is in the frustum planes
  32971. */
  32972. isInFrustum(frustumPlanes: Plane[]): boolean;
  32973. /**
  32974. * get the rotation matrix of the particle
  32975. * @hidden
  32976. */
  32977. getRotationMatrix(m: Matrix): void;
  32978. }
  32979. /**
  32980. * Represents the shape of the model used by one particle of a solid particle system.
  32981. * SPS internal tool, don't use it manually.
  32982. */
  32983. export class ModelShape {
  32984. /**
  32985. * The shape id
  32986. * @hidden
  32987. */
  32988. shapeID: number;
  32989. /**
  32990. * flat array of model positions (internal use)
  32991. * @hidden
  32992. */
  32993. _shape: Vector3[];
  32994. /**
  32995. * flat array of model UVs (internal use)
  32996. * @hidden
  32997. */
  32998. _shapeUV: number[];
  32999. /**
  33000. * color array of the model
  33001. * @hidden
  33002. */
  33003. _shapeColors: number[];
  33004. /**
  33005. * indices array of the model
  33006. * @hidden
  33007. */
  33008. _indices: number[];
  33009. /**
  33010. * normals array of the model
  33011. * @hidden
  33012. */
  33013. _normals: number[];
  33014. /**
  33015. * length of the shape in the model indices array (internal use)
  33016. * @hidden
  33017. */
  33018. _indicesLength: number;
  33019. /**
  33020. * Custom position function (internal use)
  33021. * @hidden
  33022. */
  33023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33024. /**
  33025. * Custom vertex function (internal use)
  33026. * @hidden
  33027. */
  33028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33029. /**
  33030. * Model material (internal use)
  33031. * @hidden
  33032. */
  33033. _material: Nullable<Material>;
  33034. /**
  33035. * 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.
  33036. * SPS internal tool, don't use it manually.
  33037. * @hidden
  33038. */
  33039. 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>);
  33040. }
  33041. /**
  33042. * Represents a Depth Sorted Particle in the solid particle system.
  33043. * @hidden
  33044. */
  33045. export class DepthSortedParticle {
  33046. /**
  33047. * Particle index
  33048. */
  33049. idx: number;
  33050. /**
  33051. * Index of the particle in the "indices" array
  33052. */
  33053. ind: number;
  33054. /**
  33055. * Length of the particle shape in the "indices" array
  33056. */
  33057. indicesLength: number;
  33058. /**
  33059. * Squared distance from the particle to the camera
  33060. */
  33061. sqDistance: number;
  33062. /**
  33063. * Material index when used with MultiMaterials
  33064. */
  33065. materialIndex: number;
  33066. /**
  33067. * Creates a new sorted particle
  33068. * @param materialIndex
  33069. */
  33070. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33071. }
  33072. /**
  33073. * Represents a solid particle vertex
  33074. */
  33075. export class SolidParticleVertex {
  33076. /**
  33077. * Vertex position
  33078. */
  33079. position: Vector3;
  33080. /**
  33081. * Vertex color
  33082. */
  33083. color: Color4;
  33084. /**
  33085. * Vertex UV
  33086. */
  33087. uv: Vector2;
  33088. /**
  33089. * Creates a new solid particle vertex
  33090. */
  33091. constructor();
  33092. /** Vertex x coordinate */
  33093. get x(): number;
  33094. set x(val: number);
  33095. /** Vertex y coordinate */
  33096. get y(): number;
  33097. set y(val: number);
  33098. /** Vertex z coordinate */
  33099. get z(): number;
  33100. set z(val: number);
  33101. }
  33102. }
  33103. declare module "babylonjs/Collisions/meshCollisionData" {
  33104. import { Collider } from "babylonjs/Collisions/collider";
  33105. import { Vector3 } from "babylonjs/Maths/math.vector";
  33106. import { Nullable } from "babylonjs/types";
  33107. import { Observer } from "babylonjs/Misc/observable";
  33108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33109. /**
  33110. * @hidden
  33111. */
  33112. export class _MeshCollisionData {
  33113. _checkCollisions: boolean;
  33114. _collisionMask: number;
  33115. _collisionGroup: number;
  33116. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33117. _collider: Nullable<Collider>;
  33118. _oldPositionForCollisions: Vector3;
  33119. _diffPositionForCollisions: Vector3;
  33120. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33121. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33122. _collisionResponse: boolean;
  33123. }
  33124. }
  33125. declare module "babylonjs/Meshes/abstractMesh" {
  33126. import { Observable } from "babylonjs/Misc/observable";
  33127. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33128. import { Camera } from "babylonjs/Cameras/camera";
  33129. import { Scene, IDisposable } from "babylonjs/scene";
  33130. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33131. import { Node } from "babylonjs/node";
  33132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33133. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33136. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33137. import { Material } from "babylonjs/Materials/material";
  33138. import { Light } from "babylonjs/Lights/light";
  33139. import { Skeleton } from "babylonjs/Bones/skeleton";
  33140. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33141. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33142. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33143. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33144. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33145. import { Plane } from "babylonjs/Maths/math.plane";
  33146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33147. import { Ray } from "babylonjs/Culling/ray";
  33148. import { Collider } from "babylonjs/Collisions/collider";
  33149. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33150. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33151. /** @hidden */
  33152. class _FacetDataStorage {
  33153. facetPositions: Vector3[];
  33154. facetNormals: Vector3[];
  33155. facetPartitioning: number[][];
  33156. facetNb: number;
  33157. partitioningSubdivisions: number;
  33158. partitioningBBoxRatio: number;
  33159. facetDataEnabled: boolean;
  33160. facetParameters: any;
  33161. bbSize: Vector3;
  33162. subDiv: {
  33163. max: number;
  33164. X: number;
  33165. Y: number;
  33166. Z: number;
  33167. };
  33168. facetDepthSort: boolean;
  33169. facetDepthSortEnabled: boolean;
  33170. depthSortedIndices: IndicesArray;
  33171. depthSortedFacets: {
  33172. ind: number;
  33173. sqDistance: number;
  33174. }[];
  33175. facetDepthSortFunction: (f1: {
  33176. ind: number;
  33177. sqDistance: number;
  33178. }, f2: {
  33179. ind: number;
  33180. sqDistance: number;
  33181. }) => number;
  33182. facetDepthSortFrom: Vector3;
  33183. facetDepthSortOrigin: Vector3;
  33184. invertedMatrix: Matrix;
  33185. }
  33186. /**
  33187. * @hidden
  33188. **/
  33189. class _InternalAbstractMeshDataInfo {
  33190. _hasVertexAlpha: boolean;
  33191. _useVertexColors: boolean;
  33192. _numBoneInfluencers: number;
  33193. _applyFog: boolean;
  33194. _receiveShadows: boolean;
  33195. _facetData: _FacetDataStorage;
  33196. _visibility: number;
  33197. _skeleton: Nullable<Skeleton>;
  33198. _layerMask: number;
  33199. _computeBonesUsingShaders: boolean;
  33200. _isActive: boolean;
  33201. _onlyForInstances: boolean;
  33202. _isActiveIntermediate: boolean;
  33203. _onlyForInstancesIntermediate: boolean;
  33204. _actAsRegularMesh: boolean;
  33205. }
  33206. /**
  33207. * Class used to store all common mesh properties
  33208. */
  33209. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33210. /** No occlusion */
  33211. static OCCLUSION_TYPE_NONE: number;
  33212. /** Occlusion set to optimisitic */
  33213. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33214. /** Occlusion set to strict */
  33215. static OCCLUSION_TYPE_STRICT: number;
  33216. /** Use an accurante occlusion algorithm */
  33217. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33218. /** Use a conservative occlusion algorithm */
  33219. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33220. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33221. * Test order :
  33222. * Is the bounding sphere outside the frustum ?
  33223. * If not, are the bounding box vertices outside the frustum ?
  33224. * It not, then the cullable object is in the frustum.
  33225. */
  33226. static readonly CULLINGSTRATEGY_STANDARD: number;
  33227. /** Culling strategy : Bounding Sphere Only.
  33228. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33229. * It's also less accurate than the standard because some not visible objects can still be selected.
  33230. * Test : is the bounding sphere outside the frustum ?
  33231. * If not, then the cullable object is in the frustum.
  33232. */
  33233. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33234. /** Culling strategy : Optimistic Inclusion.
  33235. * This in an inclusion test first, then the standard exclusion test.
  33236. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33237. * 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.
  33238. * Anyway, it's as accurate as the standard strategy.
  33239. * Test :
  33240. * Is the cullable object bounding sphere center in the frustum ?
  33241. * If not, apply the default culling strategy.
  33242. */
  33243. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33244. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33245. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33246. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33247. * 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.
  33248. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33249. * Test :
  33250. * Is the cullable object bounding sphere center in the frustum ?
  33251. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33252. */
  33253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33254. /**
  33255. * No billboard
  33256. */
  33257. static get BILLBOARDMODE_NONE(): number;
  33258. /** Billboard on X axis */
  33259. static get BILLBOARDMODE_X(): number;
  33260. /** Billboard on Y axis */
  33261. static get BILLBOARDMODE_Y(): number;
  33262. /** Billboard on Z axis */
  33263. static get BILLBOARDMODE_Z(): number;
  33264. /** Billboard on all axes */
  33265. static get BILLBOARDMODE_ALL(): number;
  33266. /** Billboard on using position instead of orientation */
  33267. static get BILLBOARDMODE_USE_POSITION(): number;
  33268. /** @hidden */
  33269. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33270. /**
  33271. * The culling strategy to use to check whether the mesh must be rendered or not.
  33272. * This value can be changed at any time and will be used on the next render mesh selection.
  33273. * The possible values are :
  33274. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33275. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33276. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33278. * Please read each static variable documentation to get details about the culling process.
  33279. * */
  33280. cullingStrategy: number;
  33281. /**
  33282. * Gets the number of facets in the mesh
  33283. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33284. */
  33285. get facetNb(): number;
  33286. /**
  33287. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33289. */
  33290. get partitioningSubdivisions(): number;
  33291. set partitioningSubdivisions(nb: number);
  33292. /**
  33293. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33294. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33295. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33296. */
  33297. get partitioningBBoxRatio(): number;
  33298. set partitioningBBoxRatio(ratio: number);
  33299. /**
  33300. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33301. * Works only for updatable meshes.
  33302. * Doesn't work with multi-materials
  33303. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33304. */
  33305. get mustDepthSortFacets(): boolean;
  33306. set mustDepthSortFacets(sort: boolean);
  33307. /**
  33308. * The location (Vector3) where the facet depth sort must be computed from.
  33309. * By default, the active camera position.
  33310. * Used only when facet depth sort is enabled
  33311. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33312. */
  33313. get facetDepthSortFrom(): Vector3;
  33314. set facetDepthSortFrom(location: Vector3);
  33315. /**
  33316. * gets a boolean indicating if facetData is enabled
  33317. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33318. */
  33319. get isFacetDataEnabled(): boolean;
  33320. /** @hidden */
  33321. _updateNonUniformScalingState(value: boolean): boolean;
  33322. /**
  33323. * An event triggered when this mesh collides with another one
  33324. */
  33325. onCollideObservable: Observable<AbstractMesh>;
  33326. /** Set a function to call when this mesh collides with another one */
  33327. set onCollide(callback: () => void);
  33328. /**
  33329. * An event triggered when the collision's position changes
  33330. */
  33331. onCollisionPositionChangeObservable: Observable<Vector3>;
  33332. /** Set a function to call when the collision's position changes */
  33333. set onCollisionPositionChange(callback: () => void);
  33334. /**
  33335. * An event triggered when material is changed
  33336. */
  33337. onMaterialChangedObservable: Observable<AbstractMesh>;
  33338. /**
  33339. * Gets or sets the orientation for POV movement & rotation
  33340. */
  33341. definedFacingForward: boolean;
  33342. /** @hidden */
  33343. _occlusionQuery: Nullable<WebGLQuery>;
  33344. /** @hidden */
  33345. _renderingGroup: Nullable<RenderingGroup>;
  33346. /**
  33347. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33348. */
  33349. get visibility(): number;
  33350. /**
  33351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33352. */
  33353. set visibility(value: number);
  33354. /** Gets or sets the alpha index used to sort transparent meshes
  33355. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33356. */
  33357. alphaIndex: number;
  33358. /**
  33359. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33360. */
  33361. isVisible: boolean;
  33362. /**
  33363. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33364. */
  33365. isPickable: boolean;
  33366. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33367. showSubMeshesBoundingBox: boolean;
  33368. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33369. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33370. */
  33371. isBlocker: boolean;
  33372. /**
  33373. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33374. */
  33375. enablePointerMoveEvents: boolean;
  33376. private _renderingGroupId;
  33377. /**
  33378. * Specifies the rendering group id for this mesh (0 by default)
  33379. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33380. */
  33381. get renderingGroupId(): number;
  33382. set renderingGroupId(value: number);
  33383. private _material;
  33384. /** Gets or sets current material */
  33385. get material(): Nullable<Material>;
  33386. set material(value: Nullable<Material>);
  33387. /**
  33388. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33389. * @see https://doc.babylonjs.com/babylon101/shadows
  33390. */
  33391. get receiveShadows(): boolean;
  33392. set receiveShadows(value: boolean);
  33393. /** Defines color to use when rendering outline */
  33394. outlineColor: Color3;
  33395. /** Define width to use when rendering outline */
  33396. outlineWidth: number;
  33397. /** Defines color to use when rendering overlay */
  33398. overlayColor: Color3;
  33399. /** Defines alpha to use when rendering overlay */
  33400. overlayAlpha: number;
  33401. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33402. get hasVertexAlpha(): boolean;
  33403. set hasVertexAlpha(value: boolean);
  33404. /** 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) */
  33405. get useVertexColors(): boolean;
  33406. set useVertexColors(value: boolean);
  33407. /**
  33408. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33409. */
  33410. get computeBonesUsingShaders(): boolean;
  33411. set computeBonesUsingShaders(value: boolean);
  33412. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33413. get numBoneInfluencers(): number;
  33414. set numBoneInfluencers(value: number);
  33415. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33416. get applyFog(): boolean;
  33417. set applyFog(value: boolean);
  33418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33419. useOctreeForRenderingSelection: boolean;
  33420. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33421. useOctreeForPicking: boolean;
  33422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33423. useOctreeForCollisions: boolean;
  33424. /**
  33425. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33426. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33427. */
  33428. get layerMask(): number;
  33429. set layerMask(value: number);
  33430. /**
  33431. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33432. */
  33433. alwaysSelectAsActiveMesh: boolean;
  33434. /**
  33435. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33436. */
  33437. doNotSyncBoundingInfo: boolean;
  33438. /**
  33439. * Gets or sets the current action manager
  33440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33441. */
  33442. actionManager: Nullable<AbstractActionManager>;
  33443. private _meshCollisionData;
  33444. /**
  33445. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33446. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33447. */
  33448. ellipsoid: Vector3;
  33449. /**
  33450. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33452. */
  33453. ellipsoidOffset: Vector3;
  33454. /**
  33455. * Gets or sets a collision mask used to mask collisions (default is -1).
  33456. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33457. */
  33458. get collisionMask(): number;
  33459. set collisionMask(mask: number);
  33460. /**
  33461. * Gets or sets a collision response flag (default is true).
  33462. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33463. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33464. * to respond to the collision.
  33465. */
  33466. get collisionResponse(): boolean;
  33467. set collisionResponse(response: boolean);
  33468. /**
  33469. * Gets or sets the current collision group mask (-1 by default).
  33470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33471. */
  33472. get collisionGroup(): number;
  33473. set collisionGroup(mask: number);
  33474. /**
  33475. * Gets or sets current surrounding meshes (null by default).
  33476. *
  33477. * By default collision detection is tested against every mesh in the scene.
  33478. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33479. * meshes will be tested for the collision.
  33480. *
  33481. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33482. */
  33483. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33484. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33485. /**
  33486. * Defines edge width used when edgesRenderer is enabled
  33487. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33488. */
  33489. edgesWidth: number;
  33490. /**
  33491. * Defines edge color used when edgesRenderer is enabled
  33492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33493. */
  33494. edgesColor: Color4;
  33495. /** @hidden */
  33496. _edgesRenderer: Nullable<IEdgesRenderer>;
  33497. /** @hidden */
  33498. _masterMesh: Nullable<AbstractMesh>;
  33499. /** @hidden */
  33500. _boundingInfo: Nullable<BoundingInfo>;
  33501. /** @hidden */
  33502. _renderId: number;
  33503. /**
  33504. * Gets or sets the list of subMeshes
  33505. * @see https://doc.babylonjs.com/how_to/multi_materials
  33506. */
  33507. subMeshes: SubMesh[];
  33508. /** @hidden */
  33509. _intersectionsInProgress: AbstractMesh[];
  33510. /** @hidden */
  33511. _unIndexed: boolean;
  33512. /** @hidden */
  33513. _lightSources: Light[];
  33514. /** Gets the list of lights affecting that mesh */
  33515. get lightSources(): Light[];
  33516. /** @hidden */
  33517. get _positions(): Nullable<Vector3[]>;
  33518. /** @hidden */
  33519. _waitingData: {
  33520. lods: Nullable<any>;
  33521. actions: Nullable<any>;
  33522. freezeWorldMatrix: Nullable<boolean>;
  33523. };
  33524. /** @hidden */
  33525. _bonesTransformMatrices: Nullable<Float32Array>;
  33526. /** @hidden */
  33527. _transformMatrixTexture: Nullable<RawTexture>;
  33528. /**
  33529. * Gets or sets a skeleton to apply skining transformations
  33530. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33531. */
  33532. set skeleton(value: Nullable<Skeleton>);
  33533. get skeleton(): Nullable<Skeleton>;
  33534. /**
  33535. * An event triggered when the mesh is rebuilt.
  33536. */
  33537. onRebuildObservable: Observable<AbstractMesh>;
  33538. /**
  33539. * Creates a new AbstractMesh
  33540. * @param name defines the name of the mesh
  33541. * @param scene defines the hosting scene
  33542. */
  33543. constructor(name: string, scene?: Nullable<Scene>);
  33544. /**
  33545. * Returns the string "AbstractMesh"
  33546. * @returns "AbstractMesh"
  33547. */
  33548. getClassName(): string;
  33549. /**
  33550. * Gets a string representation of the current mesh
  33551. * @param fullDetails defines a boolean indicating if full details must be included
  33552. * @returns a string representation of the current mesh
  33553. */
  33554. toString(fullDetails?: boolean): string;
  33555. /**
  33556. * @hidden
  33557. */
  33558. protected _getEffectiveParent(): Nullable<Node>;
  33559. /** @hidden */
  33560. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33561. /** @hidden */
  33562. _rebuild(): void;
  33563. /** @hidden */
  33564. _resyncLightSources(): void;
  33565. /** @hidden */
  33566. _resyncLightSource(light: Light): void;
  33567. /** @hidden */
  33568. _unBindEffect(): void;
  33569. /** @hidden */
  33570. _removeLightSource(light: Light, dispose: boolean): void;
  33571. private _markSubMeshesAsDirty;
  33572. /** @hidden */
  33573. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33574. /** @hidden */
  33575. _markSubMeshesAsAttributesDirty(): void;
  33576. /** @hidden */
  33577. _markSubMeshesAsMiscDirty(): void;
  33578. /**
  33579. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33580. */
  33581. get scaling(): Vector3;
  33582. set scaling(newScaling: Vector3);
  33583. /**
  33584. * Returns true if the mesh is blocked. Implemented by child classes
  33585. */
  33586. get isBlocked(): boolean;
  33587. /**
  33588. * Returns the mesh itself by default. Implemented by child classes
  33589. * @param camera defines the camera to use to pick the right LOD level
  33590. * @returns the currentAbstractMesh
  33591. */
  33592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33593. /**
  33594. * Returns 0 by default. Implemented by child classes
  33595. * @returns an integer
  33596. */
  33597. getTotalVertices(): number;
  33598. /**
  33599. * Returns a positive integer : the total number of indices in this mesh geometry.
  33600. * @returns the numner of indices or zero if the mesh has no geometry.
  33601. */
  33602. getTotalIndices(): number;
  33603. /**
  33604. * Returns null by default. Implemented by child classes
  33605. * @returns null
  33606. */
  33607. getIndices(): Nullable<IndicesArray>;
  33608. /**
  33609. * Returns the array of the requested vertex data kind. Implemented by child classes
  33610. * @param kind defines the vertex data kind to use
  33611. * @returns null
  33612. */
  33613. getVerticesData(kind: string): Nullable<FloatArray>;
  33614. /**
  33615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33617. * Note that a new underlying VertexBuffer object is created each call.
  33618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33619. * @param kind defines vertex data kind:
  33620. * * VertexBuffer.PositionKind
  33621. * * VertexBuffer.UVKind
  33622. * * VertexBuffer.UV2Kind
  33623. * * VertexBuffer.UV3Kind
  33624. * * VertexBuffer.UV4Kind
  33625. * * VertexBuffer.UV5Kind
  33626. * * VertexBuffer.UV6Kind
  33627. * * VertexBuffer.ColorKind
  33628. * * VertexBuffer.MatricesIndicesKind
  33629. * * VertexBuffer.MatricesIndicesExtraKind
  33630. * * VertexBuffer.MatricesWeightsKind
  33631. * * VertexBuffer.MatricesWeightsExtraKind
  33632. * @param data defines the data source
  33633. * @param updatable defines if the data must be flagged as updatable (or static)
  33634. * @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
  33635. * @returns the current mesh
  33636. */
  33637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33638. /**
  33639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33640. * If the mesh has no geometry, it is simply returned as it is.
  33641. * @param kind defines vertex data kind:
  33642. * * VertexBuffer.PositionKind
  33643. * * VertexBuffer.UVKind
  33644. * * VertexBuffer.UV2Kind
  33645. * * VertexBuffer.UV3Kind
  33646. * * VertexBuffer.UV4Kind
  33647. * * VertexBuffer.UV5Kind
  33648. * * VertexBuffer.UV6Kind
  33649. * * VertexBuffer.ColorKind
  33650. * * VertexBuffer.MatricesIndicesKind
  33651. * * VertexBuffer.MatricesIndicesExtraKind
  33652. * * VertexBuffer.MatricesWeightsKind
  33653. * * VertexBuffer.MatricesWeightsExtraKind
  33654. * @param data defines the data source
  33655. * @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
  33656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33657. * @returns the current mesh
  33658. */
  33659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33660. /**
  33661. * Sets the mesh indices,
  33662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33664. * @param totalVertices Defines the total number of vertices
  33665. * @returns the current mesh
  33666. */
  33667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33668. /**
  33669. * Gets a boolean indicating if specific vertex data is present
  33670. * @param kind defines the vertex data kind to use
  33671. * @returns true is data kind is present
  33672. */
  33673. isVerticesDataPresent(kind: string): boolean;
  33674. /**
  33675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33678. * @returns a BoundingInfo
  33679. */
  33680. getBoundingInfo(): BoundingInfo;
  33681. /**
  33682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33686. * @returns the current mesh
  33687. */
  33688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33689. /**
  33690. * Overwrite the current bounding info
  33691. * @param boundingInfo defines the new bounding info
  33692. * @returns the current mesh
  33693. */
  33694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33696. get useBones(): boolean;
  33697. /** @hidden */
  33698. _preActivate(): void;
  33699. /** @hidden */
  33700. _preActivateForIntermediateRendering(renderId: number): void;
  33701. /** @hidden */
  33702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33703. /** @hidden */
  33704. _postActivate(): void;
  33705. /** @hidden */
  33706. _freeze(): void;
  33707. /** @hidden */
  33708. _unFreeze(): void;
  33709. /**
  33710. * Gets the current world matrix
  33711. * @returns a Matrix
  33712. */
  33713. getWorldMatrix(): Matrix;
  33714. /** @hidden */
  33715. _getWorldMatrixDeterminant(): number;
  33716. /**
  33717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33718. */
  33719. get isAnInstance(): boolean;
  33720. /**
  33721. * Gets a boolean indicating if this mesh has instances
  33722. */
  33723. get hasInstances(): boolean;
  33724. /**
  33725. * Gets a boolean indicating if this mesh has thin instances
  33726. */
  33727. get hasThinInstances(): boolean;
  33728. /**
  33729. * Perform relative position change from the point of view of behind the front of the mesh.
  33730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33731. * Supports definition of mesh facing forward or backward
  33732. * @param amountRight defines the distance on the right axis
  33733. * @param amountUp defines the distance on the up axis
  33734. * @param amountForward defines the distance on the forward axis
  33735. * @returns the current mesh
  33736. */
  33737. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33738. /**
  33739. * Calculate relative position change from the point of view of behind the front of the mesh.
  33740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33741. * Supports definition of mesh facing forward or backward
  33742. * @param amountRight defines the distance on the right axis
  33743. * @param amountUp defines the distance on the up axis
  33744. * @param amountForward defines the distance on the forward axis
  33745. * @returns the new displacement vector
  33746. */
  33747. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33748. /**
  33749. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33750. * Supports definition of mesh facing forward or backward
  33751. * @param flipBack defines the flip
  33752. * @param twirlClockwise defines the twirl
  33753. * @param tiltRight defines the tilt
  33754. * @returns the current mesh
  33755. */
  33756. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33757. /**
  33758. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33759. * Supports definition of mesh facing forward or backward.
  33760. * @param flipBack defines the flip
  33761. * @param twirlClockwise defines the twirl
  33762. * @param tiltRight defines the tilt
  33763. * @returns the new rotation vector
  33764. */
  33765. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33766. /**
  33767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33768. * This means the mesh underlying bounding box and sphere are recomputed.
  33769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33770. * @returns the current mesh
  33771. */
  33772. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33773. /** @hidden */
  33774. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33775. /** @hidden */
  33776. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33777. /** @hidden */
  33778. _updateBoundingInfo(): AbstractMesh;
  33779. /** @hidden */
  33780. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33781. /** @hidden */
  33782. protected _afterComputeWorldMatrix(): void;
  33783. /** @hidden */
  33784. get _effectiveMesh(): AbstractMesh;
  33785. /**
  33786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33787. * A mesh is in the frustum if its bounding box intersects the frustum
  33788. * @param frustumPlanes defines the frustum to test
  33789. * @returns true if the mesh is in the frustum planes
  33790. */
  33791. isInFrustum(frustumPlanes: Plane[]): boolean;
  33792. /**
  33793. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33794. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33795. * @param frustumPlanes defines the frustum to test
  33796. * @returns true if the mesh is completely in the frustum planes
  33797. */
  33798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33799. /**
  33800. * True if the mesh intersects another mesh or a SolidParticle object
  33801. * @param mesh defines a target mesh or SolidParticle to test
  33802. * @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)
  33803. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33804. * @returns true if there is an intersection
  33805. */
  33806. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33807. /**
  33808. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33809. * @param point defines the point to test
  33810. * @returns true if there is an intersection
  33811. */
  33812. intersectsPoint(point: Vector3): boolean;
  33813. /**
  33814. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33815. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33816. */
  33817. get checkCollisions(): boolean;
  33818. set checkCollisions(collisionEnabled: boolean);
  33819. /**
  33820. * Gets Collider object used to compute collisions (not physics)
  33821. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33822. */
  33823. get collider(): Nullable<Collider>;
  33824. /**
  33825. * Move the mesh using collision engine
  33826. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33827. * @param displacement defines the requested displacement vector
  33828. * @returns the current mesh
  33829. */
  33830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33831. private _onCollisionPositionChange;
  33832. /** @hidden */
  33833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33834. /** @hidden */
  33835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33836. /** @hidden */
  33837. _checkCollision(collider: Collider): AbstractMesh;
  33838. /** @hidden */
  33839. _generatePointsArray(): boolean;
  33840. /**
  33841. * Checks if the passed Ray intersects with the mesh
  33842. * @param ray defines the ray to use
  33843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33845. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33846. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33847. * @returns the picking info
  33848. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33849. */
  33850. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33851. /**
  33852. * Clones the current mesh
  33853. * @param name defines the mesh name
  33854. * @param newParent defines the new mesh parent
  33855. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33856. * @returns the new mesh
  33857. */
  33858. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33859. /**
  33860. * Disposes all the submeshes of the current meshnp
  33861. * @returns the current mesh
  33862. */
  33863. releaseSubMeshes(): AbstractMesh;
  33864. /**
  33865. * Releases resources associated with this abstract mesh.
  33866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33868. */
  33869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33870. /**
  33871. * Adds the passed mesh as a child to the current mesh
  33872. * @param mesh defines the child mesh
  33873. * @returns the current mesh
  33874. */
  33875. addChild(mesh: AbstractMesh): AbstractMesh;
  33876. /**
  33877. * Removes the passed mesh from the current mesh children list
  33878. * @param mesh defines the child mesh
  33879. * @returns the current mesh
  33880. */
  33881. removeChild(mesh: AbstractMesh): AbstractMesh;
  33882. /** @hidden */
  33883. private _initFacetData;
  33884. /**
  33885. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33886. * This method can be called within the render loop.
  33887. * 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
  33888. * @returns the current mesh
  33889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33890. */
  33891. updateFacetData(): AbstractMesh;
  33892. /**
  33893. * Returns the facetLocalNormals array.
  33894. * The normals are expressed in the mesh local spac
  33895. * @returns an array of Vector3
  33896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33897. */
  33898. getFacetLocalNormals(): Vector3[];
  33899. /**
  33900. * Returns the facetLocalPositions array.
  33901. * The facet positions are expressed in the mesh local space
  33902. * @returns an array of Vector3
  33903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33904. */
  33905. getFacetLocalPositions(): Vector3[];
  33906. /**
  33907. * Returns the facetLocalPartioning array
  33908. * @returns an array of array of numbers
  33909. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33910. */
  33911. getFacetLocalPartitioning(): number[][];
  33912. /**
  33913. * Returns the i-th facet position in the world system.
  33914. * This method allocates a new Vector3 per call
  33915. * @param i defines the facet index
  33916. * @returns a new Vector3
  33917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33918. */
  33919. getFacetPosition(i: number): Vector3;
  33920. /**
  33921. * Sets the reference Vector3 with the i-th facet position in the world system
  33922. * @param i defines the facet index
  33923. * @param ref defines the target vector
  33924. * @returns the current mesh
  33925. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33926. */
  33927. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33928. /**
  33929. * Returns the i-th facet normal in the world system.
  33930. * This method allocates a new Vector3 per call
  33931. * @param i defines the facet index
  33932. * @returns a new Vector3
  33933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33934. */
  33935. getFacetNormal(i: number): Vector3;
  33936. /**
  33937. * Sets the reference Vector3 with the i-th facet normal in the world system
  33938. * @param i defines the facet index
  33939. * @param ref defines the target vector
  33940. * @returns the current mesh
  33941. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33942. */
  33943. getFacetNormalToRef(i: number, ref: Vector3): this;
  33944. /**
  33945. * 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)
  33946. * @param x defines x coordinate
  33947. * @param y defines y coordinate
  33948. * @param z defines z coordinate
  33949. * @returns the array of facet indexes
  33950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33951. */
  33952. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33953. /**
  33954. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33955. * @param projected sets as the (x,y,z) world projection on the facet
  33956. * @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
  33957. * @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
  33958. * @param x defines x coordinate
  33959. * @param y defines y coordinate
  33960. * @param z defines z coordinate
  33961. * @returns the face index if found (or null instead)
  33962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33963. */
  33964. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33965. /**
  33966. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33967. * @param projected sets as the (x,y,z) local projection on the facet
  33968. * @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
  33969. * @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
  33970. * @param x defines x coordinate
  33971. * @param y defines y coordinate
  33972. * @param z defines z coordinate
  33973. * @returns the face index if found (or null instead)
  33974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33975. */
  33976. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33977. /**
  33978. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33979. * @returns the parameters
  33980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33981. */
  33982. getFacetDataParameters(): any;
  33983. /**
  33984. * Disables the feature FacetData and frees the related memory
  33985. * @returns the current mesh
  33986. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33987. */
  33988. disableFacetData(): AbstractMesh;
  33989. /**
  33990. * Updates the AbstractMesh indices array
  33991. * @param indices defines the data source
  33992. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33993. * @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)
  33994. * @returns the current mesh
  33995. */
  33996. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33997. /**
  33998. * Creates new normals data for the mesh
  33999. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34000. * @returns the current mesh
  34001. */
  34002. createNormals(updatable: boolean): AbstractMesh;
  34003. /**
  34004. * Align the mesh with a normal
  34005. * @param normal defines the normal to use
  34006. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34007. * @returns the current mesh
  34008. */
  34009. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34010. /** @hidden */
  34011. _checkOcclusionQuery(): boolean;
  34012. /**
  34013. * Disables the mesh edge rendering mode
  34014. * @returns the currentAbstractMesh
  34015. */
  34016. disableEdgesRendering(): AbstractMesh;
  34017. /**
  34018. * Enables the edge rendering mode on the mesh.
  34019. * This mode makes the mesh edges visible
  34020. * @param epsilon defines the maximal distance between two angles to detect a face
  34021. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34022. * @returns the currentAbstractMesh
  34023. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34024. */
  34025. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34026. /**
  34027. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34028. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34029. */
  34030. getConnectedParticleSystems(): IParticleSystem[];
  34031. }
  34032. }
  34033. declare module "babylonjs/Actions/actionEvent" {
  34034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34035. import { Nullable } from "babylonjs/types";
  34036. import { Sprite } from "babylonjs/Sprites/sprite";
  34037. import { Scene } from "babylonjs/scene";
  34038. import { Vector2 } from "babylonjs/Maths/math.vector";
  34039. /**
  34040. * Interface used to define ActionEvent
  34041. */
  34042. export interface IActionEvent {
  34043. /** The mesh or sprite that triggered the action */
  34044. source: any;
  34045. /** The X mouse cursor position at the time of the event */
  34046. pointerX: number;
  34047. /** The Y mouse cursor position at the time of the event */
  34048. pointerY: number;
  34049. /** The mesh that is currently pointed at (can be null) */
  34050. meshUnderPointer: Nullable<AbstractMesh>;
  34051. /** the original (browser) event that triggered the ActionEvent */
  34052. sourceEvent?: any;
  34053. /** additional data for the event */
  34054. additionalData?: any;
  34055. }
  34056. /**
  34057. * ActionEvent is the event being sent when an action is triggered.
  34058. */
  34059. export class ActionEvent implements IActionEvent {
  34060. /** The mesh or sprite that triggered the action */
  34061. source: any;
  34062. /** The X mouse cursor position at the time of the event */
  34063. pointerX: number;
  34064. /** The Y mouse cursor position at the time of the event */
  34065. pointerY: number;
  34066. /** The mesh that is currently pointed at (can be null) */
  34067. meshUnderPointer: Nullable<AbstractMesh>;
  34068. /** the original (browser) event that triggered the ActionEvent */
  34069. sourceEvent?: any;
  34070. /** additional data for the event */
  34071. additionalData?: any;
  34072. /**
  34073. * Creates a new ActionEvent
  34074. * @param source The mesh or sprite that triggered the action
  34075. * @param pointerX The X mouse cursor position at the time of the event
  34076. * @param pointerY The Y mouse cursor position at the time of the event
  34077. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34078. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34079. * @param additionalData additional data for the event
  34080. */
  34081. constructor(
  34082. /** The mesh or sprite that triggered the action */
  34083. source: any,
  34084. /** The X mouse cursor position at the time of the event */
  34085. pointerX: number,
  34086. /** The Y mouse cursor position at the time of the event */
  34087. pointerY: number,
  34088. /** The mesh that is currently pointed at (can be null) */
  34089. meshUnderPointer: Nullable<AbstractMesh>,
  34090. /** the original (browser) event that triggered the ActionEvent */
  34091. sourceEvent?: any,
  34092. /** additional data for the event */
  34093. additionalData?: any);
  34094. /**
  34095. * Helper function to auto-create an ActionEvent from a source mesh.
  34096. * @param source The source mesh that triggered the event
  34097. * @param evt The original (browser) event
  34098. * @param additionalData additional data for the event
  34099. * @returns the new ActionEvent
  34100. */
  34101. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34102. /**
  34103. * Helper function to auto-create an ActionEvent from a source sprite
  34104. * @param source The source sprite that triggered the event
  34105. * @param scene Scene associated with the sprite
  34106. * @param evt The original (browser) event
  34107. * @param additionalData additional data for the event
  34108. * @returns the new ActionEvent
  34109. */
  34110. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34111. /**
  34112. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34113. * @param scene the scene where the event occurred
  34114. * @param evt The original (browser) event
  34115. * @returns the new ActionEvent
  34116. */
  34117. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34118. /**
  34119. * Helper function to auto-create an ActionEvent from a primitive
  34120. * @param prim defines the target primitive
  34121. * @param pointerPos defines the pointer position
  34122. * @param evt The original (browser) event
  34123. * @param additionalData additional data for the event
  34124. * @returns the new ActionEvent
  34125. */
  34126. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34127. }
  34128. }
  34129. declare module "babylonjs/Actions/abstractActionManager" {
  34130. import { IDisposable } from "babylonjs/scene";
  34131. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34132. import { IAction } from "babylonjs/Actions/action";
  34133. import { Nullable } from "babylonjs/types";
  34134. /**
  34135. * Abstract class used to decouple action Manager from scene and meshes.
  34136. * Do not instantiate.
  34137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34138. */
  34139. export abstract class AbstractActionManager implements IDisposable {
  34140. /** Gets the list of active triggers */
  34141. static Triggers: {
  34142. [key: string]: number;
  34143. };
  34144. /** Gets the cursor to use when hovering items */
  34145. hoverCursor: string;
  34146. /** Gets the list of actions */
  34147. actions: IAction[];
  34148. /**
  34149. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34150. */
  34151. isRecursive: boolean;
  34152. /**
  34153. * Releases all associated resources
  34154. */
  34155. abstract dispose(): void;
  34156. /**
  34157. * Does this action manager has pointer triggers
  34158. */
  34159. abstract get hasPointerTriggers(): boolean;
  34160. /**
  34161. * Does this action manager has pick triggers
  34162. */
  34163. abstract get hasPickTriggers(): boolean;
  34164. /**
  34165. * Process a specific trigger
  34166. * @param trigger defines the trigger to process
  34167. * @param evt defines the event details to be processed
  34168. */
  34169. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34170. /**
  34171. * Does this action manager handles actions of any of the given triggers
  34172. * @param triggers defines the triggers to be tested
  34173. * @return a boolean indicating whether one (or more) of the triggers is handled
  34174. */
  34175. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34176. /**
  34177. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34178. * speed.
  34179. * @param triggerA defines the trigger to be tested
  34180. * @param triggerB defines the trigger to be tested
  34181. * @return a boolean indicating whether one (or more) of the triggers is handled
  34182. */
  34183. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34184. /**
  34185. * Does this action manager handles actions of a given trigger
  34186. * @param trigger defines the trigger to be tested
  34187. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34188. * @return whether the trigger is handled
  34189. */
  34190. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34191. /**
  34192. * Serialize this manager to a JSON object
  34193. * @param name defines the property name to store this manager
  34194. * @returns a JSON representation of this manager
  34195. */
  34196. abstract serialize(name: string): any;
  34197. /**
  34198. * Registers an action to this action manager
  34199. * @param action defines the action to be registered
  34200. * @return the action amended (prepared) after registration
  34201. */
  34202. abstract registerAction(action: IAction): Nullable<IAction>;
  34203. /**
  34204. * Unregisters an action to this action manager
  34205. * @param action defines the action to be unregistered
  34206. * @return a boolean indicating whether the action has been unregistered
  34207. */
  34208. abstract unregisterAction(action: IAction): Boolean;
  34209. /**
  34210. * Does exist one action manager with at least one trigger
  34211. **/
  34212. static get HasTriggers(): boolean;
  34213. /**
  34214. * Does exist one action manager with at least one pick trigger
  34215. **/
  34216. static get HasPickTriggers(): boolean;
  34217. /**
  34218. * Does exist one action manager that handles actions of a given trigger
  34219. * @param trigger defines the trigger to be tested
  34220. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34221. **/
  34222. static HasSpecificTrigger(trigger: number): boolean;
  34223. }
  34224. }
  34225. declare module "babylonjs/node" {
  34226. import { Scene } from "babylonjs/scene";
  34227. import { Nullable } from "babylonjs/types";
  34228. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34229. import { Engine } from "babylonjs/Engines/engine";
  34230. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34231. import { Observable } from "babylonjs/Misc/observable";
  34232. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34233. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34234. import { Animatable } from "babylonjs/Animations/animatable";
  34235. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34236. import { Animation } from "babylonjs/Animations/animation";
  34237. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34239. /**
  34240. * Defines how a node can be built from a string name.
  34241. */
  34242. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34243. /**
  34244. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34245. */
  34246. export class Node implements IBehaviorAware<Node> {
  34247. /** @hidden */
  34248. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34249. private static _NodeConstructors;
  34250. /**
  34251. * Add a new node constructor
  34252. * @param type defines the type name of the node to construct
  34253. * @param constructorFunc defines the constructor function
  34254. */
  34255. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34256. /**
  34257. * Returns a node constructor based on type name
  34258. * @param type defines the type name
  34259. * @param name defines the new node name
  34260. * @param scene defines the hosting scene
  34261. * @param options defines optional options to transmit to constructors
  34262. * @returns the new constructor or null
  34263. */
  34264. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34265. /**
  34266. * Gets or sets the name of the node
  34267. */
  34268. name: string;
  34269. /**
  34270. * Gets or sets the id of the node
  34271. */
  34272. id: string;
  34273. /**
  34274. * Gets or sets the unique id of the node
  34275. */
  34276. uniqueId: number;
  34277. /**
  34278. * Gets or sets a string used to store user defined state for the node
  34279. */
  34280. state: string;
  34281. /**
  34282. * Gets or sets an object used to store user defined information for the node
  34283. */
  34284. metadata: any;
  34285. /**
  34286. * For internal use only. Please do not use.
  34287. */
  34288. reservedDataStore: any;
  34289. /**
  34290. * List of inspectable custom properties (used by the Inspector)
  34291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34292. */
  34293. inspectableCustomProperties: IInspectable[];
  34294. private _doNotSerialize;
  34295. /**
  34296. * Gets or sets a boolean used to define if the node must be serialized
  34297. */
  34298. get doNotSerialize(): boolean;
  34299. set doNotSerialize(value: boolean);
  34300. /** @hidden */
  34301. _isDisposed: boolean;
  34302. /**
  34303. * Gets a list of Animations associated with the node
  34304. */
  34305. animations: import("babylonjs/Animations/animation").Animation[];
  34306. protected _ranges: {
  34307. [name: string]: Nullable<AnimationRange>;
  34308. };
  34309. /**
  34310. * Callback raised when the node is ready to be used
  34311. */
  34312. onReady: Nullable<(node: Node) => void>;
  34313. private _isEnabled;
  34314. private _isParentEnabled;
  34315. private _isReady;
  34316. /** @hidden */
  34317. _currentRenderId: number;
  34318. private _parentUpdateId;
  34319. /** @hidden */
  34320. _childUpdateId: number;
  34321. /** @hidden */
  34322. _waitingParentId: Nullable<string>;
  34323. /** @hidden */
  34324. _scene: Scene;
  34325. /** @hidden */
  34326. _cache: any;
  34327. private _parentNode;
  34328. private _children;
  34329. /** @hidden */
  34330. _worldMatrix: Matrix;
  34331. /** @hidden */
  34332. _worldMatrixDeterminant: number;
  34333. /** @hidden */
  34334. _worldMatrixDeterminantIsDirty: boolean;
  34335. /** @hidden */
  34336. private _sceneRootNodesIndex;
  34337. /**
  34338. * Gets a boolean indicating if the node has been disposed
  34339. * @returns true if the node was disposed
  34340. */
  34341. isDisposed(): boolean;
  34342. /**
  34343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34344. * @see https://doc.babylonjs.com/how_to/parenting
  34345. */
  34346. set parent(parent: Nullable<Node>);
  34347. get parent(): Nullable<Node>;
  34348. /** @hidden */
  34349. _addToSceneRootNodes(): void;
  34350. /** @hidden */
  34351. _removeFromSceneRootNodes(): void;
  34352. private _animationPropertiesOverride;
  34353. /**
  34354. * Gets or sets the animation properties override
  34355. */
  34356. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34357. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34358. /**
  34359. * Gets a string identifying the name of the class
  34360. * @returns "Node" string
  34361. */
  34362. getClassName(): string;
  34363. /** @hidden */
  34364. readonly _isNode: boolean;
  34365. /**
  34366. * An event triggered when the mesh is disposed
  34367. */
  34368. onDisposeObservable: Observable<Node>;
  34369. private _onDisposeObserver;
  34370. /**
  34371. * Sets a callback that will be raised when the node will be disposed
  34372. */
  34373. set onDispose(callback: () => void);
  34374. /**
  34375. * Creates a new Node
  34376. * @param name the name and id to be given to this node
  34377. * @param scene the scene this node will be added to
  34378. */
  34379. constructor(name: string, scene?: Nullable<Scene>);
  34380. /**
  34381. * Gets the scene of the node
  34382. * @returns a scene
  34383. */
  34384. getScene(): Scene;
  34385. /**
  34386. * Gets the engine of the node
  34387. * @returns a Engine
  34388. */
  34389. getEngine(): Engine;
  34390. private _behaviors;
  34391. /**
  34392. * Attach a behavior to the node
  34393. * @see https://doc.babylonjs.com/features/behaviour
  34394. * @param behavior defines the behavior to attach
  34395. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34396. * @returns the current Node
  34397. */
  34398. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34399. /**
  34400. * Remove an attached behavior
  34401. * @see https://doc.babylonjs.com/features/behaviour
  34402. * @param behavior defines the behavior to attach
  34403. * @returns the current Node
  34404. */
  34405. removeBehavior(behavior: Behavior<Node>): Node;
  34406. /**
  34407. * Gets the list of attached behaviors
  34408. * @see https://doc.babylonjs.com/features/behaviour
  34409. */
  34410. get behaviors(): Behavior<Node>[];
  34411. /**
  34412. * Gets an attached behavior by name
  34413. * @param name defines the name of the behavior to look for
  34414. * @see https://doc.babylonjs.com/features/behaviour
  34415. * @returns null if behavior was not found else the requested behavior
  34416. */
  34417. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34418. /**
  34419. * Returns the latest update of the World matrix
  34420. * @returns a Matrix
  34421. */
  34422. getWorldMatrix(): Matrix;
  34423. /** @hidden */
  34424. _getWorldMatrixDeterminant(): number;
  34425. /**
  34426. * Returns directly the latest state of the mesh World matrix.
  34427. * A Matrix is returned.
  34428. */
  34429. get worldMatrixFromCache(): Matrix;
  34430. /** @hidden */
  34431. _initCache(): void;
  34432. /** @hidden */
  34433. updateCache(force?: boolean): void;
  34434. /** @hidden */
  34435. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34436. /** @hidden */
  34437. _updateCache(ignoreParentClass?: boolean): void;
  34438. /** @hidden */
  34439. _isSynchronized(): boolean;
  34440. /** @hidden */
  34441. _markSyncedWithParent(): void;
  34442. /** @hidden */
  34443. isSynchronizedWithParent(): boolean;
  34444. /** @hidden */
  34445. isSynchronized(): boolean;
  34446. /**
  34447. * Is this node ready to be used/rendered
  34448. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34449. * @return true if the node is ready
  34450. */
  34451. isReady(completeCheck?: boolean): boolean;
  34452. /**
  34453. * Is this node enabled?
  34454. * 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
  34455. * @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
  34456. * @return whether this node (and its parent) is enabled
  34457. */
  34458. isEnabled(checkAncestors?: boolean): boolean;
  34459. /** @hidden */
  34460. protected _syncParentEnabledState(): void;
  34461. /**
  34462. * Set the enabled state of this node
  34463. * @param value defines the new enabled state
  34464. */
  34465. setEnabled(value: boolean): void;
  34466. /**
  34467. * Is this node a descendant of the given node?
  34468. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34469. * @param ancestor defines the parent node to inspect
  34470. * @returns a boolean indicating if this node is a descendant of the given node
  34471. */
  34472. isDescendantOf(ancestor: Node): boolean;
  34473. /** @hidden */
  34474. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34475. /**
  34476. * Will return all nodes that have this node as ascendant
  34477. * @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
  34478. * @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
  34479. * @return all children nodes of all types
  34480. */
  34481. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34482. /**
  34483. * Get all child-meshes of this node
  34484. * @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)
  34485. * @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
  34486. * @returns an array of AbstractMesh
  34487. */
  34488. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34489. /**
  34490. * Get all direct children of this node
  34491. * @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
  34492. * @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)
  34493. * @returns an array of Node
  34494. */
  34495. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34496. /** @hidden */
  34497. _setReady(state: boolean): void;
  34498. /**
  34499. * Get an animation by name
  34500. * @param name defines the name of the animation to look for
  34501. * @returns null if not found else the requested animation
  34502. */
  34503. getAnimationByName(name: string): Nullable<Animation>;
  34504. /**
  34505. * Creates an animation range for this node
  34506. * @param name defines the name of the range
  34507. * @param from defines the starting key
  34508. * @param to defines the end key
  34509. */
  34510. createAnimationRange(name: string, from: number, to: number): void;
  34511. /**
  34512. * Delete a specific animation range
  34513. * @param name defines the name of the range to delete
  34514. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34515. */
  34516. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34517. /**
  34518. * Get an animation range by name
  34519. * @param name defines the name of the animation range to look for
  34520. * @returns null if not found else the requested animation range
  34521. */
  34522. getAnimationRange(name: string): Nullable<AnimationRange>;
  34523. /**
  34524. * Gets the list of all animation ranges defined on this node
  34525. * @returns an array
  34526. */
  34527. getAnimationRanges(): Nullable<AnimationRange>[];
  34528. /**
  34529. * Will start the animation sequence
  34530. * @param name defines the range frames for animation sequence
  34531. * @param loop defines if the animation should loop (false by default)
  34532. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34533. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34534. * @returns the object created for this animation. If range does not exist, it will return null
  34535. */
  34536. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34537. /**
  34538. * Serialize animation ranges into a JSON compatible object
  34539. * @returns serialization object
  34540. */
  34541. serializeAnimationRanges(): any;
  34542. /**
  34543. * Computes the world matrix of the node
  34544. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34545. * @returns the world matrix
  34546. */
  34547. computeWorldMatrix(force?: boolean): Matrix;
  34548. /**
  34549. * Releases resources associated with this node.
  34550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34552. */
  34553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34554. /**
  34555. * Parse animation range data from a serialization object and store them into a given node
  34556. * @param node defines where to store the animation ranges
  34557. * @param parsedNode defines the serialization object to read data from
  34558. * @param scene defines the hosting scene
  34559. */
  34560. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34561. /**
  34562. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34563. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34564. * @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
  34565. * @returns the new bounding vectors
  34566. */
  34567. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34568. min: Vector3;
  34569. max: Vector3;
  34570. };
  34571. }
  34572. }
  34573. declare module "babylonjs/Animations/animation" {
  34574. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34575. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34576. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34577. import { Nullable } from "babylonjs/types";
  34578. import { Scene } from "babylonjs/scene";
  34579. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34580. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34581. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34582. import { Node } from "babylonjs/node";
  34583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34584. import { Size } from "babylonjs/Maths/math.size";
  34585. import { Animatable } from "babylonjs/Animations/animatable";
  34586. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34587. /**
  34588. * @hidden
  34589. */
  34590. export class _IAnimationState {
  34591. key: number;
  34592. repeatCount: number;
  34593. workValue?: any;
  34594. loopMode?: number;
  34595. offsetValue?: any;
  34596. highLimitValue?: any;
  34597. }
  34598. /**
  34599. * Class used to store any kind of animation
  34600. */
  34601. export class Animation {
  34602. /**Name of the animation */
  34603. name: string;
  34604. /**Property to animate */
  34605. targetProperty: string;
  34606. /**The frames per second of the animation */
  34607. framePerSecond: number;
  34608. /**The data type of the animation */
  34609. dataType: number;
  34610. /**The loop mode of the animation */
  34611. loopMode?: number | undefined;
  34612. /**Specifies if blending should be enabled */
  34613. enableBlending?: boolean | undefined;
  34614. /**
  34615. * Use matrix interpolation instead of using direct key value when animating matrices
  34616. */
  34617. static AllowMatricesInterpolation: boolean;
  34618. /**
  34619. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34620. */
  34621. static AllowMatrixDecomposeForInterpolation: boolean;
  34622. /** Define the Url to load snippets */
  34623. static SnippetUrl: string;
  34624. /** Snippet ID if the animation was created from the snippet server */
  34625. snippetId: string;
  34626. /**
  34627. * Stores the key frames of the animation
  34628. */
  34629. private _keys;
  34630. /**
  34631. * Stores the easing function of the animation
  34632. */
  34633. private _easingFunction;
  34634. /**
  34635. * @hidden Internal use only
  34636. */
  34637. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34638. /**
  34639. * The set of event that will be linked to this animation
  34640. */
  34641. private _events;
  34642. /**
  34643. * Stores an array of target property paths
  34644. */
  34645. targetPropertyPath: string[];
  34646. /**
  34647. * Stores the blending speed of the animation
  34648. */
  34649. blendingSpeed: number;
  34650. /**
  34651. * Stores the animation ranges for the animation
  34652. */
  34653. private _ranges;
  34654. /**
  34655. * @hidden Internal use
  34656. */
  34657. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34658. /**
  34659. * Sets up an animation
  34660. * @param property The property to animate
  34661. * @param animationType The animation type to apply
  34662. * @param framePerSecond The frames per second of the animation
  34663. * @param easingFunction The easing function used in the animation
  34664. * @returns The created animation
  34665. */
  34666. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34667. /**
  34668. * Create and start an animation on a node
  34669. * @param name defines the name of the global animation that will be run on all nodes
  34670. * @param node defines the root node where the animation will take place
  34671. * @param targetProperty defines property to animate
  34672. * @param framePerSecond defines the number of frame per second yo use
  34673. * @param totalFrame defines the number of frames in total
  34674. * @param from defines the initial value
  34675. * @param to defines the final value
  34676. * @param loopMode defines which loop mode you want to use (off by default)
  34677. * @param easingFunction defines the easing function to use (linear by default)
  34678. * @param onAnimationEnd defines the callback to call when animation end
  34679. * @returns the animatable created for this animation
  34680. */
  34681. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34682. /**
  34683. * Create and start an animation on a node and its descendants
  34684. * @param name defines the name of the global animation that will be run on all nodes
  34685. * @param node defines the root node where the animation will take place
  34686. * @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
  34687. * @param targetProperty defines property to animate
  34688. * @param framePerSecond defines the number of frame per second to use
  34689. * @param totalFrame defines the number of frames in total
  34690. * @param from defines the initial value
  34691. * @param to defines the final value
  34692. * @param loopMode defines which loop mode you want to use (off by default)
  34693. * @param easingFunction defines the easing function to use (linear by default)
  34694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34695. * @returns the list of animatables created for all nodes
  34696. * @example https://www.babylonjs-playground.com/#MH0VLI
  34697. */
  34698. 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[]>;
  34699. /**
  34700. * Creates a new animation, merges it with the existing animations and starts it
  34701. * @param name Name of the animation
  34702. * @param node Node which contains the scene that begins the animations
  34703. * @param targetProperty Specifies which property to animate
  34704. * @param framePerSecond The frames per second of the animation
  34705. * @param totalFrame The total number of frames
  34706. * @param from The frame at the beginning of the animation
  34707. * @param to The frame at the end of the animation
  34708. * @param loopMode Specifies the loop mode of the animation
  34709. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34710. * @param onAnimationEnd Callback to run once the animation is complete
  34711. * @returns Nullable animation
  34712. */
  34713. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34714. /**
  34715. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34716. * @param sourceAnimation defines the Animation containing keyframes to convert
  34717. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34718. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34719. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34720. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34721. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34722. */
  34723. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34724. /**
  34725. * Transition property of an host to the target Value
  34726. * @param property The property to transition
  34727. * @param targetValue The target Value of the property
  34728. * @param host The object where the property to animate belongs
  34729. * @param scene Scene used to run the animation
  34730. * @param frameRate Framerate (in frame/s) to use
  34731. * @param transition The transition type we want to use
  34732. * @param duration The duration of the animation, in milliseconds
  34733. * @param onAnimationEnd Callback trigger at the end of the animation
  34734. * @returns Nullable animation
  34735. */
  34736. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34737. /**
  34738. * Return the array of runtime animations currently using this animation
  34739. */
  34740. get runtimeAnimations(): RuntimeAnimation[];
  34741. /**
  34742. * Specifies if any of the runtime animations are currently running
  34743. */
  34744. get hasRunningRuntimeAnimations(): boolean;
  34745. /**
  34746. * Initializes the animation
  34747. * @param name Name of the animation
  34748. * @param targetProperty Property to animate
  34749. * @param framePerSecond The frames per second of the animation
  34750. * @param dataType The data type of the animation
  34751. * @param loopMode The loop mode of the animation
  34752. * @param enableBlending Specifies if blending should be enabled
  34753. */
  34754. constructor(
  34755. /**Name of the animation */
  34756. name: string,
  34757. /**Property to animate */
  34758. targetProperty: string,
  34759. /**The frames per second of the animation */
  34760. framePerSecond: number,
  34761. /**The data type of the animation */
  34762. dataType: number,
  34763. /**The loop mode of the animation */
  34764. loopMode?: number | undefined,
  34765. /**Specifies if blending should be enabled */
  34766. enableBlending?: boolean | undefined);
  34767. /**
  34768. * Converts the animation to a string
  34769. * @param fullDetails support for multiple levels of logging within scene loading
  34770. * @returns String form of the animation
  34771. */
  34772. toString(fullDetails?: boolean): string;
  34773. /**
  34774. * Add an event to this animation
  34775. * @param event Event to add
  34776. */
  34777. addEvent(event: AnimationEvent): void;
  34778. /**
  34779. * Remove all events found at the given frame
  34780. * @param frame The frame to remove events from
  34781. */
  34782. removeEvents(frame: number): void;
  34783. /**
  34784. * Retrieves all the events from the animation
  34785. * @returns Events from the animation
  34786. */
  34787. getEvents(): AnimationEvent[];
  34788. /**
  34789. * Creates an animation range
  34790. * @param name Name of the animation range
  34791. * @param from Starting frame of the animation range
  34792. * @param to Ending frame of the animation
  34793. */
  34794. createRange(name: string, from: number, to: number): void;
  34795. /**
  34796. * Deletes an animation range by name
  34797. * @param name Name of the animation range to delete
  34798. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34799. */
  34800. deleteRange(name: string, deleteFrames?: boolean): void;
  34801. /**
  34802. * Gets the animation range by name, or null if not defined
  34803. * @param name Name of the animation range
  34804. * @returns Nullable animation range
  34805. */
  34806. getRange(name: string): Nullable<AnimationRange>;
  34807. /**
  34808. * Gets the key frames from the animation
  34809. * @returns The key frames of the animation
  34810. */
  34811. getKeys(): Array<IAnimationKey>;
  34812. /**
  34813. * Gets the highest frame rate of the animation
  34814. * @returns Highest frame rate of the animation
  34815. */
  34816. getHighestFrame(): number;
  34817. /**
  34818. * Gets the easing function of the animation
  34819. * @returns Easing function of the animation
  34820. */
  34821. getEasingFunction(): IEasingFunction;
  34822. /**
  34823. * Sets the easing function of the animation
  34824. * @param easingFunction A custom mathematical formula for animation
  34825. */
  34826. setEasingFunction(easingFunction: EasingFunction): void;
  34827. /**
  34828. * Interpolates a scalar linearly
  34829. * @param startValue Start value of the animation curve
  34830. * @param endValue End value of the animation curve
  34831. * @param gradient Scalar amount to interpolate
  34832. * @returns Interpolated scalar value
  34833. */
  34834. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34835. /**
  34836. * Interpolates a scalar cubically
  34837. * @param startValue Start value of the animation curve
  34838. * @param outTangent End tangent of the animation
  34839. * @param endValue End value of the animation curve
  34840. * @param inTangent Start tangent of the animation curve
  34841. * @param gradient Scalar amount to interpolate
  34842. * @returns Interpolated scalar value
  34843. */
  34844. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34845. /**
  34846. * Interpolates a quaternion using a spherical linear interpolation
  34847. * @param startValue Start value of the animation curve
  34848. * @param endValue End value of the animation curve
  34849. * @param gradient Scalar amount to interpolate
  34850. * @returns Interpolated quaternion value
  34851. */
  34852. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34853. /**
  34854. * Interpolates a quaternion cubically
  34855. * @param startValue Start value of the animation curve
  34856. * @param outTangent End tangent of the animation curve
  34857. * @param endValue End value of the animation curve
  34858. * @param inTangent Start tangent of the animation curve
  34859. * @param gradient Scalar amount to interpolate
  34860. * @returns Interpolated quaternion value
  34861. */
  34862. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34863. /**
  34864. * Interpolates a Vector3 linearl
  34865. * @param startValue Start value of the animation curve
  34866. * @param endValue End value of the animation curve
  34867. * @param gradient Scalar amount to interpolate
  34868. * @returns Interpolated scalar value
  34869. */
  34870. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34871. /**
  34872. * Interpolates a Vector3 cubically
  34873. * @param startValue Start value of the animation curve
  34874. * @param outTangent End tangent of the animation
  34875. * @param endValue End value of the animation curve
  34876. * @param inTangent Start tangent of the animation curve
  34877. * @param gradient Scalar amount to interpolate
  34878. * @returns InterpolatedVector3 value
  34879. */
  34880. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34881. /**
  34882. * Interpolates a Vector2 linearly
  34883. * @param startValue Start value of the animation curve
  34884. * @param endValue End value of the animation curve
  34885. * @param gradient Scalar amount to interpolate
  34886. * @returns Interpolated Vector2 value
  34887. */
  34888. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34889. /**
  34890. * Interpolates a Vector2 cubically
  34891. * @param startValue Start value of the animation curve
  34892. * @param outTangent End tangent of the animation
  34893. * @param endValue End value of the animation curve
  34894. * @param inTangent Start tangent of the animation curve
  34895. * @param gradient Scalar amount to interpolate
  34896. * @returns Interpolated Vector2 value
  34897. */
  34898. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34899. /**
  34900. * Interpolates a size linearly
  34901. * @param startValue Start value of the animation curve
  34902. * @param endValue End value of the animation curve
  34903. * @param gradient Scalar amount to interpolate
  34904. * @returns Interpolated Size value
  34905. */
  34906. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34907. /**
  34908. * Interpolates a Color3 linearly
  34909. * @param startValue Start value of the animation curve
  34910. * @param endValue End value of the animation curve
  34911. * @param gradient Scalar amount to interpolate
  34912. * @returns Interpolated Color3 value
  34913. */
  34914. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34915. /**
  34916. * Interpolates a Color4 linearly
  34917. * @param startValue Start value of the animation curve
  34918. * @param endValue End value of the animation curve
  34919. * @param gradient Scalar amount to interpolate
  34920. * @returns Interpolated Color3 value
  34921. */
  34922. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34923. /**
  34924. * @hidden Internal use only
  34925. */
  34926. _getKeyValue(value: any): any;
  34927. /**
  34928. * @hidden Internal use only
  34929. */
  34930. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34931. /**
  34932. * Defines the function to use to interpolate matrices
  34933. * @param startValue defines the start matrix
  34934. * @param endValue defines the end matrix
  34935. * @param gradient defines the gradient between both matrices
  34936. * @param result defines an optional target matrix where to store the interpolation
  34937. * @returns the interpolated matrix
  34938. */
  34939. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34940. /**
  34941. * Makes a copy of the animation
  34942. * @returns Cloned animation
  34943. */
  34944. clone(): Animation;
  34945. /**
  34946. * Sets the key frames of the animation
  34947. * @param values The animation key frames to set
  34948. */
  34949. setKeys(values: Array<IAnimationKey>): void;
  34950. /**
  34951. * Serializes the animation to an object
  34952. * @returns Serialized object
  34953. */
  34954. serialize(): any;
  34955. /**
  34956. * Float animation type
  34957. */
  34958. static readonly ANIMATIONTYPE_FLOAT: number;
  34959. /**
  34960. * Vector3 animation type
  34961. */
  34962. static readonly ANIMATIONTYPE_VECTOR3: number;
  34963. /**
  34964. * Quaternion animation type
  34965. */
  34966. static readonly ANIMATIONTYPE_QUATERNION: number;
  34967. /**
  34968. * Matrix animation type
  34969. */
  34970. static readonly ANIMATIONTYPE_MATRIX: number;
  34971. /**
  34972. * Color3 animation type
  34973. */
  34974. static readonly ANIMATIONTYPE_COLOR3: number;
  34975. /**
  34976. * Color3 animation type
  34977. */
  34978. static readonly ANIMATIONTYPE_COLOR4: number;
  34979. /**
  34980. * Vector2 animation type
  34981. */
  34982. static readonly ANIMATIONTYPE_VECTOR2: number;
  34983. /**
  34984. * Size animation type
  34985. */
  34986. static readonly ANIMATIONTYPE_SIZE: number;
  34987. /**
  34988. * Relative Loop Mode
  34989. */
  34990. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34991. /**
  34992. * Cycle Loop Mode
  34993. */
  34994. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34995. /**
  34996. * Constant Loop Mode
  34997. */
  34998. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34999. /** @hidden */
  35000. static _UniversalLerp(left: any, right: any, amount: number): any;
  35001. /**
  35002. * Parses an animation object and creates an animation
  35003. * @param parsedAnimation Parsed animation object
  35004. * @returns Animation object
  35005. */
  35006. static Parse(parsedAnimation: any): Animation;
  35007. /**
  35008. * Appends the serialized animations from the source animations
  35009. * @param source Source containing the animations
  35010. * @param destination Target to store the animations
  35011. */
  35012. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35013. /**
  35014. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35015. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35016. * @param url defines the url to load from
  35017. * @returns a promise that will resolve to the new animation or an array of animations
  35018. */
  35019. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35020. /**
  35021. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35022. * @param snippetId defines the snippet to load
  35023. * @returns a promise that will resolve to the new animation or a new array of animations
  35024. */
  35025. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35026. }
  35027. }
  35028. declare module "babylonjs/Animations/animatable.interface" {
  35029. import { Nullable } from "babylonjs/types";
  35030. import { Animation } from "babylonjs/Animations/animation";
  35031. /**
  35032. * Interface containing an array of animations
  35033. */
  35034. export interface IAnimatable {
  35035. /**
  35036. * Array of animations
  35037. */
  35038. animations: Nullable<Array<Animation>>;
  35039. }
  35040. }
  35041. declare module "babylonjs/Misc/decorators" {
  35042. import { Nullable } from "babylonjs/types";
  35043. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35044. import { Scene } from "babylonjs/scene";
  35045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35046. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35047. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35049. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35050. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35051. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35052. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35053. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35054. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. /**
  35063. * Decorator used to define property that can be serialized as reference to a camera
  35064. * @param sourceName defines the name of the property to decorate
  35065. */
  35066. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35067. /**
  35068. * Class used to help serialization objects
  35069. */
  35070. export class SerializationHelper {
  35071. /** @hidden */
  35072. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35073. /** @hidden */
  35074. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35075. /** @hidden */
  35076. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35077. /** @hidden */
  35078. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35079. /**
  35080. * Appends the serialized animations from the source animations
  35081. * @param source Source containing the animations
  35082. * @param destination Target to store the animations
  35083. */
  35084. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35085. /**
  35086. * Static function used to serialized a specific entity
  35087. * @param entity defines the entity to serialize
  35088. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35089. * @returns a JSON compatible object representing the serialization of the entity
  35090. */
  35091. static Serialize<T>(entity: T, serializationObject?: any): any;
  35092. /**
  35093. * Creates a new entity from a serialization data object
  35094. * @param creationFunction defines a function used to instanciated the new entity
  35095. * @param source defines the source serialization data
  35096. * @param scene defines the hosting scene
  35097. * @param rootUrl defines the root url for resources
  35098. * @returns a new entity
  35099. */
  35100. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35101. /**
  35102. * Clones an object
  35103. * @param creationFunction defines the function used to instanciate the new object
  35104. * @param source defines the source object
  35105. * @returns the cloned object
  35106. */
  35107. static Clone<T>(creationFunction: () => T, source: T): T;
  35108. /**
  35109. * Instanciates a new object based on a source one (some data will be shared between both object)
  35110. * @param creationFunction defines the function used to instanciate the new object
  35111. * @param source defines the source object
  35112. * @returns the new object
  35113. */
  35114. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35115. }
  35116. }
  35117. declare module "babylonjs/Materials/Textures/baseTexture" {
  35118. import { Observable } from "babylonjs/Misc/observable";
  35119. import { Nullable } from "babylonjs/types";
  35120. import { Scene } from "babylonjs/scene";
  35121. import { Matrix } from "babylonjs/Maths/math.vector";
  35122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35124. import { ISize } from "babylonjs/Maths/math.size";
  35125. import "babylonjs/Misc/fileTools";
  35126. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35127. /**
  35128. * Base class of all the textures in babylon.
  35129. * It groups all the common properties the materials, post process, lights... might need
  35130. * in order to make a correct use of the texture.
  35131. */
  35132. export class BaseTexture implements IAnimatable {
  35133. /**
  35134. * Default anisotropic filtering level for the application.
  35135. * It is set to 4 as a good tradeoff between perf and quality.
  35136. */
  35137. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35138. /**
  35139. * Gets or sets the unique id of the texture
  35140. */
  35141. uniqueId: number;
  35142. /**
  35143. * Define the name of the texture.
  35144. */
  35145. name: string;
  35146. /**
  35147. * Gets or sets an object used to store user defined information.
  35148. */
  35149. metadata: any;
  35150. /**
  35151. * For internal use only. Please do not use.
  35152. */
  35153. reservedDataStore: any;
  35154. private _hasAlpha;
  35155. /**
  35156. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35157. */
  35158. set hasAlpha(value: boolean);
  35159. get hasAlpha(): boolean;
  35160. /**
  35161. * Defines if the alpha value should be determined via the rgb values.
  35162. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35163. */
  35164. getAlphaFromRGB: boolean;
  35165. /**
  35166. * Intensity or strength of the texture.
  35167. * It is commonly used by materials to fine tune the intensity of the texture
  35168. */
  35169. level: number;
  35170. /**
  35171. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35172. * This is part of the texture as textures usually maps to one uv set.
  35173. */
  35174. coordinatesIndex: number;
  35175. protected _coordinatesMode: number;
  35176. /**
  35177. * How a texture is mapped.
  35178. *
  35179. * | Value | Type | Description |
  35180. * | ----- | ----------------------------------- | ----------- |
  35181. * | 0 | EXPLICIT_MODE | |
  35182. * | 1 | SPHERICAL_MODE | |
  35183. * | 2 | PLANAR_MODE | |
  35184. * | 3 | CUBIC_MODE | |
  35185. * | 4 | PROJECTION_MODE | |
  35186. * | 5 | SKYBOX_MODE | |
  35187. * | 6 | INVCUBIC_MODE | |
  35188. * | 7 | EQUIRECTANGULAR_MODE | |
  35189. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35190. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35191. */
  35192. set coordinatesMode(value: number);
  35193. get coordinatesMode(): number;
  35194. private _wrapU;
  35195. /**
  35196. * | Value | Type | Description |
  35197. * | ----- | ------------------ | ----------- |
  35198. * | 0 | CLAMP_ADDRESSMODE | |
  35199. * | 1 | WRAP_ADDRESSMODE | |
  35200. * | 2 | MIRROR_ADDRESSMODE | |
  35201. */
  35202. get wrapU(): number;
  35203. set wrapU(value: number);
  35204. private _wrapV;
  35205. /**
  35206. * | Value | Type | Description |
  35207. * | ----- | ------------------ | ----------- |
  35208. * | 0 | CLAMP_ADDRESSMODE | |
  35209. * | 1 | WRAP_ADDRESSMODE | |
  35210. * | 2 | MIRROR_ADDRESSMODE | |
  35211. */
  35212. get wrapV(): number;
  35213. set wrapV(value: number);
  35214. /**
  35215. * | Value | Type | Description |
  35216. * | ----- | ------------------ | ----------- |
  35217. * | 0 | CLAMP_ADDRESSMODE | |
  35218. * | 1 | WRAP_ADDRESSMODE | |
  35219. * | 2 | MIRROR_ADDRESSMODE | |
  35220. */
  35221. wrapR: number;
  35222. /**
  35223. * With compliant hardware and browser (supporting anisotropic filtering)
  35224. * this defines the level of anisotropic filtering in the texture.
  35225. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35226. */
  35227. anisotropicFilteringLevel: number;
  35228. /**
  35229. * Define if the texture is a cube texture or if false a 2d texture.
  35230. */
  35231. get isCube(): boolean;
  35232. set isCube(value: boolean);
  35233. /**
  35234. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35235. */
  35236. get is3D(): boolean;
  35237. set is3D(value: boolean);
  35238. /**
  35239. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35240. */
  35241. get is2DArray(): boolean;
  35242. set is2DArray(value: boolean);
  35243. private _gammaSpace;
  35244. /**
  35245. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35246. * HDR texture are usually stored in linear space.
  35247. * This only impacts the PBR and Background materials
  35248. */
  35249. get gammaSpace(): boolean;
  35250. set gammaSpace(gamma: boolean);
  35251. /**
  35252. * Gets or sets whether or not the texture contains RGBD data.
  35253. */
  35254. get isRGBD(): boolean;
  35255. set isRGBD(value: boolean);
  35256. /**
  35257. * Is Z inverted in the texture (useful in a cube texture).
  35258. */
  35259. invertZ: boolean;
  35260. /**
  35261. * Are mip maps generated for this texture or not.
  35262. */
  35263. get noMipmap(): boolean;
  35264. /**
  35265. * @hidden
  35266. */
  35267. lodLevelInAlpha: boolean;
  35268. /**
  35269. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35270. */
  35271. get lodGenerationOffset(): number;
  35272. set lodGenerationOffset(value: number);
  35273. /**
  35274. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35275. */
  35276. get lodGenerationScale(): number;
  35277. set lodGenerationScale(value: number);
  35278. /**
  35279. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35280. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35281. * average roughness values.
  35282. */
  35283. get linearSpecularLOD(): boolean;
  35284. set linearSpecularLOD(value: boolean);
  35285. /**
  35286. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35287. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35288. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35289. */
  35290. get irradianceTexture(): Nullable<BaseTexture>;
  35291. set irradianceTexture(value: Nullable<BaseTexture>);
  35292. /**
  35293. * Define if the texture is a render target.
  35294. */
  35295. isRenderTarget: boolean;
  35296. /**
  35297. * Define the unique id of the texture in the scene.
  35298. */
  35299. get uid(): string;
  35300. /** @hidden */
  35301. _prefiltered: boolean;
  35302. /**
  35303. * Return a string representation of the texture.
  35304. * @returns the texture as a string
  35305. */
  35306. toString(): string;
  35307. /**
  35308. * Get the class name of the texture.
  35309. * @returns "BaseTexture"
  35310. */
  35311. getClassName(): string;
  35312. /**
  35313. * Define the list of animation attached to the texture.
  35314. */
  35315. animations: import("babylonjs/Animations/animation").Animation[];
  35316. /**
  35317. * An event triggered when the texture is disposed.
  35318. */
  35319. onDisposeObservable: Observable<BaseTexture>;
  35320. private _onDisposeObserver;
  35321. /**
  35322. * Callback triggered when the texture has been disposed.
  35323. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35324. */
  35325. set onDispose(callback: () => void);
  35326. /**
  35327. * Define the current state of the loading sequence when in delayed load mode.
  35328. */
  35329. delayLoadState: number;
  35330. protected _scene: Nullable<Scene>;
  35331. protected _engine: Nullable<ThinEngine>;
  35332. /** @hidden */
  35333. _texture: Nullable<InternalTexture>;
  35334. private _uid;
  35335. /**
  35336. * Define if the texture is preventinga material to render or not.
  35337. * If not and the texture is not ready, the engine will use a default black texture instead.
  35338. */
  35339. get isBlocking(): boolean;
  35340. /**
  35341. * Instantiates a new BaseTexture.
  35342. * Base class of all the textures in babylon.
  35343. * It groups all the common properties the materials, post process, lights... might need
  35344. * in order to make a correct use of the texture.
  35345. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35346. */
  35347. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35348. /**
  35349. * Get the scene the texture belongs to.
  35350. * @returns the scene or null if undefined
  35351. */
  35352. getScene(): Nullable<Scene>;
  35353. /** @hidden */
  35354. protected _getEngine(): Nullable<ThinEngine>;
  35355. /**
  35356. * Get the texture transform matrix used to offset tile the texture for istance.
  35357. * @returns the transformation matrix
  35358. */
  35359. getTextureMatrix(): Matrix;
  35360. /**
  35361. * Get the texture reflection matrix used to rotate/transform the reflection.
  35362. * @returns the reflection matrix
  35363. */
  35364. getReflectionTextureMatrix(): Matrix;
  35365. /**
  35366. * Get the underlying lower level texture from Babylon.
  35367. * @returns the insternal texture
  35368. */
  35369. getInternalTexture(): Nullable<InternalTexture>;
  35370. /**
  35371. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35372. * @returns true if ready or not blocking
  35373. */
  35374. isReadyOrNotBlocking(): boolean;
  35375. /**
  35376. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35377. * @returns true if fully ready
  35378. */
  35379. isReady(): boolean;
  35380. private _cachedSize;
  35381. /**
  35382. * Get the size of the texture.
  35383. * @returns the texture size.
  35384. */
  35385. getSize(): ISize;
  35386. /**
  35387. * Get the base size of the texture.
  35388. * It can be different from the size if the texture has been resized for POT for instance
  35389. * @returns the base size
  35390. */
  35391. getBaseSize(): ISize;
  35392. /**
  35393. * Update the sampling mode of the texture.
  35394. * Default is Trilinear mode.
  35395. *
  35396. * | Value | Type | Description |
  35397. * | ----- | ------------------ | ----------- |
  35398. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35399. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35400. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35401. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35402. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35403. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35404. * | 7 | NEAREST_LINEAR | |
  35405. * | 8 | NEAREST_NEAREST | |
  35406. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35407. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35408. * | 11 | LINEAR_LINEAR | |
  35409. * | 12 | LINEAR_NEAREST | |
  35410. *
  35411. * > _mag_: magnification filter (close to the viewer)
  35412. * > _min_: minification filter (far from the viewer)
  35413. * > _mip_: filter used between mip map levels
  35414. *@param samplingMode Define the new sampling mode of the texture
  35415. */
  35416. updateSamplingMode(samplingMode: number): void;
  35417. /**
  35418. * Scales the texture if is `canRescale()`
  35419. * @param ratio the resize factor we want to use to rescale
  35420. */
  35421. scale(ratio: number): void;
  35422. /**
  35423. * Get if the texture can rescale.
  35424. */
  35425. get canRescale(): boolean;
  35426. /** @hidden */
  35427. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35428. /** @hidden */
  35429. _rebuild(): void;
  35430. /**
  35431. * Triggers the load sequence in delayed load mode.
  35432. */
  35433. delayLoad(): void;
  35434. /**
  35435. * Clones the texture.
  35436. * @returns the cloned texture
  35437. */
  35438. clone(): Nullable<BaseTexture>;
  35439. /**
  35440. * Get the texture underlying type (INT, FLOAT...)
  35441. */
  35442. get textureType(): number;
  35443. /**
  35444. * Get the texture underlying format (RGB, RGBA...)
  35445. */
  35446. get textureFormat(): number;
  35447. /**
  35448. * Indicates that textures need to be re-calculated for all materials
  35449. */
  35450. protected _markAllSubMeshesAsTexturesDirty(): void;
  35451. /**
  35452. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35453. * This will returns an RGBA array buffer containing either in values (0-255) or
  35454. * float values (0-1) depending of the underlying buffer type.
  35455. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35456. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35457. * @param buffer defines a user defined buffer to fill with data (can be null)
  35458. * @returns The Array buffer containing the pixels data.
  35459. */
  35460. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35461. /**
  35462. * Release and destroy the underlying lower level texture aka internalTexture.
  35463. */
  35464. releaseInternalTexture(): void;
  35465. /** @hidden */
  35466. get _lodTextureHigh(): Nullable<BaseTexture>;
  35467. /** @hidden */
  35468. get _lodTextureMid(): Nullable<BaseTexture>;
  35469. /** @hidden */
  35470. get _lodTextureLow(): Nullable<BaseTexture>;
  35471. /**
  35472. * Dispose the texture and release its associated resources.
  35473. */
  35474. dispose(): void;
  35475. /**
  35476. * Serialize the texture into a JSON representation that can be parsed later on.
  35477. * @returns the JSON representation of the texture
  35478. */
  35479. serialize(): any;
  35480. /**
  35481. * Helper function to be called back once a list of texture contains only ready textures.
  35482. * @param textures Define the list of textures to wait for
  35483. * @param callback Define the callback triggered once the entire list will be ready
  35484. */
  35485. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35486. private static _isScene;
  35487. }
  35488. }
  35489. declare module "babylonjs/Materials/effect" {
  35490. import { Observable } from "babylonjs/Misc/observable";
  35491. import { Nullable } from "babylonjs/types";
  35492. import { IDisposable } from "babylonjs/scene";
  35493. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35495. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35496. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35497. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35498. import { Engine } from "babylonjs/Engines/engine";
  35499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35501. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35502. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35503. /**
  35504. * Options to be used when creating an effect.
  35505. */
  35506. export interface IEffectCreationOptions {
  35507. /**
  35508. * Atrributes that will be used in the shader.
  35509. */
  35510. attributes: string[];
  35511. /**
  35512. * Uniform varible names that will be set in the shader.
  35513. */
  35514. uniformsNames: string[];
  35515. /**
  35516. * Uniform buffer variable names that will be set in the shader.
  35517. */
  35518. uniformBuffersNames: string[];
  35519. /**
  35520. * Sampler texture variable names that will be set in the shader.
  35521. */
  35522. samplers: string[];
  35523. /**
  35524. * Define statements that will be set in the shader.
  35525. */
  35526. defines: any;
  35527. /**
  35528. * Possible fallbacks for this effect to improve performance when needed.
  35529. */
  35530. fallbacks: Nullable<IEffectFallbacks>;
  35531. /**
  35532. * Callback that will be called when the shader is compiled.
  35533. */
  35534. onCompiled: Nullable<(effect: Effect) => void>;
  35535. /**
  35536. * Callback that will be called if an error occurs during shader compilation.
  35537. */
  35538. onError: Nullable<(effect: Effect, errors: string) => void>;
  35539. /**
  35540. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35541. */
  35542. indexParameters?: any;
  35543. /**
  35544. * Max number of lights that can be used in the shader.
  35545. */
  35546. maxSimultaneousLights?: number;
  35547. /**
  35548. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35549. */
  35550. transformFeedbackVaryings?: Nullable<string[]>;
  35551. /**
  35552. * 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
  35553. */
  35554. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35555. /**
  35556. * Is this effect rendering to several color attachments ?
  35557. */
  35558. multiTarget?: boolean;
  35559. }
  35560. /**
  35561. * Effect containing vertex and fragment shader that can be executed on an object.
  35562. */
  35563. export class Effect implements IDisposable {
  35564. /**
  35565. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35566. */
  35567. static ShadersRepository: string;
  35568. /**
  35569. * Enable logging of the shader code when a compilation error occurs
  35570. */
  35571. static LogShaderCodeOnCompilationError: boolean;
  35572. /**
  35573. * Name of the effect.
  35574. */
  35575. name: any;
  35576. /**
  35577. * String container all the define statements that should be set on the shader.
  35578. */
  35579. defines: string;
  35580. /**
  35581. * Callback that will be called when the shader is compiled.
  35582. */
  35583. onCompiled: Nullable<(effect: Effect) => void>;
  35584. /**
  35585. * Callback that will be called if an error occurs during shader compilation.
  35586. */
  35587. onError: Nullable<(effect: Effect, errors: string) => void>;
  35588. /**
  35589. * Callback that will be called when effect is bound.
  35590. */
  35591. onBind: Nullable<(effect: Effect) => void>;
  35592. /**
  35593. * Unique ID of the effect.
  35594. */
  35595. uniqueId: number;
  35596. /**
  35597. * Observable that will be called when the shader is compiled.
  35598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35599. */
  35600. onCompileObservable: Observable<Effect>;
  35601. /**
  35602. * Observable that will be called if an error occurs during shader compilation.
  35603. */
  35604. onErrorObservable: Observable<Effect>;
  35605. /** @hidden */
  35606. _onBindObservable: Nullable<Observable<Effect>>;
  35607. /**
  35608. * @hidden
  35609. * Specifies if the effect was previously ready
  35610. */
  35611. _wasPreviouslyReady: boolean;
  35612. /**
  35613. * Observable that will be called when effect is bound.
  35614. */
  35615. get onBindObservable(): Observable<Effect>;
  35616. /** @hidden */
  35617. _bonesComputationForcedToCPU: boolean;
  35618. /** @hidden */
  35619. _multiTarget: boolean;
  35620. private static _uniqueIdSeed;
  35621. private _engine;
  35622. private _uniformBuffersNames;
  35623. private _uniformBuffersNamesList;
  35624. private _uniformsNames;
  35625. private _samplerList;
  35626. private _samplers;
  35627. private _isReady;
  35628. private _compilationError;
  35629. private _allFallbacksProcessed;
  35630. private _attributesNames;
  35631. private _attributes;
  35632. private _attributeLocationByName;
  35633. private _uniforms;
  35634. /**
  35635. * Key for the effect.
  35636. * @hidden
  35637. */
  35638. _key: string;
  35639. private _indexParameters;
  35640. private _fallbacks;
  35641. private _vertexSourceCode;
  35642. private _fragmentSourceCode;
  35643. private _vertexSourceCodeOverride;
  35644. private _fragmentSourceCodeOverride;
  35645. private _transformFeedbackVaryings;
  35646. /**
  35647. * Compiled shader to webGL program.
  35648. * @hidden
  35649. */
  35650. _pipelineContext: Nullable<IPipelineContext>;
  35651. private _valueCache;
  35652. private static _baseCache;
  35653. /**
  35654. * Instantiates an effect.
  35655. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35656. * @param baseName Name of the effect.
  35657. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35658. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35659. * @param samplers List of sampler variables that will be passed to the shader.
  35660. * @param engine Engine to be used to render the effect
  35661. * @param defines Define statements to be added to the shader.
  35662. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35663. * @param onCompiled Callback that will be called when the shader is compiled.
  35664. * @param onError Callback that will be called if an error occurs during shader compilation.
  35665. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35666. */
  35667. 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);
  35668. private _useFinalCode;
  35669. /**
  35670. * Unique key for this effect
  35671. */
  35672. get key(): string;
  35673. /**
  35674. * If the effect has been compiled and prepared.
  35675. * @returns if the effect is compiled and prepared.
  35676. */
  35677. isReady(): boolean;
  35678. private _isReadyInternal;
  35679. /**
  35680. * The engine the effect was initialized with.
  35681. * @returns the engine.
  35682. */
  35683. getEngine(): Engine;
  35684. /**
  35685. * The pipeline context for this effect
  35686. * @returns the associated pipeline context
  35687. */
  35688. getPipelineContext(): Nullable<IPipelineContext>;
  35689. /**
  35690. * The set of names of attribute variables for the shader.
  35691. * @returns An array of attribute names.
  35692. */
  35693. getAttributesNames(): string[];
  35694. /**
  35695. * Returns the attribute at the given index.
  35696. * @param index The index of the attribute.
  35697. * @returns The location of the attribute.
  35698. */
  35699. getAttributeLocation(index: number): number;
  35700. /**
  35701. * Returns the attribute based on the name of the variable.
  35702. * @param name of the attribute to look up.
  35703. * @returns the attribute location.
  35704. */
  35705. getAttributeLocationByName(name: string): number;
  35706. /**
  35707. * The number of attributes.
  35708. * @returns the numnber of attributes.
  35709. */
  35710. getAttributesCount(): number;
  35711. /**
  35712. * Gets the index of a uniform variable.
  35713. * @param uniformName of the uniform to look up.
  35714. * @returns the index.
  35715. */
  35716. getUniformIndex(uniformName: string): number;
  35717. /**
  35718. * Returns the attribute based on the name of the variable.
  35719. * @param uniformName of the uniform to look up.
  35720. * @returns the location of the uniform.
  35721. */
  35722. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35723. /**
  35724. * Returns an array of sampler variable names
  35725. * @returns The array of sampler variable names.
  35726. */
  35727. getSamplers(): string[];
  35728. /**
  35729. * Returns an array of uniform variable names
  35730. * @returns The array of uniform variable names.
  35731. */
  35732. getUniformNames(): string[];
  35733. /**
  35734. * Returns an array of uniform buffer variable names
  35735. * @returns The array of uniform buffer variable names.
  35736. */
  35737. getUniformBuffersNames(): string[];
  35738. /**
  35739. * Returns the index parameters used to create the effect
  35740. * @returns The index parameters object
  35741. */
  35742. getIndexParameters(): any;
  35743. /**
  35744. * The error from the last compilation.
  35745. * @returns the error string.
  35746. */
  35747. getCompilationError(): string;
  35748. /**
  35749. * Gets a boolean indicating that all fallbacks were used during compilation
  35750. * @returns true if all fallbacks were used
  35751. */
  35752. allFallbacksProcessed(): boolean;
  35753. /**
  35754. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35755. * @param func The callback to be used.
  35756. */
  35757. executeWhenCompiled(func: (effect: Effect) => void): void;
  35758. private _checkIsReady;
  35759. private _loadShader;
  35760. /**
  35761. * Gets the vertex shader source code of this effect
  35762. */
  35763. get vertexSourceCode(): string;
  35764. /**
  35765. * Gets the fragment shader source code of this effect
  35766. */
  35767. get fragmentSourceCode(): string;
  35768. /**
  35769. * Recompiles the webGL program
  35770. * @param vertexSourceCode The source code for the vertex shader.
  35771. * @param fragmentSourceCode The source code for the fragment shader.
  35772. * @param onCompiled Callback called when completed.
  35773. * @param onError Callback called on error.
  35774. * @hidden
  35775. */
  35776. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35777. /**
  35778. * Prepares the effect
  35779. * @hidden
  35780. */
  35781. _prepareEffect(): void;
  35782. private _getShaderCodeAndErrorLine;
  35783. private _processCompilationErrors;
  35784. /**
  35785. * Checks if the effect is supported. (Must be called after compilation)
  35786. */
  35787. get isSupported(): boolean;
  35788. /**
  35789. * Binds a texture to the engine to be used as output of the shader.
  35790. * @param channel Name of the output variable.
  35791. * @param texture Texture to bind.
  35792. * @hidden
  35793. */
  35794. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35795. /**
  35796. * Sets a texture on the engine to be used in the shader.
  35797. * @param channel Name of the sampler variable.
  35798. * @param texture Texture to set.
  35799. */
  35800. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35801. /**
  35802. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35803. * @param channel Name of the sampler variable.
  35804. * @param texture Texture to set.
  35805. */
  35806. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35807. /**
  35808. * Sets an array of textures on the engine to be used in the shader.
  35809. * @param channel Name of the variable.
  35810. * @param textures Textures to set.
  35811. */
  35812. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35813. /**
  35814. * 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)
  35815. * @param channel Name of the sampler variable.
  35816. * @param postProcess Post process to get the input texture from.
  35817. */
  35818. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35819. /**
  35820. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35821. * 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)
  35822. * @param channel Name of the sampler variable.
  35823. * @param postProcess Post process to get the output texture from.
  35824. */
  35825. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35826. /** @hidden */
  35827. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35828. /** @hidden */
  35829. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35830. /** @hidden */
  35831. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35832. /** @hidden */
  35833. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35834. /**
  35835. * Binds a buffer to a uniform.
  35836. * @param buffer Buffer to bind.
  35837. * @param name Name of the uniform variable to bind to.
  35838. */
  35839. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35840. /**
  35841. * Binds block to a uniform.
  35842. * @param blockName Name of the block to bind.
  35843. * @param index Index to bind.
  35844. */
  35845. bindUniformBlock(blockName: string, index: number): void;
  35846. /**
  35847. * Sets an interger value on a uniform variable.
  35848. * @param uniformName Name of the variable.
  35849. * @param value Value to be set.
  35850. * @returns this effect.
  35851. */
  35852. setInt(uniformName: string, value: number): Effect;
  35853. /**
  35854. * Sets an int array on a uniform variable.
  35855. * @param uniformName Name of the variable.
  35856. * @param array array to be set.
  35857. * @returns this effect.
  35858. */
  35859. setIntArray(uniformName: string, array: Int32Array): Effect;
  35860. /**
  35861. * 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)
  35862. * @param uniformName Name of the variable.
  35863. * @param array array to be set.
  35864. * @returns this effect.
  35865. */
  35866. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35867. /**
  35868. * 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)
  35869. * @param uniformName Name of the variable.
  35870. * @param array array to be set.
  35871. * @returns this effect.
  35872. */
  35873. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35874. /**
  35875. * 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)
  35876. * @param uniformName Name of the variable.
  35877. * @param array array to be set.
  35878. * @returns this effect.
  35879. */
  35880. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35881. /**
  35882. * Sets an float array on a uniform variable.
  35883. * @param uniformName Name of the variable.
  35884. * @param array array to be set.
  35885. * @returns this effect.
  35886. */
  35887. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35888. /**
  35889. * 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)
  35890. * @param uniformName Name of the variable.
  35891. * @param array array to be set.
  35892. * @returns this effect.
  35893. */
  35894. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35895. /**
  35896. * 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)
  35897. * @param uniformName Name of the variable.
  35898. * @param array array to be set.
  35899. * @returns this effect.
  35900. */
  35901. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35902. /**
  35903. * 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)
  35904. * @param uniformName Name of the variable.
  35905. * @param array array to be set.
  35906. * @returns this effect.
  35907. */
  35908. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35909. /**
  35910. * Sets an array on a uniform variable.
  35911. * @param uniformName Name of the variable.
  35912. * @param array array to be set.
  35913. * @returns this effect.
  35914. */
  35915. setArray(uniformName: string, array: number[]): Effect;
  35916. /**
  35917. * 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)
  35918. * @param uniformName Name of the variable.
  35919. * @param array array to be set.
  35920. * @returns this effect.
  35921. */
  35922. setArray2(uniformName: string, array: number[]): Effect;
  35923. /**
  35924. * 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)
  35925. * @param uniformName Name of the variable.
  35926. * @param array array to be set.
  35927. * @returns this effect.
  35928. */
  35929. setArray3(uniformName: string, array: number[]): Effect;
  35930. /**
  35931. * 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)
  35932. * @param uniformName Name of the variable.
  35933. * @param array array to be set.
  35934. * @returns this effect.
  35935. */
  35936. setArray4(uniformName: string, array: number[]): Effect;
  35937. /**
  35938. * Sets matrices on a uniform variable.
  35939. * @param uniformName Name of the variable.
  35940. * @param matrices matrices to be set.
  35941. * @returns this effect.
  35942. */
  35943. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35944. /**
  35945. * Sets matrix on a uniform variable.
  35946. * @param uniformName Name of the variable.
  35947. * @param matrix matrix to be set.
  35948. * @returns this effect.
  35949. */
  35950. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35951. /**
  35952. * 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)
  35953. * @param uniformName Name of the variable.
  35954. * @param matrix matrix to be set.
  35955. * @returns this effect.
  35956. */
  35957. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35958. /**
  35959. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35960. * @param uniformName Name of the variable.
  35961. * @param matrix matrix to be set.
  35962. * @returns this effect.
  35963. */
  35964. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35965. /**
  35966. * Sets a float on a uniform variable.
  35967. * @param uniformName Name of the variable.
  35968. * @param value value to be set.
  35969. * @returns this effect.
  35970. */
  35971. setFloat(uniformName: string, value: number): Effect;
  35972. /**
  35973. * Sets a boolean on a uniform variable.
  35974. * @param uniformName Name of the variable.
  35975. * @param bool value to be set.
  35976. * @returns this effect.
  35977. */
  35978. setBool(uniformName: string, bool: boolean): Effect;
  35979. /**
  35980. * Sets a Vector2 on a uniform variable.
  35981. * @param uniformName Name of the variable.
  35982. * @param vector2 vector2 to be set.
  35983. * @returns this effect.
  35984. */
  35985. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35986. /**
  35987. * Sets a float2 on a uniform variable.
  35988. * @param uniformName Name of the variable.
  35989. * @param x First float in float2.
  35990. * @param y Second float in float2.
  35991. * @returns this effect.
  35992. */
  35993. setFloat2(uniformName: string, x: number, y: number): Effect;
  35994. /**
  35995. * Sets a Vector3 on a uniform variable.
  35996. * @param uniformName Name of the variable.
  35997. * @param vector3 Value to be set.
  35998. * @returns this effect.
  35999. */
  36000. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36001. /**
  36002. * Sets a float3 on a uniform variable.
  36003. * @param uniformName Name of the variable.
  36004. * @param x First float in float3.
  36005. * @param y Second float in float3.
  36006. * @param z Third float in float3.
  36007. * @returns this effect.
  36008. */
  36009. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36010. /**
  36011. * Sets a Vector4 on a uniform variable.
  36012. * @param uniformName Name of the variable.
  36013. * @param vector4 Value to be set.
  36014. * @returns this effect.
  36015. */
  36016. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36017. /**
  36018. * Sets a float4 on a uniform variable.
  36019. * @param uniformName Name of the variable.
  36020. * @param x First float in float4.
  36021. * @param y Second float in float4.
  36022. * @param z Third float in float4.
  36023. * @param w Fourth float in float4.
  36024. * @returns this effect.
  36025. */
  36026. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36027. /**
  36028. * Sets a Color3 on a uniform variable.
  36029. * @param uniformName Name of the variable.
  36030. * @param color3 Value to be set.
  36031. * @returns this effect.
  36032. */
  36033. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36034. /**
  36035. * Sets a Color4 on a uniform variable.
  36036. * @param uniformName Name of the variable.
  36037. * @param color3 Value to be set.
  36038. * @param alpha Alpha value to be set.
  36039. * @returns this effect.
  36040. */
  36041. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36042. /**
  36043. * Sets a Color4 on a uniform variable
  36044. * @param uniformName defines the name of the variable
  36045. * @param color4 defines the value to be set
  36046. * @returns this effect.
  36047. */
  36048. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36049. /** Release all associated resources */
  36050. dispose(): void;
  36051. /**
  36052. * This function will add a new shader to the shader store
  36053. * @param name the name of the shader
  36054. * @param pixelShader optional pixel shader content
  36055. * @param vertexShader optional vertex shader content
  36056. */
  36057. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36058. /**
  36059. * Store of each shader (The can be looked up using effect.key)
  36060. */
  36061. static ShadersStore: {
  36062. [key: string]: string;
  36063. };
  36064. /**
  36065. * Store of each included file for a shader (The can be looked up using effect.key)
  36066. */
  36067. static IncludesShadersStore: {
  36068. [key: string]: string;
  36069. };
  36070. /**
  36071. * Resets the cache of effects.
  36072. */
  36073. static ResetCache(): void;
  36074. }
  36075. }
  36076. declare module "babylonjs/Engines/engineCapabilities" {
  36077. /**
  36078. * Interface used to describe the capabilities of the engine relatively to the current browser
  36079. */
  36080. export interface EngineCapabilities {
  36081. /** Maximum textures units per fragment shader */
  36082. maxTexturesImageUnits: number;
  36083. /** Maximum texture units per vertex shader */
  36084. maxVertexTextureImageUnits: number;
  36085. /** Maximum textures units in the entire pipeline */
  36086. maxCombinedTexturesImageUnits: number;
  36087. /** Maximum texture size */
  36088. maxTextureSize: number;
  36089. /** Maximum texture samples */
  36090. maxSamples?: number;
  36091. /** Maximum cube texture size */
  36092. maxCubemapTextureSize: number;
  36093. /** Maximum render texture size */
  36094. maxRenderTextureSize: number;
  36095. /** Maximum number of vertex attributes */
  36096. maxVertexAttribs: number;
  36097. /** Maximum number of varyings */
  36098. maxVaryingVectors: number;
  36099. /** Maximum number of uniforms per vertex shader */
  36100. maxVertexUniformVectors: number;
  36101. /** Maximum number of uniforms per fragment shader */
  36102. maxFragmentUniformVectors: number;
  36103. /** Defines if standard derivates (dx/dy) are supported */
  36104. standardDerivatives: boolean;
  36105. /** Defines if s3tc texture compression is supported */
  36106. s3tc?: WEBGL_compressed_texture_s3tc;
  36107. /** Defines if pvrtc texture compression is supported */
  36108. pvrtc: any;
  36109. /** Defines if etc1 texture compression is supported */
  36110. etc1: any;
  36111. /** Defines if etc2 texture compression is supported */
  36112. etc2: any;
  36113. /** Defines if astc texture compression is supported */
  36114. astc: any;
  36115. /** Defines if bptc texture compression is supported */
  36116. bptc: any;
  36117. /** Defines if float textures are supported */
  36118. textureFloat: boolean;
  36119. /** Defines if vertex array objects are supported */
  36120. vertexArrayObject: boolean;
  36121. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36122. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36123. /** Gets the maximum level of anisotropy supported */
  36124. maxAnisotropy: number;
  36125. /** Defines if instancing is supported */
  36126. instancedArrays: boolean;
  36127. /** Defines if 32 bits indices are supported */
  36128. uintIndices: boolean;
  36129. /** Defines if high precision shaders are supported */
  36130. highPrecisionShaderSupported: boolean;
  36131. /** Defines if depth reading in the fragment shader is supported */
  36132. fragmentDepthSupported: boolean;
  36133. /** Defines if float texture linear filtering is supported*/
  36134. textureFloatLinearFiltering: boolean;
  36135. /** Defines if rendering to float textures is supported */
  36136. textureFloatRender: boolean;
  36137. /** Defines if half float textures are supported*/
  36138. textureHalfFloat: boolean;
  36139. /** Defines if half float texture linear filtering is supported*/
  36140. textureHalfFloatLinearFiltering: boolean;
  36141. /** Defines if rendering to half float textures is supported */
  36142. textureHalfFloatRender: boolean;
  36143. /** Defines if textureLOD shader command is supported */
  36144. textureLOD: boolean;
  36145. /** Defines if draw buffers extension is supported */
  36146. drawBuffersExtension: boolean;
  36147. /** Defines if depth textures are supported */
  36148. depthTextureExtension: boolean;
  36149. /** Defines if float color buffer are supported */
  36150. colorBufferFloat: boolean;
  36151. /** Gets disjoint timer query extension (null if not supported) */
  36152. timerQuery?: EXT_disjoint_timer_query;
  36153. /** Defines if timestamp can be used with timer query */
  36154. canUseTimestampForTimerQuery: boolean;
  36155. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36156. multiview?: any;
  36157. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36158. oculusMultiview?: any;
  36159. /** Function used to let the system compiles shaders in background */
  36160. parallelShaderCompile?: {
  36161. COMPLETION_STATUS_KHR: number;
  36162. };
  36163. /** Max number of texture samples for MSAA */
  36164. maxMSAASamples: number;
  36165. /** Defines if the blend min max extension is supported */
  36166. blendMinMax: boolean;
  36167. }
  36168. }
  36169. declare module "babylonjs/States/depthCullingState" {
  36170. import { Nullable } from "babylonjs/types";
  36171. /**
  36172. * @hidden
  36173. **/
  36174. export class DepthCullingState {
  36175. private _isDepthTestDirty;
  36176. private _isDepthMaskDirty;
  36177. private _isDepthFuncDirty;
  36178. private _isCullFaceDirty;
  36179. private _isCullDirty;
  36180. private _isZOffsetDirty;
  36181. private _isFrontFaceDirty;
  36182. private _depthTest;
  36183. private _depthMask;
  36184. private _depthFunc;
  36185. private _cull;
  36186. private _cullFace;
  36187. private _zOffset;
  36188. private _frontFace;
  36189. /**
  36190. * Initializes the state.
  36191. */
  36192. constructor();
  36193. get isDirty(): boolean;
  36194. get zOffset(): number;
  36195. set zOffset(value: number);
  36196. get cullFace(): Nullable<number>;
  36197. set cullFace(value: Nullable<number>);
  36198. get cull(): Nullable<boolean>;
  36199. set cull(value: Nullable<boolean>);
  36200. get depthFunc(): Nullable<number>;
  36201. set depthFunc(value: Nullable<number>);
  36202. get depthMask(): boolean;
  36203. set depthMask(value: boolean);
  36204. get depthTest(): boolean;
  36205. set depthTest(value: boolean);
  36206. get frontFace(): Nullable<number>;
  36207. set frontFace(value: Nullable<number>);
  36208. reset(): void;
  36209. apply(gl: WebGLRenderingContext): void;
  36210. }
  36211. }
  36212. declare module "babylonjs/States/stencilState" {
  36213. /**
  36214. * @hidden
  36215. **/
  36216. export class StencilState {
  36217. /** 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 */
  36218. static readonly ALWAYS: number;
  36219. /** Passed to stencilOperation to specify that stencil value must be kept */
  36220. static readonly KEEP: number;
  36221. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36222. static readonly REPLACE: number;
  36223. private _isStencilTestDirty;
  36224. private _isStencilMaskDirty;
  36225. private _isStencilFuncDirty;
  36226. private _isStencilOpDirty;
  36227. private _stencilTest;
  36228. private _stencilMask;
  36229. private _stencilFunc;
  36230. private _stencilFuncRef;
  36231. private _stencilFuncMask;
  36232. private _stencilOpStencilFail;
  36233. private _stencilOpDepthFail;
  36234. private _stencilOpStencilDepthPass;
  36235. get isDirty(): boolean;
  36236. get stencilFunc(): number;
  36237. set stencilFunc(value: number);
  36238. get stencilFuncRef(): number;
  36239. set stencilFuncRef(value: number);
  36240. get stencilFuncMask(): number;
  36241. set stencilFuncMask(value: number);
  36242. get stencilOpStencilFail(): number;
  36243. set stencilOpStencilFail(value: number);
  36244. get stencilOpDepthFail(): number;
  36245. set stencilOpDepthFail(value: number);
  36246. get stencilOpStencilDepthPass(): number;
  36247. set stencilOpStencilDepthPass(value: number);
  36248. get stencilMask(): number;
  36249. set stencilMask(value: number);
  36250. get stencilTest(): boolean;
  36251. set stencilTest(value: boolean);
  36252. constructor();
  36253. reset(): void;
  36254. apply(gl: WebGLRenderingContext): void;
  36255. }
  36256. }
  36257. declare module "babylonjs/States/alphaCullingState" {
  36258. /**
  36259. * @hidden
  36260. **/
  36261. export class AlphaState {
  36262. private _isAlphaBlendDirty;
  36263. private _isBlendFunctionParametersDirty;
  36264. private _isBlendEquationParametersDirty;
  36265. private _isBlendConstantsDirty;
  36266. private _alphaBlend;
  36267. private _blendFunctionParameters;
  36268. private _blendEquationParameters;
  36269. private _blendConstants;
  36270. /**
  36271. * Initializes the state.
  36272. */
  36273. constructor();
  36274. get isDirty(): boolean;
  36275. get alphaBlend(): boolean;
  36276. set alphaBlend(value: boolean);
  36277. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36278. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36279. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36280. reset(): void;
  36281. apply(gl: WebGLRenderingContext): void;
  36282. }
  36283. }
  36284. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36285. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36286. /** @hidden */
  36287. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36288. attributeProcessor(attribute: string): string;
  36289. varyingProcessor(varying: string, isFragment: boolean): string;
  36290. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36291. }
  36292. }
  36293. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36294. /**
  36295. * Interface for attribute information associated with buffer instanciation
  36296. */
  36297. export interface InstancingAttributeInfo {
  36298. /**
  36299. * Name of the GLSL attribute
  36300. * if attribute index is not specified, this is used to retrieve the index from the effect
  36301. */
  36302. attributeName: string;
  36303. /**
  36304. * Index/offset of the attribute in the vertex shader
  36305. * if not specified, this will be computes from the name.
  36306. */
  36307. index?: number;
  36308. /**
  36309. * size of the attribute, 1, 2, 3 or 4
  36310. */
  36311. attributeSize: number;
  36312. /**
  36313. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36314. */
  36315. offset: number;
  36316. /**
  36317. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36318. * default to 1
  36319. */
  36320. divisor?: number;
  36321. /**
  36322. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36323. * default is FLOAT
  36324. */
  36325. attributeType?: number;
  36326. /**
  36327. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36328. */
  36329. normalized?: boolean;
  36330. }
  36331. }
  36332. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36334. import { Nullable } from "babylonjs/types";
  36335. module "babylonjs/Engines/thinEngine" {
  36336. interface ThinEngine {
  36337. /**
  36338. * Update a video texture
  36339. * @param texture defines the texture to update
  36340. * @param video defines the video element to use
  36341. * @param invertY defines if data must be stored with Y axis inverted
  36342. */
  36343. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36344. }
  36345. }
  36346. }
  36347. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36349. import { Nullable } from "babylonjs/types";
  36350. module "babylonjs/Engines/thinEngine" {
  36351. interface ThinEngine {
  36352. /**
  36353. * Creates a dynamic texture
  36354. * @param width defines the width of the texture
  36355. * @param height defines the height of the texture
  36356. * @param generateMipMaps defines if the engine should generate the mip levels
  36357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36358. * @returns the dynamic texture inside an InternalTexture
  36359. */
  36360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36361. /**
  36362. * Update the content of a dynamic texture
  36363. * @param texture defines the texture to update
  36364. * @param canvas defines the canvas containing the source
  36365. * @param invertY defines if data must be stored with Y axis inverted
  36366. * @param premulAlpha defines if alpha is stored as premultiplied
  36367. * @param format defines the format of the data
  36368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36369. */
  36370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36371. }
  36372. }
  36373. }
  36374. declare module "babylonjs/Materials/Textures/videoTexture" {
  36375. import { Observable } from "babylonjs/Misc/observable";
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Scene } from "babylonjs/scene";
  36378. import { Texture } from "babylonjs/Materials/Textures/texture";
  36379. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36380. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36381. /**
  36382. * Settings for finer control over video usage
  36383. */
  36384. export interface VideoTextureSettings {
  36385. /**
  36386. * Applies `autoplay` to video, if specified
  36387. */
  36388. autoPlay?: boolean;
  36389. /**
  36390. * Applies `loop` to video, if specified
  36391. */
  36392. loop?: boolean;
  36393. /**
  36394. * Automatically updates internal texture from video at every frame in the render loop
  36395. */
  36396. autoUpdateTexture: boolean;
  36397. /**
  36398. * Image src displayed during the video loading or until the user interacts with the video.
  36399. */
  36400. poster?: string;
  36401. }
  36402. /**
  36403. * If you want to display a video in your scene, this is the special texture for that.
  36404. * This special texture works similar to other textures, with the exception of a few parameters.
  36405. * @see https://doc.babylonjs.com/how_to/video_texture
  36406. */
  36407. export class VideoTexture extends Texture {
  36408. /**
  36409. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36410. */
  36411. readonly autoUpdateTexture: boolean;
  36412. /**
  36413. * The video instance used by the texture internally
  36414. */
  36415. readonly video: HTMLVideoElement;
  36416. private _onUserActionRequestedObservable;
  36417. /**
  36418. * Event triggerd when a dom action is required by the user to play the video.
  36419. * This happens due to recent changes in browser policies preventing video to auto start.
  36420. */
  36421. get onUserActionRequestedObservable(): Observable<Texture>;
  36422. private _generateMipMaps;
  36423. private _stillImageCaptured;
  36424. private _displayingPosterTexture;
  36425. private _settings;
  36426. private _createInternalTextureOnEvent;
  36427. private _frameId;
  36428. private _currentSrc;
  36429. /**
  36430. * Creates a video texture.
  36431. * If you want to display a video in your scene, this is the special texture for that.
  36432. * This special texture works similar to other textures, with the exception of a few parameters.
  36433. * @see https://doc.babylonjs.com/how_to/video_texture
  36434. * @param name optional name, will detect from video source, if not defined
  36435. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36436. * @param scene is obviously the current scene.
  36437. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36438. * @param invertY is false by default but can be used to invert video on Y axis
  36439. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36440. * @param settings allows finer control over video usage
  36441. */
  36442. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36443. private _getName;
  36444. private _getVideo;
  36445. private _createInternalTexture;
  36446. private reset;
  36447. /**
  36448. * @hidden Internal method to initiate `update`.
  36449. */
  36450. _rebuild(): void;
  36451. /**
  36452. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36453. */
  36454. update(): void;
  36455. /**
  36456. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36457. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36458. */
  36459. updateTexture(isVisible: boolean): void;
  36460. protected _updateInternalTexture: () => void;
  36461. /**
  36462. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36463. * @param url New url.
  36464. */
  36465. updateURL(url: string): void;
  36466. /**
  36467. * Clones the texture.
  36468. * @returns the cloned texture
  36469. */
  36470. clone(): VideoTexture;
  36471. /**
  36472. * Dispose the texture and release its associated resources.
  36473. */
  36474. dispose(): void;
  36475. /**
  36476. * Creates a video texture straight from a stream.
  36477. * @param scene Define the scene the texture should be created in
  36478. * @param stream Define the stream the texture should be created from
  36479. * @returns The created video texture as a promise
  36480. */
  36481. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36482. /**
  36483. * Creates a video texture straight from your WebCam video feed.
  36484. * @param scene Define the scene the texture should be created in
  36485. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36486. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36487. * @returns The created video texture as a promise
  36488. */
  36489. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36490. minWidth: number;
  36491. maxWidth: number;
  36492. minHeight: number;
  36493. maxHeight: number;
  36494. deviceId: string;
  36495. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36496. /**
  36497. * Creates a video texture straight from your WebCam video feed.
  36498. * @param scene Define the scene the texture should be created in
  36499. * @param onReady Define a callback to triggered once the texture will be ready
  36500. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36501. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36502. */
  36503. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36504. minWidth: number;
  36505. maxWidth: number;
  36506. minHeight: number;
  36507. maxHeight: number;
  36508. deviceId: string;
  36509. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36510. }
  36511. }
  36512. declare module "babylonjs/Engines/thinEngine" {
  36513. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36514. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36515. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36516. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36517. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36518. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36519. import { Observable } from "babylonjs/Misc/observable";
  36520. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36521. import { StencilState } from "babylonjs/States/stencilState";
  36522. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36524. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36526. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36527. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36528. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36529. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36530. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36532. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36533. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36534. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36535. import { WebRequest } from "babylonjs/Misc/webRequest";
  36536. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36537. /**
  36538. * Defines the interface used by objects working like Scene
  36539. * @hidden
  36540. */
  36541. export interface ISceneLike {
  36542. _addPendingData(data: any): void;
  36543. _removePendingData(data: any): void;
  36544. offlineProvider: IOfflineProvider;
  36545. }
  36546. /**
  36547. * Information about the current host
  36548. */
  36549. export interface HostInformation {
  36550. /**
  36551. * Defines if the current host is a mobile
  36552. */
  36553. isMobile: boolean;
  36554. }
  36555. /** Interface defining initialization parameters for Engine class */
  36556. export interface EngineOptions extends WebGLContextAttributes {
  36557. /**
  36558. * Defines if the engine should no exceed a specified device ratio
  36559. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36560. */
  36561. limitDeviceRatio?: number;
  36562. /**
  36563. * Defines if webvr should be enabled automatically
  36564. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36565. */
  36566. autoEnableWebVR?: boolean;
  36567. /**
  36568. * Defines if webgl2 should be turned off even if supported
  36569. * @see https://doc.babylonjs.com/features/webgl2
  36570. */
  36571. disableWebGL2Support?: boolean;
  36572. /**
  36573. * Defines if webaudio should be initialized as well
  36574. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36575. */
  36576. audioEngine?: boolean;
  36577. /**
  36578. * Defines if animations should run using a deterministic lock step
  36579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36580. */
  36581. deterministicLockstep?: boolean;
  36582. /** Defines the maximum steps to use with deterministic lock step mode */
  36583. lockstepMaxSteps?: number;
  36584. /** Defines the seconds between each deterministic lock step */
  36585. timeStep?: number;
  36586. /**
  36587. * Defines that engine should ignore context lost events
  36588. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36589. */
  36590. doNotHandleContextLost?: boolean;
  36591. /**
  36592. * Defines that engine should ignore modifying touch action attribute and style
  36593. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36594. */
  36595. doNotHandleTouchAction?: boolean;
  36596. /**
  36597. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36598. */
  36599. useHighPrecisionFloats?: boolean;
  36600. /**
  36601. * Make the canvas XR Compatible for XR sessions
  36602. */
  36603. xrCompatible?: boolean;
  36604. /**
  36605. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36606. */
  36607. useHighPrecisionMatrix?: boolean;
  36608. }
  36609. /**
  36610. * The base engine class (root of all engines)
  36611. */
  36612. export class ThinEngine {
  36613. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36614. static ExceptionList: ({
  36615. key: string;
  36616. capture: string;
  36617. captureConstraint: number;
  36618. targets: string[];
  36619. } | {
  36620. key: string;
  36621. capture: null;
  36622. captureConstraint: null;
  36623. targets: string[];
  36624. })[];
  36625. /** @hidden */
  36626. static _TextureLoaders: IInternalTextureLoader[];
  36627. /**
  36628. * Returns the current npm package of the sdk
  36629. */
  36630. static get NpmPackage(): string;
  36631. /**
  36632. * Returns the current version of the framework
  36633. */
  36634. static get Version(): string;
  36635. /**
  36636. * Returns a string describing the current engine
  36637. */
  36638. get description(): string;
  36639. /**
  36640. * Gets or sets the epsilon value used by collision engine
  36641. */
  36642. static CollisionsEpsilon: number;
  36643. /**
  36644. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36645. */
  36646. static get ShadersRepository(): string;
  36647. static set ShadersRepository(value: string);
  36648. /** @hidden */
  36649. _shaderProcessor: IShaderProcessor;
  36650. /**
  36651. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36652. */
  36653. forcePOTTextures: boolean;
  36654. /**
  36655. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36656. */
  36657. isFullscreen: boolean;
  36658. /**
  36659. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36660. */
  36661. cullBackFaces: boolean;
  36662. /**
  36663. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36664. */
  36665. renderEvenInBackground: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating that cache can be kept between frames
  36668. */
  36669. preventCacheWipeBetweenFrames: boolean;
  36670. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36671. validateShaderPrograms: boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36674. * This can provide greater z depth for distant objects.
  36675. */
  36676. useReverseDepthBuffer: boolean;
  36677. /**
  36678. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36679. */
  36680. disableUniformBuffers: boolean;
  36681. /** @hidden */
  36682. _uniformBuffers: UniformBuffer[];
  36683. /**
  36684. * Gets a boolean indicating that the engine supports uniform buffers
  36685. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36686. */
  36687. get supportsUniformBuffers(): boolean;
  36688. /** @hidden */
  36689. _gl: WebGLRenderingContext;
  36690. /** @hidden */
  36691. _webGLVersion: number;
  36692. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36693. protected _windowIsBackground: boolean;
  36694. protected _creationOptions: EngineOptions;
  36695. protected _highPrecisionShadersAllowed: boolean;
  36696. /** @hidden */
  36697. get _shouldUseHighPrecisionShader(): boolean;
  36698. /**
  36699. * Gets a boolean indicating that only power of 2 textures are supported
  36700. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36701. */
  36702. get needPOTTextures(): boolean;
  36703. /** @hidden */
  36704. _badOS: boolean;
  36705. /** @hidden */
  36706. _badDesktopOS: boolean;
  36707. private _hardwareScalingLevel;
  36708. /** @hidden */
  36709. _caps: EngineCapabilities;
  36710. private _isStencilEnable;
  36711. private _glVersion;
  36712. private _glRenderer;
  36713. private _glVendor;
  36714. /** @hidden */
  36715. _videoTextureSupported: boolean;
  36716. protected _renderingQueueLaunched: boolean;
  36717. protected _activeRenderLoops: (() => void)[];
  36718. /**
  36719. * Observable signaled when a context lost event is raised
  36720. */
  36721. onContextLostObservable: Observable<ThinEngine>;
  36722. /**
  36723. * Observable signaled when a context restored event is raised
  36724. */
  36725. onContextRestoredObservable: Observable<ThinEngine>;
  36726. private _onContextLost;
  36727. private _onContextRestored;
  36728. protected _contextWasLost: boolean;
  36729. /** @hidden */
  36730. _doNotHandleContextLost: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36733. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36734. */
  36735. get doNotHandleContextLost(): boolean;
  36736. set doNotHandleContextLost(value: boolean);
  36737. /**
  36738. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36739. */
  36740. disableVertexArrayObjects: boolean;
  36741. /** @hidden */
  36742. protected _colorWrite: boolean;
  36743. /** @hidden */
  36744. protected _colorWriteChanged: boolean;
  36745. /** @hidden */
  36746. protected _depthCullingState: DepthCullingState;
  36747. /** @hidden */
  36748. protected _stencilState: StencilState;
  36749. /** @hidden */
  36750. _alphaState: AlphaState;
  36751. /** @hidden */
  36752. _alphaMode: number;
  36753. /** @hidden */
  36754. _alphaEquation: number;
  36755. /** @hidden */
  36756. _internalTexturesCache: InternalTexture[];
  36757. /** @hidden */
  36758. protected _activeChannel: number;
  36759. private _currentTextureChannel;
  36760. /** @hidden */
  36761. protected _boundTexturesCache: {
  36762. [key: string]: Nullable<InternalTexture>;
  36763. };
  36764. /** @hidden */
  36765. protected _currentEffect: Nullable<Effect>;
  36766. /** @hidden */
  36767. protected _currentProgram: Nullable<WebGLProgram>;
  36768. private _compiledEffects;
  36769. private _vertexAttribArraysEnabled;
  36770. /** @hidden */
  36771. protected _cachedViewport: Nullable<IViewportLike>;
  36772. private _cachedVertexArrayObject;
  36773. /** @hidden */
  36774. protected _cachedVertexBuffers: any;
  36775. /** @hidden */
  36776. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36777. /** @hidden */
  36778. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36779. /** @hidden */
  36780. _currentRenderTarget: Nullable<InternalTexture>;
  36781. private _uintIndicesCurrentlySet;
  36782. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36783. /** @hidden */
  36784. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36785. /** @hidden */
  36786. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36787. private _currentBufferPointers;
  36788. private _currentInstanceLocations;
  36789. private _currentInstanceBuffers;
  36790. private _textureUnits;
  36791. /** @hidden */
  36792. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36793. /** @hidden */
  36794. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36795. /** @hidden */
  36796. _boundRenderFunction: any;
  36797. private _vaoRecordInProgress;
  36798. private _mustWipeVertexAttributes;
  36799. private _emptyTexture;
  36800. private _emptyCubeTexture;
  36801. private _emptyTexture3D;
  36802. private _emptyTexture2DArray;
  36803. /** @hidden */
  36804. _frameHandler: number;
  36805. private _nextFreeTextureSlots;
  36806. private _maxSimultaneousTextures;
  36807. private _activeRequests;
  36808. /** @hidden */
  36809. _transformTextureUrl: Nullable<(url: string) => string>;
  36810. /**
  36811. * Gets information about the current host
  36812. */
  36813. hostInformation: HostInformation;
  36814. protected get _supportsHardwareTextureRescaling(): boolean;
  36815. private _framebufferDimensionsObject;
  36816. /**
  36817. * sets the object from which width and height will be taken from when getting render width and height
  36818. * Will fallback to the gl object
  36819. * @param dimensions the framebuffer width and height that will be used.
  36820. */
  36821. set framebufferDimensionsObject(dimensions: Nullable<{
  36822. framebufferWidth: number;
  36823. framebufferHeight: number;
  36824. }>);
  36825. /**
  36826. * Gets the current viewport
  36827. */
  36828. get currentViewport(): Nullable<IViewportLike>;
  36829. /**
  36830. * Gets the default empty texture
  36831. */
  36832. get emptyTexture(): InternalTexture;
  36833. /**
  36834. * Gets the default empty 3D texture
  36835. */
  36836. get emptyTexture3D(): InternalTexture;
  36837. /**
  36838. * Gets the default empty 2D array texture
  36839. */
  36840. get emptyTexture2DArray(): InternalTexture;
  36841. /**
  36842. * Gets the default empty cube texture
  36843. */
  36844. get emptyCubeTexture(): InternalTexture;
  36845. /**
  36846. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36847. */
  36848. readonly premultipliedAlpha: boolean;
  36849. /**
  36850. * Observable event triggered before each texture is initialized
  36851. */
  36852. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36853. /**
  36854. * Creates a new engine
  36855. * @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
  36856. * @param antialias defines enable antialiasing (default: false)
  36857. * @param options defines further options to be sent to the getContext() function
  36858. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36859. */
  36860. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36861. private _rebuildInternalTextures;
  36862. private _rebuildEffects;
  36863. /**
  36864. * Gets a boolean indicating if all created effects are ready
  36865. * @returns true if all effects are ready
  36866. */
  36867. areAllEffectsReady(): boolean;
  36868. protected _rebuildBuffers(): void;
  36869. protected _initGLContext(): void;
  36870. /**
  36871. * Gets version of the current webGL context
  36872. */
  36873. get webGLVersion(): number;
  36874. /**
  36875. * Gets a string identifying the name of the class
  36876. * @returns "Engine" string
  36877. */
  36878. getClassName(): string;
  36879. /**
  36880. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36881. */
  36882. get isStencilEnable(): boolean;
  36883. /** @hidden */
  36884. _prepareWorkingCanvas(): void;
  36885. /**
  36886. * Reset the texture cache to empty state
  36887. */
  36888. resetTextureCache(): void;
  36889. /**
  36890. * Gets an object containing information about the current webGL context
  36891. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36892. */
  36893. getGlInfo(): {
  36894. vendor: string;
  36895. renderer: string;
  36896. version: string;
  36897. };
  36898. /**
  36899. * Defines the hardware scaling level.
  36900. * By default the hardware scaling level is computed from the window device ratio.
  36901. * 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.
  36902. * @param level defines the level to use
  36903. */
  36904. setHardwareScalingLevel(level: number): void;
  36905. /**
  36906. * Gets the current hardware scaling level.
  36907. * By default the hardware scaling level is computed from the window device ratio.
  36908. * 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.
  36909. * @returns a number indicating the current hardware scaling level
  36910. */
  36911. getHardwareScalingLevel(): number;
  36912. /**
  36913. * Gets the list of loaded textures
  36914. * @returns an array containing all loaded textures
  36915. */
  36916. getLoadedTexturesCache(): InternalTexture[];
  36917. /**
  36918. * Gets the object containing all engine capabilities
  36919. * @returns the EngineCapabilities object
  36920. */
  36921. getCaps(): EngineCapabilities;
  36922. /**
  36923. * stop executing a render loop function and remove it from the execution array
  36924. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36925. */
  36926. stopRenderLoop(renderFunction?: () => void): void;
  36927. /** @hidden */
  36928. _renderLoop(): void;
  36929. /**
  36930. * Gets the HTML canvas attached with the current webGL context
  36931. * @returns a HTML canvas
  36932. */
  36933. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36934. /**
  36935. * Gets host window
  36936. * @returns the host window object
  36937. */
  36938. getHostWindow(): Nullable<Window>;
  36939. /**
  36940. * Gets the current render width
  36941. * @param useScreen defines if screen size must be used (or the current render target if any)
  36942. * @returns a number defining the current render width
  36943. */
  36944. getRenderWidth(useScreen?: boolean): number;
  36945. /**
  36946. * Gets the current render height
  36947. * @param useScreen defines if screen size must be used (or the current render target if any)
  36948. * @returns a number defining the current render height
  36949. */
  36950. getRenderHeight(useScreen?: boolean): number;
  36951. /**
  36952. * Can be used to override the current requestAnimationFrame requester.
  36953. * @hidden
  36954. */
  36955. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36956. /**
  36957. * Register and execute a render loop. The engine can have more than one render function
  36958. * @param renderFunction defines the function to continuously execute
  36959. */
  36960. runRenderLoop(renderFunction: () => void): void;
  36961. /**
  36962. * Clear the current render buffer or the current render target (if any is set up)
  36963. * @param color defines the color to use
  36964. * @param backBuffer defines if the back buffer must be cleared
  36965. * @param depth defines if the depth buffer must be cleared
  36966. * @param stencil defines if the stencil buffer must be cleared
  36967. */
  36968. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36969. private _viewportCached;
  36970. /** @hidden */
  36971. _viewport(x: number, y: number, width: number, height: number): void;
  36972. /**
  36973. * Set the WebGL's viewport
  36974. * @param viewport defines the viewport element to be used
  36975. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36976. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36977. */
  36978. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36979. /**
  36980. * Begin a new frame
  36981. */
  36982. beginFrame(): void;
  36983. /**
  36984. * Enf the current frame
  36985. */
  36986. endFrame(): void;
  36987. /**
  36988. * Resize the view according to the canvas' size
  36989. */
  36990. resize(): void;
  36991. /**
  36992. * Force a specific size of the canvas
  36993. * @param width defines the new canvas' width
  36994. * @param height defines the new canvas' height
  36995. * @returns true if the size was changed
  36996. */
  36997. setSize(width: number, height: number): boolean;
  36998. /**
  36999. * Binds the frame buffer to the specified texture.
  37000. * @param texture The texture to render to or null for the default canvas
  37001. * @param faceIndex The face of the texture to render to in case of cube texture
  37002. * @param requiredWidth The width of the target to render to
  37003. * @param requiredHeight The height of the target to render to
  37004. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37005. * @param lodLevel defines the lod level to bind to the frame buffer
  37006. * @param layer defines the 2d array index to bind to frame buffer to
  37007. */
  37008. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37009. /** @hidden */
  37010. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37011. /**
  37012. * Unbind the current render target texture from the webGL context
  37013. * @param texture defines the render target texture to unbind
  37014. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37015. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37016. */
  37017. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37018. /**
  37019. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37020. */
  37021. flushFramebuffer(): void;
  37022. /**
  37023. * Unbind the current render target and bind the default framebuffer
  37024. */
  37025. restoreDefaultFramebuffer(): void;
  37026. /** @hidden */
  37027. protected _resetVertexBufferBinding(): void;
  37028. /**
  37029. * Creates a vertex buffer
  37030. * @param data the data for the vertex buffer
  37031. * @returns the new WebGL static buffer
  37032. */
  37033. createVertexBuffer(data: DataArray): DataBuffer;
  37034. private _createVertexBuffer;
  37035. /**
  37036. * Creates a dynamic vertex buffer
  37037. * @param data the data for the dynamic vertex buffer
  37038. * @returns the new WebGL dynamic buffer
  37039. */
  37040. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37041. protected _resetIndexBufferBinding(): void;
  37042. /**
  37043. * Creates a new index buffer
  37044. * @param indices defines the content of the index buffer
  37045. * @param updatable defines if the index buffer must be updatable
  37046. * @returns a new webGL buffer
  37047. */
  37048. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37049. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37050. /**
  37051. * Bind a webGL buffer to the webGL context
  37052. * @param buffer defines the buffer to bind
  37053. */
  37054. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37055. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37056. private bindBuffer;
  37057. /**
  37058. * update the bound buffer with the given data
  37059. * @param data defines the data to update
  37060. */
  37061. updateArrayBuffer(data: Float32Array): void;
  37062. private _vertexAttribPointer;
  37063. /** @hidden */
  37064. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37065. private _bindVertexBuffersAttributes;
  37066. /**
  37067. * Records a vertex array object
  37068. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37069. * @param vertexBuffers defines the list of vertex buffers to store
  37070. * @param indexBuffer defines the index buffer to store
  37071. * @param effect defines the effect to store
  37072. * @returns the new vertex array object
  37073. */
  37074. recordVertexArrayObject(vertexBuffers: {
  37075. [key: string]: VertexBuffer;
  37076. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37077. /**
  37078. * Bind a specific vertex array object
  37079. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37080. * @param vertexArrayObject defines the vertex array object to bind
  37081. * @param indexBuffer defines the index buffer to bind
  37082. */
  37083. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37084. /**
  37085. * Bind webGl buffers directly to the webGL context
  37086. * @param vertexBuffer defines the vertex buffer to bind
  37087. * @param indexBuffer defines the index buffer to bind
  37088. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37089. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37090. * @param effect defines the effect associated with the vertex buffer
  37091. */
  37092. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37093. private _unbindVertexArrayObject;
  37094. /**
  37095. * Bind a list of vertex buffers to the webGL context
  37096. * @param vertexBuffers defines the list of vertex buffers to bind
  37097. * @param indexBuffer defines the index buffer to bind
  37098. * @param effect defines the effect associated with the vertex buffers
  37099. */
  37100. bindBuffers(vertexBuffers: {
  37101. [key: string]: Nullable<VertexBuffer>;
  37102. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37103. /**
  37104. * Unbind all instance attributes
  37105. */
  37106. unbindInstanceAttributes(): void;
  37107. /**
  37108. * Release and free the memory of a vertex array object
  37109. * @param vao defines the vertex array object to delete
  37110. */
  37111. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37112. /** @hidden */
  37113. _releaseBuffer(buffer: DataBuffer): boolean;
  37114. protected _deleteBuffer(buffer: DataBuffer): void;
  37115. /**
  37116. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37117. * @param instancesBuffer defines the webGL buffer to update and bind
  37118. * @param data defines the data to store in the buffer
  37119. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37120. */
  37121. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37122. /**
  37123. * Bind the content of a webGL buffer used with instantiation
  37124. * @param instancesBuffer defines the webGL buffer to bind
  37125. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37126. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37127. */
  37128. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37129. /**
  37130. * Disable the instance attribute corresponding to the name in parameter
  37131. * @param name defines the name of the attribute to disable
  37132. */
  37133. disableInstanceAttributeByName(name: string): void;
  37134. /**
  37135. * Disable the instance attribute corresponding to the location in parameter
  37136. * @param attributeLocation defines the attribute location of the attribute to disable
  37137. */
  37138. disableInstanceAttribute(attributeLocation: number): void;
  37139. /**
  37140. * Disable the attribute corresponding to the location in parameter
  37141. * @param attributeLocation defines the attribute location of the attribute to disable
  37142. */
  37143. disableAttributeByIndex(attributeLocation: number): void;
  37144. /**
  37145. * Send a draw order
  37146. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37147. * @param indexStart defines the starting index
  37148. * @param indexCount defines the number of index to draw
  37149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37150. */
  37151. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37152. /**
  37153. * Draw a list of points
  37154. * @param verticesStart defines the index of first vertex to draw
  37155. * @param verticesCount defines the count of vertices to draw
  37156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37157. */
  37158. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37159. /**
  37160. * Draw a list of unindexed primitives
  37161. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37162. * @param verticesStart defines the index of first vertex to draw
  37163. * @param verticesCount defines the count of vertices to draw
  37164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37165. */
  37166. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37167. /**
  37168. * Draw a list of indexed primitives
  37169. * @param fillMode defines the primitive to use
  37170. * @param indexStart defines the starting index
  37171. * @param indexCount defines the number of index to draw
  37172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37173. */
  37174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37175. /**
  37176. * Draw a list of unindexed primitives
  37177. * @param fillMode defines the primitive to use
  37178. * @param verticesStart defines the index of first vertex to draw
  37179. * @param verticesCount defines the count of vertices to draw
  37180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37181. */
  37182. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37183. private _drawMode;
  37184. /** @hidden */
  37185. protected _reportDrawCall(): void;
  37186. /** @hidden */
  37187. _releaseEffect(effect: Effect): void;
  37188. /** @hidden */
  37189. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37190. /**
  37191. * Create a new effect (used to store vertex/fragment shaders)
  37192. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37193. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37194. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37195. * @param samplers defines an array of string used to represent textures
  37196. * @param defines defines the string containing the defines to use to compile the shaders
  37197. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37198. * @param onCompiled defines a function to call when the effect creation is successful
  37199. * @param onError defines a function to call when the effect creation has failed
  37200. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37201. * @returns the new Effect
  37202. */
  37203. 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;
  37204. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37205. private _compileShader;
  37206. private _compileRawShader;
  37207. /** @hidden */
  37208. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37209. /**
  37210. * Directly creates a webGL program
  37211. * @param pipelineContext defines the pipeline context to attach to
  37212. * @param vertexCode defines the vertex shader code to use
  37213. * @param fragmentCode defines the fragment shader code to use
  37214. * @param context defines the webGL context to use (if not set, the current one will be used)
  37215. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37216. * @returns the new webGL program
  37217. */
  37218. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37219. /**
  37220. * Creates a webGL program
  37221. * @param pipelineContext defines the pipeline context to attach to
  37222. * @param vertexCode defines the vertex shader code to use
  37223. * @param fragmentCode defines the fragment shader code to use
  37224. * @param defines defines the string containing the defines to use to compile the shaders
  37225. * @param context defines the webGL context to use (if not set, the current one will be used)
  37226. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37227. * @returns the new webGL program
  37228. */
  37229. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37230. /**
  37231. * Creates a new pipeline context
  37232. * @returns the new pipeline
  37233. */
  37234. createPipelineContext(): IPipelineContext;
  37235. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37236. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37237. /** @hidden */
  37238. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37239. /** @hidden */
  37240. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37241. /** @hidden */
  37242. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37243. /**
  37244. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37245. * @param pipelineContext defines the pipeline context to use
  37246. * @param uniformsNames defines the list of uniform names
  37247. * @returns an array of webGL uniform locations
  37248. */
  37249. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37250. /**
  37251. * Gets the lsit of active attributes for a given webGL program
  37252. * @param pipelineContext defines the pipeline context to use
  37253. * @param attributesNames defines the list of attribute names to get
  37254. * @returns an array of indices indicating the offset of each attribute
  37255. */
  37256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37257. /**
  37258. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37259. * @param effect defines the effect to activate
  37260. */
  37261. enableEffect(effect: Nullable<Effect>): void;
  37262. /**
  37263. * Set the value of an uniform to a number (int)
  37264. * @param uniform defines the webGL uniform location where to store the value
  37265. * @param value defines the int number to store
  37266. * @returns true if the value was set
  37267. */
  37268. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37269. /**
  37270. * Set the value of an uniform to an array of int32
  37271. * @param uniform defines the webGL uniform location where to store the value
  37272. * @param array defines the array of int32 to store
  37273. * @returns true if the value was set
  37274. */
  37275. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37276. /**
  37277. * Set the value of an uniform to an array of int32 (stored as vec2)
  37278. * @param uniform defines the webGL uniform location where to store the value
  37279. * @param array defines the array of int32 to store
  37280. * @returns true if the value was set
  37281. */
  37282. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37283. /**
  37284. * Set the value of an uniform to an array of int32 (stored as vec3)
  37285. * @param uniform defines the webGL uniform location where to store the value
  37286. * @param array defines the array of int32 to store
  37287. * @returns true if the value was set
  37288. */
  37289. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37290. /**
  37291. * Set the value of an uniform to an array of int32 (stored as vec4)
  37292. * @param uniform defines the webGL uniform location where to store the value
  37293. * @param array defines the array of int32 to store
  37294. * @returns true if the value was set
  37295. */
  37296. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37297. /**
  37298. * Set the value of an uniform to an array of number
  37299. * @param uniform defines the webGL uniform location where to store the value
  37300. * @param array defines the array of number to store
  37301. * @returns true if the value was set
  37302. */
  37303. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37304. /**
  37305. * Set the value of an uniform to an array of number (stored as vec2)
  37306. * @param uniform defines the webGL uniform location where to store the value
  37307. * @param array defines the array of number to store
  37308. * @returns true if the value was set
  37309. */
  37310. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37311. /**
  37312. * Set the value of an uniform to an array of number (stored as vec3)
  37313. * @param uniform defines the webGL uniform location where to store the value
  37314. * @param array defines the array of number to store
  37315. * @returns true if the value was set
  37316. */
  37317. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37318. /**
  37319. * Set the value of an uniform to an array of number (stored as vec4)
  37320. * @param uniform defines the webGL uniform location where to store the value
  37321. * @param array defines the array of number to store
  37322. * @returns true if the value was set
  37323. */
  37324. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37325. /**
  37326. * Set the value of an uniform to an array of float32 (stored as matrices)
  37327. * @param uniform defines the webGL uniform location where to store the value
  37328. * @param matrices defines the array of float32 to store
  37329. * @returns true if the value was set
  37330. */
  37331. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37332. /**
  37333. * Set the value of an uniform to a matrix (3x3)
  37334. * @param uniform defines the webGL uniform location where to store the value
  37335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37336. * @returns true if the value was set
  37337. */
  37338. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37339. /**
  37340. * Set the value of an uniform to a matrix (2x2)
  37341. * @param uniform defines the webGL uniform location where to store the value
  37342. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37343. * @returns true if the value was set
  37344. */
  37345. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37346. /**
  37347. * Set the value of an uniform to a number (float)
  37348. * @param uniform defines the webGL uniform location where to store the value
  37349. * @param value defines the float number to store
  37350. * @returns true if the value was transfered
  37351. */
  37352. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37353. /**
  37354. * Set the value of an uniform to a vec2
  37355. * @param uniform defines the webGL uniform location where to store the value
  37356. * @param x defines the 1st component of the value
  37357. * @param y defines the 2nd component of the value
  37358. * @returns true if the value was set
  37359. */
  37360. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37361. /**
  37362. * Set the value of an uniform to a vec3
  37363. * @param uniform defines the webGL uniform location where to store the value
  37364. * @param x defines the 1st component of the value
  37365. * @param y defines the 2nd component of the value
  37366. * @param z defines the 3rd component of the value
  37367. * @returns true if the value was set
  37368. */
  37369. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37370. /**
  37371. * Set the value of an uniform to a vec4
  37372. * @param uniform defines the webGL uniform location where to store the value
  37373. * @param x defines the 1st component of the value
  37374. * @param y defines the 2nd component of the value
  37375. * @param z defines the 3rd component of the value
  37376. * @param w defines the 4th component of the value
  37377. * @returns true if the value was set
  37378. */
  37379. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37380. /**
  37381. * Apply all cached states (depth, culling, stencil and alpha)
  37382. */
  37383. applyStates(): void;
  37384. /**
  37385. * Enable or disable color writing
  37386. * @param enable defines the state to set
  37387. */
  37388. setColorWrite(enable: boolean): void;
  37389. /**
  37390. * Gets a boolean indicating if color writing is enabled
  37391. * @returns the current color writing state
  37392. */
  37393. getColorWrite(): boolean;
  37394. /**
  37395. * Gets the depth culling state manager
  37396. */
  37397. get depthCullingState(): DepthCullingState;
  37398. /**
  37399. * Gets the alpha state manager
  37400. */
  37401. get alphaState(): AlphaState;
  37402. /**
  37403. * Gets the stencil state manager
  37404. */
  37405. get stencilState(): StencilState;
  37406. /**
  37407. * Clears the list of texture accessible through engine.
  37408. * This can help preventing texture load conflict due to name collision.
  37409. */
  37410. clearInternalTexturesCache(): void;
  37411. /**
  37412. * Force the entire cache to be cleared
  37413. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37414. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37415. */
  37416. wipeCaches(bruteForce?: boolean): void;
  37417. /** @hidden */
  37418. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37419. min: number;
  37420. mag: number;
  37421. };
  37422. /** @hidden */
  37423. _createTexture(): WebGLTexture;
  37424. /**
  37425. * Usually called from Texture.ts.
  37426. * Passed information to create a WebGLTexture
  37427. * @param url defines a value which contains one of the following:
  37428. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37429. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37430. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37432. * @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)
  37433. * @param scene needed for loading to the correct scene
  37434. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37435. * @param onLoad optional callback to be called upon successful completion
  37436. * @param onError optional callback to be called upon failure
  37437. * @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
  37438. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37439. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37440. * @param forcedExtension defines the extension to use to pick the right loader
  37441. * @param mimeType defines an optional mime type
  37442. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37443. */
  37444. 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;
  37445. /**
  37446. * Loads an image as an HTMLImageElement.
  37447. * @param input url string, ArrayBuffer, or Blob to load
  37448. * @param onLoad callback called when the image successfully loads
  37449. * @param onError callback called when the image fails to load
  37450. * @param offlineProvider offline provider for caching
  37451. * @param mimeType optional mime type
  37452. * @returns the HTMLImageElement of the loaded image
  37453. * @hidden
  37454. */
  37455. 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>;
  37456. /**
  37457. * @hidden
  37458. */
  37459. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37460. private _unpackFlipYCached;
  37461. /**
  37462. * In case you are sharing the context with other applications, it might
  37463. * be interested to not cache the unpack flip y state to ensure a consistent
  37464. * value would be set.
  37465. */
  37466. enableUnpackFlipYCached: boolean;
  37467. /** @hidden */
  37468. _unpackFlipY(value: boolean): void;
  37469. /** @hidden */
  37470. _getUnpackAlignement(): number;
  37471. private _getTextureTarget;
  37472. /**
  37473. * Update the sampling mode of a given texture
  37474. * @param samplingMode defines the required sampling mode
  37475. * @param texture defines the texture to update
  37476. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37477. */
  37478. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37479. /**
  37480. * Update the sampling mode of a given texture
  37481. * @param texture defines the texture to update
  37482. * @param wrapU defines the texture wrap mode of the u coordinates
  37483. * @param wrapV defines the texture wrap mode of the v coordinates
  37484. * @param wrapR defines the texture wrap mode of the r coordinates
  37485. */
  37486. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37487. /** @hidden */
  37488. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37489. width: number;
  37490. height: number;
  37491. layers?: number;
  37492. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37493. /** @hidden */
  37494. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37495. /** @hidden */
  37496. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37497. /**
  37498. * Update a portion of an internal texture
  37499. * @param texture defines the texture to update
  37500. * @param imageData defines the data to store into the texture
  37501. * @param xOffset defines the x coordinates of the update rectangle
  37502. * @param yOffset defines the y coordinates of the update rectangle
  37503. * @param width defines the width of the update rectangle
  37504. * @param height defines the height of the update rectangle
  37505. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37506. * @param lod defines the lod level to update (0 by default)
  37507. */
  37508. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37509. /** @hidden */
  37510. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37511. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37512. private _prepareWebGLTexture;
  37513. /** @hidden */
  37514. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37515. private _getDepthStencilBuffer;
  37516. /** @hidden */
  37517. _releaseFramebufferObjects(texture: InternalTexture): void;
  37518. /** @hidden */
  37519. _releaseTexture(texture: InternalTexture): void;
  37520. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37521. protected _setProgram(program: WebGLProgram): void;
  37522. protected _boundUniforms: {
  37523. [key: number]: WebGLUniformLocation;
  37524. };
  37525. /**
  37526. * Binds an effect to the webGL context
  37527. * @param effect defines the effect to bind
  37528. */
  37529. bindSamplers(effect: Effect): void;
  37530. private _activateCurrentTexture;
  37531. /** @hidden */
  37532. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37533. /** @hidden */
  37534. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37535. /**
  37536. * Unbind all textures from the webGL context
  37537. */
  37538. unbindAllTextures(): void;
  37539. /**
  37540. * Sets a texture to the according uniform.
  37541. * @param channel The texture channel
  37542. * @param uniform The uniform to set
  37543. * @param texture The texture to apply
  37544. */
  37545. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37546. private _bindSamplerUniformToChannel;
  37547. private _getTextureWrapMode;
  37548. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37549. /**
  37550. * Sets an array of texture to the webGL context
  37551. * @param channel defines the channel where the texture array must be set
  37552. * @param uniform defines the associated uniform location
  37553. * @param textures defines the array of textures to bind
  37554. */
  37555. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37556. /** @hidden */
  37557. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37558. private _setTextureParameterFloat;
  37559. private _setTextureParameterInteger;
  37560. /**
  37561. * Unbind all vertex attributes from the webGL context
  37562. */
  37563. unbindAllAttributes(): void;
  37564. /**
  37565. * 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
  37566. */
  37567. releaseEffects(): void;
  37568. /**
  37569. * Dispose and release all associated resources
  37570. */
  37571. dispose(): void;
  37572. /**
  37573. * Attach a new callback raised when context lost event is fired
  37574. * @param callback defines the callback to call
  37575. */
  37576. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37577. /**
  37578. * Attach a new callback raised when context restored event is fired
  37579. * @param callback defines the callback to call
  37580. */
  37581. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37582. /**
  37583. * Get the current error code of the webGL context
  37584. * @returns the error code
  37585. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37586. */
  37587. getError(): number;
  37588. private _canRenderToFloatFramebuffer;
  37589. private _canRenderToHalfFloatFramebuffer;
  37590. private _canRenderToFramebuffer;
  37591. /** @hidden */
  37592. _getWebGLTextureType(type: number): number;
  37593. /** @hidden */
  37594. _getInternalFormat(format: number): number;
  37595. /** @hidden */
  37596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37597. /** @hidden */
  37598. _getRGBAMultiSampleBufferFormat(type: number): number;
  37599. /** @hidden */
  37600. _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;
  37601. /**
  37602. * Loads a file from a url
  37603. * @param url url to load
  37604. * @param onSuccess callback called when the file successfully loads
  37605. * @param onProgress callback called while file is loading (if the server supports this mode)
  37606. * @param offlineProvider defines the offline provider for caching
  37607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37608. * @param onError callback called when the file fails to load
  37609. * @returns a file request object
  37610. * @hidden
  37611. */
  37612. 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;
  37613. /**
  37614. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37615. * @param x defines the x coordinate of the rectangle where pixels must be read
  37616. * @param y defines the y coordinate of the rectangle where pixels must be read
  37617. * @param width defines the width of the rectangle where pixels must be read
  37618. * @param height defines the height of the rectangle where pixels must be read
  37619. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37620. * @returns a Uint8Array containing RGBA colors
  37621. */
  37622. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37623. private static _isSupported;
  37624. /**
  37625. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37626. * @returns true if the engine can be created
  37627. * @ignorenaming
  37628. */
  37629. static isSupported(): boolean;
  37630. /**
  37631. * Find the next highest power of two.
  37632. * @param x Number to start search from.
  37633. * @return Next highest power of two.
  37634. */
  37635. static CeilingPOT(x: number): number;
  37636. /**
  37637. * Find the next lowest power of two.
  37638. * @param x Number to start search from.
  37639. * @return Next lowest power of two.
  37640. */
  37641. static FloorPOT(x: number): number;
  37642. /**
  37643. * Find the nearest power of two.
  37644. * @param x Number to start search from.
  37645. * @return Next nearest power of two.
  37646. */
  37647. static NearestPOT(x: number): number;
  37648. /**
  37649. * Get the closest exponent of two
  37650. * @param value defines the value to approximate
  37651. * @param max defines the maximum value to return
  37652. * @param mode defines how to define the closest value
  37653. * @returns closest exponent of two of the given value
  37654. */
  37655. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37656. /**
  37657. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37658. * @param func - the function to be called
  37659. * @param requester - the object that will request the next frame. Falls back to window.
  37660. * @returns frame number
  37661. */
  37662. static QueueNewFrame(func: () => void, requester?: any): number;
  37663. /**
  37664. * Gets host document
  37665. * @returns the host document object
  37666. */
  37667. getHostDocument(): Nullable<Document>;
  37668. }
  37669. }
  37670. declare module "babylonjs/Maths/sphericalPolynomial" {
  37671. import { Vector3 } from "babylonjs/Maths/math.vector";
  37672. import { Color3 } from "babylonjs/Maths/math.color";
  37673. /**
  37674. * Class representing spherical harmonics coefficients to the 3rd degree
  37675. */
  37676. export class SphericalHarmonics {
  37677. /**
  37678. * Defines whether or not the harmonics have been prescaled for rendering.
  37679. */
  37680. preScaled: boolean;
  37681. /**
  37682. * The l0,0 coefficients of the spherical harmonics
  37683. */
  37684. l00: Vector3;
  37685. /**
  37686. * The l1,-1 coefficients of the spherical harmonics
  37687. */
  37688. l1_1: Vector3;
  37689. /**
  37690. * The l1,0 coefficients of the spherical harmonics
  37691. */
  37692. l10: Vector3;
  37693. /**
  37694. * The l1,1 coefficients of the spherical harmonics
  37695. */
  37696. l11: Vector3;
  37697. /**
  37698. * The l2,-2 coefficients of the spherical harmonics
  37699. */
  37700. l2_2: Vector3;
  37701. /**
  37702. * The l2,-1 coefficients of the spherical harmonics
  37703. */
  37704. l2_1: Vector3;
  37705. /**
  37706. * The l2,0 coefficients of the spherical harmonics
  37707. */
  37708. l20: Vector3;
  37709. /**
  37710. * The l2,1 coefficients of the spherical harmonics
  37711. */
  37712. l21: Vector3;
  37713. /**
  37714. * The l2,2 coefficients of the spherical harmonics
  37715. */
  37716. l22: Vector3;
  37717. /**
  37718. * Adds a light to the spherical harmonics
  37719. * @param direction the direction of the light
  37720. * @param color the color of the light
  37721. * @param deltaSolidAngle the delta solid angle of the light
  37722. */
  37723. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37724. /**
  37725. * Scales the spherical harmonics by the given amount
  37726. * @param scale the amount to scale
  37727. */
  37728. scaleInPlace(scale: number): void;
  37729. /**
  37730. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37731. *
  37732. * ```
  37733. * E_lm = A_l * L_lm
  37734. * ```
  37735. *
  37736. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37737. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37738. * the scaling factors are given in equation 9.
  37739. */
  37740. convertIncidentRadianceToIrradiance(): void;
  37741. /**
  37742. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37743. *
  37744. * ```
  37745. * L = (1/pi) * E * rho
  37746. * ```
  37747. *
  37748. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37749. */
  37750. convertIrradianceToLambertianRadiance(): void;
  37751. /**
  37752. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37753. * required operations at run time.
  37754. *
  37755. * This is simply done by scaling back the SH with Ylm constants parameter.
  37756. * The trigonometric part being applied by the shader at run time.
  37757. */
  37758. preScaleForRendering(): void;
  37759. /**
  37760. * Constructs a spherical harmonics from an array.
  37761. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37762. * @returns the spherical harmonics
  37763. */
  37764. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37765. /**
  37766. * Gets the spherical harmonics from polynomial
  37767. * @param polynomial the spherical polynomial
  37768. * @returns the spherical harmonics
  37769. */
  37770. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37771. }
  37772. /**
  37773. * Class representing spherical polynomial coefficients to the 3rd degree
  37774. */
  37775. export class SphericalPolynomial {
  37776. private _harmonics;
  37777. /**
  37778. * The spherical harmonics used to create the polynomials.
  37779. */
  37780. get preScaledHarmonics(): SphericalHarmonics;
  37781. /**
  37782. * The x coefficients of the spherical polynomial
  37783. */
  37784. x: Vector3;
  37785. /**
  37786. * The y coefficients of the spherical polynomial
  37787. */
  37788. y: Vector3;
  37789. /**
  37790. * The z coefficients of the spherical polynomial
  37791. */
  37792. z: Vector3;
  37793. /**
  37794. * The xx coefficients of the spherical polynomial
  37795. */
  37796. xx: Vector3;
  37797. /**
  37798. * The yy coefficients of the spherical polynomial
  37799. */
  37800. yy: Vector3;
  37801. /**
  37802. * The zz coefficients of the spherical polynomial
  37803. */
  37804. zz: Vector3;
  37805. /**
  37806. * The xy coefficients of the spherical polynomial
  37807. */
  37808. xy: Vector3;
  37809. /**
  37810. * The yz coefficients of the spherical polynomial
  37811. */
  37812. yz: Vector3;
  37813. /**
  37814. * The zx coefficients of the spherical polynomial
  37815. */
  37816. zx: Vector3;
  37817. /**
  37818. * Adds an ambient color to the spherical polynomial
  37819. * @param color the color to add
  37820. */
  37821. addAmbient(color: Color3): void;
  37822. /**
  37823. * Scales the spherical polynomial by the given amount
  37824. * @param scale the amount to scale
  37825. */
  37826. scaleInPlace(scale: number): void;
  37827. /**
  37828. * Gets the spherical polynomial from harmonics
  37829. * @param harmonics the spherical harmonics
  37830. * @returns the spherical polynomial
  37831. */
  37832. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37833. /**
  37834. * Constructs a spherical polynomial from an array.
  37835. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37836. * @returns the spherical polynomial
  37837. */
  37838. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37839. }
  37840. }
  37841. declare module "babylonjs/Materials/Textures/internalTexture" {
  37842. import { Observable } from "babylonjs/Misc/observable";
  37843. import { Nullable, int } from "babylonjs/types";
  37844. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37846. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37847. /**
  37848. * Defines the source of the internal texture
  37849. */
  37850. export enum InternalTextureSource {
  37851. /**
  37852. * The source of the texture data is unknown
  37853. */
  37854. Unknown = 0,
  37855. /**
  37856. * Texture data comes from an URL
  37857. */
  37858. Url = 1,
  37859. /**
  37860. * Texture data is only used for temporary storage
  37861. */
  37862. Temp = 2,
  37863. /**
  37864. * Texture data comes from raw data (ArrayBuffer)
  37865. */
  37866. Raw = 3,
  37867. /**
  37868. * Texture content is dynamic (video or dynamic texture)
  37869. */
  37870. Dynamic = 4,
  37871. /**
  37872. * Texture content is generated by rendering to it
  37873. */
  37874. RenderTarget = 5,
  37875. /**
  37876. * Texture content is part of a multi render target process
  37877. */
  37878. MultiRenderTarget = 6,
  37879. /**
  37880. * Texture data comes from a cube data file
  37881. */
  37882. Cube = 7,
  37883. /**
  37884. * Texture data comes from a raw cube data
  37885. */
  37886. CubeRaw = 8,
  37887. /**
  37888. * Texture data come from a prefiltered cube data file
  37889. */
  37890. CubePrefiltered = 9,
  37891. /**
  37892. * Texture content is raw 3D data
  37893. */
  37894. Raw3D = 10,
  37895. /**
  37896. * Texture content is raw 2D array data
  37897. */
  37898. Raw2DArray = 11,
  37899. /**
  37900. * Texture content is a depth texture
  37901. */
  37902. Depth = 12,
  37903. /**
  37904. * Texture data comes from a raw cube data encoded with RGBD
  37905. */
  37906. CubeRawRGBD = 13
  37907. }
  37908. /**
  37909. * Class used to store data associated with WebGL texture data for the engine
  37910. * This class should not be used directly
  37911. */
  37912. export class InternalTexture {
  37913. /** @hidden */
  37914. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37915. /**
  37916. * Defines if the texture is ready
  37917. */
  37918. isReady: boolean;
  37919. /**
  37920. * Defines if the texture is a cube texture
  37921. */
  37922. isCube: boolean;
  37923. /**
  37924. * Defines if the texture contains 3D data
  37925. */
  37926. is3D: boolean;
  37927. /**
  37928. * Defines if the texture contains 2D array data
  37929. */
  37930. is2DArray: boolean;
  37931. /**
  37932. * Defines if the texture contains multiview data
  37933. */
  37934. isMultiview: boolean;
  37935. /**
  37936. * Gets the URL used to load this texture
  37937. */
  37938. url: string;
  37939. /**
  37940. * Gets the sampling mode of the texture
  37941. */
  37942. samplingMode: number;
  37943. /**
  37944. * Gets a boolean indicating if the texture needs mipmaps generation
  37945. */
  37946. generateMipMaps: boolean;
  37947. /**
  37948. * Gets the number of samples used by the texture (WebGL2+ only)
  37949. */
  37950. samples: number;
  37951. /**
  37952. * Gets the type of the texture (int, float...)
  37953. */
  37954. type: number;
  37955. /**
  37956. * Gets the format of the texture (RGB, RGBA...)
  37957. */
  37958. format: number;
  37959. /**
  37960. * Observable called when the texture is loaded
  37961. */
  37962. onLoadedObservable: Observable<InternalTexture>;
  37963. /**
  37964. * Gets the width of the texture
  37965. */
  37966. width: number;
  37967. /**
  37968. * Gets the height of the texture
  37969. */
  37970. height: number;
  37971. /**
  37972. * Gets the depth of the texture
  37973. */
  37974. depth: number;
  37975. /**
  37976. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37977. */
  37978. baseWidth: number;
  37979. /**
  37980. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37981. */
  37982. baseHeight: number;
  37983. /**
  37984. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37985. */
  37986. baseDepth: number;
  37987. /**
  37988. * Gets a boolean indicating if the texture is inverted on Y axis
  37989. */
  37990. invertY: boolean;
  37991. /** @hidden */
  37992. _invertVScale: boolean;
  37993. /** @hidden */
  37994. _associatedChannel: number;
  37995. /** @hidden */
  37996. _source: InternalTextureSource;
  37997. /** @hidden */
  37998. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37999. /** @hidden */
  38000. _bufferView: Nullable<ArrayBufferView>;
  38001. /** @hidden */
  38002. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38003. /** @hidden */
  38004. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38005. /** @hidden */
  38006. _size: number;
  38007. /** @hidden */
  38008. _extension: string;
  38009. /** @hidden */
  38010. _files: Nullable<string[]>;
  38011. /** @hidden */
  38012. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38013. /** @hidden */
  38014. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38015. /** @hidden */
  38016. _framebuffer: Nullable<WebGLFramebuffer>;
  38017. /** @hidden */
  38018. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38019. /** @hidden */
  38020. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38021. /** @hidden */
  38022. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38023. /** @hidden */
  38024. _attachments: Nullable<number[]>;
  38025. /** @hidden */
  38026. _textureArray: Nullable<InternalTexture[]>;
  38027. /** @hidden */
  38028. _cachedCoordinatesMode: Nullable<number>;
  38029. /** @hidden */
  38030. _cachedWrapU: Nullable<number>;
  38031. /** @hidden */
  38032. _cachedWrapV: Nullable<number>;
  38033. /** @hidden */
  38034. _cachedWrapR: Nullable<number>;
  38035. /** @hidden */
  38036. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38037. /** @hidden */
  38038. _isDisabled: boolean;
  38039. /** @hidden */
  38040. _compression: Nullable<string>;
  38041. /** @hidden */
  38042. _generateStencilBuffer: boolean;
  38043. /** @hidden */
  38044. _generateDepthBuffer: boolean;
  38045. /** @hidden */
  38046. _comparisonFunction: number;
  38047. /** @hidden */
  38048. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38049. /** @hidden */
  38050. _lodGenerationScale: number;
  38051. /** @hidden */
  38052. _lodGenerationOffset: number;
  38053. /** @hidden */
  38054. _depthStencilTexture: Nullable<InternalTexture>;
  38055. /** @hidden */
  38056. _colorTextureArray: Nullable<WebGLTexture>;
  38057. /** @hidden */
  38058. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38059. /** @hidden */
  38060. _lodTextureHigh: Nullable<BaseTexture>;
  38061. /** @hidden */
  38062. _lodTextureMid: Nullable<BaseTexture>;
  38063. /** @hidden */
  38064. _lodTextureLow: Nullable<BaseTexture>;
  38065. /** @hidden */
  38066. _isRGBD: boolean;
  38067. /** @hidden */
  38068. _linearSpecularLOD: boolean;
  38069. /** @hidden */
  38070. _irradianceTexture: Nullable<BaseTexture>;
  38071. /** @hidden */
  38072. _webGLTexture: Nullable<WebGLTexture>;
  38073. /** @hidden */
  38074. _references: number;
  38075. /** @hidden */
  38076. _gammaSpace: Nullable<boolean>;
  38077. private _engine;
  38078. /**
  38079. * Gets the Engine the texture belongs to.
  38080. * @returns The babylon engine
  38081. */
  38082. getEngine(): ThinEngine;
  38083. /**
  38084. * Gets the data source type of the texture
  38085. */
  38086. get source(): InternalTextureSource;
  38087. /**
  38088. * Creates a new InternalTexture
  38089. * @param engine defines the engine to use
  38090. * @param source defines the type of data that will be used
  38091. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38092. */
  38093. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38094. /**
  38095. * Increments the number of references (ie. the number of Texture that point to it)
  38096. */
  38097. incrementReferences(): void;
  38098. /**
  38099. * Change the size of the texture (not the size of the content)
  38100. * @param width defines the new width
  38101. * @param height defines the new height
  38102. * @param depth defines the new depth (1 by default)
  38103. */
  38104. updateSize(width: int, height: int, depth?: int): void;
  38105. /** @hidden */
  38106. _rebuild(): void;
  38107. /** @hidden */
  38108. _swapAndDie(target: InternalTexture): void;
  38109. /**
  38110. * Dispose the current allocated resources
  38111. */
  38112. dispose(): void;
  38113. }
  38114. }
  38115. declare module "babylonjs/Audio/analyser" {
  38116. import { Scene } from "babylonjs/scene";
  38117. /**
  38118. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38120. */
  38121. export class Analyser {
  38122. /**
  38123. * Gets or sets the smoothing
  38124. * @ignorenaming
  38125. */
  38126. SMOOTHING: number;
  38127. /**
  38128. * Gets or sets the FFT table size
  38129. * @ignorenaming
  38130. */
  38131. FFT_SIZE: number;
  38132. /**
  38133. * Gets or sets the bar graph amplitude
  38134. * @ignorenaming
  38135. */
  38136. BARGRAPHAMPLITUDE: number;
  38137. /**
  38138. * Gets or sets the position of the debug canvas
  38139. * @ignorenaming
  38140. */
  38141. DEBUGCANVASPOS: {
  38142. x: number;
  38143. y: number;
  38144. };
  38145. /**
  38146. * Gets or sets the debug canvas size
  38147. * @ignorenaming
  38148. */
  38149. DEBUGCANVASSIZE: {
  38150. width: number;
  38151. height: number;
  38152. };
  38153. private _byteFreqs;
  38154. private _byteTime;
  38155. private _floatFreqs;
  38156. private _webAudioAnalyser;
  38157. private _debugCanvas;
  38158. private _debugCanvasContext;
  38159. private _scene;
  38160. private _registerFunc;
  38161. private _audioEngine;
  38162. /**
  38163. * Creates a new analyser
  38164. * @param scene defines hosting scene
  38165. */
  38166. constructor(scene: Scene);
  38167. /**
  38168. * Get the number of data values you will have to play with for the visualization
  38169. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38170. * @returns a number
  38171. */
  38172. getFrequencyBinCount(): number;
  38173. /**
  38174. * Gets the current frequency data as a byte array
  38175. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38176. * @returns a Uint8Array
  38177. */
  38178. getByteFrequencyData(): Uint8Array;
  38179. /**
  38180. * Gets the current waveform as a byte array
  38181. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38182. * @returns a Uint8Array
  38183. */
  38184. getByteTimeDomainData(): Uint8Array;
  38185. /**
  38186. * Gets the current frequency data as a float array
  38187. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38188. * @returns a Float32Array
  38189. */
  38190. getFloatFrequencyData(): Float32Array;
  38191. /**
  38192. * Renders the debug canvas
  38193. */
  38194. drawDebugCanvas(): void;
  38195. /**
  38196. * Stops rendering the debug canvas and removes it
  38197. */
  38198. stopDebugCanvas(): void;
  38199. /**
  38200. * Connects two audio nodes
  38201. * @param inputAudioNode defines first node to connect
  38202. * @param outputAudioNode defines second node to connect
  38203. */
  38204. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38205. /**
  38206. * Releases all associated resources
  38207. */
  38208. dispose(): void;
  38209. }
  38210. }
  38211. declare module "babylonjs/Audio/audioEngine" {
  38212. import { IDisposable } from "babylonjs/scene";
  38213. import { Analyser } from "babylonjs/Audio/analyser";
  38214. import { Nullable } from "babylonjs/types";
  38215. import { Observable } from "babylonjs/Misc/observable";
  38216. /**
  38217. * This represents an audio engine and it is responsible
  38218. * to play, synchronize and analyse sounds throughout the application.
  38219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38220. */
  38221. export interface IAudioEngine extends IDisposable {
  38222. /**
  38223. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38224. */
  38225. readonly canUseWebAudio: boolean;
  38226. /**
  38227. * Gets the current AudioContext if available.
  38228. */
  38229. readonly audioContext: Nullable<AudioContext>;
  38230. /**
  38231. * The master gain node defines the global audio volume of your audio engine.
  38232. */
  38233. readonly masterGain: GainNode;
  38234. /**
  38235. * Gets whether or not mp3 are supported by your browser.
  38236. */
  38237. readonly isMP3supported: boolean;
  38238. /**
  38239. * Gets whether or not ogg are supported by your browser.
  38240. */
  38241. readonly isOGGsupported: boolean;
  38242. /**
  38243. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38244. * @ignoreNaming
  38245. */
  38246. WarnedWebAudioUnsupported: boolean;
  38247. /**
  38248. * Defines if the audio engine relies on a custom unlocked button.
  38249. * In this case, the embedded button will not be displayed.
  38250. */
  38251. useCustomUnlockedButton: boolean;
  38252. /**
  38253. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38254. */
  38255. readonly unlocked: boolean;
  38256. /**
  38257. * Event raised when audio has been unlocked on the browser.
  38258. */
  38259. onAudioUnlockedObservable: Observable<AudioEngine>;
  38260. /**
  38261. * Event raised when audio has been locked on the browser.
  38262. */
  38263. onAudioLockedObservable: Observable<AudioEngine>;
  38264. /**
  38265. * Flags the audio engine in Locked state.
  38266. * This happens due to new browser policies preventing audio to autoplay.
  38267. */
  38268. lock(): void;
  38269. /**
  38270. * Unlocks the audio engine once a user action has been done on the dom.
  38271. * This is helpful to resume play once browser policies have been satisfied.
  38272. */
  38273. unlock(): void;
  38274. /**
  38275. * Gets the global volume sets on the master gain.
  38276. * @returns the global volume if set or -1 otherwise
  38277. */
  38278. getGlobalVolume(): number;
  38279. /**
  38280. * Sets the global volume of your experience (sets on the master gain).
  38281. * @param newVolume Defines the new global volume of the application
  38282. */
  38283. setGlobalVolume(newVolume: number): void;
  38284. /**
  38285. * Connect the audio engine to an audio analyser allowing some amazing
  38286. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38287. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38288. * @param analyser The analyser to connect to the engine
  38289. */
  38290. connectToAnalyser(analyser: Analyser): void;
  38291. }
  38292. /**
  38293. * This represents the default audio engine used in babylon.
  38294. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38296. */
  38297. export class AudioEngine implements IAudioEngine {
  38298. private _audioContext;
  38299. private _audioContextInitialized;
  38300. private _muteButton;
  38301. private _hostElement;
  38302. /**
  38303. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38304. */
  38305. canUseWebAudio: boolean;
  38306. /**
  38307. * The master gain node defines the global audio volume of your audio engine.
  38308. */
  38309. masterGain: GainNode;
  38310. /**
  38311. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38312. * @ignoreNaming
  38313. */
  38314. WarnedWebAudioUnsupported: boolean;
  38315. /**
  38316. * Gets whether or not mp3 are supported by your browser.
  38317. */
  38318. isMP3supported: boolean;
  38319. /**
  38320. * Gets whether or not ogg are supported by your browser.
  38321. */
  38322. isOGGsupported: boolean;
  38323. /**
  38324. * Gets whether audio has been unlocked on the device.
  38325. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38326. * a user interaction has happened.
  38327. */
  38328. unlocked: boolean;
  38329. /**
  38330. * Defines if the audio engine relies on a custom unlocked button.
  38331. * In this case, the embedded button will not be displayed.
  38332. */
  38333. useCustomUnlockedButton: boolean;
  38334. /**
  38335. * Event raised when audio has been unlocked on the browser.
  38336. */
  38337. onAudioUnlockedObservable: Observable<AudioEngine>;
  38338. /**
  38339. * Event raised when audio has been locked on the browser.
  38340. */
  38341. onAudioLockedObservable: Observable<AudioEngine>;
  38342. /**
  38343. * Gets the current AudioContext if available.
  38344. */
  38345. get audioContext(): Nullable<AudioContext>;
  38346. private _connectedAnalyser;
  38347. /**
  38348. * Instantiates a new audio engine.
  38349. *
  38350. * There should be only one per page as some browsers restrict the number
  38351. * of audio contexts you can create.
  38352. * @param hostElement defines the host element where to display the mute icon if necessary
  38353. */
  38354. constructor(hostElement?: Nullable<HTMLElement>);
  38355. /**
  38356. * Flags the audio engine in Locked state.
  38357. * This happens due to new browser policies preventing audio to autoplay.
  38358. */
  38359. lock(): void;
  38360. /**
  38361. * Unlocks the audio engine once a user action has been done on the dom.
  38362. * This is helpful to resume play once browser policies have been satisfied.
  38363. */
  38364. unlock(): void;
  38365. private _resumeAudioContext;
  38366. private _initializeAudioContext;
  38367. private _tryToRun;
  38368. private _triggerRunningState;
  38369. private _triggerSuspendedState;
  38370. private _displayMuteButton;
  38371. private _moveButtonToTopLeft;
  38372. private _onResize;
  38373. private _hideMuteButton;
  38374. /**
  38375. * Destroy and release the resources associated with the audio ccontext.
  38376. */
  38377. dispose(): void;
  38378. /**
  38379. * Gets the global volume sets on the master gain.
  38380. * @returns the global volume if set or -1 otherwise
  38381. */
  38382. getGlobalVolume(): number;
  38383. /**
  38384. * Sets the global volume of your experience (sets on the master gain).
  38385. * @param newVolume Defines the new global volume of the application
  38386. */
  38387. setGlobalVolume(newVolume: number): void;
  38388. /**
  38389. * Connect the audio engine to an audio analyser allowing some amazing
  38390. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38391. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38392. * @param analyser The analyser to connect to the engine
  38393. */
  38394. connectToAnalyser(analyser: Analyser): void;
  38395. }
  38396. }
  38397. declare module "babylonjs/Loading/loadingScreen" {
  38398. /**
  38399. * Interface used to present a loading screen while loading a scene
  38400. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38401. */
  38402. export interface ILoadingScreen {
  38403. /**
  38404. * Function called to display the loading screen
  38405. */
  38406. displayLoadingUI: () => void;
  38407. /**
  38408. * Function called to hide the loading screen
  38409. */
  38410. hideLoadingUI: () => void;
  38411. /**
  38412. * Gets or sets the color to use for the background
  38413. */
  38414. loadingUIBackgroundColor: string;
  38415. /**
  38416. * Gets or sets the text to display while loading
  38417. */
  38418. loadingUIText: string;
  38419. }
  38420. /**
  38421. * Class used for the default loading screen
  38422. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38423. */
  38424. export class DefaultLoadingScreen implements ILoadingScreen {
  38425. private _renderingCanvas;
  38426. private _loadingText;
  38427. private _loadingDivBackgroundColor;
  38428. private _loadingDiv;
  38429. private _loadingTextDiv;
  38430. /** Gets or sets the logo url to use for the default loading screen */
  38431. static DefaultLogoUrl: string;
  38432. /** Gets or sets the spinner url to use for the default loading screen */
  38433. static DefaultSpinnerUrl: string;
  38434. /**
  38435. * Creates a new default loading screen
  38436. * @param _renderingCanvas defines the canvas used to render the scene
  38437. * @param _loadingText defines the default text to display
  38438. * @param _loadingDivBackgroundColor defines the default background color
  38439. */
  38440. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38441. /**
  38442. * Function called to display the loading screen
  38443. */
  38444. displayLoadingUI(): void;
  38445. /**
  38446. * Function called to hide the loading screen
  38447. */
  38448. hideLoadingUI(): void;
  38449. /**
  38450. * Gets or sets the text to display while loading
  38451. */
  38452. set loadingUIText(text: string);
  38453. get loadingUIText(): string;
  38454. /**
  38455. * Gets or sets the color to use for the background
  38456. */
  38457. get loadingUIBackgroundColor(): string;
  38458. set loadingUIBackgroundColor(color: string);
  38459. private _resizeLoadingUI;
  38460. }
  38461. }
  38462. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38463. /**
  38464. * Interface for any object that can request an animation frame
  38465. */
  38466. export interface ICustomAnimationFrameRequester {
  38467. /**
  38468. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38469. */
  38470. renderFunction?: Function;
  38471. /**
  38472. * Called to request the next frame to render to
  38473. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38474. */
  38475. requestAnimationFrame: Function;
  38476. /**
  38477. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38478. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38479. */
  38480. requestID?: number;
  38481. }
  38482. }
  38483. declare module "babylonjs/Misc/performanceMonitor" {
  38484. /**
  38485. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38486. */
  38487. export class PerformanceMonitor {
  38488. private _enabled;
  38489. private _rollingFrameTime;
  38490. private _lastFrameTimeMs;
  38491. /**
  38492. * constructor
  38493. * @param frameSampleSize The number of samples required to saturate the sliding window
  38494. */
  38495. constructor(frameSampleSize?: number);
  38496. /**
  38497. * Samples current frame
  38498. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38499. */
  38500. sampleFrame(timeMs?: number): void;
  38501. /**
  38502. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38503. */
  38504. get averageFrameTime(): number;
  38505. /**
  38506. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38507. */
  38508. get averageFrameTimeVariance(): number;
  38509. /**
  38510. * Returns the frame time of the most recent frame
  38511. */
  38512. get instantaneousFrameTime(): number;
  38513. /**
  38514. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38515. */
  38516. get averageFPS(): number;
  38517. /**
  38518. * Returns the average framerate in frames per second using the most recent frame time
  38519. */
  38520. get instantaneousFPS(): number;
  38521. /**
  38522. * Returns true if enough samples have been taken to completely fill the sliding window
  38523. */
  38524. get isSaturated(): boolean;
  38525. /**
  38526. * Enables contributions to the sliding window sample set
  38527. */
  38528. enable(): void;
  38529. /**
  38530. * Disables contributions to the sliding window sample set
  38531. * Samples will not be interpolated over the disabled period
  38532. */
  38533. disable(): void;
  38534. /**
  38535. * Returns true if sampling is enabled
  38536. */
  38537. get isEnabled(): boolean;
  38538. /**
  38539. * Resets performance monitor
  38540. */
  38541. reset(): void;
  38542. }
  38543. /**
  38544. * RollingAverage
  38545. *
  38546. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38547. */
  38548. export class RollingAverage {
  38549. /**
  38550. * Current average
  38551. */
  38552. average: number;
  38553. /**
  38554. * Current variance
  38555. */
  38556. variance: number;
  38557. protected _samples: Array<number>;
  38558. protected _sampleCount: number;
  38559. protected _pos: number;
  38560. protected _m2: number;
  38561. /**
  38562. * constructor
  38563. * @param length The number of samples required to saturate the sliding window
  38564. */
  38565. constructor(length: number);
  38566. /**
  38567. * Adds a sample to the sample set
  38568. * @param v The sample value
  38569. */
  38570. add(v: number): void;
  38571. /**
  38572. * Returns previously added values or null if outside of history or outside the sliding window domain
  38573. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38574. * @return Value previously recorded with add() or null if outside of range
  38575. */
  38576. history(i: number): number;
  38577. /**
  38578. * Returns true if enough samples have been taken to completely fill the sliding window
  38579. * @return true if sample-set saturated
  38580. */
  38581. isSaturated(): boolean;
  38582. /**
  38583. * Resets the rolling average (equivalent to 0 samples taken so far)
  38584. */
  38585. reset(): void;
  38586. /**
  38587. * Wraps a value around the sample range boundaries
  38588. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38589. * @return Wrapped position in sample range
  38590. */
  38591. protected _wrapPosition(i: number): number;
  38592. }
  38593. }
  38594. declare module "babylonjs/Misc/perfCounter" {
  38595. /**
  38596. * This class is used to track a performance counter which is number based.
  38597. * The user has access to many properties which give statistics of different nature.
  38598. *
  38599. * The implementer can track two kinds of Performance Counter: time and count.
  38600. * 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.
  38601. * 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.
  38602. */
  38603. export class PerfCounter {
  38604. /**
  38605. * Gets or sets a global boolean to turn on and off all the counters
  38606. */
  38607. static Enabled: boolean;
  38608. /**
  38609. * Returns the smallest value ever
  38610. */
  38611. get min(): number;
  38612. /**
  38613. * Returns the biggest value ever
  38614. */
  38615. get max(): number;
  38616. /**
  38617. * Returns the average value since the performance counter is running
  38618. */
  38619. get average(): number;
  38620. /**
  38621. * Returns the average value of the last second the counter was monitored
  38622. */
  38623. get lastSecAverage(): number;
  38624. /**
  38625. * Returns the current value
  38626. */
  38627. get current(): number;
  38628. /**
  38629. * Gets the accumulated total
  38630. */
  38631. get total(): number;
  38632. /**
  38633. * Gets the total value count
  38634. */
  38635. get count(): number;
  38636. /**
  38637. * Creates a new counter
  38638. */
  38639. constructor();
  38640. /**
  38641. * Call this method to start monitoring a new frame.
  38642. * 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.
  38643. */
  38644. fetchNewFrame(): void;
  38645. /**
  38646. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38647. * @param newCount the count value to add to the monitored count
  38648. * @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.
  38649. */
  38650. addCount(newCount: number, fetchResult: boolean): void;
  38651. /**
  38652. * Start monitoring this performance counter
  38653. */
  38654. beginMonitoring(): void;
  38655. /**
  38656. * Compute the time lapsed since the previous beginMonitoring() call.
  38657. * @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
  38658. */
  38659. endMonitoring(newFrame?: boolean): void;
  38660. private _fetchResult;
  38661. private _startMonitoringTime;
  38662. private _min;
  38663. private _max;
  38664. private _average;
  38665. private _current;
  38666. private _totalValueCount;
  38667. private _totalAccumulated;
  38668. private _lastSecAverage;
  38669. private _lastSecAccumulated;
  38670. private _lastSecTime;
  38671. private _lastSecValueCount;
  38672. }
  38673. }
  38674. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38676. import { Nullable } from "babylonjs/types";
  38677. module "babylonjs/Engines/thinEngine" {
  38678. interface ThinEngine {
  38679. /** @hidden */
  38680. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38681. }
  38682. }
  38683. }
  38684. declare module "babylonjs/Engines/engine" {
  38685. import { Observable } from "babylonjs/Misc/observable";
  38686. import { Nullable } from "babylonjs/types";
  38687. import { Scene } from "babylonjs/scene";
  38688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38689. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38690. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38691. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38692. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38693. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38694. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38695. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38696. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38698. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38699. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38700. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38701. import "babylonjs/Engines/Extensions/engine.alpha";
  38702. import "babylonjs/Engines/Extensions/engine.readTexture";
  38703. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38704. import { Material } from "babylonjs/Materials/material";
  38705. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38706. /**
  38707. * Defines the interface used by display changed events
  38708. */
  38709. export interface IDisplayChangedEventArgs {
  38710. /** Gets the vrDisplay object (if any) */
  38711. vrDisplay: Nullable<any>;
  38712. /** Gets a boolean indicating if webVR is supported */
  38713. vrSupported: boolean;
  38714. }
  38715. /**
  38716. * Defines the interface used by objects containing a viewport (like a camera)
  38717. */
  38718. interface IViewportOwnerLike {
  38719. /**
  38720. * Gets or sets the viewport
  38721. */
  38722. viewport: IViewportLike;
  38723. }
  38724. /**
  38725. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38726. */
  38727. export class Engine extends ThinEngine {
  38728. /** Defines that alpha blending is disabled */
  38729. static readonly ALPHA_DISABLE: number;
  38730. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38731. static readonly ALPHA_ADD: number;
  38732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38733. static readonly ALPHA_COMBINE: number;
  38734. /** Defines that alpha blending to DEST - SRC * DEST */
  38735. static readonly ALPHA_SUBTRACT: number;
  38736. /** Defines that alpha blending to SRC * DEST */
  38737. static readonly ALPHA_MULTIPLY: number;
  38738. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38739. static readonly ALPHA_MAXIMIZED: number;
  38740. /** Defines that alpha blending to SRC + DEST */
  38741. static readonly ALPHA_ONEONE: number;
  38742. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38743. static readonly ALPHA_PREMULTIPLIED: number;
  38744. /**
  38745. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38746. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38747. */
  38748. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38749. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38750. static readonly ALPHA_INTERPOLATE: number;
  38751. /**
  38752. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38753. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38754. */
  38755. static readonly ALPHA_SCREENMODE: number;
  38756. /** Defines that the ressource is not delayed*/
  38757. static readonly DELAYLOADSTATE_NONE: number;
  38758. /** Defines that the ressource was successfully delay loaded */
  38759. static readonly DELAYLOADSTATE_LOADED: number;
  38760. /** Defines that the ressource is currently delay loading */
  38761. static readonly DELAYLOADSTATE_LOADING: number;
  38762. /** Defines that the ressource is delayed and has not started loading */
  38763. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38765. static readonly NEVER: number;
  38766. /** 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 */
  38767. static readonly ALWAYS: number;
  38768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38769. static readonly LESS: number;
  38770. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38771. static readonly EQUAL: number;
  38772. /** 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 */
  38773. static readonly LEQUAL: number;
  38774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38775. static readonly GREATER: number;
  38776. /** 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 */
  38777. static readonly GEQUAL: number;
  38778. /** 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 */
  38779. static readonly NOTEQUAL: number;
  38780. /** Passed to stencilOperation to specify that stencil value must be kept */
  38781. static readonly KEEP: number;
  38782. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38783. static readonly REPLACE: number;
  38784. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38785. static readonly INCR: number;
  38786. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38787. static readonly DECR: number;
  38788. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38789. static readonly INVERT: number;
  38790. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38791. static readonly INCR_WRAP: number;
  38792. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38793. static readonly DECR_WRAP: number;
  38794. /** Texture is not repeating outside of 0..1 UVs */
  38795. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38796. /** Texture is repeating outside of 0..1 UVs */
  38797. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38798. /** Texture is repeating and mirrored */
  38799. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38800. /** ALPHA */
  38801. static readonly TEXTUREFORMAT_ALPHA: number;
  38802. /** LUMINANCE */
  38803. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38804. /** LUMINANCE_ALPHA */
  38805. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38806. /** RGB */
  38807. static readonly TEXTUREFORMAT_RGB: number;
  38808. /** RGBA */
  38809. static readonly TEXTUREFORMAT_RGBA: number;
  38810. /** RED */
  38811. static readonly TEXTUREFORMAT_RED: number;
  38812. /** RED (2nd reference) */
  38813. static readonly TEXTUREFORMAT_R: number;
  38814. /** RG */
  38815. static readonly TEXTUREFORMAT_RG: number;
  38816. /** RED_INTEGER */
  38817. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38818. /** RED_INTEGER (2nd reference) */
  38819. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38820. /** RG_INTEGER */
  38821. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38822. /** RGB_INTEGER */
  38823. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38824. /** RGBA_INTEGER */
  38825. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38826. /** UNSIGNED_BYTE */
  38827. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38828. /** UNSIGNED_BYTE (2nd reference) */
  38829. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38830. /** FLOAT */
  38831. static readonly TEXTURETYPE_FLOAT: number;
  38832. /** HALF_FLOAT */
  38833. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38834. /** BYTE */
  38835. static readonly TEXTURETYPE_BYTE: number;
  38836. /** SHORT */
  38837. static readonly TEXTURETYPE_SHORT: number;
  38838. /** UNSIGNED_SHORT */
  38839. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38840. /** INT */
  38841. static readonly TEXTURETYPE_INT: number;
  38842. /** UNSIGNED_INT */
  38843. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38844. /** UNSIGNED_SHORT_4_4_4_4 */
  38845. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38846. /** UNSIGNED_SHORT_5_5_5_1 */
  38847. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38848. /** UNSIGNED_SHORT_5_6_5 */
  38849. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38850. /** UNSIGNED_INT_2_10_10_10_REV */
  38851. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38852. /** UNSIGNED_INT_24_8 */
  38853. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38854. /** UNSIGNED_INT_10F_11F_11F_REV */
  38855. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38856. /** UNSIGNED_INT_5_9_9_9_REV */
  38857. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38858. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38859. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38860. /** nearest is mag = nearest and min = nearest and mip = linear */
  38861. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38863. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38864. /** Trilinear is mag = linear and min = linear and mip = linear */
  38865. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38866. /** nearest is mag = nearest and min = nearest and mip = linear */
  38867. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38869. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38870. /** Trilinear is mag = linear and min = linear and mip = linear */
  38871. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38872. /** mag = nearest and min = nearest and mip = nearest */
  38873. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38874. /** mag = nearest and min = linear and mip = nearest */
  38875. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38876. /** mag = nearest and min = linear and mip = linear */
  38877. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38878. /** mag = nearest and min = linear and mip = none */
  38879. static readonly TEXTURE_NEAREST_LINEAR: number;
  38880. /** mag = nearest and min = nearest and mip = none */
  38881. static readonly TEXTURE_NEAREST_NEAREST: number;
  38882. /** mag = linear and min = nearest and mip = nearest */
  38883. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38884. /** mag = linear and min = nearest and mip = linear */
  38885. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38886. /** mag = linear and min = linear and mip = none */
  38887. static readonly TEXTURE_LINEAR_LINEAR: number;
  38888. /** mag = linear and min = nearest and mip = none */
  38889. static readonly TEXTURE_LINEAR_NEAREST: number;
  38890. /** Explicit coordinates mode */
  38891. static readonly TEXTURE_EXPLICIT_MODE: number;
  38892. /** Spherical coordinates mode */
  38893. static readonly TEXTURE_SPHERICAL_MODE: number;
  38894. /** Planar coordinates mode */
  38895. static readonly TEXTURE_PLANAR_MODE: number;
  38896. /** Cubic coordinates mode */
  38897. static readonly TEXTURE_CUBIC_MODE: number;
  38898. /** Projection coordinates mode */
  38899. static readonly TEXTURE_PROJECTION_MODE: number;
  38900. /** Skybox coordinates mode */
  38901. static readonly TEXTURE_SKYBOX_MODE: number;
  38902. /** Inverse Cubic coordinates mode */
  38903. static readonly TEXTURE_INVCUBIC_MODE: number;
  38904. /** Equirectangular coordinates mode */
  38905. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38906. /** Equirectangular Fixed coordinates mode */
  38907. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38908. /** Equirectangular Fixed Mirrored coordinates mode */
  38909. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38910. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38911. static readonly SCALEMODE_FLOOR: number;
  38912. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38913. static readonly SCALEMODE_NEAREST: number;
  38914. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38915. static readonly SCALEMODE_CEILING: number;
  38916. /**
  38917. * Returns the current npm package of the sdk
  38918. */
  38919. static get NpmPackage(): string;
  38920. /**
  38921. * Returns the current version of the framework
  38922. */
  38923. static get Version(): string;
  38924. /** Gets the list of created engines */
  38925. static get Instances(): Engine[];
  38926. /**
  38927. * Gets the latest created engine
  38928. */
  38929. static get LastCreatedEngine(): Nullable<Engine>;
  38930. /**
  38931. * Gets the latest created scene
  38932. */
  38933. static get LastCreatedScene(): Nullable<Scene>;
  38934. /**
  38935. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38936. * @param flag defines which part of the materials must be marked as dirty
  38937. * @param predicate defines a predicate used to filter which materials should be affected
  38938. */
  38939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38940. /**
  38941. * Method called to create the default loading screen.
  38942. * This can be overriden in your own app.
  38943. * @param canvas The rendering canvas element
  38944. * @returns The loading screen
  38945. */
  38946. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38947. /**
  38948. * Method called to create the default rescale post process on each engine.
  38949. */
  38950. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38951. /**
  38952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38953. **/
  38954. enableOfflineSupport: boolean;
  38955. /**
  38956. * 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)
  38957. **/
  38958. disableManifestCheck: boolean;
  38959. /**
  38960. * Gets the list of created scenes
  38961. */
  38962. scenes: Scene[];
  38963. /**
  38964. * Event raised when a new scene is created
  38965. */
  38966. onNewSceneAddedObservable: Observable<Scene>;
  38967. /**
  38968. * Gets the list of created postprocesses
  38969. */
  38970. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38971. /**
  38972. * Gets a boolean indicating if the pointer is currently locked
  38973. */
  38974. isPointerLock: boolean;
  38975. /**
  38976. * Observable event triggered each time the rendering canvas is resized
  38977. */
  38978. onResizeObservable: Observable<Engine>;
  38979. /**
  38980. * Observable event triggered each time the canvas loses focus
  38981. */
  38982. onCanvasBlurObservable: Observable<Engine>;
  38983. /**
  38984. * Observable event triggered each time the canvas gains focus
  38985. */
  38986. onCanvasFocusObservable: Observable<Engine>;
  38987. /**
  38988. * Observable event triggered each time the canvas receives pointerout event
  38989. */
  38990. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38991. /**
  38992. * Observable raised when the engine begins a new frame
  38993. */
  38994. onBeginFrameObservable: Observable<Engine>;
  38995. /**
  38996. * If set, will be used to request the next animation frame for the render loop
  38997. */
  38998. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38999. /**
  39000. * Observable raised when the engine ends the current frame
  39001. */
  39002. onEndFrameObservable: Observable<Engine>;
  39003. /**
  39004. * Observable raised when the engine is about to compile a shader
  39005. */
  39006. onBeforeShaderCompilationObservable: Observable<Engine>;
  39007. /**
  39008. * Observable raised when the engine has jsut compiled a shader
  39009. */
  39010. onAfterShaderCompilationObservable: Observable<Engine>;
  39011. /**
  39012. * Gets the audio engine
  39013. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39014. * @ignorenaming
  39015. */
  39016. static audioEngine: IAudioEngine;
  39017. /**
  39018. * Default AudioEngine factory responsible of creating the Audio Engine.
  39019. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39020. */
  39021. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39022. /**
  39023. * Default offline support factory responsible of creating a tool used to store data locally.
  39024. * By default, this will create a Database object if the workload has been embedded.
  39025. */
  39026. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39027. private _loadingScreen;
  39028. private _pointerLockRequested;
  39029. private _rescalePostProcess;
  39030. private _deterministicLockstep;
  39031. private _lockstepMaxSteps;
  39032. private _timeStep;
  39033. protected get _supportsHardwareTextureRescaling(): boolean;
  39034. private _fps;
  39035. private _deltaTime;
  39036. /** @hidden */
  39037. _drawCalls: PerfCounter;
  39038. /** 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 */
  39039. canvasTabIndex: number;
  39040. /**
  39041. * Turn this value on if you want to pause FPS computation when in background
  39042. */
  39043. disablePerformanceMonitorInBackground: boolean;
  39044. private _performanceMonitor;
  39045. /**
  39046. * Gets the performance monitor attached to this engine
  39047. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39048. */
  39049. get performanceMonitor(): PerformanceMonitor;
  39050. private _onFocus;
  39051. private _onBlur;
  39052. private _onCanvasPointerOut;
  39053. private _onCanvasBlur;
  39054. private _onCanvasFocus;
  39055. private _onFullscreenChange;
  39056. private _onPointerLockChange;
  39057. /**
  39058. * Gets the HTML element used to attach event listeners
  39059. * @returns a HTML element
  39060. */
  39061. getInputElement(): Nullable<HTMLElement>;
  39062. /**
  39063. * Creates a new engine
  39064. * @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
  39065. * @param antialias defines enable antialiasing (default: false)
  39066. * @param options defines further options to be sent to the getContext() function
  39067. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39068. */
  39069. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39070. /**
  39071. * Gets current aspect ratio
  39072. * @param viewportOwner defines the camera to use to get the aspect ratio
  39073. * @param useScreen defines if screen size must be used (or the current render target if any)
  39074. * @returns a number defining the aspect ratio
  39075. */
  39076. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39077. /**
  39078. * Gets current screen aspect ratio
  39079. * @returns a number defining the aspect ratio
  39080. */
  39081. getScreenAspectRatio(): number;
  39082. /**
  39083. * Gets the client rect of the HTML canvas attached with the current webGL context
  39084. * @returns a client rectanglee
  39085. */
  39086. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39087. /**
  39088. * Gets the client rect of the HTML element used for events
  39089. * @returns a client rectanglee
  39090. */
  39091. getInputElementClientRect(): Nullable<ClientRect>;
  39092. /**
  39093. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39095. * @returns true if engine is in deterministic lock step mode
  39096. */
  39097. isDeterministicLockStep(): boolean;
  39098. /**
  39099. * Gets the max steps when engine is running in deterministic lock step
  39100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39101. * @returns the max steps
  39102. */
  39103. getLockstepMaxSteps(): number;
  39104. /**
  39105. * Returns the time in ms between steps when using deterministic lock step.
  39106. * @returns time step in (ms)
  39107. */
  39108. getTimeStep(): number;
  39109. /**
  39110. * Force the mipmap generation for the given render target texture
  39111. * @param texture defines the render target texture to use
  39112. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39113. */
  39114. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39115. /** States */
  39116. /**
  39117. * Set various states to the webGL context
  39118. * @param culling defines backface culling state
  39119. * @param zOffset defines the value to apply to zOffset (0 by default)
  39120. * @param force defines if states must be applied even if cache is up to date
  39121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39122. */
  39123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39124. /**
  39125. * Set the z offset to apply to current rendering
  39126. * @param value defines the offset to apply
  39127. */
  39128. setZOffset(value: number): void;
  39129. /**
  39130. * Gets the current value of the zOffset
  39131. * @returns the current zOffset state
  39132. */
  39133. getZOffset(): number;
  39134. /**
  39135. * Enable or disable depth buffering
  39136. * @param enable defines the state to set
  39137. */
  39138. setDepthBuffer(enable: boolean): void;
  39139. /**
  39140. * Gets a boolean indicating if depth writing is enabled
  39141. * @returns the current depth writing state
  39142. */
  39143. getDepthWrite(): boolean;
  39144. /**
  39145. * Enable or disable depth writing
  39146. * @param enable defines the state to set
  39147. */
  39148. setDepthWrite(enable: boolean): void;
  39149. /**
  39150. * Gets a boolean indicating if stencil buffer is enabled
  39151. * @returns the current stencil buffer state
  39152. */
  39153. getStencilBuffer(): boolean;
  39154. /**
  39155. * Enable or disable the stencil buffer
  39156. * @param enable defines if the stencil buffer must be enabled or disabled
  39157. */
  39158. setStencilBuffer(enable: boolean): void;
  39159. /**
  39160. * Gets the current stencil mask
  39161. * @returns a number defining the new stencil mask to use
  39162. */
  39163. getStencilMask(): number;
  39164. /**
  39165. * Sets the current stencil mask
  39166. * @param mask defines the new stencil mask to use
  39167. */
  39168. setStencilMask(mask: number): void;
  39169. /**
  39170. * Gets the current stencil function
  39171. * @returns a number defining the stencil function to use
  39172. */
  39173. getStencilFunction(): number;
  39174. /**
  39175. * Gets the current stencil reference value
  39176. * @returns a number defining the stencil reference value to use
  39177. */
  39178. getStencilFunctionReference(): number;
  39179. /**
  39180. * Gets the current stencil mask
  39181. * @returns a number defining the stencil mask to use
  39182. */
  39183. getStencilFunctionMask(): number;
  39184. /**
  39185. * Sets the current stencil function
  39186. * @param stencilFunc defines the new stencil function to use
  39187. */
  39188. setStencilFunction(stencilFunc: number): void;
  39189. /**
  39190. * Sets the current stencil reference
  39191. * @param reference defines the new stencil reference to use
  39192. */
  39193. setStencilFunctionReference(reference: number): void;
  39194. /**
  39195. * Sets the current stencil mask
  39196. * @param mask defines the new stencil mask to use
  39197. */
  39198. setStencilFunctionMask(mask: number): void;
  39199. /**
  39200. * Gets the current stencil operation when stencil fails
  39201. * @returns a number defining stencil operation to use when stencil fails
  39202. */
  39203. getStencilOperationFail(): number;
  39204. /**
  39205. * Gets the current stencil operation when depth fails
  39206. * @returns a number defining stencil operation to use when depth fails
  39207. */
  39208. getStencilOperationDepthFail(): number;
  39209. /**
  39210. * Gets the current stencil operation when stencil passes
  39211. * @returns a number defining stencil operation to use when stencil passes
  39212. */
  39213. getStencilOperationPass(): number;
  39214. /**
  39215. * Sets the stencil operation to use when stencil fails
  39216. * @param operation defines the stencil operation to use when stencil fails
  39217. */
  39218. setStencilOperationFail(operation: number): void;
  39219. /**
  39220. * Sets the stencil operation to use when depth fails
  39221. * @param operation defines the stencil operation to use when depth fails
  39222. */
  39223. setStencilOperationDepthFail(operation: number): void;
  39224. /**
  39225. * Sets the stencil operation to use when stencil passes
  39226. * @param operation defines the stencil operation to use when stencil passes
  39227. */
  39228. setStencilOperationPass(operation: number): void;
  39229. /**
  39230. * Sets a boolean indicating if the dithering state is enabled or disabled
  39231. * @param value defines the dithering state
  39232. */
  39233. setDitheringState(value: boolean): void;
  39234. /**
  39235. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39236. * @param value defines the rasterizer state
  39237. */
  39238. setRasterizerState(value: boolean): void;
  39239. /**
  39240. * Gets the current depth function
  39241. * @returns a number defining the depth function
  39242. */
  39243. getDepthFunction(): Nullable<number>;
  39244. /**
  39245. * Sets the current depth function
  39246. * @param depthFunc defines the function to use
  39247. */
  39248. setDepthFunction(depthFunc: number): void;
  39249. /**
  39250. * Sets the current depth function to GREATER
  39251. */
  39252. setDepthFunctionToGreater(): void;
  39253. /**
  39254. * Sets the current depth function to GEQUAL
  39255. */
  39256. setDepthFunctionToGreaterOrEqual(): void;
  39257. /**
  39258. * Sets the current depth function to LESS
  39259. */
  39260. setDepthFunctionToLess(): void;
  39261. /**
  39262. * Sets the current depth function to LEQUAL
  39263. */
  39264. setDepthFunctionToLessOrEqual(): void;
  39265. private _cachedStencilBuffer;
  39266. private _cachedStencilFunction;
  39267. private _cachedStencilMask;
  39268. private _cachedStencilOperationPass;
  39269. private _cachedStencilOperationFail;
  39270. private _cachedStencilOperationDepthFail;
  39271. private _cachedStencilReference;
  39272. /**
  39273. * Caches the the state of the stencil buffer
  39274. */
  39275. cacheStencilState(): void;
  39276. /**
  39277. * Restores the state of the stencil buffer
  39278. */
  39279. restoreStencilState(): void;
  39280. /**
  39281. * Directly set the WebGL Viewport
  39282. * @param x defines the x coordinate of the viewport (in screen space)
  39283. * @param y defines the y coordinate of the viewport (in screen space)
  39284. * @param width defines the width of the viewport (in screen space)
  39285. * @param height defines the height of the viewport (in screen space)
  39286. * @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
  39287. */
  39288. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39289. /**
  39290. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39291. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39292. * @param y defines the y-coordinate of the corner of the clear rectangle
  39293. * @param width defines the width of the clear rectangle
  39294. * @param height defines the height of the clear rectangle
  39295. * @param clearColor defines the clear color
  39296. */
  39297. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39298. /**
  39299. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39300. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39301. * @param y defines the y-coordinate of the corner of the clear rectangle
  39302. * @param width defines the width of the clear rectangle
  39303. * @param height defines the height of the clear rectangle
  39304. */
  39305. enableScissor(x: number, y: number, width: number, height: number): void;
  39306. /**
  39307. * Disable previously set scissor test rectangle
  39308. */
  39309. disableScissor(): void;
  39310. protected _reportDrawCall(): void;
  39311. /**
  39312. * Initializes a webVR display and starts listening to display change events
  39313. * The onVRDisplayChangedObservable will be notified upon these changes
  39314. * @returns The onVRDisplayChangedObservable
  39315. */
  39316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39317. /** @hidden */
  39318. _prepareVRComponent(): void;
  39319. /** @hidden */
  39320. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39321. /** @hidden */
  39322. _submitVRFrame(): void;
  39323. /**
  39324. * Call this function to leave webVR mode
  39325. * Will do nothing if webVR is not supported or if there is no webVR device
  39326. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39327. */
  39328. disableVR(): void;
  39329. /**
  39330. * Gets a boolean indicating that the system is in VR mode and is presenting
  39331. * @returns true if VR mode is engaged
  39332. */
  39333. isVRPresenting(): boolean;
  39334. /** @hidden */
  39335. _requestVRFrame(): void;
  39336. /** @hidden */
  39337. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39338. /**
  39339. * Gets the source code of the vertex shader associated with a specific webGL program
  39340. * @param program defines the program to use
  39341. * @returns a string containing the source code of the vertex shader associated with the program
  39342. */
  39343. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39344. /**
  39345. * Gets the source code of the fragment shader associated with a specific webGL program
  39346. * @param program defines the program to use
  39347. * @returns a string containing the source code of the fragment shader associated with the program
  39348. */
  39349. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39350. /**
  39351. * Sets a depth stencil texture from a render target to the according uniform.
  39352. * @param channel The texture channel
  39353. * @param uniform The uniform to set
  39354. * @param texture The render target texture containing the depth stencil texture to apply
  39355. */
  39356. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39357. /**
  39358. * Sets a texture to the webGL context from a postprocess
  39359. * @param channel defines the channel to use
  39360. * @param postProcess defines the source postprocess
  39361. */
  39362. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39363. /**
  39364. * Binds the output of the passed in post process to the texture channel specified
  39365. * @param channel The channel the texture should be bound to
  39366. * @param postProcess The post process which's output should be bound
  39367. */
  39368. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39369. protected _rebuildBuffers(): void;
  39370. /** @hidden */
  39371. _renderFrame(): void;
  39372. _renderLoop(): void;
  39373. /** @hidden */
  39374. _renderViews(): boolean;
  39375. /**
  39376. * Toggle full screen mode
  39377. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39378. */
  39379. switchFullscreen(requestPointerLock: boolean): void;
  39380. /**
  39381. * Enters full screen mode
  39382. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39383. */
  39384. enterFullscreen(requestPointerLock: boolean): void;
  39385. /**
  39386. * Exits full screen mode
  39387. */
  39388. exitFullscreen(): void;
  39389. /**
  39390. * Enters Pointerlock mode
  39391. */
  39392. enterPointerlock(): void;
  39393. /**
  39394. * Exits Pointerlock mode
  39395. */
  39396. exitPointerlock(): void;
  39397. /**
  39398. * Begin a new frame
  39399. */
  39400. beginFrame(): void;
  39401. /**
  39402. * Enf the current frame
  39403. */
  39404. endFrame(): void;
  39405. resize(): void;
  39406. /**
  39407. * Force a specific size of the canvas
  39408. * @param width defines the new canvas' width
  39409. * @param height defines the new canvas' height
  39410. * @returns true if the size was changed
  39411. */
  39412. setSize(width: number, height: number): boolean;
  39413. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39415. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39416. _releaseTexture(texture: InternalTexture): void;
  39417. /**
  39418. * @hidden
  39419. * Rescales a texture
  39420. * @param source input texutre
  39421. * @param destination destination texture
  39422. * @param scene scene to use to render the resize
  39423. * @param internalFormat format to use when resizing
  39424. * @param onComplete callback to be called when resize has completed
  39425. */
  39426. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39427. /**
  39428. * Gets the current framerate
  39429. * @returns a number representing the framerate
  39430. */
  39431. getFps(): number;
  39432. /**
  39433. * Gets the time spent between current and previous frame
  39434. * @returns a number representing the delta time in ms
  39435. */
  39436. getDeltaTime(): number;
  39437. private _measureFps;
  39438. /** @hidden */
  39439. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39440. /**
  39441. * Updates the sample count of a render target texture
  39442. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39443. * @param texture defines the texture to update
  39444. * @param samples defines the sample count to set
  39445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39446. */
  39447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39448. /**
  39449. * Updates a depth texture Comparison Mode and Function.
  39450. * If the comparison Function is equal to 0, the mode will be set to none.
  39451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39452. * @param texture The texture to set the comparison function for
  39453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39454. */
  39455. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39456. /**
  39457. * Creates a webGL buffer to use with instanciation
  39458. * @param capacity defines the size of the buffer
  39459. * @returns the webGL buffer
  39460. */
  39461. createInstancesBuffer(capacity: number): DataBuffer;
  39462. /**
  39463. * Delete a webGL buffer used with instanciation
  39464. * @param buffer defines the webGL buffer to delete
  39465. */
  39466. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39467. private _clientWaitAsync;
  39468. /** @hidden */
  39469. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39470. dispose(): void;
  39471. private _disableTouchAction;
  39472. /**
  39473. * Display the loading screen
  39474. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39475. */
  39476. displayLoadingUI(): void;
  39477. /**
  39478. * Hide the loading screen
  39479. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39480. */
  39481. hideLoadingUI(): void;
  39482. /**
  39483. * Gets the current loading screen object
  39484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39485. */
  39486. get loadingScreen(): ILoadingScreen;
  39487. /**
  39488. * Sets the current loading screen object
  39489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39490. */
  39491. set loadingScreen(loadingScreen: ILoadingScreen);
  39492. /**
  39493. * Sets the current loading screen text
  39494. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39495. */
  39496. set loadingUIText(text: string);
  39497. /**
  39498. * Sets the current loading screen background color
  39499. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39500. */
  39501. set loadingUIBackgroundColor(color: string);
  39502. /** Pointerlock and fullscreen */
  39503. /**
  39504. * Ask the browser to promote the current element to pointerlock mode
  39505. * @param element defines the DOM element to promote
  39506. */
  39507. static _RequestPointerlock(element: HTMLElement): void;
  39508. /**
  39509. * Asks the browser to exit pointerlock mode
  39510. */
  39511. static _ExitPointerlock(): void;
  39512. /**
  39513. * Ask the browser to promote the current element to fullscreen rendering mode
  39514. * @param element defines the DOM element to promote
  39515. */
  39516. static _RequestFullscreen(element: HTMLElement): void;
  39517. /**
  39518. * Asks the browser to exit fullscreen mode
  39519. */
  39520. static _ExitFullscreen(): void;
  39521. }
  39522. }
  39523. declare module "babylonjs/Engines/engineStore" {
  39524. import { Nullable } from "babylonjs/types";
  39525. import { Engine } from "babylonjs/Engines/engine";
  39526. import { Scene } from "babylonjs/scene";
  39527. /**
  39528. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39529. * during the life time of the application.
  39530. */
  39531. export class EngineStore {
  39532. /** Gets the list of created engines */
  39533. static Instances: import("babylonjs/Engines/engine").Engine[];
  39534. /** @hidden */
  39535. static _LastCreatedScene: Nullable<Scene>;
  39536. /**
  39537. * Gets the latest created engine
  39538. */
  39539. static get LastCreatedEngine(): Nullable<Engine>;
  39540. /**
  39541. * Gets the latest created scene
  39542. */
  39543. static get LastCreatedScene(): Nullable<Scene>;
  39544. /**
  39545. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39546. * @ignorenaming
  39547. */
  39548. static UseFallbackTexture: boolean;
  39549. /**
  39550. * Texture content used if a texture cannot loaded
  39551. * @ignorenaming
  39552. */
  39553. static FallbackTexture: string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Misc/promise" {
  39557. /**
  39558. * Helper class that provides a small promise polyfill
  39559. */
  39560. export class PromisePolyfill {
  39561. /**
  39562. * Static function used to check if the polyfill is required
  39563. * If this is the case then the function will inject the polyfill to window.Promise
  39564. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39565. */
  39566. static Apply(force?: boolean): void;
  39567. }
  39568. }
  39569. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39570. /**
  39571. * Interface for screenshot methods with describe argument called `size` as object with options
  39572. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39573. */
  39574. export interface IScreenshotSize {
  39575. /**
  39576. * number in pixels for canvas height
  39577. */
  39578. height?: number;
  39579. /**
  39580. * multiplier allowing render at a higher or lower resolution
  39581. * If value is defined then height and width will be ignored and taken from camera
  39582. */
  39583. precision?: number;
  39584. /**
  39585. * number in pixels for canvas width
  39586. */
  39587. width?: number;
  39588. }
  39589. }
  39590. declare module "babylonjs/Misc/tools" {
  39591. import { Nullable, float } from "babylonjs/types";
  39592. import { DomManagement } from "babylonjs/Misc/domManagement";
  39593. import { WebRequest } from "babylonjs/Misc/webRequest";
  39594. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39595. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39596. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39597. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39598. import { Camera } from "babylonjs/Cameras/camera";
  39599. import { Engine } from "babylonjs/Engines/engine";
  39600. interface IColor4Like {
  39601. r: float;
  39602. g: float;
  39603. b: float;
  39604. a: float;
  39605. }
  39606. /**
  39607. * Class containing a set of static utilities functions
  39608. */
  39609. export class Tools {
  39610. /**
  39611. * Gets or sets the base URL to use to load assets
  39612. */
  39613. static get BaseUrl(): string;
  39614. static set BaseUrl(value: string);
  39615. /**
  39616. * Enable/Disable Custom HTTP Request Headers globally.
  39617. * default = false
  39618. * @see CustomRequestHeaders
  39619. */
  39620. static UseCustomRequestHeaders: boolean;
  39621. /**
  39622. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39623. * i.e. when loading files, where the server/service expects an Authorization header
  39624. */
  39625. static CustomRequestHeaders: {
  39626. [key: string]: string;
  39627. };
  39628. /**
  39629. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39630. */
  39631. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39632. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39633. /**
  39634. * Default behaviour for cors in the application.
  39635. * It can be a string if the expected behavior is identical in the entire app.
  39636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39637. */
  39638. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39639. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39640. /**
  39641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39642. * @ignorenaming
  39643. */
  39644. static get UseFallbackTexture(): boolean;
  39645. static set UseFallbackTexture(value: boolean);
  39646. /**
  39647. * Use this object to register external classes like custom textures or material
  39648. * to allow the laoders to instantiate them
  39649. */
  39650. static get RegisteredExternalClasses(): {
  39651. [key: string]: Object;
  39652. };
  39653. static set RegisteredExternalClasses(classes: {
  39654. [key: string]: Object;
  39655. });
  39656. /**
  39657. * Texture content used if a texture cannot loaded
  39658. * @ignorenaming
  39659. */
  39660. static get fallbackTexture(): string;
  39661. static set fallbackTexture(value: string);
  39662. /**
  39663. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39664. * @param u defines the coordinate on X axis
  39665. * @param v defines the coordinate on Y axis
  39666. * @param width defines the width of the source data
  39667. * @param height defines the height of the source data
  39668. * @param pixels defines the source byte array
  39669. * @param color defines the output color
  39670. */
  39671. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39672. /**
  39673. * Interpolates between a and b via alpha
  39674. * @param a The lower value (returned when alpha = 0)
  39675. * @param b The upper value (returned when alpha = 1)
  39676. * @param alpha The interpolation-factor
  39677. * @return The mixed value
  39678. */
  39679. static Mix(a: number, b: number, alpha: number): number;
  39680. /**
  39681. * Tries to instantiate a new object from a given class name
  39682. * @param className defines the class name to instantiate
  39683. * @returns the new object or null if the system was not able to do the instantiation
  39684. */
  39685. static Instantiate(className: string): any;
  39686. /**
  39687. * Provides a slice function that will work even on IE
  39688. * @param data defines the array to slice
  39689. * @param start defines the start of the data (optional)
  39690. * @param end defines the end of the data (optional)
  39691. * @returns the new sliced array
  39692. */
  39693. static Slice<T>(data: T, start?: number, end?: number): T;
  39694. /**
  39695. * Polyfill for setImmediate
  39696. * @param action defines the action to execute after the current execution block
  39697. */
  39698. static SetImmediate(action: () => void): void;
  39699. /**
  39700. * Function indicating if a number is an exponent of 2
  39701. * @param value defines the value to test
  39702. * @returns true if the value is an exponent of 2
  39703. */
  39704. static IsExponentOfTwo(value: number): boolean;
  39705. private static _tmpFloatArray;
  39706. /**
  39707. * Returns the nearest 32-bit single precision float representation of a Number
  39708. * @param value A Number. If the parameter is of a different type, it will get converted
  39709. * to a number or to NaN if it cannot be converted
  39710. * @returns number
  39711. */
  39712. static FloatRound(value: number): number;
  39713. /**
  39714. * Extracts the filename from a path
  39715. * @param path defines the path to use
  39716. * @returns the filename
  39717. */
  39718. static GetFilename(path: string): string;
  39719. /**
  39720. * Extracts the "folder" part of a path (everything before the filename).
  39721. * @param uri The URI to extract the info from
  39722. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39723. * @returns The "folder" part of the path
  39724. */
  39725. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39726. /**
  39727. * Extracts text content from a DOM element hierarchy
  39728. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39729. */
  39730. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39731. /**
  39732. * Convert an angle in radians to degrees
  39733. * @param angle defines the angle to convert
  39734. * @returns the angle in degrees
  39735. */
  39736. static ToDegrees(angle: number): number;
  39737. /**
  39738. * Convert an angle in degrees to radians
  39739. * @param angle defines the angle to convert
  39740. * @returns the angle in radians
  39741. */
  39742. static ToRadians(angle: number): number;
  39743. /**
  39744. * Returns an array if obj is not an array
  39745. * @param obj defines the object to evaluate as an array
  39746. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39747. * @returns either obj directly if obj is an array or a new array containing obj
  39748. */
  39749. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39750. /**
  39751. * Gets the pointer prefix to use
  39752. * @param engine defines the engine we are finding the prefix for
  39753. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39754. */
  39755. static GetPointerPrefix(engine: Engine): string;
  39756. /**
  39757. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39758. * @param url define the url we are trying
  39759. * @param element define the dom element where to configure the cors policy
  39760. */
  39761. static SetCorsBehavior(url: string | string[], element: {
  39762. crossOrigin: string | null;
  39763. }): void;
  39764. /**
  39765. * Removes unwanted characters from an url
  39766. * @param url defines the url to clean
  39767. * @returns the cleaned url
  39768. */
  39769. static CleanUrl(url: string): string;
  39770. /**
  39771. * Gets or sets a function used to pre-process url before using them to load assets
  39772. */
  39773. static get PreprocessUrl(): (url: string) => string;
  39774. static set PreprocessUrl(processor: (url: string) => string);
  39775. /**
  39776. * Loads an image as an HTMLImageElement.
  39777. * @param input url string, ArrayBuffer, or Blob to load
  39778. * @param onLoad callback called when the image successfully loads
  39779. * @param onError callback called when the image fails to load
  39780. * @param offlineProvider offline provider for caching
  39781. * @param mimeType optional mime type
  39782. * @returns the HTMLImageElement of the loaded image
  39783. */
  39784. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39785. /**
  39786. * Loads a file from a url
  39787. * @param url url string, ArrayBuffer, or Blob to load
  39788. * @param onSuccess callback called when the file successfully loads
  39789. * @param onProgress callback called while file is loading (if the server supports this mode)
  39790. * @param offlineProvider defines the offline provider for caching
  39791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39792. * @param onError callback called when the file fails to load
  39793. * @returns a file request object
  39794. */
  39795. 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;
  39796. /**
  39797. * Loads a file from a url
  39798. * @param url the file url to load
  39799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39800. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39801. */
  39802. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39803. /**
  39804. * Load a script (identified by an url). When the url returns, the
  39805. * content of this file is added into a new script element, attached to the DOM (body element)
  39806. * @param scriptUrl defines the url of the script to laod
  39807. * @param onSuccess defines the callback called when the script is loaded
  39808. * @param onError defines the callback to call if an error occurs
  39809. * @param scriptId defines the id of the script element
  39810. */
  39811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39812. /**
  39813. * Load an asynchronous script (identified by an url). When the url returns, the
  39814. * content of this file is added into a new script element, attached to the DOM (body element)
  39815. * @param scriptUrl defines the url of the script to laod
  39816. * @param scriptId defines the id of the script element
  39817. * @returns a promise request object
  39818. */
  39819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39820. /**
  39821. * Loads a file from a blob
  39822. * @param fileToLoad defines the blob to use
  39823. * @param callback defines the callback to call when data is loaded
  39824. * @param progressCallback defines the callback to call during loading process
  39825. * @returns a file request object
  39826. */
  39827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39828. /**
  39829. * Reads a file from a File object
  39830. * @param file defines the file to load
  39831. * @param onSuccess defines the callback to call when data is loaded
  39832. * @param onProgress defines the callback to call during loading process
  39833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39834. * @param onError defines the callback to call when an error occurs
  39835. * @returns a file request object
  39836. */
  39837. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39838. /**
  39839. * Creates a data url from a given string content
  39840. * @param content defines the content to convert
  39841. * @returns the new data url link
  39842. */
  39843. static FileAsURL(content: string): string;
  39844. /**
  39845. * Format the given number to a specific decimal format
  39846. * @param value defines the number to format
  39847. * @param decimals defines the number of decimals to use
  39848. * @returns the formatted string
  39849. */
  39850. static Format(value: number, decimals?: number): string;
  39851. /**
  39852. * Tries to copy an object by duplicating every property
  39853. * @param source defines the source object
  39854. * @param destination defines the target object
  39855. * @param doNotCopyList defines a list of properties to avoid
  39856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39857. */
  39858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39859. /**
  39860. * Gets a boolean indicating if the given object has no own property
  39861. * @param obj defines the object to test
  39862. * @returns true if object has no own property
  39863. */
  39864. static IsEmpty(obj: any): boolean;
  39865. /**
  39866. * Function used to register events at window level
  39867. * @param windowElement defines the Window object to use
  39868. * @param events defines the events to register
  39869. */
  39870. static RegisterTopRootEvents(windowElement: Window, events: {
  39871. name: string;
  39872. handler: Nullable<(e: FocusEvent) => any>;
  39873. }[]): void;
  39874. /**
  39875. * Function used to unregister events from window level
  39876. * @param windowElement defines the Window object to use
  39877. * @param events defines the events to unregister
  39878. */
  39879. static UnregisterTopRootEvents(windowElement: Window, events: {
  39880. name: string;
  39881. handler: Nullable<(e: FocusEvent) => any>;
  39882. }[]): void;
  39883. /**
  39884. * @ignore
  39885. */
  39886. static _ScreenshotCanvas: HTMLCanvasElement;
  39887. /**
  39888. * Dumps the current bound framebuffer
  39889. * @param width defines the rendering width
  39890. * @param height defines the rendering height
  39891. * @param engine defines the hosting engine
  39892. * @param successCallback defines the callback triggered once the data are available
  39893. * @param mimeType defines the mime type of the result
  39894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39895. */
  39896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39897. /**
  39898. * Converts the canvas data to blob.
  39899. * This acts as a polyfill for browsers not supporting the to blob function.
  39900. * @param canvas Defines the canvas to extract the data from
  39901. * @param successCallback Defines the callback triggered once the data are available
  39902. * @param mimeType Defines the mime type of the result
  39903. */
  39904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39905. /**
  39906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39907. * @param successCallback defines the callback triggered once the data are available
  39908. * @param mimeType defines the mime type of the result
  39909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39910. */
  39911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39912. /**
  39913. * Downloads a blob in the browser
  39914. * @param blob defines the blob to download
  39915. * @param fileName defines the name of the downloaded file
  39916. */
  39917. static Download(blob: Blob, fileName: string): void;
  39918. /**
  39919. * Captures a screenshot of the current rendering
  39920. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39921. * @param engine defines the rendering engine
  39922. * @param camera defines the source camera
  39923. * @param size This parameter can be set to a single number or to an object with the
  39924. * following (optional) properties: precision, width, height. If a single number is passed,
  39925. * it will be used for both width and height. If an object is passed, the screenshot size
  39926. * will be derived from the parameters. The precision property is a multiplier allowing
  39927. * rendering at a higher or lower resolution
  39928. * @param successCallback defines the callback receives a single parameter which contains the
  39929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39930. * src parameter of an <img> to display it
  39931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39932. * Check your browser for supported MIME types
  39933. */
  39934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39935. /**
  39936. * Captures a screenshot of the current rendering
  39937. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39938. * @param engine defines the rendering engine
  39939. * @param camera defines the source camera
  39940. * @param size This parameter can be set to a single number or to an object with the
  39941. * following (optional) properties: precision, width, height. If a single number is passed,
  39942. * it will be used for both width and height. If an object is passed, the screenshot size
  39943. * will be derived from the parameters. The precision property is a multiplier allowing
  39944. * rendering at a higher or lower resolution
  39945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39946. * Check your browser for supported MIME types
  39947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39948. * to the src parameter of an <img> to display it
  39949. */
  39950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39951. /**
  39952. * Generates an image screenshot from the specified camera.
  39953. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39954. * @param engine The engine to use for rendering
  39955. * @param camera The camera to use for rendering
  39956. * @param size This parameter can be set to a single number or to an object with the
  39957. * following (optional) properties: precision, width, height. If a single number is passed,
  39958. * it will be used for both width and height. If an object is passed, the screenshot size
  39959. * will be derived from the parameters. The precision property is a multiplier allowing
  39960. * rendering at a higher or lower resolution
  39961. * @param successCallback The callback receives a single parameter which contains the
  39962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39963. * src parameter of an <img> to display it
  39964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39965. * Check your browser for supported MIME types
  39966. * @param samples Texture samples (default: 1)
  39967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39968. * @param fileName A name for for the downloaded file.
  39969. */
  39970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39971. /**
  39972. * Generates an image screenshot from the specified camera.
  39973. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39974. * @param engine The engine to use for rendering
  39975. * @param camera The camera to use for rendering
  39976. * @param size This parameter can be set to a single number or to an object with the
  39977. * following (optional) properties: precision, width, height. If a single number is passed,
  39978. * it will be used for both width and height. If an object is passed, the screenshot size
  39979. * will be derived from the parameters. The precision property is a multiplier allowing
  39980. * rendering at a higher or lower resolution
  39981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39982. * Check your browser for supported MIME types
  39983. * @param samples Texture samples (default: 1)
  39984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39985. * @param fileName A name for for the downloaded file.
  39986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39987. * to the src parameter of an <img> to display it
  39988. */
  39989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39990. /**
  39991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39992. * Be aware Math.random() could cause collisions, but:
  39993. * "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"
  39994. * @returns a pseudo random id
  39995. */
  39996. static RandomId(): string;
  39997. /**
  39998. * Test if the given uri is a base64 string
  39999. * @param uri The uri to test
  40000. * @return True if the uri is a base64 string or false otherwise
  40001. */
  40002. static IsBase64(uri: string): boolean;
  40003. /**
  40004. * Decode the given base64 uri.
  40005. * @param uri The uri to decode
  40006. * @return The decoded base64 data.
  40007. */
  40008. static DecodeBase64(uri: string): ArrayBuffer;
  40009. /**
  40010. * Gets the absolute url.
  40011. * @param url the input url
  40012. * @return the absolute url
  40013. */
  40014. static GetAbsoluteUrl(url: string): string;
  40015. /**
  40016. * No log
  40017. */
  40018. static readonly NoneLogLevel: number;
  40019. /**
  40020. * Only message logs
  40021. */
  40022. static readonly MessageLogLevel: number;
  40023. /**
  40024. * Only warning logs
  40025. */
  40026. static readonly WarningLogLevel: number;
  40027. /**
  40028. * Only error logs
  40029. */
  40030. static readonly ErrorLogLevel: number;
  40031. /**
  40032. * All logs
  40033. */
  40034. static readonly AllLogLevel: number;
  40035. /**
  40036. * Gets a value indicating the number of loading errors
  40037. * @ignorenaming
  40038. */
  40039. static get errorsCount(): number;
  40040. /**
  40041. * Callback called when a new log is added
  40042. */
  40043. static OnNewCacheEntry: (entry: string) => void;
  40044. /**
  40045. * Log a message to the console
  40046. * @param message defines the message to log
  40047. */
  40048. static Log(message: string): void;
  40049. /**
  40050. * Write a warning message to the console
  40051. * @param message defines the message to log
  40052. */
  40053. static Warn(message: string): void;
  40054. /**
  40055. * Write an error message to the console
  40056. * @param message defines the message to log
  40057. */
  40058. static Error(message: string): void;
  40059. /**
  40060. * Gets current log cache (list of logs)
  40061. */
  40062. static get LogCache(): string;
  40063. /**
  40064. * Clears the log cache
  40065. */
  40066. static ClearLogCache(): void;
  40067. /**
  40068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40069. */
  40070. static set LogLevels(level: number);
  40071. /**
  40072. * Checks if the window object exists
  40073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40074. */
  40075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40076. /**
  40077. * No performance log
  40078. */
  40079. static readonly PerformanceNoneLogLevel: number;
  40080. /**
  40081. * Use user marks to log performance
  40082. */
  40083. static readonly PerformanceUserMarkLogLevel: number;
  40084. /**
  40085. * Log performance to the console
  40086. */
  40087. static readonly PerformanceConsoleLogLevel: number;
  40088. private static _performance;
  40089. /**
  40090. * Sets the current performance log level
  40091. */
  40092. static set PerformanceLogLevel(level: number);
  40093. private static _StartPerformanceCounterDisabled;
  40094. private static _EndPerformanceCounterDisabled;
  40095. private static _StartUserMark;
  40096. private static _EndUserMark;
  40097. private static _StartPerformanceConsole;
  40098. private static _EndPerformanceConsole;
  40099. /**
  40100. * Starts a performance counter
  40101. */
  40102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40103. /**
  40104. * Ends a specific performance coutner
  40105. */
  40106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40107. /**
  40108. * Gets either window.performance.now() if supported or Date.now() else
  40109. */
  40110. static get Now(): number;
  40111. /**
  40112. * This method will return the name of the class used to create the instance of the given object.
  40113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40114. * @param object the object to get the class name from
  40115. * @param isType defines if the object is actually a type
  40116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40117. */
  40118. static GetClassName(object: any, isType?: boolean): string;
  40119. /**
  40120. * Gets the first element of an array satisfying a given predicate
  40121. * @param array defines the array to browse
  40122. * @param predicate defines the predicate to use
  40123. * @returns null if not found or the element
  40124. */
  40125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40126. /**
  40127. * This method will return the name of the full name of the class, including its owning module (if any).
  40128. * 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).
  40129. * @param object the object to get the class name from
  40130. * @param isType defines if the object is actually a type
  40131. * @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.
  40132. * @ignorenaming
  40133. */
  40134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40135. /**
  40136. * Returns a promise that resolves after the given amount of time.
  40137. * @param delay Number of milliseconds to delay
  40138. * @returns Promise that resolves after the given amount of time
  40139. */
  40140. static DelayAsync(delay: number): Promise<void>;
  40141. /**
  40142. * Utility function to detect if the current user agent is Safari
  40143. * @returns whether or not the current user agent is safari
  40144. */
  40145. static IsSafari(): boolean;
  40146. }
  40147. /**
  40148. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40149. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40150. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40151. * @param name The name of the class, case should be preserved
  40152. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40153. */
  40154. export function className(name: string, module?: string): (target: Object) => void;
  40155. /**
  40156. * An implementation of a loop for asynchronous functions.
  40157. */
  40158. export class AsyncLoop {
  40159. /**
  40160. * Defines the number of iterations for the loop
  40161. */
  40162. iterations: number;
  40163. /**
  40164. * Defines the current index of the loop.
  40165. */
  40166. index: number;
  40167. private _done;
  40168. private _fn;
  40169. private _successCallback;
  40170. /**
  40171. * Constructor.
  40172. * @param iterations the number of iterations.
  40173. * @param func the function to run each iteration
  40174. * @param successCallback the callback that will be called upon succesful execution
  40175. * @param offset starting offset.
  40176. */
  40177. constructor(
  40178. /**
  40179. * Defines the number of iterations for the loop
  40180. */
  40181. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40182. /**
  40183. * Execute the next iteration. Must be called after the last iteration was finished.
  40184. */
  40185. executeNext(): void;
  40186. /**
  40187. * Break the loop and run the success callback.
  40188. */
  40189. breakLoop(): void;
  40190. /**
  40191. * Create and run an async loop.
  40192. * @param iterations the number of iterations.
  40193. * @param fn the function to run each iteration
  40194. * @param successCallback the callback that will be called upon succesful execution
  40195. * @param offset starting offset.
  40196. * @returns the created async loop object
  40197. */
  40198. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40199. /**
  40200. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40201. * @param iterations total number of iterations
  40202. * @param syncedIterations number of synchronous iterations in each async iteration.
  40203. * @param fn the function to call each iteration.
  40204. * @param callback a success call back that will be called when iterating stops.
  40205. * @param breakFunction a break condition (optional)
  40206. * @param timeout timeout settings for the setTimeout function. default - 0.
  40207. * @returns the created async loop object
  40208. */
  40209. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40210. }
  40211. }
  40212. declare module "babylonjs/Misc/stringDictionary" {
  40213. import { Nullable } from "babylonjs/types";
  40214. /**
  40215. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40216. * The underlying implementation relies on an associative array to ensure the best performances.
  40217. * The value can be anything including 'null' but except 'undefined'
  40218. */
  40219. export class StringDictionary<T> {
  40220. /**
  40221. * This will clear this dictionary and copy the content from the 'source' one.
  40222. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40223. * @param source the dictionary to take the content from and copy to this dictionary
  40224. */
  40225. copyFrom(source: StringDictionary<T>): void;
  40226. /**
  40227. * Get a value based from its key
  40228. * @param key the given key to get the matching value from
  40229. * @return the value if found, otherwise undefined is returned
  40230. */
  40231. get(key: string): T | undefined;
  40232. /**
  40233. * Get a value from its key or add it if it doesn't exist.
  40234. * This method will ensure you that a given key/data will be present in the dictionary.
  40235. * @param key the given key to get the matching value from
  40236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40237. * The factory will only be invoked if there's no data for the given key.
  40238. * @return the value corresponding to the key.
  40239. */
  40240. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40241. /**
  40242. * Get a value from its key if present in the dictionary otherwise add it
  40243. * @param key the key to get the value from
  40244. * @param val if there's no such key/value pair in the dictionary add it with this value
  40245. * @return the value corresponding to the key
  40246. */
  40247. getOrAdd(key: string, val: T): T;
  40248. /**
  40249. * Check if there's a given key in the dictionary
  40250. * @param key the key to check for
  40251. * @return true if the key is present, false otherwise
  40252. */
  40253. contains(key: string): boolean;
  40254. /**
  40255. * Add a new key and its corresponding value
  40256. * @param key the key to add
  40257. * @param value the value corresponding to the key
  40258. * @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
  40259. */
  40260. add(key: string, value: T): boolean;
  40261. /**
  40262. * Update a specific value associated to a key
  40263. * @param key defines the key to use
  40264. * @param value defines the value to store
  40265. * @returns true if the value was updated (or false if the key was not found)
  40266. */
  40267. set(key: string, value: T): boolean;
  40268. /**
  40269. * Get the element of the given key and remove it from the dictionary
  40270. * @param key defines the key to search
  40271. * @returns the value associated with the key or null if not found
  40272. */
  40273. getAndRemove(key: string): Nullable<T>;
  40274. /**
  40275. * Remove a key/value from the dictionary.
  40276. * @param key the key to remove
  40277. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40278. */
  40279. remove(key: string): boolean;
  40280. /**
  40281. * Clear the whole content of the dictionary
  40282. */
  40283. clear(): void;
  40284. /**
  40285. * Gets the current count
  40286. */
  40287. get count(): number;
  40288. /**
  40289. * Execute a callback on each key/val of the dictionary.
  40290. * Note that you can remove any element in this dictionary in the callback implementation
  40291. * @param callback the callback to execute on a given key/value pair
  40292. */
  40293. forEach(callback: (key: string, val: T) => void): void;
  40294. /**
  40295. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40296. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40297. * Note that you can remove any element in this dictionary in the callback implementation
  40298. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40299. * @returns the first item
  40300. */
  40301. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40302. private _count;
  40303. private _data;
  40304. }
  40305. }
  40306. declare module "babylonjs/Collisions/collisionCoordinator" {
  40307. import { Nullable } from "babylonjs/types";
  40308. import { Scene } from "babylonjs/scene";
  40309. import { Vector3 } from "babylonjs/Maths/math.vector";
  40310. import { Collider } from "babylonjs/Collisions/collider";
  40311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40312. /** @hidden */
  40313. export interface ICollisionCoordinator {
  40314. createCollider(): Collider;
  40315. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40316. init(scene: Scene): void;
  40317. }
  40318. /** @hidden */
  40319. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40320. private _scene;
  40321. private _scaledPosition;
  40322. private _scaledVelocity;
  40323. private _finalPosition;
  40324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40325. createCollider(): Collider;
  40326. init(scene: Scene): void;
  40327. private _collideWithWorld;
  40328. }
  40329. }
  40330. declare module "babylonjs/Inputs/scene.inputManager" {
  40331. import { Nullable } from "babylonjs/types";
  40332. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40333. import { Vector2 } from "babylonjs/Maths/math.vector";
  40334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40335. import { Scene } from "babylonjs/scene";
  40336. /**
  40337. * Class used to manage all inputs for the scene.
  40338. */
  40339. export class InputManager {
  40340. /** The distance in pixel that you have to move to prevent some events */
  40341. static DragMovementThreshold: number;
  40342. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40343. static LongPressDelay: number;
  40344. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40345. static DoubleClickDelay: number;
  40346. /** If you need to check double click without raising a single click at first click, enable this flag */
  40347. static ExclusiveDoubleClickMode: boolean;
  40348. /** 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. */
  40349. private _alreadyAttached;
  40350. private _wheelEventName;
  40351. private _onPointerMove;
  40352. private _onPointerDown;
  40353. private _onPointerUp;
  40354. private _initClickEvent;
  40355. private _initActionManager;
  40356. private _delayedSimpleClick;
  40357. private _delayedSimpleClickTimeout;
  40358. private _previousDelayedSimpleClickTimeout;
  40359. private _meshPickProceed;
  40360. private _previousButtonPressed;
  40361. private _currentPickResult;
  40362. private _previousPickResult;
  40363. private _totalPointersPressed;
  40364. private _doubleClickOccured;
  40365. private _pointerOverMesh;
  40366. private _pickedDownMesh;
  40367. private _pickedUpMesh;
  40368. private _pointerX;
  40369. private _pointerY;
  40370. private _unTranslatedPointerX;
  40371. private _unTranslatedPointerY;
  40372. private _startingPointerPosition;
  40373. private _previousStartingPointerPosition;
  40374. private _startingPointerTime;
  40375. private _previousStartingPointerTime;
  40376. private _pointerCaptures;
  40377. private _meshUnderPointerId;
  40378. private _onKeyDown;
  40379. private _onKeyUp;
  40380. private _onCanvasFocusObserver;
  40381. private _onCanvasBlurObserver;
  40382. private _scene;
  40383. /**
  40384. * Creates a new InputManager
  40385. * @param scene defines the hosting scene
  40386. */
  40387. constructor(scene: Scene);
  40388. /**
  40389. * Gets the mesh that is currently under the pointer
  40390. */
  40391. get meshUnderPointer(): Nullable<AbstractMesh>;
  40392. /**
  40393. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40394. * @param pointerId the pointer id to use
  40395. * @returns The mesh under this pointer id or null if not found
  40396. */
  40397. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40398. /**
  40399. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40400. */
  40401. get unTranslatedPointer(): Vector2;
  40402. /**
  40403. * Gets or sets the current on-screen X position of the pointer
  40404. */
  40405. get pointerX(): number;
  40406. set pointerX(value: number);
  40407. /**
  40408. * Gets or sets the current on-screen Y position of the pointer
  40409. */
  40410. get pointerY(): number;
  40411. set pointerY(value: number);
  40412. private _updatePointerPosition;
  40413. private _processPointerMove;
  40414. private _setRayOnPointerInfo;
  40415. private _checkPrePointerObservable;
  40416. /**
  40417. * Use this method to simulate a pointer move on a mesh
  40418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40421. */
  40422. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40423. /**
  40424. * Use this method to simulate a pointer down on a mesh
  40425. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40426. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40427. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40428. */
  40429. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40430. private _processPointerDown;
  40431. /** @hidden */
  40432. _isPointerSwiping(): boolean;
  40433. /**
  40434. * Use this method to simulate a pointer up on a mesh
  40435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40438. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40439. */
  40440. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40441. private _processPointerUp;
  40442. /**
  40443. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40444. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40445. * @returns true if the pointer was captured
  40446. */
  40447. isPointerCaptured(pointerId?: number): boolean;
  40448. /**
  40449. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40450. * @param attachUp defines if you want to attach events to pointerup
  40451. * @param attachDown defines if you want to attach events to pointerdown
  40452. * @param attachMove defines if you want to attach events to pointermove
  40453. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40454. */
  40455. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40456. /**
  40457. * Detaches all event handlers
  40458. */
  40459. detachControl(): void;
  40460. /**
  40461. * Force the value of meshUnderPointer
  40462. * @param mesh defines the mesh to use
  40463. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40464. */
  40465. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40466. /**
  40467. * Gets the mesh under the pointer
  40468. * @returns a Mesh or null if no mesh is under the pointer
  40469. */
  40470. getPointerOverMesh(): Nullable<AbstractMesh>;
  40471. }
  40472. }
  40473. declare module "babylonjs/Animations/animationGroup" {
  40474. import { Animatable } from "babylonjs/Animations/animatable";
  40475. import { Animation } from "babylonjs/Animations/animation";
  40476. import { Scene, IDisposable } from "babylonjs/scene";
  40477. import { Observable } from "babylonjs/Misc/observable";
  40478. import { Nullable } from "babylonjs/types";
  40479. import "babylonjs/Animations/animatable";
  40480. /**
  40481. * This class defines the direct association between an animation and a target
  40482. */
  40483. export class TargetedAnimation {
  40484. /**
  40485. * Animation to perform
  40486. */
  40487. animation: Animation;
  40488. /**
  40489. * Target to animate
  40490. */
  40491. target: any;
  40492. /**
  40493. * Returns the string "TargetedAnimation"
  40494. * @returns "TargetedAnimation"
  40495. */
  40496. getClassName(): string;
  40497. /**
  40498. * Serialize the object
  40499. * @returns the JSON object representing the current entity
  40500. */
  40501. serialize(): any;
  40502. }
  40503. /**
  40504. * Use this class to create coordinated animations on multiple targets
  40505. */
  40506. export class AnimationGroup implements IDisposable {
  40507. /** The name of the animation group */
  40508. name: string;
  40509. private _scene;
  40510. private _targetedAnimations;
  40511. private _animatables;
  40512. private _from;
  40513. private _to;
  40514. private _isStarted;
  40515. private _isPaused;
  40516. private _speedRatio;
  40517. private _loopAnimation;
  40518. private _isAdditive;
  40519. /**
  40520. * Gets or sets the unique id of the node
  40521. */
  40522. uniqueId: number;
  40523. /**
  40524. * This observable will notify when one animation have ended
  40525. */
  40526. onAnimationEndObservable: Observable<TargetedAnimation>;
  40527. /**
  40528. * Observer raised when one animation loops
  40529. */
  40530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40531. /**
  40532. * Observer raised when all animations have looped
  40533. */
  40534. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40535. /**
  40536. * This observable will notify when all animations have ended.
  40537. */
  40538. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40539. /**
  40540. * This observable will notify when all animations have paused.
  40541. */
  40542. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40543. /**
  40544. * This observable will notify when all animations are playing.
  40545. */
  40546. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40547. /**
  40548. * Gets the first frame
  40549. */
  40550. get from(): number;
  40551. /**
  40552. * Gets the last frame
  40553. */
  40554. get to(): number;
  40555. /**
  40556. * Define if the animations are started
  40557. */
  40558. get isStarted(): boolean;
  40559. /**
  40560. * Gets a value indicating that the current group is playing
  40561. */
  40562. get isPlaying(): boolean;
  40563. /**
  40564. * Gets or sets the speed ratio to use for all animations
  40565. */
  40566. get speedRatio(): number;
  40567. /**
  40568. * Gets or sets the speed ratio to use for all animations
  40569. */
  40570. set speedRatio(value: number);
  40571. /**
  40572. * Gets or sets if all animations should loop or not
  40573. */
  40574. get loopAnimation(): boolean;
  40575. set loopAnimation(value: boolean);
  40576. /**
  40577. * Gets or sets if all animations should be evaluated additively
  40578. */
  40579. get isAdditive(): boolean;
  40580. set isAdditive(value: boolean);
  40581. /**
  40582. * Gets the targeted animations for this animation group
  40583. */
  40584. get targetedAnimations(): Array<TargetedAnimation>;
  40585. /**
  40586. * returning the list of animatables controlled by this animation group.
  40587. */
  40588. get animatables(): Array<Animatable>;
  40589. /**
  40590. * Gets the list of target animations
  40591. */
  40592. get children(): TargetedAnimation[];
  40593. /**
  40594. * Instantiates a new Animation Group.
  40595. * This helps managing several animations at once.
  40596. * @see https://doc.babylonjs.com/how_to/group
  40597. * @param name Defines the name of the group
  40598. * @param scene Defines the scene the group belongs to
  40599. */
  40600. constructor(
  40601. /** The name of the animation group */
  40602. name: string, scene?: Nullable<Scene>);
  40603. /**
  40604. * Add an animation (with its target) in the group
  40605. * @param animation defines the animation we want to add
  40606. * @param target defines the target of the animation
  40607. * @returns the TargetedAnimation object
  40608. */
  40609. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40610. /**
  40611. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40612. * It can add constant keys at begin or end
  40613. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40614. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40615. * @returns the animation group
  40616. */
  40617. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40618. private _animationLoopCount;
  40619. private _animationLoopFlags;
  40620. private _processLoop;
  40621. /**
  40622. * Start all animations on given targets
  40623. * @param loop defines if animations must loop
  40624. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40625. * @param from defines the from key (optional)
  40626. * @param to defines the to key (optional)
  40627. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40628. * @returns the current animation group
  40629. */
  40630. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40631. /**
  40632. * Pause all animations
  40633. * @returns the animation group
  40634. */
  40635. pause(): AnimationGroup;
  40636. /**
  40637. * Play all animations to initial state
  40638. * This function will start() the animations if they were not started or will restart() them if they were paused
  40639. * @param loop defines if animations must loop
  40640. * @returns the animation group
  40641. */
  40642. play(loop?: boolean): AnimationGroup;
  40643. /**
  40644. * Reset all animations to initial state
  40645. * @returns the animation group
  40646. */
  40647. reset(): AnimationGroup;
  40648. /**
  40649. * Restart animations from key 0
  40650. * @returns the animation group
  40651. */
  40652. restart(): AnimationGroup;
  40653. /**
  40654. * Stop all animations
  40655. * @returns the animation group
  40656. */
  40657. stop(): AnimationGroup;
  40658. /**
  40659. * Set animation weight for all animatables
  40660. * @param weight defines the weight to use
  40661. * @return the animationGroup
  40662. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40663. */
  40664. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40665. /**
  40666. * Synchronize and normalize all animatables with a source animatable
  40667. * @param root defines the root animatable to synchronize with
  40668. * @return the animationGroup
  40669. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40670. */
  40671. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40672. /**
  40673. * Goes to a specific frame in this animation group
  40674. * @param frame the frame number to go to
  40675. * @return the animationGroup
  40676. */
  40677. goToFrame(frame: number): AnimationGroup;
  40678. /**
  40679. * Dispose all associated resources
  40680. */
  40681. dispose(): void;
  40682. private _checkAnimationGroupEnded;
  40683. /**
  40684. * Clone the current animation group and returns a copy
  40685. * @param newName defines the name of the new group
  40686. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40687. * @returns the new aniamtion group
  40688. */
  40689. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40690. /**
  40691. * Serializes the animationGroup to an object
  40692. * @returns Serialized object
  40693. */
  40694. serialize(): any;
  40695. /**
  40696. * Returns a new AnimationGroup object parsed from the source provided.
  40697. * @param parsedAnimationGroup defines the source
  40698. * @param scene defines the scene that will receive the animationGroup
  40699. * @returns a new AnimationGroup
  40700. */
  40701. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40702. /**
  40703. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40704. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40705. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40706. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40707. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40708. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40709. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40710. */
  40711. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40712. /**
  40713. * Returns the string "AnimationGroup"
  40714. * @returns "AnimationGroup"
  40715. */
  40716. getClassName(): string;
  40717. /**
  40718. * Creates a detailled string about the object
  40719. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40720. * @returns a string representing the object
  40721. */
  40722. toString(fullDetails?: boolean): string;
  40723. }
  40724. }
  40725. declare module "babylonjs/scene" {
  40726. import { Nullable } from "babylonjs/types";
  40727. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40728. import { Observable } from "babylonjs/Misc/observable";
  40729. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40730. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40731. import { Geometry } from "babylonjs/Meshes/geometry";
  40732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40735. import { Mesh } from "babylonjs/Meshes/mesh";
  40736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40737. import { Bone } from "babylonjs/Bones/bone";
  40738. import { Skeleton } from "babylonjs/Bones/skeleton";
  40739. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40740. import { Camera } from "babylonjs/Cameras/camera";
  40741. import { AbstractScene } from "babylonjs/abstractScene";
  40742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40744. import { Material } from "babylonjs/Materials/material";
  40745. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40746. import { Effect } from "babylonjs/Materials/effect";
  40747. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40748. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40749. import { Light } from "babylonjs/Lights/light";
  40750. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40751. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40752. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40753. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40754. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40756. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40757. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40758. import { Engine } from "babylonjs/Engines/engine";
  40759. import { Node } from "babylonjs/node";
  40760. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40761. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40762. import { WebRequest } from "babylonjs/Misc/webRequest";
  40763. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40764. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40765. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40766. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40767. import { Plane } from "babylonjs/Maths/math.plane";
  40768. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40769. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40770. import { Ray } from "babylonjs/Culling/ray";
  40771. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40772. import { Animation } from "babylonjs/Animations/animation";
  40773. import { Animatable } from "babylonjs/Animations/animatable";
  40774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40775. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40776. import { Collider } from "babylonjs/Collisions/collider";
  40777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40778. /**
  40779. * Define an interface for all classes that will hold resources
  40780. */
  40781. export interface IDisposable {
  40782. /**
  40783. * Releases all held resources
  40784. */
  40785. dispose(): void;
  40786. }
  40787. /** Interface defining initialization parameters for Scene class */
  40788. export interface SceneOptions {
  40789. /**
  40790. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40791. * It will improve performance when the number of geometries becomes important.
  40792. */
  40793. useGeometryUniqueIdsMap?: boolean;
  40794. /**
  40795. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40796. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40797. */
  40798. useMaterialMeshMap?: boolean;
  40799. /**
  40800. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40801. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40802. */
  40803. useClonedMeshMap?: boolean;
  40804. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40805. virtual?: boolean;
  40806. }
  40807. /**
  40808. * Represents a scene to be rendered by the engine.
  40809. * @see https://doc.babylonjs.com/features/scene
  40810. */
  40811. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40812. /** The fog is deactivated */
  40813. static readonly FOGMODE_NONE: number;
  40814. /** The fog density is following an exponential function */
  40815. static readonly FOGMODE_EXP: number;
  40816. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40817. static readonly FOGMODE_EXP2: number;
  40818. /** The fog density is following a linear function. */
  40819. static readonly FOGMODE_LINEAR: number;
  40820. /**
  40821. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40822. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40823. */
  40824. static MinDeltaTime: number;
  40825. /**
  40826. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40827. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40828. */
  40829. static MaxDeltaTime: number;
  40830. /**
  40831. * Factory used to create the default material.
  40832. * @param name The name of the material to create
  40833. * @param scene The scene to create the material for
  40834. * @returns The default material
  40835. */
  40836. static DefaultMaterialFactory(scene: Scene): Material;
  40837. /**
  40838. * Factory used to create the a collision coordinator.
  40839. * @returns The collision coordinator
  40840. */
  40841. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40842. /** @hidden */
  40843. _inputManager: InputManager;
  40844. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40845. cameraToUseForPointers: Nullable<Camera>;
  40846. /** @hidden */
  40847. readonly _isScene: boolean;
  40848. /** @hidden */
  40849. _blockEntityCollection: boolean;
  40850. /**
  40851. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40852. */
  40853. autoClear: boolean;
  40854. /**
  40855. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40856. */
  40857. autoClearDepthAndStencil: boolean;
  40858. /**
  40859. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40860. */
  40861. clearColor: Color4;
  40862. /**
  40863. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40864. */
  40865. ambientColor: Color3;
  40866. /**
  40867. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40868. * It should only be one of the following (if not the default embedded one):
  40869. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40870. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40871. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40872. * The material properties need to be setup according to the type of texture in use.
  40873. */
  40874. environmentBRDFTexture: BaseTexture;
  40875. /**
  40876. * Texture used in all pbr material as the reflection texture.
  40877. * As in the majority of the scene they are the same (exception for multi room and so on),
  40878. * this is easier to reference from here than from all the materials.
  40879. */
  40880. get environmentTexture(): Nullable<BaseTexture>;
  40881. /**
  40882. * Texture used in all pbr material as the reflection texture.
  40883. * As in the majority of the scene they are the same (exception for multi room and so on),
  40884. * this is easier to set here than in all the materials.
  40885. */
  40886. set environmentTexture(value: Nullable<BaseTexture>);
  40887. /** @hidden */
  40888. protected _environmentIntensity: number;
  40889. /**
  40890. * Intensity of the environment in all pbr material.
  40891. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40892. * As in the majority of the scene they are the same (exception for multi room and so on),
  40893. * this is easier to reference from here than from all the materials.
  40894. */
  40895. get environmentIntensity(): number;
  40896. /**
  40897. * Intensity of the environment in all pbr material.
  40898. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40899. * As in the majority of the scene they are the same (exception for multi room and so on),
  40900. * this is easier to set here than in all the materials.
  40901. */
  40902. set environmentIntensity(value: number);
  40903. /** @hidden */
  40904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40905. /**
  40906. * Default image processing configuration used either in the rendering
  40907. * Forward main pass or through the imageProcessingPostProcess if present.
  40908. * As in the majority of the scene they are the same (exception for multi camera),
  40909. * this is easier to reference from here than from all the materials and post process.
  40910. *
  40911. * No setter as we it is a shared configuration, you can set the values instead.
  40912. */
  40913. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40914. private _forceWireframe;
  40915. /**
  40916. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40917. */
  40918. set forceWireframe(value: boolean);
  40919. get forceWireframe(): boolean;
  40920. private _skipFrustumClipping;
  40921. /**
  40922. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40923. */
  40924. set skipFrustumClipping(value: boolean);
  40925. get skipFrustumClipping(): boolean;
  40926. private _forcePointsCloud;
  40927. /**
  40928. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40929. */
  40930. set forcePointsCloud(value: boolean);
  40931. get forcePointsCloud(): boolean;
  40932. /**
  40933. * Gets or sets the active clipplane 1
  40934. */
  40935. clipPlane: Nullable<Plane>;
  40936. /**
  40937. * Gets or sets the active clipplane 2
  40938. */
  40939. clipPlane2: Nullable<Plane>;
  40940. /**
  40941. * Gets or sets the active clipplane 3
  40942. */
  40943. clipPlane3: Nullable<Plane>;
  40944. /**
  40945. * Gets or sets the active clipplane 4
  40946. */
  40947. clipPlane4: Nullable<Plane>;
  40948. /**
  40949. * Gets or sets the active clipplane 5
  40950. */
  40951. clipPlane5: Nullable<Plane>;
  40952. /**
  40953. * Gets or sets the active clipplane 6
  40954. */
  40955. clipPlane6: Nullable<Plane>;
  40956. /**
  40957. * Gets or sets a boolean indicating if animations are enabled
  40958. */
  40959. animationsEnabled: boolean;
  40960. private _animationPropertiesOverride;
  40961. /**
  40962. * Gets or sets the animation properties override
  40963. */
  40964. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40965. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40966. /**
  40967. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40968. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40969. */
  40970. useConstantAnimationDeltaTime: boolean;
  40971. /**
  40972. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40973. * Please note that it requires to run a ray cast through the scene on every frame
  40974. */
  40975. constantlyUpdateMeshUnderPointer: boolean;
  40976. /**
  40977. * Defines the HTML cursor to use when hovering over interactive elements
  40978. */
  40979. hoverCursor: string;
  40980. /**
  40981. * Defines the HTML default cursor to use (empty by default)
  40982. */
  40983. defaultCursor: string;
  40984. /**
  40985. * Defines whether cursors are handled by the scene.
  40986. */
  40987. doNotHandleCursors: boolean;
  40988. /**
  40989. * This is used to call preventDefault() on pointer down
  40990. * in order to block unwanted artifacts like system double clicks
  40991. */
  40992. preventDefaultOnPointerDown: boolean;
  40993. /**
  40994. * This is used to call preventDefault() on pointer up
  40995. * in order to block unwanted artifacts like system double clicks
  40996. */
  40997. preventDefaultOnPointerUp: boolean;
  40998. /**
  40999. * Gets or sets user defined metadata
  41000. */
  41001. metadata: any;
  41002. /**
  41003. * For internal use only. Please do not use.
  41004. */
  41005. reservedDataStore: any;
  41006. /**
  41007. * Gets the name of the plugin used to load this scene (null by default)
  41008. */
  41009. loadingPluginName: string;
  41010. /**
  41011. * Use this array to add regular expressions used to disable offline support for specific urls
  41012. */
  41013. disableOfflineSupportExceptionRules: RegExp[];
  41014. /**
  41015. * An event triggered when the scene is disposed.
  41016. */
  41017. onDisposeObservable: Observable<Scene>;
  41018. private _onDisposeObserver;
  41019. /** Sets a function to be executed when this scene is disposed. */
  41020. set onDispose(callback: () => void);
  41021. /**
  41022. * An event triggered before rendering the scene (right after animations and physics)
  41023. */
  41024. onBeforeRenderObservable: Observable<Scene>;
  41025. private _onBeforeRenderObserver;
  41026. /** Sets a function to be executed before rendering this scene */
  41027. set beforeRender(callback: Nullable<() => void>);
  41028. /**
  41029. * An event triggered after rendering the scene
  41030. */
  41031. onAfterRenderObservable: Observable<Scene>;
  41032. /**
  41033. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41034. */
  41035. onAfterRenderCameraObservable: Observable<Camera>;
  41036. private _onAfterRenderObserver;
  41037. /** Sets a function to be executed after rendering this scene */
  41038. set afterRender(callback: Nullable<() => void>);
  41039. /**
  41040. * An event triggered before animating the scene
  41041. */
  41042. onBeforeAnimationsObservable: Observable<Scene>;
  41043. /**
  41044. * An event triggered after animations processing
  41045. */
  41046. onAfterAnimationsObservable: Observable<Scene>;
  41047. /**
  41048. * An event triggered before draw calls are ready to be sent
  41049. */
  41050. onBeforeDrawPhaseObservable: Observable<Scene>;
  41051. /**
  41052. * An event triggered after draw calls have been sent
  41053. */
  41054. onAfterDrawPhaseObservable: Observable<Scene>;
  41055. /**
  41056. * An event triggered when the scene is ready
  41057. */
  41058. onReadyObservable: Observable<Scene>;
  41059. /**
  41060. * An event triggered before rendering a camera
  41061. */
  41062. onBeforeCameraRenderObservable: Observable<Camera>;
  41063. private _onBeforeCameraRenderObserver;
  41064. /** Sets a function to be executed before rendering a camera*/
  41065. set beforeCameraRender(callback: () => void);
  41066. /**
  41067. * An event triggered after rendering a camera
  41068. */
  41069. onAfterCameraRenderObservable: Observable<Camera>;
  41070. private _onAfterCameraRenderObserver;
  41071. /** Sets a function to be executed after rendering a camera*/
  41072. set afterCameraRender(callback: () => void);
  41073. /**
  41074. * An event triggered when active meshes evaluation is about to start
  41075. */
  41076. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41077. /**
  41078. * An event triggered when active meshes evaluation is done
  41079. */
  41080. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41081. /**
  41082. * An event triggered when particles rendering is about to start
  41083. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41084. */
  41085. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41086. /**
  41087. * An event triggered when particles rendering is done
  41088. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41089. */
  41090. onAfterParticlesRenderingObservable: Observable<Scene>;
  41091. /**
  41092. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41093. */
  41094. onDataLoadedObservable: Observable<Scene>;
  41095. /**
  41096. * An event triggered when a camera is created
  41097. */
  41098. onNewCameraAddedObservable: Observable<Camera>;
  41099. /**
  41100. * An event triggered when a camera is removed
  41101. */
  41102. onCameraRemovedObservable: Observable<Camera>;
  41103. /**
  41104. * An event triggered when a light is created
  41105. */
  41106. onNewLightAddedObservable: Observable<Light>;
  41107. /**
  41108. * An event triggered when a light is removed
  41109. */
  41110. onLightRemovedObservable: Observable<Light>;
  41111. /**
  41112. * An event triggered when a geometry is created
  41113. */
  41114. onNewGeometryAddedObservable: Observable<Geometry>;
  41115. /**
  41116. * An event triggered when a geometry is removed
  41117. */
  41118. onGeometryRemovedObservable: Observable<Geometry>;
  41119. /**
  41120. * An event triggered when a transform node is created
  41121. */
  41122. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41123. /**
  41124. * An event triggered when a transform node is removed
  41125. */
  41126. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41127. /**
  41128. * An event triggered when a mesh is created
  41129. */
  41130. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41131. /**
  41132. * An event triggered when a mesh is removed
  41133. */
  41134. onMeshRemovedObservable: Observable<AbstractMesh>;
  41135. /**
  41136. * An event triggered when a skeleton is created
  41137. */
  41138. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41139. /**
  41140. * An event triggered when a skeleton is removed
  41141. */
  41142. onSkeletonRemovedObservable: Observable<Skeleton>;
  41143. /**
  41144. * An event triggered when a material is created
  41145. */
  41146. onNewMaterialAddedObservable: Observable<Material>;
  41147. /**
  41148. * An event triggered when a material is removed
  41149. */
  41150. onMaterialRemovedObservable: Observable<Material>;
  41151. /**
  41152. * An event triggered when a texture is created
  41153. */
  41154. onNewTextureAddedObservable: Observable<BaseTexture>;
  41155. /**
  41156. * An event triggered when a texture is removed
  41157. */
  41158. onTextureRemovedObservable: Observable<BaseTexture>;
  41159. /**
  41160. * An event triggered when render targets are about to be rendered
  41161. * Can happen multiple times per frame.
  41162. */
  41163. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41164. /**
  41165. * An event triggered when render targets were rendered.
  41166. * Can happen multiple times per frame.
  41167. */
  41168. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41169. /**
  41170. * An event triggered before calculating deterministic simulation step
  41171. */
  41172. onBeforeStepObservable: Observable<Scene>;
  41173. /**
  41174. * An event triggered after calculating deterministic simulation step
  41175. */
  41176. onAfterStepObservable: Observable<Scene>;
  41177. /**
  41178. * An event triggered when the activeCamera property is updated
  41179. */
  41180. onActiveCameraChanged: Observable<Scene>;
  41181. /**
  41182. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41183. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41184. * 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)
  41185. */
  41186. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41187. /**
  41188. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41189. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41190. * 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)
  41191. */
  41192. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41193. /**
  41194. * This Observable will when a mesh has been imported into the scene.
  41195. */
  41196. onMeshImportedObservable: Observable<AbstractMesh>;
  41197. /**
  41198. * This Observable will when an animation file has been imported into the scene.
  41199. */
  41200. onAnimationFileImportedObservable: Observable<Scene>;
  41201. /**
  41202. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41203. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41204. */
  41205. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41206. /** @hidden */
  41207. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41208. /**
  41209. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41210. */
  41211. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41212. /**
  41213. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41214. */
  41215. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41216. /**
  41217. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41218. */
  41219. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41220. /** Callback called when a pointer move is detected */
  41221. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41222. /** Callback called when a pointer down is detected */
  41223. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41224. /** Callback called when a pointer up is detected */
  41225. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41226. /** Callback called when a pointer pick is detected */
  41227. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41228. /**
  41229. * 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).
  41230. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41231. */
  41232. onPrePointerObservable: Observable<PointerInfoPre>;
  41233. /**
  41234. * Observable event triggered each time an input event is received from the rendering canvas
  41235. */
  41236. onPointerObservable: Observable<PointerInfo>;
  41237. /**
  41238. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41239. */
  41240. get unTranslatedPointer(): Vector2;
  41241. /**
  41242. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41243. */
  41244. static get DragMovementThreshold(): number;
  41245. static set DragMovementThreshold(value: number);
  41246. /**
  41247. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41248. */
  41249. static get LongPressDelay(): number;
  41250. static set LongPressDelay(value: number);
  41251. /**
  41252. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41253. */
  41254. static get DoubleClickDelay(): number;
  41255. static set DoubleClickDelay(value: number);
  41256. /** If you need to check double click without raising a single click at first click, enable this flag */
  41257. static get ExclusiveDoubleClickMode(): boolean;
  41258. static set ExclusiveDoubleClickMode(value: boolean);
  41259. /** @hidden */
  41260. _mirroredCameraPosition: Nullable<Vector3>;
  41261. /**
  41262. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41263. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41264. */
  41265. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41266. /**
  41267. * Observable event triggered each time an keyboard event is received from the hosting window
  41268. */
  41269. onKeyboardObservable: Observable<KeyboardInfo>;
  41270. private _useRightHandedSystem;
  41271. /**
  41272. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41273. */
  41274. set useRightHandedSystem(value: boolean);
  41275. get useRightHandedSystem(): boolean;
  41276. private _timeAccumulator;
  41277. private _currentStepId;
  41278. private _currentInternalStep;
  41279. /**
  41280. * Sets the step Id used by deterministic lock step
  41281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41282. * @param newStepId defines the step Id
  41283. */
  41284. setStepId(newStepId: number): void;
  41285. /**
  41286. * Gets the step Id used by deterministic lock step
  41287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41288. * @returns the step Id
  41289. */
  41290. getStepId(): number;
  41291. /**
  41292. * Gets the internal step used by deterministic lock step
  41293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41294. * @returns the internal step
  41295. */
  41296. getInternalStep(): number;
  41297. private _fogEnabled;
  41298. /**
  41299. * Gets or sets a boolean indicating if fog is enabled on this scene
  41300. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41301. * (Default is true)
  41302. */
  41303. set fogEnabled(value: boolean);
  41304. get fogEnabled(): boolean;
  41305. private _fogMode;
  41306. /**
  41307. * Gets or sets the fog mode to use
  41308. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41309. * | mode | value |
  41310. * | --- | --- |
  41311. * | FOGMODE_NONE | 0 |
  41312. * | FOGMODE_EXP | 1 |
  41313. * | FOGMODE_EXP2 | 2 |
  41314. * | FOGMODE_LINEAR | 3 |
  41315. */
  41316. set fogMode(value: number);
  41317. get fogMode(): number;
  41318. /**
  41319. * Gets or sets the fog color to use
  41320. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41321. * (Default is Color3(0.2, 0.2, 0.3))
  41322. */
  41323. fogColor: Color3;
  41324. /**
  41325. * Gets or sets the fog density to use
  41326. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41327. * (Default is 0.1)
  41328. */
  41329. fogDensity: number;
  41330. /**
  41331. * Gets or sets the fog start distance to use
  41332. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41333. * (Default is 0)
  41334. */
  41335. fogStart: number;
  41336. /**
  41337. * Gets or sets the fog end distance to use
  41338. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41339. * (Default is 1000)
  41340. */
  41341. fogEnd: number;
  41342. /**
  41343. * Flag indicating that the frame buffer binding is handled by another component
  41344. */
  41345. prePass: boolean;
  41346. private _shadowsEnabled;
  41347. /**
  41348. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41349. */
  41350. set shadowsEnabled(value: boolean);
  41351. get shadowsEnabled(): boolean;
  41352. private _lightsEnabled;
  41353. /**
  41354. * Gets or sets a boolean indicating if lights are enabled on this scene
  41355. */
  41356. set lightsEnabled(value: boolean);
  41357. get lightsEnabled(): boolean;
  41358. /** All of the active cameras added to this scene. */
  41359. activeCameras: Camera[];
  41360. /** @hidden */
  41361. _activeCamera: Nullable<Camera>;
  41362. /** Gets or sets the current active camera */
  41363. get activeCamera(): Nullable<Camera>;
  41364. set activeCamera(value: Nullable<Camera>);
  41365. private _defaultMaterial;
  41366. /** The default material used on meshes when no material is affected */
  41367. get defaultMaterial(): Material;
  41368. /** The default material used on meshes when no material is affected */
  41369. set defaultMaterial(value: Material);
  41370. private _texturesEnabled;
  41371. /**
  41372. * Gets or sets a boolean indicating if textures are enabled on this scene
  41373. */
  41374. set texturesEnabled(value: boolean);
  41375. get texturesEnabled(): boolean;
  41376. /**
  41377. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41378. */
  41379. physicsEnabled: boolean;
  41380. /**
  41381. * Gets or sets a boolean indicating if particles are enabled on this scene
  41382. */
  41383. particlesEnabled: boolean;
  41384. /**
  41385. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41386. */
  41387. spritesEnabled: boolean;
  41388. private _skeletonsEnabled;
  41389. /**
  41390. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41391. */
  41392. set skeletonsEnabled(value: boolean);
  41393. get skeletonsEnabled(): boolean;
  41394. /**
  41395. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41396. */
  41397. lensFlaresEnabled: boolean;
  41398. /**
  41399. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41400. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41401. */
  41402. collisionsEnabled: boolean;
  41403. private _collisionCoordinator;
  41404. /** @hidden */
  41405. get collisionCoordinator(): ICollisionCoordinator;
  41406. /**
  41407. * Defines the gravity applied to this scene (used only for collisions)
  41408. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41409. */
  41410. gravity: Vector3;
  41411. /**
  41412. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41413. */
  41414. postProcessesEnabled: boolean;
  41415. /**
  41416. * Gets the current postprocess manager
  41417. */
  41418. postProcessManager: PostProcessManager;
  41419. /**
  41420. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41421. */
  41422. renderTargetsEnabled: boolean;
  41423. /**
  41424. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41425. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41426. */
  41427. dumpNextRenderTargets: boolean;
  41428. /**
  41429. * The list of user defined render targets added to the scene
  41430. */
  41431. customRenderTargets: RenderTargetTexture[];
  41432. /**
  41433. * Defines if texture loading must be delayed
  41434. * If true, textures will only be loaded when they need to be rendered
  41435. */
  41436. useDelayedTextureLoading: boolean;
  41437. /**
  41438. * Gets the list of meshes imported to the scene through SceneLoader
  41439. */
  41440. importedMeshesFiles: String[];
  41441. /**
  41442. * Gets or sets a boolean indicating if probes are enabled on this scene
  41443. */
  41444. probesEnabled: boolean;
  41445. /**
  41446. * Gets or sets the current offline provider to use to store scene data
  41447. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41448. */
  41449. offlineProvider: IOfflineProvider;
  41450. /**
  41451. * Gets or sets the action manager associated with the scene
  41452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41453. */
  41454. actionManager: AbstractActionManager;
  41455. private _meshesForIntersections;
  41456. /**
  41457. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41458. */
  41459. proceduralTexturesEnabled: boolean;
  41460. private _engine;
  41461. private _totalVertices;
  41462. /** @hidden */
  41463. _activeIndices: PerfCounter;
  41464. /** @hidden */
  41465. _activeParticles: PerfCounter;
  41466. /** @hidden */
  41467. _activeBones: PerfCounter;
  41468. private _animationRatio;
  41469. /** @hidden */
  41470. _animationTimeLast: number;
  41471. /** @hidden */
  41472. _animationTime: number;
  41473. /**
  41474. * Gets or sets a general scale for animation speed
  41475. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41476. */
  41477. animationTimeScale: number;
  41478. /** @hidden */
  41479. _cachedMaterial: Nullable<Material>;
  41480. /** @hidden */
  41481. _cachedEffect: Nullable<Effect>;
  41482. /** @hidden */
  41483. _cachedVisibility: Nullable<number>;
  41484. private _renderId;
  41485. private _frameId;
  41486. private _executeWhenReadyTimeoutId;
  41487. private _intermediateRendering;
  41488. private _viewUpdateFlag;
  41489. private _projectionUpdateFlag;
  41490. /** @hidden */
  41491. _toBeDisposed: Nullable<IDisposable>[];
  41492. private _activeRequests;
  41493. /** @hidden */
  41494. _pendingData: any[];
  41495. private _isDisposed;
  41496. /**
  41497. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41498. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41499. */
  41500. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41501. private _activeMeshes;
  41502. private _processedMaterials;
  41503. private _renderTargets;
  41504. /** @hidden */
  41505. _activeParticleSystems: SmartArray<IParticleSystem>;
  41506. private _activeSkeletons;
  41507. private _softwareSkinnedMeshes;
  41508. private _renderingManager;
  41509. /** @hidden */
  41510. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41511. private _transformMatrix;
  41512. private _sceneUbo;
  41513. /** @hidden */
  41514. _viewMatrix: Matrix;
  41515. private _projectionMatrix;
  41516. /** @hidden */
  41517. _forcedViewPosition: Nullable<Vector3>;
  41518. /** @hidden */
  41519. _frustumPlanes: Plane[];
  41520. /**
  41521. * Gets the list of frustum planes (built from the active camera)
  41522. */
  41523. get frustumPlanes(): Plane[];
  41524. /**
  41525. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41526. * This is useful if there are more lights that the maximum simulteanous authorized
  41527. */
  41528. requireLightSorting: boolean;
  41529. /** @hidden */
  41530. readonly useMaterialMeshMap: boolean;
  41531. /** @hidden */
  41532. readonly useClonedMeshMap: boolean;
  41533. private _externalData;
  41534. private _uid;
  41535. /**
  41536. * @hidden
  41537. * Backing store of defined scene components.
  41538. */
  41539. _components: ISceneComponent[];
  41540. /**
  41541. * @hidden
  41542. * Backing store of defined scene components.
  41543. */
  41544. _serializableComponents: ISceneSerializableComponent[];
  41545. /**
  41546. * List of components to register on the next registration step.
  41547. */
  41548. private _transientComponents;
  41549. /**
  41550. * Registers the transient components if needed.
  41551. */
  41552. private _registerTransientComponents;
  41553. /**
  41554. * @hidden
  41555. * Add a component to the scene.
  41556. * Note that the ccomponent could be registered on th next frame if this is called after
  41557. * the register component stage.
  41558. * @param component Defines the component to add to the scene
  41559. */
  41560. _addComponent(component: ISceneComponent): void;
  41561. /**
  41562. * @hidden
  41563. * Gets a component from the scene.
  41564. * @param name defines the name of the component to retrieve
  41565. * @returns the component or null if not present
  41566. */
  41567. _getComponent(name: string): Nullable<ISceneComponent>;
  41568. /**
  41569. * @hidden
  41570. * Defines the actions happening before camera updates.
  41571. */
  41572. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41573. /**
  41574. * @hidden
  41575. * Defines the actions happening before clear the canvas.
  41576. */
  41577. _beforeClearStage: Stage<SimpleStageAction>;
  41578. /**
  41579. * @hidden
  41580. * Defines the actions when collecting render targets for the frame.
  41581. */
  41582. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41583. /**
  41584. * @hidden
  41585. * Defines the actions happening for one camera in the frame.
  41586. */
  41587. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41588. /**
  41589. * @hidden
  41590. * Defines the actions happening during the per mesh ready checks.
  41591. */
  41592. _isReadyForMeshStage: Stage<MeshStageAction>;
  41593. /**
  41594. * @hidden
  41595. * Defines the actions happening before evaluate active mesh checks.
  41596. */
  41597. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41598. /**
  41599. * @hidden
  41600. * Defines the actions happening during the evaluate sub mesh checks.
  41601. */
  41602. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41603. /**
  41604. * @hidden
  41605. * Defines the actions happening during the active mesh stage.
  41606. */
  41607. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41608. /**
  41609. * @hidden
  41610. * Defines the actions happening during the per camera render target step.
  41611. */
  41612. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41613. /**
  41614. * @hidden
  41615. * Defines the actions happening just before the active camera is drawing.
  41616. */
  41617. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41618. /**
  41619. * @hidden
  41620. * Defines the actions happening just before a render target is drawing.
  41621. */
  41622. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41623. /**
  41624. * @hidden
  41625. * Defines the actions happening just before a rendering group is drawing.
  41626. */
  41627. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41628. /**
  41629. * @hidden
  41630. * Defines the actions happening just before a mesh is drawing.
  41631. */
  41632. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41633. /**
  41634. * @hidden
  41635. * Defines the actions happening just after a mesh has been drawn.
  41636. */
  41637. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41638. /**
  41639. * @hidden
  41640. * Defines the actions happening just after a rendering group has been drawn.
  41641. */
  41642. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41643. /**
  41644. * @hidden
  41645. * Defines the actions happening just after the active camera has been drawn.
  41646. */
  41647. _afterCameraDrawStage: Stage<CameraStageAction>;
  41648. /**
  41649. * @hidden
  41650. * Defines the actions happening just after a render target has been drawn.
  41651. */
  41652. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41653. /**
  41654. * @hidden
  41655. * Defines the actions happening just after rendering all cameras and computing intersections.
  41656. */
  41657. _afterRenderStage: Stage<SimpleStageAction>;
  41658. /**
  41659. * @hidden
  41660. * Defines the actions happening when a pointer move event happens.
  41661. */
  41662. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41663. /**
  41664. * @hidden
  41665. * Defines the actions happening when a pointer down event happens.
  41666. */
  41667. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41668. /**
  41669. * @hidden
  41670. * Defines the actions happening when a pointer up event happens.
  41671. */
  41672. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41673. /**
  41674. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41675. */
  41676. private geometriesByUniqueId;
  41677. /**
  41678. * Creates a new Scene
  41679. * @param engine defines the engine to use to render this scene
  41680. * @param options defines the scene options
  41681. */
  41682. constructor(engine: Engine, options?: SceneOptions);
  41683. /**
  41684. * Gets a string identifying the name of the class
  41685. * @returns "Scene" string
  41686. */
  41687. getClassName(): string;
  41688. private _defaultMeshCandidates;
  41689. /**
  41690. * @hidden
  41691. */
  41692. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41693. private _defaultSubMeshCandidates;
  41694. /**
  41695. * @hidden
  41696. */
  41697. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41698. /**
  41699. * Sets the default candidate providers for the scene.
  41700. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41701. * and getCollidingSubMeshCandidates to their default function
  41702. */
  41703. setDefaultCandidateProviders(): void;
  41704. /**
  41705. * Gets the mesh that is currently under the pointer
  41706. */
  41707. get meshUnderPointer(): Nullable<AbstractMesh>;
  41708. /**
  41709. * Gets or sets the current on-screen X position of the pointer
  41710. */
  41711. get pointerX(): number;
  41712. set pointerX(value: number);
  41713. /**
  41714. * Gets or sets the current on-screen Y position of the pointer
  41715. */
  41716. get pointerY(): number;
  41717. set pointerY(value: number);
  41718. /**
  41719. * Gets the cached material (ie. the latest rendered one)
  41720. * @returns the cached material
  41721. */
  41722. getCachedMaterial(): Nullable<Material>;
  41723. /**
  41724. * Gets the cached effect (ie. the latest rendered one)
  41725. * @returns the cached effect
  41726. */
  41727. getCachedEffect(): Nullable<Effect>;
  41728. /**
  41729. * Gets the cached visibility state (ie. the latest rendered one)
  41730. * @returns the cached visibility state
  41731. */
  41732. getCachedVisibility(): Nullable<number>;
  41733. /**
  41734. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41735. * @param material defines the current material
  41736. * @param effect defines the current effect
  41737. * @param visibility defines the current visibility state
  41738. * @returns true if one parameter is not cached
  41739. */
  41740. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41741. /**
  41742. * Gets the engine associated with the scene
  41743. * @returns an Engine
  41744. */
  41745. getEngine(): Engine;
  41746. /**
  41747. * Gets the total number of vertices rendered per frame
  41748. * @returns the total number of vertices rendered per frame
  41749. */
  41750. getTotalVertices(): number;
  41751. /**
  41752. * Gets the performance counter for total vertices
  41753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41754. */
  41755. get totalVerticesPerfCounter(): PerfCounter;
  41756. /**
  41757. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41758. * @returns the total number of active indices rendered per frame
  41759. */
  41760. getActiveIndices(): number;
  41761. /**
  41762. * Gets the performance counter for active indices
  41763. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41764. */
  41765. get totalActiveIndicesPerfCounter(): PerfCounter;
  41766. /**
  41767. * Gets the total number of active particles rendered per frame
  41768. * @returns the total number of active particles rendered per frame
  41769. */
  41770. getActiveParticles(): number;
  41771. /**
  41772. * Gets the performance counter for active particles
  41773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41774. */
  41775. get activeParticlesPerfCounter(): PerfCounter;
  41776. /**
  41777. * Gets the total number of active bones rendered per frame
  41778. * @returns the total number of active bones rendered per frame
  41779. */
  41780. getActiveBones(): number;
  41781. /**
  41782. * Gets the performance counter for active bones
  41783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41784. */
  41785. get activeBonesPerfCounter(): PerfCounter;
  41786. /**
  41787. * Gets the array of active meshes
  41788. * @returns an array of AbstractMesh
  41789. */
  41790. getActiveMeshes(): SmartArray<AbstractMesh>;
  41791. /**
  41792. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41793. * @returns a number
  41794. */
  41795. getAnimationRatio(): number;
  41796. /**
  41797. * Gets an unique Id for the current render phase
  41798. * @returns a number
  41799. */
  41800. getRenderId(): number;
  41801. /**
  41802. * Gets an unique Id for the current frame
  41803. * @returns a number
  41804. */
  41805. getFrameId(): number;
  41806. /** Call this function if you want to manually increment the render Id*/
  41807. incrementRenderId(): void;
  41808. private _createUbo;
  41809. /**
  41810. * Use this method to simulate a pointer move on a mesh
  41811. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41812. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41813. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41814. * @returns the current scene
  41815. */
  41816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41817. /**
  41818. * Use this method to simulate a pointer down on a mesh
  41819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41822. * @returns the current scene
  41823. */
  41824. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41825. /**
  41826. * Use this method to simulate a pointer up on a mesh
  41827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41830. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41831. * @returns the current scene
  41832. */
  41833. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41834. /**
  41835. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41836. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41837. * @returns true if the pointer was captured
  41838. */
  41839. isPointerCaptured(pointerId?: number): boolean;
  41840. /**
  41841. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41842. * @param attachUp defines if you want to attach events to pointerup
  41843. * @param attachDown defines if you want to attach events to pointerdown
  41844. * @param attachMove defines if you want to attach events to pointermove
  41845. */
  41846. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41847. /** Detaches all event handlers*/
  41848. detachControl(): void;
  41849. /**
  41850. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41851. * Delay loaded resources are not taking in account
  41852. * @return true if all required resources are ready
  41853. */
  41854. isReady(): boolean;
  41855. /** Resets all cached information relative to material (including effect and visibility) */
  41856. resetCachedMaterial(): void;
  41857. /**
  41858. * Registers a function to be called before every frame render
  41859. * @param func defines the function to register
  41860. */
  41861. registerBeforeRender(func: () => void): void;
  41862. /**
  41863. * Unregisters a function called before every frame render
  41864. * @param func defines the function to unregister
  41865. */
  41866. unregisterBeforeRender(func: () => void): void;
  41867. /**
  41868. * Registers a function to be called after every frame render
  41869. * @param func defines the function to register
  41870. */
  41871. registerAfterRender(func: () => void): void;
  41872. /**
  41873. * Unregisters a function called after every frame render
  41874. * @param func defines the function to unregister
  41875. */
  41876. unregisterAfterRender(func: () => void): void;
  41877. private _executeOnceBeforeRender;
  41878. /**
  41879. * The provided function will run before render once and will be disposed afterwards.
  41880. * A timeout delay can be provided so that the function will be executed in N ms.
  41881. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41882. * @param func The function to be executed.
  41883. * @param timeout optional delay in ms
  41884. */
  41885. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41886. /** @hidden */
  41887. _addPendingData(data: any): void;
  41888. /** @hidden */
  41889. _removePendingData(data: any): void;
  41890. /**
  41891. * Returns the number of items waiting to be loaded
  41892. * @returns the number of items waiting to be loaded
  41893. */
  41894. getWaitingItemsCount(): number;
  41895. /**
  41896. * Returns a boolean indicating if the scene is still loading data
  41897. */
  41898. get isLoading(): boolean;
  41899. /**
  41900. * Registers a function to be executed when the scene is ready
  41901. * @param {Function} func - the function to be executed
  41902. */
  41903. executeWhenReady(func: () => void): void;
  41904. /**
  41905. * Returns a promise that resolves when the scene is ready
  41906. * @returns A promise that resolves when the scene is ready
  41907. */
  41908. whenReadyAsync(): Promise<void>;
  41909. /** @hidden */
  41910. _checkIsReady(): void;
  41911. /**
  41912. * Gets all animatable attached to the scene
  41913. */
  41914. get animatables(): Animatable[];
  41915. /**
  41916. * Resets the last animation time frame.
  41917. * Useful to override when animations start running when loading a scene for the first time.
  41918. */
  41919. resetLastAnimationTimeFrame(): void;
  41920. /**
  41921. * Gets the current view matrix
  41922. * @returns a Matrix
  41923. */
  41924. getViewMatrix(): Matrix;
  41925. /**
  41926. * Gets the current projection matrix
  41927. * @returns a Matrix
  41928. */
  41929. getProjectionMatrix(): Matrix;
  41930. /**
  41931. * Gets the current transform matrix
  41932. * @returns a Matrix made of View * Projection
  41933. */
  41934. getTransformMatrix(): Matrix;
  41935. /**
  41936. * Sets the current transform matrix
  41937. * @param viewL defines the View matrix to use
  41938. * @param projectionL defines the Projection matrix to use
  41939. * @param viewR defines the right View matrix to use (if provided)
  41940. * @param projectionR defines the right Projection matrix to use (if provided)
  41941. */
  41942. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41943. /**
  41944. * Gets the uniform buffer used to store scene data
  41945. * @returns a UniformBuffer
  41946. */
  41947. getSceneUniformBuffer(): UniformBuffer;
  41948. /**
  41949. * Gets an unique (relatively to the current scene) Id
  41950. * @returns an unique number for the scene
  41951. */
  41952. getUniqueId(): number;
  41953. /**
  41954. * Add a mesh to the list of scene's meshes
  41955. * @param newMesh defines the mesh to add
  41956. * @param recursive if all child meshes should also be added to the scene
  41957. */
  41958. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41959. /**
  41960. * Remove a mesh for the list of scene's meshes
  41961. * @param toRemove defines the mesh to remove
  41962. * @param recursive if all child meshes should also be removed from the scene
  41963. * @returns the index where the mesh was in the mesh list
  41964. */
  41965. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41966. /**
  41967. * Add a transform node to the list of scene's transform nodes
  41968. * @param newTransformNode defines the transform node to add
  41969. */
  41970. addTransformNode(newTransformNode: TransformNode): void;
  41971. /**
  41972. * Remove a transform node for the list of scene's transform nodes
  41973. * @param toRemove defines the transform node to remove
  41974. * @returns the index where the transform node was in the transform node list
  41975. */
  41976. removeTransformNode(toRemove: TransformNode): number;
  41977. /**
  41978. * Remove a skeleton for the list of scene's skeletons
  41979. * @param toRemove defines the skeleton to remove
  41980. * @returns the index where the skeleton was in the skeleton list
  41981. */
  41982. removeSkeleton(toRemove: Skeleton): number;
  41983. /**
  41984. * Remove a morph target for the list of scene's morph targets
  41985. * @param toRemove defines the morph target to remove
  41986. * @returns the index where the morph target was in the morph target list
  41987. */
  41988. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41989. /**
  41990. * Remove a light for the list of scene's lights
  41991. * @param toRemove defines the light to remove
  41992. * @returns the index where the light was in the light list
  41993. */
  41994. removeLight(toRemove: Light): number;
  41995. /**
  41996. * Remove a camera for the list of scene's cameras
  41997. * @param toRemove defines the camera to remove
  41998. * @returns the index where the camera was in the camera list
  41999. */
  42000. removeCamera(toRemove: Camera): number;
  42001. /**
  42002. * Remove a particle system for the list of scene's particle systems
  42003. * @param toRemove defines the particle system to remove
  42004. * @returns the index where the particle system was in the particle system list
  42005. */
  42006. removeParticleSystem(toRemove: IParticleSystem): number;
  42007. /**
  42008. * Remove a animation for the list of scene's animations
  42009. * @param toRemove defines the animation to remove
  42010. * @returns the index where the animation was in the animation list
  42011. */
  42012. removeAnimation(toRemove: Animation): number;
  42013. /**
  42014. * Will stop the animation of the given target
  42015. * @param target - the target
  42016. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42017. * @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)
  42018. */
  42019. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42020. /**
  42021. * Removes the given animation group from this scene.
  42022. * @param toRemove The animation group to remove
  42023. * @returns The index of the removed animation group
  42024. */
  42025. removeAnimationGroup(toRemove: AnimationGroup): number;
  42026. /**
  42027. * Removes the given multi-material from this scene.
  42028. * @param toRemove The multi-material to remove
  42029. * @returns The index of the removed multi-material
  42030. */
  42031. removeMultiMaterial(toRemove: MultiMaterial): number;
  42032. /**
  42033. * Removes the given material from this scene.
  42034. * @param toRemove The material to remove
  42035. * @returns The index of the removed material
  42036. */
  42037. removeMaterial(toRemove: Material): number;
  42038. /**
  42039. * Removes the given action manager from this scene.
  42040. * @param toRemove The action manager to remove
  42041. * @returns The index of the removed action manager
  42042. */
  42043. removeActionManager(toRemove: AbstractActionManager): number;
  42044. /**
  42045. * Removes the given texture from this scene.
  42046. * @param toRemove The texture to remove
  42047. * @returns The index of the removed texture
  42048. */
  42049. removeTexture(toRemove: BaseTexture): number;
  42050. /**
  42051. * Adds the given light to this scene
  42052. * @param newLight The light to add
  42053. */
  42054. addLight(newLight: Light): void;
  42055. /**
  42056. * Sorts the list list based on light priorities
  42057. */
  42058. sortLightsByPriority(): void;
  42059. /**
  42060. * Adds the given camera to this scene
  42061. * @param newCamera The camera to add
  42062. */
  42063. addCamera(newCamera: Camera): void;
  42064. /**
  42065. * Adds the given skeleton to this scene
  42066. * @param newSkeleton The skeleton to add
  42067. */
  42068. addSkeleton(newSkeleton: Skeleton): void;
  42069. /**
  42070. * Adds the given particle system to this scene
  42071. * @param newParticleSystem The particle system to add
  42072. */
  42073. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42074. /**
  42075. * Adds the given animation to this scene
  42076. * @param newAnimation The animation to add
  42077. */
  42078. addAnimation(newAnimation: Animation): void;
  42079. /**
  42080. * Adds the given animation group to this scene.
  42081. * @param newAnimationGroup The animation group to add
  42082. */
  42083. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42084. /**
  42085. * Adds the given multi-material to this scene
  42086. * @param newMultiMaterial The multi-material to add
  42087. */
  42088. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42089. /**
  42090. * Adds the given material to this scene
  42091. * @param newMaterial The material to add
  42092. */
  42093. addMaterial(newMaterial: Material): void;
  42094. /**
  42095. * Adds the given morph target to this scene
  42096. * @param newMorphTargetManager The morph target to add
  42097. */
  42098. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42099. /**
  42100. * Adds the given geometry to this scene
  42101. * @param newGeometry The geometry to add
  42102. */
  42103. addGeometry(newGeometry: Geometry): void;
  42104. /**
  42105. * Adds the given action manager to this scene
  42106. * @param newActionManager The action manager to add
  42107. */
  42108. addActionManager(newActionManager: AbstractActionManager): void;
  42109. /**
  42110. * Adds the given texture to this scene.
  42111. * @param newTexture The texture to add
  42112. */
  42113. addTexture(newTexture: BaseTexture): void;
  42114. /**
  42115. * Switch active camera
  42116. * @param newCamera defines the new active camera
  42117. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42118. */
  42119. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42120. /**
  42121. * sets the active camera of the scene using its ID
  42122. * @param id defines the camera's ID
  42123. * @return the new active camera or null if none found.
  42124. */
  42125. setActiveCameraByID(id: string): Nullable<Camera>;
  42126. /**
  42127. * sets the active camera of the scene using its name
  42128. * @param name defines the camera's name
  42129. * @returns the new active camera or null if none found.
  42130. */
  42131. setActiveCameraByName(name: string): Nullable<Camera>;
  42132. /**
  42133. * get an animation group using its name
  42134. * @param name defines the material's name
  42135. * @return the animation group or null if none found.
  42136. */
  42137. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42138. /**
  42139. * Get a material using its unique id
  42140. * @param uniqueId defines the material's unique id
  42141. * @return the material or null if none found.
  42142. */
  42143. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42144. /**
  42145. * get a material using its id
  42146. * @param id defines the material's ID
  42147. * @return the material or null if none found.
  42148. */
  42149. getMaterialByID(id: string): Nullable<Material>;
  42150. /**
  42151. * Gets a the last added material using a given id
  42152. * @param id defines the material's ID
  42153. * @return the last material with the given id or null if none found.
  42154. */
  42155. getLastMaterialByID(id: string): Nullable<Material>;
  42156. /**
  42157. * Gets a material using its name
  42158. * @param name defines the material's name
  42159. * @return the material or null if none found.
  42160. */
  42161. getMaterialByName(name: string): Nullable<Material>;
  42162. /**
  42163. * Get a texture using its unique id
  42164. * @param uniqueId defines the texture's unique id
  42165. * @return the texture or null if none found.
  42166. */
  42167. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42168. /**
  42169. * Gets a camera using its id
  42170. * @param id defines the id to look for
  42171. * @returns the camera or null if not found
  42172. */
  42173. getCameraByID(id: string): Nullable<Camera>;
  42174. /**
  42175. * Gets a camera using its unique id
  42176. * @param uniqueId defines the unique id to look for
  42177. * @returns the camera or null if not found
  42178. */
  42179. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42180. /**
  42181. * Gets a camera using its name
  42182. * @param name defines the camera's name
  42183. * @return the camera or null if none found.
  42184. */
  42185. getCameraByName(name: string): Nullable<Camera>;
  42186. /**
  42187. * Gets a bone using its id
  42188. * @param id defines the bone's id
  42189. * @return the bone or null if not found
  42190. */
  42191. getBoneByID(id: string): Nullable<Bone>;
  42192. /**
  42193. * Gets a bone using its id
  42194. * @param name defines the bone's name
  42195. * @return the bone or null if not found
  42196. */
  42197. getBoneByName(name: string): Nullable<Bone>;
  42198. /**
  42199. * Gets a light node using its name
  42200. * @param name defines the the light's name
  42201. * @return the light or null if none found.
  42202. */
  42203. getLightByName(name: string): Nullable<Light>;
  42204. /**
  42205. * Gets a light node using its id
  42206. * @param id defines the light's id
  42207. * @return the light or null if none found.
  42208. */
  42209. getLightByID(id: string): Nullable<Light>;
  42210. /**
  42211. * Gets a light node using its scene-generated unique ID
  42212. * @param uniqueId defines the light's unique id
  42213. * @return the light or null if none found.
  42214. */
  42215. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42216. /**
  42217. * Gets a particle system by id
  42218. * @param id defines the particle system id
  42219. * @return the corresponding system or null if none found
  42220. */
  42221. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42222. /**
  42223. * Gets a geometry using its ID
  42224. * @param id defines the geometry's id
  42225. * @return the geometry or null if none found.
  42226. */
  42227. getGeometryByID(id: string): Nullable<Geometry>;
  42228. private _getGeometryByUniqueID;
  42229. /**
  42230. * Add a new geometry to this scene
  42231. * @param geometry defines the geometry to be added to the scene.
  42232. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42233. * @return a boolean defining if the geometry was added or not
  42234. */
  42235. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42236. /**
  42237. * Removes an existing geometry
  42238. * @param geometry defines the geometry to be removed from the scene
  42239. * @return a boolean defining if the geometry was removed or not
  42240. */
  42241. removeGeometry(geometry: Geometry): boolean;
  42242. /**
  42243. * Gets the list of geometries attached to the scene
  42244. * @returns an array of Geometry
  42245. */
  42246. getGeometries(): Geometry[];
  42247. /**
  42248. * Gets the first added mesh found of a given ID
  42249. * @param id defines the id to search for
  42250. * @return the mesh found or null if not found at all
  42251. */
  42252. getMeshByID(id: string): Nullable<AbstractMesh>;
  42253. /**
  42254. * Gets a list of meshes using their id
  42255. * @param id defines the id to search for
  42256. * @returns a list of meshes
  42257. */
  42258. getMeshesByID(id: string): Array<AbstractMesh>;
  42259. /**
  42260. * Gets the first added transform node found of a given ID
  42261. * @param id defines the id to search for
  42262. * @return the found transform node or null if not found at all.
  42263. */
  42264. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42265. /**
  42266. * Gets a transform node with its auto-generated unique id
  42267. * @param uniqueId efines the unique id to search for
  42268. * @return the found transform node or null if not found at all.
  42269. */
  42270. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42271. /**
  42272. * Gets a list of transform nodes using their id
  42273. * @param id defines the id to search for
  42274. * @returns a list of transform nodes
  42275. */
  42276. getTransformNodesByID(id: string): Array<TransformNode>;
  42277. /**
  42278. * Gets a mesh with its auto-generated unique id
  42279. * @param uniqueId defines the unique id to search for
  42280. * @return the found mesh or null if not found at all.
  42281. */
  42282. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42283. /**
  42284. * Gets a the last added mesh using a given id
  42285. * @param id defines the id to search for
  42286. * @return the found mesh or null if not found at all.
  42287. */
  42288. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42289. /**
  42290. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42291. * @param id defines the id to search for
  42292. * @return the found node or null if not found at all
  42293. */
  42294. getLastEntryByID(id: string): Nullable<Node>;
  42295. /**
  42296. * Gets a node (Mesh, Camera, Light) using a given id
  42297. * @param id defines the id to search for
  42298. * @return the found node or null if not found at all
  42299. */
  42300. getNodeByID(id: string): Nullable<Node>;
  42301. /**
  42302. * Gets a node (Mesh, Camera, Light) using a given name
  42303. * @param name defines the name to search for
  42304. * @return the found node or null if not found at all.
  42305. */
  42306. getNodeByName(name: string): Nullable<Node>;
  42307. /**
  42308. * Gets a mesh using a given name
  42309. * @param name defines the name to search for
  42310. * @return the found mesh or null if not found at all.
  42311. */
  42312. getMeshByName(name: string): Nullable<AbstractMesh>;
  42313. /**
  42314. * Gets a transform node using a given name
  42315. * @param name defines the name to search for
  42316. * @return the found transform node or null if not found at all.
  42317. */
  42318. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42319. /**
  42320. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42321. * @param id defines the id to search for
  42322. * @return the found skeleton or null if not found at all.
  42323. */
  42324. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42325. /**
  42326. * Gets a skeleton using a given auto generated unique id
  42327. * @param uniqueId defines the unique id to search for
  42328. * @return the found skeleton or null if not found at all.
  42329. */
  42330. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42331. /**
  42332. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42333. * @param id defines the id to search for
  42334. * @return the found skeleton or null if not found at all.
  42335. */
  42336. getSkeletonById(id: string): Nullable<Skeleton>;
  42337. /**
  42338. * Gets a skeleton using a given name
  42339. * @param name defines the name to search for
  42340. * @return the found skeleton or null if not found at all.
  42341. */
  42342. getSkeletonByName(name: string): Nullable<Skeleton>;
  42343. /**
  42344. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42345. * @param id defines the id to search for
  42346. * @return the found morph target manager or null if not found at all.
  42347. */
  42348. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42349. /**
  42350. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42351. * @param id defines the id to search for
  42352. * @return the found morph target or null if not found at all.
  42353. */
  42354. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42355. /**
  42356. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42357. * @param name defines the name to search for
  42358. * @return the found morph target or null if not found at all.
  42359. */
  42360. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42361. /**
  42362. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42363. * @param name defines the name to search for
  42364. * @return the found post process or null if not found at all.
  42365. */
  42366. getPostProcessByName(name: string): Nullable<PostProcess>;
  42367. /**
  42368. * Gets a boolean indicating if the given mesh is active
  42369. * @param mesh defines the mesh to look for
  42370. * @returns true if the mesh is in the active list
  42371. */
  42372. isActiveMesh(mesh: AbstractMesh): boolean;
  42373. /**
  42374. * Return a unique id as a string which can serve as an identifier for the scene
  42375. */
  42376. get uid(): string;
  42377. /**
  42378. * Add an externaly attached data from its key.
  42379. * This method call will fail and return false, if such key already exists.
  42380. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42381. * @param key the unique key that identifies the data
  42382. * @param data the data object to associate to the key for this Engine instance
  42383. * @return true if no such key were already present and the data was added successfully, false otherwise
  42384. */
  42385. addExternalData<T>(key: string, data: T): boolean;
  42386. /**
  42387. * Get an externaly attached data from its key
  42388. * @param key the unique key that identifies the data
  42389. * @return the associated data, if present (can be null), or undefined if not present
  42390. */
  42391. getExternalData<T>(key: string): Nullable<T>;
  42392. /**
  42393. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42394. * @param key the unique key that identifies the data
  42395. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42396. * @return the associated data, can be null if the factory returned null.
  42397. */
  42398. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42399. /**
  42400. * Remove an externaly attached data from the Engine instance
  42401. * @param key the unique key that identifies the data
  42402. * @return true if the data was successfully removed, false if it doesn't exist
  42403. */
  42404. removeExternalData(key: string): boolean;
  42405. private _evaluateSubMesh;
  42406. /**
  42407. * Clear the processed materials smart array preventing retention point in material dispose.
  42408. */
  42409. freeProcessedMaterials(): void;
  42410. private _preventFreeActiveMeshesAndRenderingGroups;
  42411. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42412. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42413. * when disposing several meshes in a row or a hierarchy of meshes.
  42414. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42415. */
  42416. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42417. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42418. /**
  42419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42420. */
  42421. freeActiveMeshes(): void;
  42422. /**
  42423. * Clear the info related to rendering groups preventing retention points during dispose.
  42424. */
  42425. freeRenderingGroups(): void;
  42426. /** @hidden */
  42427. _isInIntermediateRendering(): boolean;
  42428. /**
  42429. * Lambda returning the list of potentially active meshes.
  42430. */
  42431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42432. /**
  42433. * Lambda returning the list of potentially active sub meshes.
  42434. */
  42435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42436. /**
  42437. * Lambda returning the list of potentially intersecting sub meshes.
  42438. */
  42439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42440. /**
  42441. * Lambda returning the list of potentially colliding sub meshes.
  42442. */
  42443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42444. private _activeMeshesFrozen;
  42445. private _skipEvaluateActiveMeshesCompletely;
  42446. /**
  42447. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42448. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42449. * @returns the current scene
  42450. */
  42451. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42452. /**
  42453. * Use this function to restart evaluating active meshes on every frame
  42454. * @returns the current scene
  42455. */
  42456. unfreezeActiveMeshes(): Scene;
  42457. private _evaluateActiveMeshes;
  42458. private _activeMesh;
  42459. /**
  42460. * Update the transform matrix to update from the current active camera
  42461. * @param force defines a boolean used to force the update even if cache is up to date
  42462. */
  42463. updateTransformMatrix(force?: boolean): void;
  42464. private _bindFrameBuffer;
  42465. /** @hidden */
  42466. _allowPostProcessClearColor: boolean;
  42467. /** @hidden */
  42468. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42469. private _processSubCameras;
  42470. private _checkIntersections;
  42471. /** @hidden */
  42472. _advancePhysicsEngineStep(step: number): void;
  42473. /**
  42474. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42475. */
  42476. getDeterministicFrameTime: () => number;
  42477. /** @hidden */
  42478. _animate(): void;
  42479. /** Execute all animations (for a frame) */
  42480. animate(): void;
  42481. /**
  42482. * Render the scene
  42483. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42484. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42485. */
  42486. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42487. /**
  42488. * Freeze all materials
  42489. * A frozen material will not be updatable but should be faster to render
  42490. */
  42491. freezeMaterials(): void;
  42492. /**
  42493. * Unfreeze all materials
  42494. * A frozen material will not be updatable but should be faster to render
  42495. */
  42496. unfreezeMaterials(): void;
  42497. /**
  42498. * Releases all held ressources
  42499. */
  42500. dispose(): void;
  42501. /**
  42502. * Gets if the scene is already disposed
  42503. */
  42504. get isDisposed(): boolean;
  42505. /**
  42506. * Call this function to reduce memory footprint of the scene.
  42507. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42508. */
  42509. clearCachedVertexData(): void;
  42510. /**
  42511. * This function will remove the local cached buffer data from texture.
  42512. * It will save memory but will prevent the texture from being rebuilt
  42513. */
  42514. cleanCachedTextureBuffer(): void;
  42515. /**
  42516. * Get the world extend vectors with an optional filter
  42517. *
  42518. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42519. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42520. */
  42521. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42522. min: Vector3;
  42523. max: Vector3;
  42524. };
  42525. /**
  42526. * Creates a ray that can be used to pick in the scene
  42527. * @param x defines the x coordinate of the origin (on-screen)
  42528. * @param y defines the y coordinate of the origin (on-screen)
  42529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42530. * @param camera defines the camera to use for the picking
  42531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42532. * @returns a Ray
  42533. */
  42534. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42535. /**
  42536. * Creates a ray that can be used to pick in the scene
  42537. * @param x defines the x coordinate of the origin (on-screen)
  42538. * @param y defines the y coordinate of the origin (on-screen)
  42539. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42540. * @param result defines the ray where to store the picking ray
  42541. * @param camera defines the camera to use for the picking
  42542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42543. * @returns the current scene
  42544. */
  42545. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42546. /**
  42547. * Creates a ray that can be used to pick in the scene
  42548. * @param x defines the x coordinate of the origin (on-screen)
  42549. * @param y defines the y coordinate of the origin (on-screen)
  42550. * @param camera defines the camera to use for the picking
  42551. * @returns a Ray
  42552. */
  42553. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42554. /**
  42555. * Creates a ray that can be used to pick in the scene
  42556. * @param x defines the x coordinate of the origin (on-screen)
  42557. * @param y defines the y coordinate of the origin (on-screen)
  42558. * @param result defines the ray where to store the picking ray
  42559. * @param camera defines the camera to use for the picking
  42560. * @returns the current scene
  42561. */
  42562. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42563. /** Launch a ray to try to pick a mesh in the scene
  42564. * @param x position on screen
  42565. * @param y position on screen
  42566. * @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
  42567. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42568. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42570. * @returns a PickingInfo
  42571. */
  42572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42573. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42574. * @param x position on screen
  42575. * @param y position on screen
  42576. * @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
  42577. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42578. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42579. * @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)
  42580. */
  42581. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42582. /** Use the given ray to pick a mesh in the scene
  42583. * @param ray The ray to use to pick meshes
  42584. * @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
  42585. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42587. * @returns a PickingInfo
  42588. */
  42589. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42590. /**
  42591. * Launch a ray to try to pick a mesh in the scene
  42592. * @param x X position on screen
  42593. * @param y Y position on screen
  42594. * @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
  42595. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42596. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42597. * @returns an array of PickingInfo
  42598. */
  42599. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42600. /**
  42601. * Launch a ray to try to pick a mesh in the scene
  42602. * @param ray Ray to use
  42603. * @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
  42604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42605. * @returns an array of PickingInfo
  42606. */
  42607. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42608. /**
  42609. * Force the value of meshUnderPointer
  42610. * @param mesh defines the mesh to use
  42611. * @param pointerId optional pointer id when using more than one pointer
  42612. */
  42613. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42614. /**
  42615. * Gets the mesh under the pointer
  42616. * @returns a Mesh or null if no mesh is under the pointer
  42617. */
  42618. getPointerOverMesh(): Nullable<AbstractMesh>;
  42619. /** @hidden */
  42620. _rebuildGeometries(): void;
  42621. /** @hidden */
  42622. _rebuildTextures(): void;
  42623. private _getByTags;
  42624. /**
  42625. * Get a list of meshes by tags
  42626. * @param tagsQuery defines the tags query to use
  42627. * @param forEach defines a predicate used to filter results
  42628. * @returns an array of Mesh
  42629. */
  42630. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42631. /**
  42632. * Get a list of cameras by tags
  42633. * @param tagsQuery defines the tags query to use
  42634. * @param forEach defines a predicate used to filter results
  42635. * @returns an array of Camera
  42636. */
  42637. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42638. /**
  42639. * Get a list of lights by tags
  42640. * @param tagsQuery defines the tags query to use
  42641. * @param forEach defines a predicate used to filter results
  42642. * @returns an array of Light
  42643. */
  42644. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42645. /**
  42646. * Get a list of materials by tags
  42647. * @param tagsQuery defines the tags query to use
  42648. * @param forEach defines a predicate used to filter results
  42649. * @returns an array of Material
  42650. */
  42651. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42652. /**
  42653. * Get a list of transform nodes by tags
  42654. * @param tagsQuery defines the tags query to use
  42655. * @param forEach defines a predicate used to filter results
  42656. * @returns an array of TransformNode
  42657. */
  42658. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42659. /**
  42660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42661. * This allowed control for front to back rendering or reversly depending of the special needs.
  42662. *
  42663. * @param renderingGroupId The rendering group id corresponding to its index
  42664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42667. */
  42668. 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;
  42669. /**
  42670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42671. *
  42672. * @param renderingGroupId The rendering group id corresponding to its index
  42673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42674. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42675. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42676. */
  42677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42678. /**
  42679. * Gets the current auto clear configuration for one rendering group of the rendering
  42680. * manager.
  42681. * @param index the rendering group index to get the information for
  42682. * @returns The auto clear setup for the requested rendering group
  42683. */
  42684. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42685. private _blockMaterialDirtyMechanism;
  42686. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42687. get blockMaterialDirtyMechanism(): boolean;
  42688. set blockMaterialDirtyMechanism(value: boolean);
  42689. /**
  42690. * Will flag all materials as dirty to trigger new shader compilation
  42691. * @param flag defines the flag used to specify which material part must be marked as dirty
  42692. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42693. */
  42694. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42695. /** @hidden */
  42696. _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;
  42697. /** @hidden */
  42698. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42699. /** @hidden */
  42700. _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;
  42701. /** @hidden */
  42702. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42703. /** @hidden */
  42704. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42705. /** @hidden */
  42706. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42707. }
  42708. }
  42709. declare module "babylonjs/assetContainer" {
  42710. import { AbstractScene } from "babylonjs/abstractScene";
  42711. import { Scene } from "babylonjs/scene";
  42712. import { Mesh } from "babylonjs/Meshes/mesh";
  42713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42714. import { Skeleton } from "babylonjs/Bones/skeleton";
  42715. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42716. import { Animatable } from "babylonjs/Animations/animatable";
  42717. import { Nullable } from "babylonjs/types";
  42718. import { Node } from "babylonjs/node";
  42719. /**
  42720. * Set of assets to keep when moving a scene into an asset container.
  42721. */
  42722. export class KeepAssets extends AbstractScene {
  42723. }
  42724. /**
  42725. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42726. */
  42727. export class InstantiatedEntries {
  42728. /**
  42729. * List of new root nodes (eg. nodes with no parent)
  42730. */
  42731. rootNodes: TransformNode[];
  42732. /**
  42733. * List of new skeletons
  42734. */
  42735. skeletons: Skeleton[];
  42736. /**
  42737. * List of new animation groups
  42738. */
  42739. animationGroups: AnimationGroup[];
  42740. }
  42741. /**
  42742. * Container with a set of assets that can be added or removed from a scene.
  42743. */
  42744. export class AssetContainer extends AbstractScene {
  42745. private _wasAddedToScene;
  42746. /**
  42747. * The scene the AssetContainer belongs to.
  42748. */
  42749. scene: Scene;
  42750. /**
  42751. * Instantiates an AssetContainer.
  42752. * @param scene The scene the AssetContainer belongs to.
  42753. */
  42754. constructor(scene: Scene);
  42755. /**
  42756. * Instantiate or clone all meshes and add the new ones to the scene.
  42757. * Skeletons and animation groups will all be cloned
  42758. * @param nameFunction defines an optional function used to get new names for clones
  42759. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42760. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42761. */
  42762. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42763. /**
  42764. * Adds all the assets from the container to the scene.
  42765. */
  42766. addAllToScene(): void;
  42767. /**
  42768. * Removes all the assets in the container from the scene
  42769. */
  42770. removeAllFromScene(): void;
  42771. /**
  42772. * Disposes all the assets in the container
  42773. */
  42774. dispose(): void;
  42775. private _moveAssets;
  42776. /**
  42777. * Removes all the assets contained in the scene and adds them to the container.
  42778. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42779. */
  42780. moveAllFromScene(keepAssets?: KeepAssets): void;
  42781. /**
  42782. * 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.
  42783. * @returns the root mesh
  42784. */
  42785. createRootMesh(): Mesh;
  42786. /**
  42787. * Merge animations (direct and animation groups) from this asset container into a scene
  42788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42789. * @param animatables set of animatables to retarget to a node from the scene
  42790. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42791. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42792. */
  42793. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42794. }
  42795. }
  42796. declare module "babylonjs/abstractScene" {
  42797. import { Scene } from "babylonjs/scene";
  42798. import { Nullable } from "babylonjs/types";
  42799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42801. import { Geometry } from "babylonjs/Meshes/geometry";
  42802. import { Skeleton } from "babylonjs/Bones/skeleton";
  42803. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42804. import { AssetContainer } from "babylonjs/assetContainer";
  42805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42806. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42808. import { Material } from "babylonjs/Materials/material";
  42809. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42810. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42811. import { Camera } from "babylonjs/Cameras/camera";
  42812. import { Light } from "babylonjs/Lights/light";
  42813. import { Node } from "babylonjs/node";
  42814. import { Animation } from "babylonjs/Animations/animation";
  42815. /**
  42816. * Defines how the parser contract is defined.
  42817. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42818. */
  42819. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42820. /**
  42821. * Defines how the individual parser contract is defined.
  42822. * These parser can parse an individual asset
  42823. */
  42824. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42825. /**
  42826. * Base class of the scene acting as a container for the different elements composing a scene.
  42827. * This class is dynamically extended by the different components of the scene increasing
  42828. * flexibility and reducing coupling
  42829. */
  42830. export abstract class AbstractScene {
  42831. /**
  42832. * Stores the list of available parsers in the application.
  42833. */
  42834. private static _BabylonFileParsers;
  42835. /**
  42836. * Stores the list of available individual parsers in the application.
  42837. */
  42838. private static _IndividualBabylonFileParsers;
  42839. /**
  42840. * Adds a parser in the list of available ones
  42841. * @param name Defines the name of the parser
  42842. * @param parser Defines the parser to add
  42843. */
  42844. static AddParser(name: string, parser: BabylonFileParser): void;
  42845. /**
  42846. * Gets a general parser from the list of avaialble ones
  42847. * @param name Defines the name of the parser
  42848. * @returns the requested parser or null
  42849. */
  42850. static GetParser(name: string): Nullable<BabylonFileParser>;
  42851. /**
  42852. * Adds n individual parser in the list of available ones
  42853. * @param name Defines the name of the parser
  42854. * @param parser Defines the parser to add
  42855. */
  42856. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42857. /**
  42858. * Gets an individual parser from the list of avaialble ones
  42859. * @param name Defines the name of the parser
  42860. * @returns the requested parser or null
  42861. */
  42862. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42863. /**
  42864. * Parser json data and populate both a scene and its associated container object
  42865. * @param jsonData Defines the data to parse
  42866. * @param scene Defines the scene to parse the data for
  42867. * @param container Defines the container attached to the parsing sequence
  42868. * @param rootUrl Defines the root url of the data
  42869. */
  42870. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42871. /**
  42872. * Gets the list of root nodes (ie. nodes with no parent)
  42873. */
  42874. rootNodes: Node[];
  42875. /** All of the cameras added to this scene
  42876. * @see https://doc.babylonjs.com/babylon101/cameras
  42877. */
  42878. cameras: Camera[];
  42879. /**
  42880. * All of the lights added to this scene
  42881. * @see https://doc.babylonjs.com/babylon101/lights
  42882. */
  42883. lights: Light[];
  42884. /**
  42885. * All of the (abstract) meshes added to this scene
  42886. */
  42887. meshes: AbstractMesh[];
  42888. /**
  42889. * The list of skeletons added to the scene
  42890. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42891. */
  42892. skeletons: Skeleton[];
  42893. /**
  42894. * All of the particle systems added to this scene
  42895. * @see https://doc.babylonjs.com/babylon101/particles
  42896. */
  42897. particleSystems: IParticleSystem[];
  42898. /**
  42899. * Gets a list of Animations associated with the scene
  42900. */
  42901. animations: Animation[];
  42902. /**
  42903. * All of the animation groups added to this scene
  42904. * @see https://doc.babylonjs.com/how_to/group
  42905. */
  42906. animationGroups: AnimationGroup[];
  42907. /**
  42908. * All of the multi-materials added to this scene
  42909. * @see https://doc.babylonjs.com/how_to/multi_materials
  42910. */
  42911. multiMaterials: MultiMaterial[];
  42912. /**
  42913. * All of the materials added to this scene
  42914. * In the context of a Scene, it is not supposed to be modified manually.
  42915. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42916. * Note also that the order of the Material within the array is not significant and might change.
  42917. * @see https://doc.babylonjs.com/babylon101/materials
  42918. */
  42919. materials: Material[];
  42920. /**
  42921. * The list of morph target managers added to the scene
  42922. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42923. */
  42924. morphTargetManagers: MorphTargetManager[];
  42925. /**
  42926. * The list of geometries used in the scene.
  42927. */
  42928. geometries: Geometry[];
  42929. /**
  42930. * All of the tranform nodes added to this scene
  42931. * In the context of a Scene, it is not supposed to be modified manually.
  42932. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42933. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42934. * @see https://doc.babylonjs.com/how_to/transformnode
  42935. */
  42936. transformNodes: TransformNode[];
  42937. /**
  42938. * ActionManagers available on the scene.
  42939. */
  42940. actionManagers: AbstractActionManager[];
  42941. /**
  42942. * Textures to keep.
  42943. */
  42944. textures: BaseTexture[];
  42945. /** @hidden */
  42946. protected _environmentTexture: Nullable<BaseTexture>;
  42947. /**
  42948. * Texture used in all pbr material as the reflection texture.
  42949. * As in the majority of the scene they are the same (exception for multi room and so on),
  42950. * this is easier to reference from here than from all the materials.
  42951. */
  42952. get environmentTexture(): Nullable<BaseTexture>;
  42953. set environmentTexture(value: Nullable<BaseTexture>);
  42954. /**
  42955. * The list of postprocesses added to the scene
  42956. */
  42957. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42958. /**
  42959. * @returns all meshes, lights, cameras, transformNodes and bones
  42960. */
  42961. getNodes(): Array<Node>;
  42962. }
  42963. }
  42964. declare module "babylonjs/Audio/sound" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Vector3 } from "babylonjs/Maths/math.vector";
  42967. import { Nullable } from "babylonjs/types";
  42968. import { Scene } from "babylonjs/scene";
  42969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42970. /**
  42971. * Interface used to define options for Sound class
  42972. */
  42973. export interface ISoundOptions {
  42974. /**
  42975. * Does the sound autoplay once loaded.
  42976. */
  42977. autoplay?: boolean;
  42978. /**
  42979. * Does the sound loop after it finishes playing once.
  42980. */
  42981. loop?: boolean;
  42982. /**
  42983. * Sound's volume
  42984. */
  42985. volume?: number;
  42986. /**
  42987. * Is it a spatial sound?
  42988. */
  42989. spatialSound?: boolean;
  42990. /**
  42991. * Maximum distance to hear that sound
  42992. */
  42993. maxDistance?: number;
  42994. /**
  42995. * Uses user defined attenuation function
  42996. */
  42997. useCustomAttenuation?: boolean;
  42998. /**
  42999. * Define the roll off factor of spatial sounds.
  43000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43001. */
  43002. rolloffFactor?: number;
  43003. /**
  43004. * Define the reference distance the sound should be heard perfectly.
  43005. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43006. */
  43007. refDistance?: number;
  43008. /**
  43009. * Define the distance attenuation model the sound will follow.
  43010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43011. */
  43012. distanceModel?: string;
  43013. /**
  43014. * Defines the playback speed (1 by default)
  43015. */
  43016. playbackRate?: number;
  43017. /**
  43018. * Defines if the sound is from a streaming source
  43019. */
  43020. streaming?: boolean;
  43021. /**
  43022. * Defines an optional length (in seconds) inside the sound file
  43023. */
  43024. length?: number;
  43025. /**
  43026. * Defines an optional offset (in seconds) inside the sound file
  43027. */
  43028. offset?: number;
  43029. /**
  43030. * If true, URLs will not be required to state the audio file codec to use.
  43031. */
  43032. skipCodecCheck?: boolean;
  43033. }
  43034. /**
  43035. * Defines a sound that can be played in the application.
  43036. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43038. */
  43039. export class Sound {
  43040. /**
  43041. * The name of the sound in the scene.
  43042. */
  43043. name: string;
  43044. /**
  43045. * Does the sound autoplay once loaded.
  43046. */
  43047. autoplay: boolean;
  43048. /**
  43049. * Does the sound loop after it finishes playing once.
  43050. */
  43051. loop: boolean;
  43052. /**
  43053. * Does the sound use a custom attenuation curve to simulate the falloff
  43054. * happening when the source gets further away from the camera.
  43055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43056. */
  43057. useCustomAttenuation: boolean;
  43058. /**
  43059. * The sound track id this sound belongs to.
  43060. */
  43061. soundTrackId: number;
  43062. /**
  43063. * Is this sound currently played.
  43064. */
  43065. isPlaying: boolean;
  43066. /**
  43067. * Is this sound currently paused.
  43068. */
  43069. isPaused: boolean;
  43070. /**
  43071. * Does this sound enables spatial sound.
  43072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43073. */
  43074. spatialSound: boolean;
  43075. /**
  43076. * Define the reference distance the sound should be heard perfectly.
  43077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43078. */
  43079. refDistance: number;
  43080. /**
  43081. * Define the roll off factor of spatial sounds.
  43082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43083. */
  43084. rolloffFactor: number;
  43085. /**
  43086. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43088. */
  43089. maxDistance: number;
  43090. /**
  43091. * Define the distance attenuation model the sound will follow.
  43092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43093. */
  43094. distanceModel: string;
  43095. /**
  43096. * @hidden
  43097. * Back Compat
  43098. **/
  43099. onended: () => any;
  43100. /**
  43101. * Gets or sets an object used to store user defined information for the sound.
  43102. */
  43103. metadata: any;
  43104. /**
  43105. * Observable event when the current playing sound finishes.
  43106. */
  43107. onEndedObservable: Observable<Sound>;
  43108. private _panningModel;
  43109. private _playbackRate;
  43110. private _streaming;
  43111. private _startTime;
  43112. private _startOffset;
  43113. private _position;
  43114. /** @hidden */
  43115. _positionInEmitterSpace: boolean;
  43116. private _localDirection;
  43117. private _volume;
  43118. private _isReadyToPlay;
  43119. private _isDirectional;
  43120. private _readyToPlayCallback;
  43121. private _audioBuffer;
  43122. private _soundSource;
  43123. private _streamingSource;
  43124. private _soundPanner;
  43125. private _soundGain;
  43126. private _inputAudioNode;
  43127. private _outputAudioNode;
  43128. private _coneInnerAngle;
  43129. private _coneOuterAngle;
  43130. private _coneOuterGain;
  43131. private _scene;
  43132. private _connectedTransformNode;
  43133. private _customAttenuationFunction;
  43134. private _registerFunc;
  43135. private _isOutputConnected;
  43136. private _htmlAudioElement;
  43137. private _urlType;
  43138. private _length?;
  43139. private _offset?;
  43140. /** @hidden */
  43141. static _SceneComponentInitialization: (scene: Scene) => void;
  43142. /**
  43143. * Create a sound and attach it to a scene
  43144. * @param name Name of your sound
  43145. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43146. * @param scene defines the scene the sound belongs to
  43147. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43148. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43149. */
  43150. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43151. /**
  43152. * Release the sound and its associated resources
  43153. */
  43154. dispose(): void;
  43155. /**
  43156. * Gets if the sounds is ready to be played or not.
  43157. * @returns true if ready, otherwise false
  43158. */
  43159. isReady(): boolean;
  43160. private _soundLoaded;
  43161. /**
  43162. * Sets the data of the sound from an audiobuffer
  43163. * @param audioBuffer The audioBuffer containing the data
  43164. */
  43165. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43166. /**
  43167. * Updates the current sounds options such as maxdistance, loop...
  43168. * @param options A JSON object containing values named as the object properties
  43169. */
  43170. updateOptions(options: ISoundOptions): void;
  43171. private _createSpatialParameters;
  43172. private _updateSpatialParameters;
  43173. /**
  43174. * Switch the panning model to HRTF:
  43175. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43177. */
  43178. switchPanningModelToHRTF(): void;
  43179. /**
  43180. * Switch the panning model to Equal Power:
  43181. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43183. */
  43184. switchPanningModelToEqualPower(): void;
  43185. private _switchPanningModel;
  43186. /**
  43187. * Connect this sound to a sound track audio node like gain...
  43188. * @param soundTrackAudioNode the sound track audio node to connect to
  43189. */
  43190. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43191. /**
  43192. * Transform this sound into a directional source
  43193. * @param coneInnerAngle Size of the inner cone in degree
  43194. * @param coneOuterAngle Size of the outer cone in degree
  43195. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43196. */
  43197. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43198. /**
  43199. * Gets or sets the inner angle for the directional cone.
  43200. */
  43201. get directionalConeInnerAngle(): number;
  43202. /**
  43203. * Gets or sets the inner angle for the directional cone.
  43204. */
  43205. set directionalConeInnerAngle(value: number);
  43206. /**
  43207. * Gets or sets the outer angle for the directional cone.
  43208. */
  43209. get directionalConeOuterAngle(): number;
  43210. /**
  43211. * Gets or sets the outer angle for the directional cone.
  43212. */
  43213. set directionalConeOuterAngle(value: number);
  43214. /**
  43215. * Sets the position of the emitter if spatial sound is enabled
  43216. * @param newPosition Defines the new posisiton
  43217. */
  43218. setPosition(newPosition: Vector3): void;
  43219. /**
  43220. * Sets the local direction of the emitter if spatial sound is enabled
  43221. * @param newLocalDirection Defines the new local direction
  43222. */
  43223. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43224. private _updateDirection;
  43225. /** @hidden */
  43226. updateDistanceFromListener(): void;
  43227. /**
  43228. * Sets a new custom attenuation function for the sound.
  43229. * @param callback Defines the function used for the attenuation
  43230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43231. */
  43232. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43233. /**
  43234. * Play the sound
  43235. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43236. * @param offset (optional) Start the sound at a specific time in seconds
  43237. * @param length (optional) Sound duration (in seconds)
  43238. */
  43239. play(time?: number, offset?: number, length?: number): void;
  43240. private _onended;
  43241. /**
  43242. * Stop the sound
  43243. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43244. */
  43245. stop(time?: number): void;
  43246. /**
  43247. * Put the sound in pause
  43248. */
  43249. pause(): void;
  43250. /**
  43251. * Sets a dedicated volume for this sounds
  43252. * @param newVolume Define the new volume of the sound
  43253. * @param time Define time for gradual change to new volume
  43254. */
  43255. setVolume(newVolume: number, time?: number): void;
  43256. /**
  43257. * Set the sound play back rate
  43258. * @param newPlaybackRate Define the playback rate the sound should be played at
  43259. */
  43260. setPlaybackRate(newPlaybackRate: number): void;
  43261. /**
  43262. * Gets the volume of the sound.
  43263. * @returns the volume of the sound
  43264. */
  43265. getVolume(): number;
  43266. /**
  43267. * Attach the sound to a dedicated mesh
  43268. * @param transformNode The transform node to connect the sound with
  43269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43270. */
  43271. attachToMesh(transformNode: TransformNode): void;
  43272. /**
  43273. * Detach the sound from the previously attached mesh
  43274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43275. */
  43276. detachFromMesh(): void;
  43277. private _onRegisterAfterWorldMatrixUpdate;
  43278. /**
  43279. * Clone the current sound in the scene.
  43280. * @returns the new sound clone
  43281. */
  43282. clone(): Nullable<Sound>;
  43283. /**
  43284. * Gets the current underlying audio buffer containing the data
  43285. * @returns the audio buffer
  43286. */
  43287. getAudioBuffer(): Nullable<AudioBuffer>;
  43288. /**
  43289. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43290. * @returns the source node
  43291. */
  43292. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43293. /**
  43294. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43295. * @returns the gain node
  43296. */
  43297. getSoundGain(): Nullable<GainNode>;
  43298. /**
  43299. * Serializes the Sound in a JSON representation
  43300. * @returns the JSON representation of the sound
  43301. */
  43302. serialize(): any;
  43303. /**
  43304. * Parse a JSON representation of a sound to innstantiate in a given scene
  43305. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43306. * @param scene Define the scene the new parsed sound should be created in
  43307. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43308. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43309. * @returns the newly parsed sound
  43310. */
  43311. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43312. }
  43313. }
  43314. declare module "babylonjs/Actions/directAudioActions" {
  43315. import { Action } from "babylonjs/Actions/action";
  43316. import { Condition } from "babylonjs/Actions/condition";
  43317. import { Sound } from "babylonjs/Audio/sound";
  43318. /**
  43319. * This defines an action helpful to play a defined sound on a triggered action.
  43320. */
  43321. export class PlaySoundAction extends Action {
  43322. private _sound;
  43323. /**
  43324. * Instantiate the action
  43325. * @param triggerOptions defines the trigger options
  43326. * @param sound defines the sound to play
  43327. * @param condition defines the trigger related conditions
  43328. */
  43329. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43330. /** @hidden */
  43331. _prepare(): void;
  43332. /**
  43333. * Execute the action and play the sound.
  43334. */
  43335. execute(): void;
  43336. /**
  43337. * Serializes the actions and its related information.
  43338. * @param parent defines the object to serialize in
  43339. * @returns the serialized object
  43340. */
  43341. serialize(parent: any): any;
  43342. }
  43343. /**
  43344. * This defines an action helpful to stop a defined sound on a triggered action.
  43345. */
  43346. export class StopSoundAction extends Action {
  43347. private _sound;
  43348. /**
  43349. * Instantiate the action
  43350. * @param triggerOptions defines the trigger options
  43351. * @param sound defines the sound to stop
  43352. * @param condition defines the trigger related conditions
  43353. */
  43354. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43355. /** @hidden */
  43356. _prepare(): void;
  43357. /**
  43358. * Execute the action and stop the sound.
  43359. */
  43360. execute(): void;
  43361. /**
  43362. * Serializes the actions and its related information.
  43363. * @param parent defines the object to serialize in
  43364. * @returns the serialized object
  43365. */
  43366. serialize(parent: any): any;
  43367. }
  43368. }
  43369. declare module "babylonjs/Actions/interpolateValueAction" {
  43370. import { Action } from "babylonjs/Actions/action";
  43371. import { Condition } from "babylonjs/Actions/condition";
  43372. import { Observable } from "babylonjs/Misc/observable";
  43373. /**
  43374. * This defines an action responsible to change the value of a property
  43375. * by interpolating between its current value and the newly set one once triggered.
  43376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43377. */
  43378. export class InterpolateValueAction extends Action {
  43379. /**
  43380. * Defines the path of the property where the value should be interpolated
  43381. */
  43382. propertyPath: string;
  43383. /**
  43384. * Defines the target value at the end of the interpolation.
  43385. */
  43386. value: any;
  43387. /**
  43388. * Defines the time it will take for the property to interpolate to the value.
  43389. */
  43390. duration: number;
  43391. /**
  43392. * Defines if the other scene animations should be stopped when the action has been triggered
  43393. */
  43394. stopOtherAnimations?: boolean;
  43395. /**
  43396. * Defines a callback raised once the interpolation animation has been done.
  43397. */
  43398. onInterpolationDone?: () => void;
  43399. /**
  43400. * Observable triggered once the interpolation animation has been done.
  43401. */
  43402. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43403. private _target;
  43404. private _effectiveTarget;
  43405. private _property;
  43406. /**
  43407. * Instantiate the action
  43408. * @param triggerOptions defines the trigger options
  43409. * @param target defines the object containing the value to interpolate
  43410. * @param propertyPath defines the path to the property in the target object
  43411. * @param value defines the target value at the end of the interpolation
  43412. * @param duration deines the time it will take for the property to interpolate to the value.
  43413. * @param condition defines the trigger related conditions
  43414. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43415. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43416. */
  43417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43418. /** @hidden */
  43419. _prepare(): void;
  43420. /**
  43421. * Execute the action starts the value interpolation.
  43422. */
  43423. execute(): void;
  43424. /**
  43425. * Serializes the actions and its related information.
  43426. * @param parent defines the object to serialize in
  43427. * @returns the serialized object
  43428. */
  43429. serialize(parent: any): any;
  43430. }
  43431. }
  43432. declare module "babylonjs/Actions/index" {
  43433. export * from "babylonjs/Actions/abstractActionManager";
  43434. export * from "babylonjs/Actions/action";
  43435. export * from "babylonjs/Actions/actionEvent";
  43436. export * from "babylonjs/Actions/actionManager";
  43437. export * from "babylonjs/Actions/condition";
  43438. export * from "babylonjs/Actions/directActions";
  43439. export * from "babylonjs/Actions/directAudioActions";
  43440. export * from "babylonjs/Actions/interpolateValueAction";
  43441. }
  43442. declare module "babylonjs/Animations/index" {
  43443. export * from "babylonjs/Animations/animatable";
  43444. export * from "babylonjs/Animations/animation";
  43445. export * from "babylonjs/Animations/animationGroup";
  43446. export * from "babylonjs/Animations/animationPropertiesOverride";
  43447. export * from "babylonjs/Animations/easing";
  43448. export * from "babylonjs/Animations/runtimeAnimation";
  43449. export * from "babylonjs/Animations/animationEvent";
  43450. export * from "babylonjs/Animations/animationGroup";
  43451. export * from "babylonjs/Animations/animationKey";
  43452. export * from "babylonjs/Animations/animationRange";
  43453. export * from "babylonjs/Animations/animatable.interface";
  43454. }
  43455. declare module "babylonjs/Audio/soundTrack" {
  43456. import { Sound } from "babylonjs/Audio/sound";
  43457. import { Analyser } from "babylonjs/Audio/analyser";
  43458. import { Scene } from "babylonjs/scene";
  43459. /**
  43460. * Options allowed during the creation of a sound track.
  43461. */
  43462. export interface ISoundTrackOptions {
  43463. /**
  43464. * The volume the sound track should take during creation
  43465. */
  43466. volume?: number;
  43467. /**
  43468. * Define if the sound track is the main sound track of the scene
  43469. */
  43470. mainTrack?: boolean;
  43471. }
  43472. /**
  43473. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43474. * It will be also used in a future release to apply effects on a specific track.
  43475. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43476. */
  43477. export class SoundTrack {
  43478. /**
  43479. * The unique identifier of the sound track in the scene.
  43480. */
  43481. id: number;
  43482. /**
  43483. * The list of sounds included in the sound track.
  43484. */
  43485. soundCollection: Array<Sound>;
  43486. private _outputAudioNode;
  43487. private _scene;
  43488. private _connectedAnalyser;
  43489. private _options;
  43490. private _isInitialized;
  43491. /**
  43492. * Creates a new sound track.
  43493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43494. * @param scene Define the scene the sound track belongs to
  43495. * @param options
  43496. */
  43497. constructor(scene: Scene, options?: ISoundTrackOptions);
  43498. private _initializeSoundTrackAudioGraph;
  43499. /**
  43500. * Release the sound track and its associated resources
  43501. */
  43502. dispose(): void;
  43503. /**
  43504. * Adds a sound to this sound track
  43505. * @param sound define the cound to add
  43506. * @ignoreNaming
  43507. */
  43508. AddSound(sound: Sound): void;
  43509. /**
  43510. * Removes a sound to this sound track
  43511. * @param sound define the cound to remove
  43512. * @ignoreNaming
  43513. */
  43514. RemoveSound(sound: Sound): void;
  43515. /**
  43516. * Set a global volume for the full sound track.
  43517. * @param newVolume Define the new volume of the sound track
  43518. */
  43519. setVolume(newVolume: number): void;
  43520. /**
  43521. * Switch the panning model to HRTF:
  43522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43523. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43524. */
  43525. switchPanningModelToHRTF(): void;
  43526. /**
  43527. * Switch the panning model to Equal Power:
  43528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43530. */
  43531. switchPanningModelToEqualPower(): void;
  43532. /**
  43533. * Connect the sound track to an audio analyser allowing some amazing
  43534. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43536. * @param analyser The analyser to connect to the engine
  43537. */
  43538. connectToAnalyser(analyser: Analyser): void;
  43539. }
  43540. }
  43541. declare module "babylonjs/Audio/audioSceneComponent" {
  43542. import { Sound } from "babylonjs/Audio/sound";
  43543. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Vector3 } from "babylonjs/Maths/math.vector";
  43546. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { AbstractScene } from "babylonjs/abstractScene";
  43549. import "babylonjs/Audio/audioEngine";
  43550. module "babylonjs/abstractScene" {
  43551. interface AbstractScene {
  43552. /**
  43553. * The list of sounds used in the scene.
  43554. */
  43555. sounds: Nullable<Array<Sound>>;
  43556. }
  43557. }
  43558. module "babylonjs/scene" {
  43559. interface Scene {
  43560. /**
  43561. * @hidden
  43562. * Backing field
  43563. */
  43564. _mainSoundTrack: SoundTrack;
  43565. /**
  43566. * The main sound track played by the scene.
  43567. * It cotains your primary collection of sounds.
  43568. */
  43569. mainSoundTrack: SoundTrack;
  43570. /**
  43571. * The list of sound tracks added to the scene
  43572. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43573. */
  43574. soundTracks: Nullable<Array<SoundTrack>>;
  43575. /**
  43576. * Gets a sound using a given name
  43577. * @param name defines the name to search for
  43578. * @return the found sound or null if not found at all.
  43579. */
  43580. getSoundByName(name: string): Nullable<Sound>;
  43581. /**
  43582. * Gets or sets if audio support is enabled
  43583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43584. */
  43585. audioEnabled: boolean;
  43586. /**
  43587. * Gets or sets if audio will be output to headphones
  43588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43589. */
  43590. headphone: boolean;
  43591. /**
  43592. * Gets or sets custom audio listener position provider
  43593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43594. */
  43595. audioListenerPositionProvider: Nullable<() => Vector3>;
  43596. /**
  43597. * Gets or sets a refresh rate when using 3D audio positioning
  43598. */
  43599. audioPositioningRefreshRate: number;
  43600. }
  43601. }
  43602. /**
  43603. * Defines the sound scene component responsible to manage any sounds
  43604. * in a given scene.
  43605. */
  43606. export class AudioSceneComponent implements ISceneSerializableComponent {
  43607. private static _CameraDirectionLH;
  43608. private static _CameraDirectionRH;
  43609. /**
  43610. * The component name helpfull to identify the component in the list of scene components.
  43611. */
  43612. readonly name: string;
  43613. /**
  43614. * The scene the component belongs to.
  43615. */
  43616. scene: Scene;
  43617. private _audioEnabled;
  43618. /**
  43619. * Gets whether audio is enabled or not.
  43620. * Please use related enable/disable method to switch state.
  43621. */
  43622. get audioEnabled(): boolean;
  43623. private _headphone;
  43624. /**
  43625. * Gets whether audio is outputing to headphone or not.
  43626. * Please use the according Switch methods to change output.
  43627. */
  43628. get headphone(): boolean;
  43629. /**
  43630. * Gets or sets a refresh rate when using 3D audio positioning
  43631. */
  43632. audioPositioningRefreshRate: number;
  43633. private _audioListenerPositionProvider;
  43634. /**
  43635. * Gets the current audio listener position provider
  43636. */
  43637. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43638. /**
  43639. * Sets a custom listener position for all sounds in the scene
  43640. * By default, this is the position of the first active camera
  43641. */
  43642. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43643. /**
  43644. * Creates a new instance of the component for the given scene
  43645. * @param scene Defines the scene to register the component in
  43646. */
  43647. constructor(scene: Scene);
  43648. /**
  43649. * Registers the component in a given scene
  43650. */
  43651. register(): void;
  43652. /**
  43653. * Rebuilds the elements related to this component in case of
  43654. * context lost for instance.
  43655. */
  43656. rebuild(): void;
  43657. /**
  43658. * Serializes the component data to the specified json object
  43659. * @param serializationObject The object to serialize to
  43660. */
  43661. serialize(serializationObject: any): void;
  43662. /**
  43663. * Adds all the elements from the container to the scene
  43664. * @param container the container holding the elements
  43665. */
  43666. addFromContainer(container: AbstractScene): void;
  43667. /**
  43668. * Removes all the elements in the container from the scene
  43669. * @param container contains the elements to remove
  43670. * @param dispose if the removed element should be disposed (default: false)
  43671. */
  43672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43673. /**
  43674. * Disposes the component and the associated ressources.
  43675. */
  43676. dispose(): void;
  43677. /**
  43678. * Disables audio in the associated scene.
  43679. */
  43680. disableAudio(): void;
  43681. /**
  43682. * Enables audio in the associated scene.
  43683. */
  43684. enableAudio(): void;
  43685. /**
  43686. * Switch audio to headphone output.
  43687. */
  43688. switchAudioModeForHeadphones(): void;
  43689. /**
  43690. * Switch audio to normal speakers.
  43691. */
  43692. switchAudioModeForNormalSpeakers(): void;
  43693. private _cachedCameraDirection;
  43694. private _cachedCameraPosition;
  43695. private _lastCheck;
  43696. private _afterRender;
  43697. }
  43698. }
  43699. declare module "babylonjs/Audio/weightedsound" {
  43700. import { Sound } from "babylonjs/Audio/sound";
  43701. /**
  43702. * Wraps one or more Sound objects and selects one with random weight for playback.
  43703. */
  43704. export class WeightedSound {
  43705. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43706. loop: boolean;
  43707. private _coneInnerAngle;
  43708. private _coneOuterAngle;
  43709. private _volume;
  43710. /** A Sound is currently playing. */
  43711. isPlaying: boolean;
  43712. /** A Sound is currently paused. */
  43713. isPaused: boolean;
  43714. private _sounds;
  43715. private _weights;
  43716. private _currentIndex?;
  43717. /**
  43718. * Creates a new WeightedSound from the list of sounds given.
  43719. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43720. * @param sounds Array of Sounds that will be selected from.
  43721. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43722. */
  43723. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43724. /**
  43725. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43726. */
  43727. get directionalConeInnerAngle(): number;
  43728. /**
  43729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43730. */
  43731. set directionalConeInnerAngle(value: number);
  43732. /**
  43733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43735. */
  43736. get directionalConeOuterAngle(): number;
  43737. /**
  43738. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43739. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43740. */
  43741. set directionalConeOuterAngle(value: number);
  43742. /**
  43743. * Playback volume.
  43744. */
  43745. get volume(): number;
  43746. /**
  43747. * Playback volume.
  43748. */
  43749. set volume(value: number);
  43750. private _onended;
  43751. /**
  43752. * Suspend playback
  43753. */
  43754. pause(): void;
  43755. /**
  43756. * Stop playback
  43757. */
  43758. stop(): void;
  43759. /**
  43760. * Start playback.
  43761. * @param startOffset Position the clip head at a specific time in seconds.
  43762. */
  43763. play(startOffset?: number): void;
  43764. }
  43765. }
  43766. declare module "babylonjs/Audio/index" {
  43767. export * from "babylonjs/Audio/analyser";
  43768. export * from "babylonjs/Audio/audioEngine";
  43769. export * from "babylonjs/Audio/audioSceneComponent";
  43770. export * from "babylonjs/Audio/sound";
  43771. export * from "babylonjs/Audio/soundTrack";
  43772. export * from "babylonjs/Audio/weightedsound";
  43773. }
  43774. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43775. import { Behavior } from "babylonjs/Behaviors/behavior";
  43776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43777. import { BackEase } from "babylonjs/Animations/easing";
  43778. /**
  43779. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43780. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43781. */
  43782. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43783. /**
  43784. * Gets the name of the behavior.
  43785. */
  43786. get name(): string;
  43787. /**
  43788. * The easing function used by animations
  43789. */
  43790. static EasingFunction: BackEase;
  43791. /**
  43792. * The easing mode used by animations
  43793. */
  43794. static EasingMode: number;
  43795. /**
  43796. * The duration of the animation, in milliseconds
  43797. */
  43798. transitionDuration: number;
  43799. /**
  43800. * Length of the distance animated by the transition when lower radius is reached
  43801. */
  43802. lowerRadiusTransitionRange: number;
  43803. /**
  43804. * Length of the distance animated by the transition when upper radius is reached
  43805. */
  43806. upperRadiusTransitionRange: number;
  43807. private _autoTransitionRange;
  43808. /**
  43809. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43810. */
  43811. get autoTransitionRange(): boolean;
  43812. /**
  43813. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43814. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43815. */
  43816. set autoTransitionRange(value: boolean);
  43817. private _attachedCamera;
  43818. private _onAfterCheckInputsObserver;
  43819. private _onMeshTargetChangedObserver;
  43820. /**
  43821. * Initializes the behavior.
  43822. */
  43823. init(): void;
  43824. /**
  43825. * Attaches the behavior to its arc rotate camera.
  43826. * @param camera Defines the camera to attach the behavior to
  43827. */
  43828. attach(camera: ArcRotateCamera): void;
  43829. /**
  43830. * Detaches the behavior from its current arc rotate camera.
  43831. */
  43832. detach(): void;
  43833. private _radiusIsAnimating;
  43834. private _radiusBounceTransition;
  43835. private _animatables;
  43836. private _cachedWheelPrecision;
  43837. /**
  43838. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43839. * @param radiusLimit The limit to check against.
  43840. * @return Bool to indicate if at limit.
  43841. */
  43842. private _isRadiusAtLimit;
  43843. /**
  43844. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43845. * @param radiusDelta The delta by which to animate to. Can be negative.
  43846. */
  43847. private _applyBoundRadiusAnimation;
  43848. /**
  43849. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43850. */
  43851. protected _clearAnimationLocks(): void;
  43852. /**
  43853. * Stops and removes all animations that have been applied to the camera
  43854. */
  43855. stopAllAnimations(): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43859. import { Behavior } from "babylonjs/Behaviors/behavior";
  43860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43861. import { ExponentialEase } from "babylonjs/Animations/easing";
  43862. import { Nullable } from "babylonjs/types";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { Vector3 } from "babylonjs/Maths/math.vector";
  43865. /**
  43866. * 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.
  43867. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43868. */
  43869. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43870. /**
  43871. * Gets the name of the behavior.
  43872. */
  43873. get name(): string;
  43874. private _mode;
  43875. private _radiusScale;
  43876. private _positionScale;
  43877. private _defaultElevation;
  43878. private _elevationReturnTime;
  43879. private _elevationReturnWaitTime;
  43880. private _zoomStopsAnimation;
  43881. private _framingTime;
  43882. /**
  43883. * The easing function used by animations
  43884. */
  43885. static EasingFunction: ExponentialEase;
  43886. /**
  43887. * The easing mode used by animations
  43888. */
  43889. static EasingMode: number;
  43890. /**
  43891. * Sets the current mode used by the behavior
  43892. */
  43893. set mode(mode: number);
  43894. /**
  43895. * Gets current mode used by the behavior.
  43896. */
  43897. get mode(): number;
  43898. /**
  43899. * Sets the scale applied to the radius (1 by default)
  43900. */
  43901. set radiusScale(radius: number);
  43902. /**
  43903. * Gets the scale applied to the radius
  43904. */
  43905. get radiusScale(): number;
  43906. /**
  43907. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43908. */
  43909. set positionScale(scale: number);
  43910. /**
  43911. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43912. */
  43913. get positionScale(): number;
  43914. /**
  43915. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43916. * behaviour is triggered, in radians.
  43917. */
  43918. set defaultElevation(elevation: number);
  43919. /**
  43920. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43921. * behaviour is triggered, in radians.
  43922. */
  43923. get defaultElevation(): number;
  43924. /**
  43925. * Sets the time (in milliseconds) taken to return to the default beta position.
  43926. * Negative value indicates camera should not return to default.
  43927. */
  43928. set elevationReturnTime(speed: number);
  43929. /**
  43930. * Gets the time (in milliseconds) taken to return to the default beta position.
  43931. * Negative value indicates camera should not return to default.
  43932. */
  43933. get elevationReturnTime(): number;
  43934. /**
  43935. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43936. */
  43937. set elevationReturnWaitTime(time: number);
  43938. /**
  43939. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43940. */
  43941. get elevationReturnWaitTime(): number;
  43942. /**
  43943. * Sets the flag that indicates if user zooming should stop animation.
  43944. */
  43945. set zoomStopsAnimation(flag: boolean);
  43946. /**
  43947. * Gets the flag that indicates if user zooming should stop animation.
  43948. */
  43949. get zoomStopsAnimation(): boolean;
  43950. /**
  43951. * Sets the transition time when framing the mesh, in milliseconds
  43952. */
  43953. set framingTime(time: number);
  43954. /**
  43955. * Gets the transition time when framing the mesh, in milliseconds
  43956. */
  43957. get framingTime(): number;
  43958. /**
  43959. * Define if the behavior should automatically change the configured
  43960. * camera limits and sensibilities.
  43961. */
  43962. autoCorrectCameraLimitsAndSensibility: boolean;
  43963. private _onPrePointerObservableObserver;
  43964. private _onAfterCheckInputsObserver;
  43965. private _onMeshTargetChangedObserver;
  43966. private _attachedCamera;
  43967. private _isPointerDown;
  43968. private _lastInteractionTime;
  43969. /**
  43970. * Initializes the behavior.
  43971. */
  43972. init(): void;
  43973. /**
  43974. * Attaches the behavior to its arc rotate camera.
  43975. * @param camera Defines the camera to attach the behavior to
  43976. */
  43977. attach(camera: ArcRotateCamera): void;
  43978. /**
  43979. * Detaches the behavior from its current arc rotate camera.
  43980. */
  43981. detach(): void;
  43982. private _animatables;
  43983. private _betaIsAnimating;
  43984. private _betaTransition;
  43985. private _radiusTransition;
  43986. private _vectorTransition;
  43987. /**
  43988. * Targets the given mesh and updates zoom level accordingly.
  43989. * @param mesh The mesh to target.
  43990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43992. */
  43993. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43994. /**
  43995. * Targets the given mesh with its children and updates zoom level accordingly.
  43996. * @param mesh The mesh to target.
  43997. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43998. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43999. */
  44000. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44001. /**
  44002. * Targets the given meshes with their children and updates zoom level accordingly.
  44003. * @param meshes The mesh to target.
  44004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44006. */
  44007. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44008. /**
  44009. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44010. * @param minimumWorld Determines the smaller position of the bounding box extend
  44011. * @param maximumWorld Determines the bigger position of the bounding box extend
  44012. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44013. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44014. */
  44015. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44016. /**
  44017. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44018. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44019. * frustum width.
  44020. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44021. * to fully enclose the mesh in the viewing frustum.
  44022. */
  44023. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44024. /**
  44025. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44026. * is automatically returned to its default position (expected to be above ground plane).
  44027. */
  44028. private _maintainCameraAboveGround;
  44029. /**
  44030. * Returns the frustum slope based on the canvas ratio and camera FOV
  44031. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44032. */
  44033. private _getFrustumSlope;
  44034. /**
  44035. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44036. */
  44037. private _clearAnimationLocks;
  44038. /**
  44039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44040. */
  44041. private _applyUserInteraction;
  44042. /**
  44043. * Stops and removes all animations that have been applied to the camera
  44044. */
  44045. stopAllAnimations(): void;
  44046. /**
  44047. * Gets a value indicating if the user is moving the camera
  44048. */
  44049. get isUserIsMoving(): boolean;
  44050. /**
  44051. * The camera can move all the way towards the mesh.
  44052. */
  44053. static IgnoreBoundsSizeMode: number;
  44054. /**
  44055. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44056. */
  44057. static FitFrustumSidesMode: number;
  44058. }
  44059. }
  44060. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44061. import { Nullable } from "babylonjs/types";
  44062. import { Camera } from "babylonjs/Cameras/camera";
  44063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44065. /**
  44066. * Base class for Camera Pointer Inputs.
  44067. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44068. * for example usage.
  44069. */
  44070. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44071. /**
  44072. * Defines the camera the input is attached to.
  44073. */
  44074. abstract camera: Camera;
  44075. /**
  44076. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44077. */
  44078. protected _altKey: boolean;
  44079. protected _ctrlKey: boolean;
  44080. protected _metaKey: boolean;
  44081. protected _shiftKey: boolean;
  44082. /**
  44083. * Which mouse buttons were pressed at time of last mouse event.
  44084. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44085. */
  44086. protected _buttonsPressed: number;
  44087. /**
  44088. * Defines the buttons associated with the input to handle camera move.
  44089. */
  44090. buttons: number[];
  44091. /**
  44092. * Attach the input controls to a specific dom element to get the input from.
  44093. * @param element Defines the element the controls should be listened from
  44094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44095. */
  44096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44097. /**
  44098. * Detach the current controls from the specified dom element.
  44099. * @param element Defines the element to stop listening the inputs from
  44100. */
  44101. detachControl(element: Nullable<HTMLElement>): void;
  44102. /**
  44103. * Gets the class name of the current input.
  44104. * @returns the class name
  44105. */
  44106. getClassName(): string;
  44107. /**
  44108. * Get the friendly name associated with the input class.
  44109. * @returns the input friendly name
  44110. */
  44111. getSimpleName(): string;
  44112. /**
  44113. * Called on pointer POINTERDOUBLETAP event.
  44114. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44115. */
  44116. protected onDoubleTap(type: string): void;
  44117. /**
  44118. * Called on pointer POINTERMOVE event if only a single touch is active.
  44119. * Override this method to provide functionality.
  44120. */
  44121. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44122. /**
  44123. * Called on pointer POINTERMOVE event if multiple touches are active.
  44124. * Override this method to provide functionality.
  44125. */
  44126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44127. /**
  44128. * Called on JS contextmenu event.
  44129. * Override this method to provide functionality.
  44130. */
  44131. protected onContextMenu(evt: PointerEvent): void;
  44132. /**
  44133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44134. * press.
  44135. * Override this method to provide functionality.
  44136. */
  44137. protected onButtonDown(evt: PointerEvent): void;
  44138. /**
  44139. * Called each time a new POINTERUP event occurs. Ie, for each button
  44140. * release.
  44141. * Override this method to provide functionality.
  44142. */
  44143. protected onButtonUp(evt: PointerEvent): void;
  44144. /**
  44145. * Called when window becomes inactive.
  44146. * Override this method to provide functionality.
  44147. */
  44148. protected onLostFocus(): void;
  44149. private _pointerInput;
  44150. private _observer;
  44151. private _onLostFocus;
  44152. private pointA;
  44153. private pointB;
  44154. }
  44155. }
  44156. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44157. import { Nullable } from "babylonjs/types";
  44158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44159. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44160. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44161. /**
  44162. * Manage the pointers inputs to control an arc rotate camera.
  44163. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44164. */
  44165. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44166. /**
  44167. * Defines the camera the input is attached to.
  44168. */
  44169. camera: ArcRotateCamera;
  44170. /**
  44171. * Gets the class name of the current input.
  44172. * @returns the class name
  44173. */
  44174. getClassName(): string;
  44175. /**
  44176. * Defines the buttons associated with the input to handle camera move.
  44177. */
  44178. buttons: number[];
  44179. /**
  44180. * Defines the pointer angular sensibility along the X axis or how fast is
  44181. * the camera rotating.
  44182. */
  44183. angularSensibilityX: number;
  44184. /**
  44185. * Defines the pointer angular sensibility along the Y axis or how fast is
  44186. * the camera rotating.
  44187. */
  44188. angularSensibilityY: number;
  44189. /**
  44190. * Defines the pointer pinch precision or how fast is the camera zooming.
  44191. */
  44192. pinchPrecision: number;
  44193. /**
  44194. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44195. * from 0.
  44196. * It defines the percentage of current camera.radius to use as delta when
  44197. * pinch zoom is used.
  44198. */
  44199. pinchDeltaPercentage: number;
  44200. /**
  44201. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44202. * that any object in the plane at the camera's target point will scale
  44203. * perfectly with finger motion.
  44204. * Overrides pinchDeltaPercentage and pinchPrecision.
  44205. */
  44206. useNaturalPinchZoom: boolean;
  44207. /**
  44208. * Defines the pointer panning sensibility or how fast is the camera moving.
  44209. */
  44210. panningSensibility: number;
  44211. /**
  44212. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44213. */
  44214. multiTouchPanning: boolean;
  44215. /**
  44216. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44217. * zoom (pinch) through multitouch.
  44218. */
  44219. multiTouchPanAndZoom: boolean;
  44220. /**
  44221. * Revers pinch action direction.
  44222. */
  44223. pinchInwards: boolean;
  44224. private _isPanClick;
  44225. private _twoFingerActivityCount;
  44226. private _isPinching;
  44227. /**
  44228. * Called on pointer POINTERMOVE event if only a single touch is active.
  44229. */
  44230. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44231. /**
  44232. * Called on pointer POINTERDOUBLETAP event.
  44233. */
  44234. protected onDoubleTap(type: string): void;
  44235. /**
  44236. * Called on pointer POINTERMOVE event if multiple touches are active.
  44237. */
  44238. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44239. /**
  44240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44241. * press.
  44242. */
  44243. protected onButtonDown(evt: PointerEvent): void;
  44244. /**
  44245. * Called each time a new POINTERUP event occurs. Ie, for each button
  44246. * release.
  44247. */
  44248. protected onButtonUp(evt: PointerEvent): void;
  44249. /**
  44250. * Called when window becomes inactive.
  44251. */
  44252. protected onLostFocus(): void;
  44253. }
  44254. }
  44255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44256. import { Nullable } from "babylonjs/types";
  44257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44259. /**
  44260. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44262. */
  44263. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44264. /**
  44265. * Defines the camera the input is attached to.
  44266. */
  44267. camera: ArcRotateCamera;
  44268. /**
  44269. * Defines the list of key codes associated with the up action (increase alpha)
  44270. */
  44271. keysUp: number[];
  44272. /**
  44273. * Defines the list of key codes associated with the down action (decrease alpha)
  44274. */
  44275. keysDown: number[];
  44276. /**
  44277. * Defines the list of key codes associated with the left action (increase beta)
  44278. */
  44279. keysLeft: number[];
  44280. /**
  44281. * Defines the list of key codes associated with the right action (decrease beta)
  44282. */
  44283. keysRight: number[];
  44284. /**
  44285. * Defines the list of key codes associated with the reset action.
  44286. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44287. */
  44288. keysReset: number[];
  44289. /**
  44290. * Defines the panning sensibility of the inputs.
  44291. * (How fast is the camera panning)
  44292. */
  44293. panningSensibility: number;
  44294. /**
  44295. * Defines the zooming sensibility of the inputs.
  44296. * (How fast is the camera zooming)
  44297. */
  44298. zoomingSensibility: number;
  44299. /**
  44300. * Defines whether maintaining the alt key down switch the movement mode from
  44301. * orientation to zoom.
  44302. */
  44303. useAltToZoom: boolean;
  44304. /**
  44305. * Rotation speed of the camera
  44306. */
  44307. angularSpeed: number;
  44308. private _keys;
  44309. private _ctrlPressed;
  44310. private _altPressed;
  44311. private _onCanvasBlurObserver;
  44312. private _onKeyboardObserver;
  44313. private _engine;
  44314. private _scene;
  44315. /**
  44316. * Attach the input controls to a specific dom element to get the input from.
  44317. * @param element Defines the element the controls should be listened from
  44318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44319. */
  44320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44321. /**
  44322. * Detach the current controls from the specified dom element.
  44323. * @param element Defines the element to stop listening the inputs from
  44324. */
  44325. detachControl(element: Nullable<HTMLElement>): void;
  44326. /**
  44327. * Update the current camera state depending on the inputs that have been used this frame.
  44328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44329. */
  44330. checkInputs(): void;
  44331. /**
  44332. * Gets the class name of the current intput.
  44333. * @returns the class name
  44334. */
  44335. getClassName(): string;
  44336. /**
  44337. * Get the friendly name associated with the input class.
  44338. * @returns the input friendly name
  44339. */
  44340. getSimpleName(): string;
  44341. }
  44342. }
  44343. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44344. import { Nullable } from "babylonjs/types";
  44345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44347. /**
  44348. * Manage the mouse wheel inputs to control an arc rotate camera.
  44349. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44350. */
  44351. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44352. /**
  44353. * Defines the camera the input is attached to.
  44354. */
  44355. camera: ArcRotateCamera;
  44356. /**
  44357. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44358. */
  44359. wheelPrecision: number;
  44360. /**
  44361. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44362. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44363. */
  44364. wheelDeltaPercentage: number;
  44365. private _wheel;
  44366. private _observer;
  44367. private computeDeltaFromMouseWheelLegacyEvent;
  44368. /**
  44369. * Attach the input controls to a specific dom element to get the input from.
  44370. * @param element Defines the element the controls should be listened from
  44371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44372. */
  44373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44374. /**
  44375. * Detach the current controls from the specified dom element.
  44376. * @param element Defines the element to stop listening the inputs from
  44377. */
  44378. detachControl(element: Nullable<HTMLElement>): void;
  44379. /**
  44380. * Gets the class name of the current intput.
  44381. * @returns the class name
  44382. */
  44383. getClassName(): string;
  44384. /**
  44385. * Get the friendly name associated with the input class.
  44386. * @returns the input friendly name
  44387. */
  44388. getSimpleName(): string;
  44389. }
  44390. }
  44391. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44393. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44394. /**
  44395. * Default Inputs manager for the ArcRotateCamera.
  44396. * It groups all the default supported inputs for ease of use.
  44397. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44398. */
  44399. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44400. /**
  44401. * Instantiates a new ArcRotateCameraInputsManager.
  44402. * @param camera Defines the camera the inputs belong to
  44403. */
  44404. constructor(camera: ArcRotateCamera);
  44405. /**
  44406. * Add mouse wheel input support to the input manager.
  44407. * @returns the current input manager
  44408. */
  44409. addMouseWheel(): ArcRotateCameraInputsManager;
  44410. /**
  44411. * Add pointers input support to the input manager.
  44412. * @returns the current input manager
  44413. */
  44414. addPointers(): ArcRotateCameraInputsManager;
  44415. /**
  44416. * Add keyboard input support to the input manager.
  44417. * @returns the current input manager
  44418. */
  44419. addKeyboard(): ArcRotateCameraInputsManager;
  44420. }
  44421. }
  44422. declare module "babylonjs/Cameras/arcRotateCamera" {
  44423. import { Observable } from "babylonjs/Misc/observable";
  44424. import { Nullable } from "babylonjs/types";
  44425. import { Scene } from "babylonjs/scene";
  44426. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44428. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44429. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44430. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44431. import { Camera } from "babylonjs/Cameras/camera";
  44432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44433. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44434. import { Collider } from "babylonjs/Collisions/collider";
  44435. /**
  44436. * This represents an orbital type of camera.
  44437. *
  44438. * 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.
  44439. * 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.
  44440. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44441. */
  44442. export class ArcRotateCamera extends TargetCamera {
  44443. /**
  44444. * Defines the rotation angle of the camera along the longitudinal axis.
  44445. */
  44446. alpha: number;
  44447. /**
  44448. * Defines the rotation angle of the camera along the latitudinal axis.
  44449. */
  44450. beta: number;
  44451. /**
  44452. * Defines the radius of the camera from it s target point.
  44453. */
  44454. radius: number;
  44455. protected _target: Vector3;
  44456. protected _targetHost: Nullable<AbstractMesh>;
  44457. /**
  44458. * Defines the target point of the camera.
  44459. * The camera looks towards it form the radius distance.
  44460. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44461. */
  44462. get target(): Vector3;
  44463. set target(value: Vector3);
  44464. /**
  44465. * Define the current local position of the camera in the scene
  44466. */
  44467. get position(): Vector3;
  44468. set position(newPosition: Vector3);
  44469. protected _upToYMatrix: Matrix;
  44470. protected _YToUpMatrix: Matrix;
  44471. /**
  44472. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44473. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44474. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44475. */
  44476. set upVector(vec: Vector3);
  44477. get upVector(): Vector3;
  44478. /**
  44479. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44480. */
  44481. setMatUp(): void;
  44482. /**
  44483. * Current inertia value on the longitudinal axis.
  44484. * The bigger this number the longer it will take for the camera to stop.
  44485. */
  44486. inertialAlphaOffset: number;
  44487. /**
  44488. * Current inertia value on the latitudinal axis.
  44489. * The bigger this number the longer it will take for the camera to stop.
  44490. */
  44491. inertialBetaOffset: number;
  44492. /**
  44493. * Current inertia value on the radius axis.
  44494. * The bigger this number the longer it will take for the camera to stop.
  44495. */
  44496. inertialRadiusOffset: number;
  44497. /**
  44498. * Minimum allowed angle on the longitudinal axis.
  44499. * This can help limiting how the Camera is able to move in the scene.
  44500. */
  44501. lowerAlphaLimit: Nullable<number>;
  44502. /**
  44503. * Maximum allowed angle on the longitudinal axis.
  44504. * This can help limiting how the Camera is able to move in the scene.
  44505. */
  44506. upperAlphaLimit: Nullable<number>;
  44507. /**
  44508. * Minimum allowed angle on the latitudinal axis.
  44509. * This can help limiting how the Camera is able to move in the scene.
  44510. */
  44511. lowerBetaLimit: number;
  44512. /**
  44513. * Maximum allowed angle on the latitudinal axis.
  44514. * This can help limiting how the Camera is able to move in the scene.
  44515. */
  44516. upperBetaLimit: number;
  44517. /**
  44518. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44519. * This can help limiting how the Camera is able to move in the scene.
  44520. */
  44521. lowerRadiusLimit: Nullable<number>;
  44522. /**
  44523. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44524. * This can help limiting how the Camera is able to move in the scene.
  44525. */
  44526. upperRadiusLimit: Nullable<number>;
  44527. /**
  44528. * Defines the current inertia value used during panning of the camera along the X axis.
  44529. */
  44530. inertialPanningX: number;
  44531. /**
  44532. * Defines the current inertia value used during panning of the camera along the Y axis.
  44533. */
  44534. inertialPanningY: number;
  44535. /**
  44536. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44537. * Basically if your fingers moves away from more than this distance you will be considered
  44538. * in pinch mode.
  44539. */
  44540. pinchToPanMaxDistance: number;
  44541. /**
  44542. * Defines the maximum distance the camera can pan.
  44543. * This could help keeping the cammera always in your scene.
  44544. */
  44545. panningDistanceLimit: Nullable<number>;
  44546. /**
  44547. * Defines the target of the camera before paning.
  44548. */
  44549. panningOriginTarget: Vector3;
  44550. /**
  44551. * Defines the value of the inertia used during panning.
  44552. * 0 would mean stop inertia and one would mean no decelleration at all.
  44553. */
  44554. panningInertia: number;
  44555. /**
  44556. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44557. */
  44558. get angularSensibilityX(): number;
  44559. set angularSensibilityX(value: number);
  44560. /**
  44561. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44562. */
  44563. get angularSensibilityY(): number;
  44564. set angularSensibilityY(value: number);
  44565. /**
  44566. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44567. */
  44568. get pinchPrecision(): number;
  44569. set pinchPrecision(value: number);
  44570. /**
  44571. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44572. * It will be used instead of pinchDeltaPrecision if different from 0.
  44573. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44574. */
  44575. get pinchDeltaPercentage(): number;
  44576. set pinchDeltaPercentage(value: number);
  44577. /**
  44578. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44579. * and pinch delta percentage.
  44580. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44581. * that any object in the plane at the camera's target point will scale
  44582. * perfectly with finger motion.
  44583. */
  44584. get useNaturalPinchZoom(): boolean;
  44585. set useNaturalPinchZoom(value: boolean);
  44586. /**
  44587. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44588. */
  44589. get panningSensibility(): number;
  44590. set panningSensibility(value: number);
  44591. /**
  44592. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44593. */
  44594. get keysUp(): number[];
  44595. set keysUp(value: number[]);
  44596. /**
  44597. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44598. */
  44599. get keysDown(): number[];
  44600. set keysDown(value: number[]);
  44601. /**
  44602. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44603. */
  44604. get keysLeft(): number[];
  44605. set keysLeft(value: number[]);
  44606. /**
  44607. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44608. */
  44609. get keysRight(): number[];
  44610. set keysRight(value: number[]);
  44611. /**
  44612. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44613. */
  44614. get wheelPrecision(): number;
  44615. set wheelPrecision(value: number);
  44616. /**
  44617. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44618. * It will be used instead of pinchDeltaPrecision if different from 0.
  44619. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44620. */
  44621. get wheelDeltaPercentage(): number;
  44622. set wheelDeltaPercentage(value: number);
  44623. /**
  44624. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44625. */
  44626. zoomOnFactor: number;
  44627. /**
  44628. * Defines a screen offset for the camera position.
  44629. */
  44630. targetScreenOffset: Vector2;
  44631. /**
  44632. * Allows the camera to be completely reversed.
  44633. * If false the camera can not arrive upside down.
  44634. */
  44635. allowUpsideDown: boolean;
  44636. /**
  44637. * Define if double tap/click is used to restore the previously saved state of the camera.
  44638. */
  44639. useInputToRestoreState: boolean;
  44640. /** @hidden */
  44641. _viewMatrix: Matrix;
  44642. /** @hidden */
  44643. _useCtrlForPanning: boolean;
  44644. /** @hidden */
  44645. _panningMouseButton: number;
  44646. /**
  44647. * Defines the input associated to the camera.
  44648. */
  44649. inputs: ArcRotateCameraInputsManager;
  44650. /** @hidden */
  44651. _reset: () => void;
  44652. /**
  44653. * Defines the allowed panning axis.
  44654. */
  44655. panningAxis: Vector3;
  44656. protected _localDirection: Vector3;
  44657. protected _transformedDirection: Vector3;
  44658. private _bouncingBehavior;
  44659. /**
  44660. * Gets the bouncing behavior of the camera if it has been enabled.
  44661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44662. */
  44663. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44664. /**
  44665. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44666. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44667. */
  44668. get useBouncingBehavior(): boolean;
  44669. set useBouncingBehavior(value: boolean);
  44670. private _framingBehavior;
  44671. /**
  44672. * Gets the framing behavior of the camera if it has been enabled.
  44673. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44674. */
  44675. get framingBehavior(): Nullable<FramingBehavior>;
  44676. /**
  44677. * Defines if the framing behavior of the camera is enabled on the camera.
  44678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44679. */
  44680. get useFramingBehavior(): boolean;
  44681. set useFramingBehavior(value: boolean);
  44682. private _autoRotationBehavior;
  44683. /**
  44684. * Gets the auto rotation behavior of the camera if it has been enabled.
  44685. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44686. */
  44687. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44688. /**
  44689. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44690. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44691. */
  44692. get useAutoRotationBehavior(): boolean;
  44693. set useAutoRotationBehavior(value: boolean);
  44694. /**
  44695. * Observable triggered when the mesh target has been changed on the camera.
  44696. */
  44697. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44698. /**
  44699. * Event raised when the camera is colliding with a mesh.
  44700. */
  44701. onCollide: (collidedMesh: AbstractMesh) => void;
  44702. /**
  44703. * Defines whether the camera should check collision with the objects oh the scene.
  44704. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44705. */
  44706. checkCollisions: boolean;
  44707. /**
  44708. * Defines the collision radius of the camera.
  44709. * This simulates a sphere around the camera.
  44710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44711. */
  44712. collisionRadius: Vector3;
  44713. protected _collider: Collider;
  44714. protected _previousPosition: Vector3;
  44715. protected _collisionVelocity: Vector3;
  44716. protected _newPosition: Vector3;
  44717. protected _previousAlpha: number;
  44718. protected _previousBeta: number;
  44719. protected _previousRadius: number;
  44720. protected _collisionTriggered: boolean;
  44721. protected _targetBoundingCenter: Nullable<Vector3>;
  44722. private _computationVector;
  44723. /**
  44724. * Instantiates a new ArcRotateCamera in a given scene
  44725. * @param name Defines the name of the camera
  44726. * @param alpha Defines the camera rotation along the logitudinal axis
  44727. * @param beta Defines the camera rotation along the latitudinal axis
  44728. * @param radius Defines the camera distance from its target
  44729. * @param target Defines the camera target
  44730. * @param scene Defines the scene the camera belongs to
  44731. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44732. */
  44733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44734. /** @hidden */
  44735. _initCache(): void;
  44736. /** @hidden */
  44737. _updateCache(ignoreParentClass?: boolean): void;
  44738. protected _getTargetPosition(): Vector3;
  44739. private _storedAlpha;
  44740. private _storedBeta;
  44741. private _storedRadius;
  44742. private _storedTarget;
  44743. private _storedTargetScreenOffset;
  44744. /**
  44745. * Stores the current state of the camera (alpha, beta, radius and target)
  44746. * @returns the camera itself
  44747. */
  44748. storeState(): Camera;
  44749. /**
  44750. * @hidden
  44751. * Restored camera state. You must call storeState() first
  44752. */
  44753. _restoreStateValues(): boolean;
  44754. /** @hidden */
  44755. _isSynchronizedViewMatrix(): boolean;
  44756. /**
  44757. * Attached controls to the current camera.
  44758. * @param element Defines the element the controls should be listened from
  44759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44761. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44762. */
  44763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44764. /**
  44765. * Detach the current controls from the camera.
  44766. * The camera will stop reacting to inputs.
  44767. * @param element Defines the element to stop listening the inputs from
  44768. */
  44769. detachControl(element: HTMLElement): void;
  44770. /** @hidden */
  44771. _checkInputs(): void;
  44772. protected _checkLimits(): void;
  44773. /**
  44774. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44775. */
  44776. rebuildAnglesAndRadius(): void;
  44777. /**
  44778. * Use a position to define the current camera related information like alpha, beta and radius
  44779. * @param position Defines the position to set the camera at
  44780. */
  44781. setPosition(position: Vector3): void;
  44782. /**
  44783. * Defines the target the camera should look at.
  44784. * This will automatically adapt alpha beta and radius to fit within the new target.
  44785. * @param target Defines the new target as a Vector or a mesh
  44786. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44787. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44788. */
  44789. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44790. /** @hidden */
  44791. _getViewMatrix(): Matrix;
  44792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44793. /**
  44794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44795. * @param meshes Defines the mesh to zoom on
  44796. * @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)
  44797. */
  44798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44799. /**
  44800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44801. * The target will be changed but the radius
  44802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44803. * @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)
  44804. */
  44805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44806. min: Vector3;
  44807. max: Vector3;
  44808. distance: number;
  44809. }, doNotUpdateMaxZ?: boolean): void;
  44810. /**
  44811. * @override
  44812. * Override Camera.createRigCamera
  44813. */
  44814. createRigCamera(name: string, cameraIndex: number): Camera;
  44815. /**
  44816. * @hidden
  44817. * @override
  44818. * Override Camera._updateRigCameras
  44819. */
  44820. _updateRigCameras(): void;
  44821. /**
  44822. * Destroy the camera and release the current resources hold by it.
  44823. */
  44824. dispose(): void;
  44825. /**
  44826. * Gets the current object class name.
  44827. * @return the class name
  44828. */
  44829. getClassName(): string;
  44830. }
  44831. }
  44832. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44833. import { Behavior } from "babylonjs/Behaviors/behavior";
  44834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44835. /**
  44836. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44837. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44838. */
  44839. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44840. /**
  44841. * Gets the name of the behavior.
  44842. */
  44843. get name(): string;
  44844. private _zoomStopsAnimation;
  44845. private _idleRotationSpeed;
  44846. private _idleRotationWaitTime;
  44847. private _idleRotationSpinupTime;
  44848. /**
  44849. * Sets the flag that indicates if user zooming should stop animation.
  44850. */
  44851. set zoomStopsAnimation(flag: boolean);
  44852. /**
  44853. * Gets the flag that indicates if user zooming should stop animation.
  44854. */
  44855. get zoomStopsAnimation(): boolean;
  44856. /**
  44857. * Sets the default speed at which the camera rotates around the model.
  44858. */
  44859. set idleRotationSpeed(speed: number);
  44860. /**
  44861. * Gets the default speed at which the camera rotates around the model.
  44862. */
  44863. get idleRotationSpeed(): number;
  44864. /**
  44865. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44866. */
  44867. set idleRotationWaitTime(time: number);
  44868. /**
  44869. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44870. */
  44871. get idleRotationWaitTime(): number;
  44872. /**
  44873. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44874. */
  44875. set idleRotationSpinupTime(time: number);
  44876. /**
  44877. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44878. */
  44879. get idleRotationSpinupTime(): number;
  44880. /**
  44881. * Gets a value indicating if the camera is currently rotating because of this behavior
  44882. */
  44883. get rotationInProgress(): boolean;
  44884. private _onPrePointerObservableObserver;
  44885. private _onAfterCheckInputsObserver;
  44886. private _attachedCamera;
  44887. private _isPointerDown;
  44888. private _lastFrameTime;
  44889. private _lastInteractionTime;
  44890. private _cameraRotationSpeed;
  44891. /**
  44892. * Initializes the behavior.
  44893. */
  44894. init(): void;
  44895. /**
  44896. * Attaches the behavior to its arc rotate camera.
  44897. * @param camera Defines the camera to attach the behavior to
  44898. */
  44899. attach(camera: ArcRotateCamera): void;
  44900. /**
  44901. * Detaches the behavior from its current arc rotate camera.
  44902. */
  44903. detach(): void;
  44904. /**
  44905. * Returns true if user is scrolling.
  44906. * @return true if user is scrolling.
  44907. */
  44908. private _userIsZooming;
  44909. private _lastFrameRadius;
  44910. private _shouldAnimationStopForInteraction;
  44911. /**
  44912. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44913. */
  44914. private _applyUserInteraction;
  44915. private _userIsMoving;
  44916. }
  44917. }
  44918. declare module "babylonjs/Behaviors/Cameras/index" {
  44919. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44920. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44921. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44922. }
  44923. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44924. import { Mesh } from "babylonjs/Meshes/mesh";
  44925. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44926. import { Behavior } from "babylonjs/Behaviors/behavior";
  44927. /**
  44928. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44929. */
  44930. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44931. private ui;
  44932. /**
  44933. * The name of the behavior
  44934. */
  44935. name: string;
  44936. /**
  44937. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44938. */
  44939. distanceAwayFromFace: number;
  44940. /**
  44941. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44942. */
  44943. distanceAwayFromBottomOfFace: number;
  44944. private _faceVectors;
  44945. private _target;
  44946. private _scene;
  44947. private _onRenderObserver;
  44948. private _tmpMatrix;
  44949. private _tmpVector;
  44950. /**
  44951. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44952. * @param ui The transform node that should be attched to the mesh
  44953. */
  44954. constructor(ui: TransformNode);
  44955. /**
  44956. * Initializes the behavior
  44957. */
  44958. init(): void;
  44959. private _closestFace;
  44960. private _zeroVector;
  44961. private _lookAtTmpMatrix;
  44962. private _lookAtToRef;
  44963. /**
  44964. * Attaches the AttachToBoxBehavior to the passed in mesh
  44965. * @param target The mesh that the specified node will be attached to
  44966. */
  44967. attach(target: Mesh): void;
  44968. /**
  44969. * Detaches the behavior from the mesh
  44970. */
  44971. detach(): void;
  44972. }
  44973. }
  44974. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44975. import { Behavior } from "babylonjs/Behaviors/behavior";
  44976. import { Mesh } from "babylonjs/Meshes/mesh";
  44977. /**
  44978. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44979. */
  44980. export class FadeInOutBehavior implements Behavior<Mesh> {
  44981. /**
  44982. * Time in milliseconds to delay before fading in (Default: 0)
  44983. */
  44984. delay: number;
  44985. /**
  44986. * Time in milliseconds for the mesh to fade in (Default: 300)
  44987. */
  44988. fadeInTime: number;
  44989. private _millisecondsPerFrame;
  44990. private _hovered;
  44991. private _hoverValue;
  44992. private _ownerNode;
  44993. /**
  44994. * Instatiates the FadeInOutBehavior
  44995. */
  44996. constructor();
  44997. /**
  44998. * The name of the behavior
  44999. */
  45000. get name(): string;
  45001. /**
  45002. * Initializes the behavior
  45003. */
  45004. init(): void;
  45005. /**
  45006. * Attaches the fade behavior on the passed in mesh
  45007. * @param ownerNode The mesh that will be faded in/out once attached
  45008. */
  45009. attach(ownerNode: Mesh): void;
  45010. /**
  45011. * Detaches the behavior from the mesh
  45012. */
  45013. detach(): void;
  45014. /**
  45015. * Triggers the mesh to begin fading in or out
  45016. * @param value if the object should fade in or out (true to fade in)
  45017. */
  45018. fadeIn(value: boolean): void;
  45019. private _update;
  45020. private _setAllVisibility;
  45021. }
  45022. }
  45023. declare module "babylonjs/Misc/pivotTools" {
  45024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45025. /**
  45026. * Class containing a set of static utilities functions for managing Pivots
  45027. * @hidden
  45028. */
  45029. export class PivotTools {
  45030. private static _PivotCached;
  45031. private static _OldPivotPoint;
  45032. private static _PivotTranslation;
  45033. private static _PivotTmpVector;
  45034. private static _PivotPostMultiplyPivotMatrix;
  45035. /** @hidden */
  45036. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45037. /** @hidden */
  45038. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45039. }
  45040. }
  45041. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45042. import { Scene } from "babylonjs/scene";
  45043. import { Vector4 } from "babylonjs/Maths/math.vector";
  45044. import { Mesh } from "babylonjs/Meshes/mesh";
  45045. import { Nullable } from "babylonjs/types";
  45046. import { Plane } from "babylonjs/Maths/math.plane";
  45047. /**
  45048. * Class containing static functions to help procedurally build meshes
  45049. */
  45050. export class PlaneBuilder {
  45051. /**
  45052. * Creates a plane mesh
  45053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45059. * @param name defines the name of the mesh
  45060. * @param options defines the options used to create the mesh
  45061. * @param scene defines the hosting scene
  45062. * @returns the plane mesh
  45063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45064. */
  45065. static CreatePlane(name: string, options: {
  45066. size?: number;
  45067. width?: number;
  45068. height?: number;
  45069. sideOrientation?: number;
  45070. frontUVs?: Vector4;
  45071. backUVs?: Vector4;
  45072. updatable?: boolean;
  45073. sourcePlane?: Plane;
  45074. }, scene?: Nullable<Scene>): Mesh;
  45075. }
  45076. }
  45077. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45078. import { Behavior } from "babylonjs/Behaviors/behavior";
  45079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45080. import { Observable } from "babylonjs/Misc/observable";
  45081. import { Vector3 } from "babylonjs/Maths/math.vector";
  45082. import { Ray } from "babylonjs/Culling/ray";
  45083. import "babylonjs/Meshes/Builders/planeBuilder";
  45084. /**
  45085. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45086. */
  45087. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45088. private static _AnyMouseID;
  45089. /**
  45090. * Abstract mesh the behavior is set on
  45091. */
  45092. attachedNode: AbstractMesh;
  45093. private _dragPlane;
  45094. private _scene;
  45095. private _pointerObserver;
  45096. private _beforeRenderObserver;
  45097. private static _planeScene;
  45098. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45099. /**
  45100. * 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)
  45101. */
  45102. maxDragAngle: number;
  45103. /**
  45104. * @hidden
  45105. */
  45106. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45107. /**
  45108. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45109. */
  45110. currentDraggingPointerID: number;
  45111. /**
  45112. * The last position where the pointer hit the drag plane in world space
  45113. */
  45114. lastDragPosition: Vector3;
  45115. /**
  45116. * If the behavior is currently in a dragging state
  45117. */
  45118. dragging: boolean;
  45119. /**
  45120. * 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)
  45121. */
  45122. dragDeltaRatio: number;
  45123. /**
  45124. * If the drag plane orientation should be updated during the dragging (Default: true)
  45125. */
  45126. updateDragPlane: boolean;
  45127. private _debugMode;
  45128. private _moving;
  45129. /**
  45130. * Fires each time the attached mesh is dragged with the pointer
  45131. * * delta between last drag position and current drag position in world space
  45132. * * dragDistance along the drag axis
  45133. * * dragPlaneNormal normal of the current drag plane used during the drag
  45134. * * dragPlanePoint in world space where the drag intersects the drag plane
  45135. */
  45136. onDragObservable: Observable<{
  45137. delta: Vector3;
  45138. dragPlanePoint: Vector3;
  45139. dragPlaneNormal: Vector3;
  45140. dragDistance: number;
  45141. pointerId: number;
  45142. }>;
  45143. /**
  45144. * Fires each time a drag begins (eg. mouse down on mesh)
  45145. */
  45146. onDragStartObservable: Observable<{
  45147. dragPlanePoint: Vector3;
  45148. pointerId: number;
  45149. }>;
  45150. /**
  45151. * Fires each time a drag ends (eg. mouse release after drag)
  45152. */
  45153. onDragEndObservable: Observable<{
  45154. dragPlanePoint: Vector3;
  45155. pointerId: number;
  45156. }>;
  45157. /**
  45158. * If the attached mesh should be moved when dragged
  45159. */
  45160. moveAttached: boolean;
  45161. /**
  45162. * If the drag behavior will react to drag events (Default: true)
  45163. */
  45164. enabled: boolean;
  45165. /**
  45166. * If pointer events should start and release the drag (Default: true)
  45167. */
  45168. startAndReleaseDragOnPointerEvents: boolean;
  45169. /**
  45170. * If camera controls should be detached during the drag
  45171. */
  45172. detachCameraControls: boolean;
  45173. /**
  45174. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45175. */
  45176. useObjectOrientationForDragging: boolean;
  45177. private _options;
  45178. /**
  45179. * Gets the options used by the behavior
  45180. */
  45181. get options(): {
  45182. dragAxis?: Vector3;
  45183. dragPlaneNormal?: Vector3;
  45184. };
  45185. /**
  45186. * Sets the options used by the behavior
  45187. */
  45188. set options(options: {
  45189. dragAxis?: Vector3;
  45190. dragPlaneNormal?: Vector3;
  45191. });
  45192. /**
  45193. * Creates a pointer drag behavior that can be attached to a mesh
  45194. * @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)
  45195. */
  45196. constructor(options?: {
  45197. dragAxis?: Vector3;
  45198. dragPlaneNormal?: Vector3;
  45199. });
  45200. /**
  45201. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45202. */
  45203. validateDrag: (targetPosition: Vector3) => boolean;
  45204. /**
  45205. * The name of the behavior
  45206. */
  45207. get name(): string;
  45208. /**
  45209. * Initializes the behavior
  45210. */
  45211. init(): void;
  45212. private _tmpVector;
  45213. private _alternatePickedPoint;
  45214. private _worldDragAxis;
  45215. private _targetPosition;
  45216. private _attachedElement;
  45217. /**
  45218. * Attaches the drag behavior the passed in mesh
  45219. * @param ownerNode The mesh that will be dragged around once attached
  45220. * @param predicate Predicate to use for pick filtering
  45221. */
  45222. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45223. /**
  45224. * Force relase the drag action by code.
  45225. */
  45226. releaseDrag(): void;
  45227. private _startDragRay;
  45228. private _lastPointerRay;
  45229. /**
  45230. * Simulates the start of a pointer drag event on the behavior
  45231. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45232. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45233. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45234. */
  45235. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45236. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45237. private _dragDelta;
  45238. protected _moveDrag(ray: Ray): void;
  45239. private _pickWithRayOnDragPlane;
  45240. private _pointA;
  45241. private _pointC;
  45242. private _localAxis;
  45243. private _lookAt;
  45244. private _updateDragPlanePosition;
  45245. /**
  45246. * Detaches the behavior from the mesh
  45247. */
  45248. detach(): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45252. import { Mesh } from "babylonjs/Meshes/mesh";
  45253. import { Behavior } from "babylonjs/Behaviors/behavior";
  45254. /**
  45255. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45256. */
  45257. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45258. private _dragBehaviorA;
  45259. private _dragBehaviorB;
  45260. private _startDistance;
  45261. private _initialScale;
  45262. private _targetScale;
  45263. private _ownerNode;
  45264. private _sceneRenderObserver;
  45265. /**
  45266. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45267. */
  45268. constructor();
  45269. /**
  45270. * The name of the behavior
  45271. */
  45272. get name(): string;
  45273. /**
  45274. * Initializes the behavior
  45275. */
  45276. init(): void;
  45277. private _getCurrentDistance;
  45278. /**
  45279. * Attaches the scale behavior the passed in mesh
  45280. * @param ownerNode The mesh that will be scaled around once attached
  45281. */
  45282. attach(ownerNode: Mesh): void;
  45283. /**
  45284. * Detaches the behavior from the mesh
  45285. */
  45286. detach(): void;
  45287. }
  45288. }
  45289. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45290. import { Behavior } from "babylonjs/Behaviors/behavior";
  45291. import { Mesh } from "babylonjs/Meshes/mesh";
  45292. import { Observable } from "babylonjs/Misc/observable";
  45293. /**
  45294. * 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
  45295. */
  45296. export class SixDofDragBehavior implements Behavior<Mesh> {
  45297. private static _virtualScene;
  45298. private _ownerNode;
  45299. private _sceneRenderObserver;
  45300. private _scene;
  45301. private _targetPosition;
  45302. private _virtualOriginMesh;
  45303. private _virtualDragMesh;
  45304. private _pointerObserver;
  45305. private _moving;
  45306. private _startingOrientation;
  45307. private _attachedElement;
  45308. /**
  45309. * 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)
  45310. */
  45311. private zDragFactor;
  45312. /**
  45313. * If the object should rotate to face the drag origin
  45314. */
  45315. rotateDraggedObject: boolean;
  45316. /**
  45317. * If the behavior is currently in a dragging state
  45318. */
  45319. dragging: boolean;
  45320. /**
  45321. * 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)
  45322. */
  45323. dragDeltaRatio: number;
  45324. /**
  45325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45326. */
  45327. currentDraggingPointerID: number;
  45328. /**
  45329. * If camera controls should be detached during the drag
  45330. */
  45331. detachCameraControls: boolean;
  45332. /**
  45333. * Fires each time a drag starts
  45334. */
  45335. onDragStartObservable: Observable<{}>;
  45336. /**
  45337. * Fires each time a drag ends (eg. mouse release after drag)
  45338. */
  45339. onDragEndObservable: Observable<{}>;
  45340. /**
  45341. * 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
  45342. */
  45343. constructor();
  45344. /**
  45345. * The name of the behavior
  45346. */
  45347. get name(): string;
  45348. /**
  45349. * Initializes the behavior
  45350. */
  45351. init(): void;
  45352. /**
  45353. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45354. */
  45355. private get _pointerCamera();
  45356. /**
  45357. * Attaches the scale behavior the passed in mesh
  45358. * @param ownerNode The mesh that will be scaled around once attached
  45359. */
  45360. attach(ownerNode: Mesh): void;
  45361. /**
  45362. * Detaches the behavior from the mesh
  45363. */
  45364. detach(): void;
  45365. }
  45366. }
  45367. declare module "babylonjs/Behaviors/Meshes/index" {
  45368. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45369. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45370. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45371. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45372. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45373. }
  45374. declare module "babylonjs/Behaviors/index" {
  45375. export * from "babylonjs/Behaviors/behavior";
  45376. export * from "babylonjs/Behaviors/Cameras/index";
  45377. export * from "babylonjs/Behaviors/Meshes/index";
  45378. }
  45379. declare module "babylonjs/Bones/boneIKController" {
  45380. import { Bone } from "babylonjs/Bones/bone";
  45381. import { Vector3 } from "babylonjs/Maths/math.vector";
  45382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45383. import { Nullable } from "babylonjs/types";
  45384. /**
  45385. * Class used to apply inverse kinematics to bones
  45386. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45387. */
  45388. export class BoneIKController {
  45389. private static _tmpVecs;
  45390. private static _tmpQuat;
  45391. private static _tmpMats;
  45392. /**
  45393. * Gets or sets the target mesh
  45394. */
  45395. targetMesh: AbstractMesh;
  45396. /** Gets or sets the mesh used as pole */
  45397. poleTargetMesh: AbstractMesh;
  45398. /**
  45399. * Gets or sets the bone used as pole
  45400. */
  45401. poleTargetBone: Nullable<Bone>;
  45402. /**
  45403. * Gets or sets the target position
  45404. */
  45405. targetPosition: Vector3;
  45406. /**
  45407. * Gets or sets the pole target position
  45408. */
  45409. poleTargetPosition: Vector3;
  45410. /**
  45411. * Gets or sets the pole target local offset
  45412. */
  45413. poleTargetLocalOffset: Vector3;
  45414. /**
  45415. * Gets or sets the pole angle
  45416. */
  45417. poleAngle: number;
  45418. /**
  45419. * Gets or sets the mesh associated with the controller
  45420. */
  45421. mesh: AbstractMesh;
  45422. /**
  45423. * 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)
  45424. */
  45425. slerpAmount: number;
  45426. private _bone1Quat;
  45427. private _bone1Mat;
  45428. private _bone2Ang;
  45429. private _bone1;
  45430. private _bone2;
  45431. private _bone1Length;
  45432. private _bone2Length;
  45433. private _maxAngle;
  45434. private _maxReach;
  45435. private _rightHandedSystem;
  45436. private _bendAxis;
  45437. private _slerping;
  45438. private _adjustRoll;
  45439. /**
  45440. * Gets or sets maximum allowed angle
  45441. */
  45442. get maxAngle(): number;
  45443. set maxAngle(value: number);
  45444. /**
  45445. * Creates a new BoneIKController
  45446. * @param mesh defines the mesh to control
  45447. * @param bone defines the bone to control
  45448. * @param options defines options to set up the controller
  45449. */
  45450. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45451. targetMesh?: AbstractMesh;
  45452. poleTargetMesh?: AbstractMesh;
  45453. poleTargetBone?: Bone;
  45454. poleTargetLocalOffset?: Vector3;
  45455. poleAngle?: number;
  45456. bendAxis?: Vector3;
  45457. maxAngle?: number;
  45458. slerpAmount?: number;
  45459. });
  45460. private _setMaxAngle;
  45461. /**
  45462. * Force the controller to update the bones
  45463. */
  45464. update(): void;
  45465. }
  45466. }
  45467. declare module "babylonjs/Bones/boneLookController" {
  45468. import { Vector3 } from "babylonjs/Maths/math.vector";
  45469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45470. import { Bone } from "babylonjs/Bones/bone";
  45471. import { Space } from "babylonjs/Maths/math.axis";
  45472. /**
  45473. * Class used to make a bone look toward a point in space
  45474. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45475. */
  45476. export class BoneLookController {
  45477. private static _tmpVecs;
  45478. private static _tmpQuat;
  45479. private static _tmpMats;
  45480. /**
  45481. * The target Vector3 that the bone will look at
  45482. */
  45483. target: Vector3;
  45484. /**
  45485. * The mesh that the bone is attached to
  45486. */
  45487. mesh: AbstractMesh;
  45488. /**
  45489. * The bone that will be looking to the target
  45490. */
  45491. bone: Bone;
  45492. /**
  45493. * The up axis of the coordinate system that is used when the bone is rotated
  45494. */
  45495. upAxis: Vector3;
  45496. /**
  45497. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45498. */
  45499. upAxisSpace: Space;
  45500. /**
  45501. * Used to make an adjustment to the yaw of the bone
  45502. */
  45503. adjustYaw: number;
  45504. /**
  45505. * Used to make an adjustment to the pitch of the bone
  45506. */
  45507. adjustPitch: number;
  45508. /**
  45509. * Used to make an adjustment to the roll of the bone
  45510. */
  45511. adjustRoll: number;
  45512. /**
  45513. * 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)
  45514. */
  45515. slerpAmount: number;
  45516. private _minYaw;
  45517. private _maxYaw;
  45518. private _minPitch;
  45519. private _maxPitch;
  45520. private _minYawSin;
  45521. private _minYawCos;
  45522. private _maxYawSin;
  45523. private _maxYawCos;
  45524. private _midYawConstraint;
  45525. private _minPitchTan;
  45526. private _maxPitchTan;
  45527. private _boneQuat;
  45528. private _slerping;
  45529. private _transformYawPitch;
  45530. private _transformYawPitchInv;
  45531. private _firstFrameSkipped;
  45532. private _yawRange;
  45533. private _fowardAxis;
  45534. /**
  45535. * Gets or sets the minimum yaw angle that the bone can look to
  45536. */
  45537. get minYaw(): number;
  45538. set minYaw(value: number);
  45539. /**
  45540. * Gets or sets the maximum yaw angle that the bone can look to
  45541. */
  45542. get maxYaw(): number;
  45543. set maxYaw(value: number);
  45544. /**
  45545. * Gets or sets the minimum pitch angle that the bone can look to
  45546. */
  45547. get minPitch(): number;
  45548. set minPitch(value: number);
  45549. /**
  45550. * Gets or sets the maximum pitch angle that the bone can look to
  45551. */
  45552. get maxPitch(): number;
  45553. set maxPitch(value: number);
  45554. /**
  45555. * Create a BoneLookController
  45556. * @param mesh the mesh that the bone belongs to
  45557. * @param bone the bone that will be looking to the target
  45558. * @param target the target Vector3 to look at
  45559. * @param options optional settings:
  45560. * * maxYaw: the maximum angle the bone will yaw to
  45561. * * minYaw: the minimum angle the bone will yaw to
  45562. * * maxPitch: the maximum angle the bone will pitch to
  45563. * * minPitch: the minimum angle the bone will yaw to
  45564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45565. * * upAxis: the up axis of the coordinate system
  45566. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45571. * * adjustRoll: used to make an adjustment to the roll of the bone
  45572. **/
  45573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45574. maxYaw?: number;
  45575. minYaw?: number;
  45576. maxPitch?: number;
  45577. minPitch?: number;
  45578. slerpAmount?: number;
  45579. upAxis?: Vector3;
  45580. upAxisSpace?: Space;
  45581. yawAxis?: Vector3;
  45582. pitchAxis?: Vector3;
  45583. adjustYaw?: number;
  45584. adjustPitch?: number;
  45585. adjustRoll?: number;
  45586. });
  45587. /**
  45588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45589. */
  45590. update(): void;
  45591. private _getAngleDiff;
  45592. private _getAngleBetween;
  45593. private _isAngleBetween;
  45594. }
  45595. }
  45596. declare module "babylonjs/Bones/index" {
  45597. export * from "babylonjs/Bones/bone";
  45598. export * from "babylonjs/Bones/boneIKController";
  45599. export * from "babylonjs/Bones/boneLookController";
  45600. export * from "babylonjs/Bones/skeleton";
  45601. }
  45602. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45603. import { Nullable } from "babylonjs/types";
  45604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45607. /**
  45608. * Manage the gamepad inputs to control an arc rotate camera.
  45609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45610. */
  45611. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45612. /**
  45613. * Defines the camera the input is attached to.
  45614. */
  45615. camera: ArcRotateCamera;
  45616. /**
  45617. * Defines the gamepad the input is gathering event from.
  45618. */
  45619. gamepad: Nullable<Gamepad>;
  45620. /**
  45621. * Defines the gamepad rotation sensiblity.
  45622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45623. */
  45624. gamepadRotationSensibility: number;
  45625. /**
  45626. * Defines the gamepad move sensiblity.
  45627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45628. */
  45629. gamepadMoveSensibility: number;
  45630. private _yAxisScale;
  45631. /**
  45632. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45633. */
  45634. get invertYAxis(): boolean;
  45635. set invertYAxis(value: boolean);
  45636. private _onGamepadConnectedObserver;
  45637. private _onGamepadDisconnectedObserver;
  45638. /**
  45639. * Attach the input controls to a specific dom element to get the input from.
  45640. * @param element Defines the element the controls should be listened from
  45641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45642. */
  45643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45644. /**
  45645. * Detach the current controls from the specified dom element.
  45646. * @param element Defines the element to stop listening the inputs from
  45647. */
  45648. detachControl(element: Nullable<HTMLElement>): void;
  45649. /**
  45650. * Update the current camera state depending on the inputs that have been used this frame.
  45651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45652. */
  45653. checkInputs(): void;
  45654. /**
  45655. * Gets the class name of the current intput.
  45656. * @returns the class name
  45657. */
  45658. getClassName(): string;
  45659. /**
  45660. * Get the friendly name associated with the input class.
  45661. * @returns the input friendly name
  45662. */
  45663. getSimpleName(): string;
  45664. }
  45665. }
  45666. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45667. import { Nullable } from "babylonjs/types";
  45668. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45669. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45670. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45671. interface ArcRotateCameraInputsManager {
  45672. /**
  45673. * Add orientation input support to the input manager.
  45674. * @returns the current input manager
  45675. */
  45676. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45677. }
  45678. }
  45679. /**
  45680. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45681. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45682. */
  45683. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45684. /**
  45685. * Defines the camera the input is attached to.
  45686. */
  45687. camera: ArcRotateCamera;
  45688. /**
  45689. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45690. */
  45691. alphaCorrection: number;
  45692. /**
  45693. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45694. */
  45695. gammaCorrection: number;
  45696. private _alpha;
  45697. private _gamma;
  45698. private _dirty;
  45699. private _deviceOrientationHandler;
  45700. /**
  45701. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45702. */
  45703. constructor();
  45704. /**
  45705. * Attach the input controls to a specific dom element to get the input from.
  45706. * @param element Defines the element the controls should be listened from
  45707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45708. */
  45709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45710. /** @hidden */
  45711. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45712. /**
  45713. * Update the current camera state depending on the inputs that have been used this frame.
  45714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45715. */
  45716. checkInputs(): void;
  45717. /**
  45718. * Detach the current controls from the specified dom element.
  45719. * @param element Defines the element to stop listening the inputs from
  45720. */
  45721. detachControl(element: Nullable<HTMLElement>): void;
  45722. /**
  45723. * Gets the class name of the current intput.
  45724. * @returns the class name
  45725. */
  45726. getClassName(): string;
  45727. /**
  45728. * Get the friendly name associated with the input class.
  45729. * @returns the input friendly name
  45730. */
  45731. getSimpleName(): string;
  45732. }
  45733. }
  45734. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45735. import { Nullable } from "babylonjs/types";
  45736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45737. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45738. /**
  45739. * Listen to mouse events to control the camera.
  45740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45741. */
  45742. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45743. /**
  45744. * Defines the camera the input is attached to.
  45745. */
  45746. camera: FlyCamera;
  45747. /**
  45748. * Defines if touch is enabled. (Default is true.)
  45749. */
  45750. touchEnabled: boolean;
  45751. /**
  45752. * Defines the buttons associated with the input to handle camera rotation.
  45753. */
  45754. buttons: number[];
  45755. /**
  45756. * Assign buttons for Yaw control.
  45757. */
  45758. buttonsYaw: number[];
  45759. /**
  45760. * Assign buttons for Pitch control.
  45761. */
  45762. buttonsPitch: number[];
  45763. /**
  45764. * Assign buttons for Roll control.
  45765. */
  45766. buttonsRoll: number[];
  45767. /**
  45768. * Detect if any button is being pressed while mouse is moved.
  45769. * -1 = Mouse locked.
  45770. * 0 = Left button.
  45771. * 1 = Middle Button.
  45772. * 2 = Right Button.
  45773. */
  45774. activeButton: number;
  45775. /**
  45776. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45777. * Higher values reduce its sensitivity.
  45778. */
  45779. angularSensibility: number;
  45780. private _mousemoveCallback;
  45781. private _observer;
  45782. private _rollObserver;
  45783. private previousPosition;
  45784. private noPreventDefault;
  45785. private element;
  45786. /**
  45787. * Listen to mouse events to control the camera.
  45788. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45790. */
  45791. constructor(touchEnabled?: boolean);
  45792. /**
  45793. * Attach the mouse control to the HTML DOM element.
  45794. * @param element Defines the element that listens to the input events.
  45795. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45796. */
  45797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45798. /**
  45799. * Detach the current controls from the specified dom element.
  45800. * @param element Defines the element to stop listening the inputs from
  45801. */
  45802. detachControl(element: Nullable<HTMLElement>): void;
  45803. /**
  45804. * Gets the class name of the current input.
  45805. * @returns the class name.
  45806. */
  45807. getClassName(): string;
  45808. /**
  45809. * Get the friendly name associated with the input class.
  45810. * @returns the input's friendly name.
  45811. */
  45812. getSimpleName(): string;
  45813. private _pointerInput;
  45814. private _onMouseMove;
  45815. /**
  45816. * Rotate camera by mouse offset.
  45817. */
  45818. private rotateCamera;
  45819. }
  45820. }
  45821. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45822. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45824. /**
  45825. * Default Inputs manager for the FlyCamera.
  45826. * It groups all the default supported inputs for ease of use.
  45827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45828. */
  45829. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45830. /**
  45831. * Instantiates a new FlyCameraInputsManager.
  45832. * @param camera Defines the camera the inputs belong to.
  45833. */
  45834. constructor(camera: FlyCamera);
  45835. /**
  45836. * Add keyboard input support to the input manager.
  45837. * @returns the new FlyCameraKeyboardMoveInput().
  45838. */
  45839. addKeyboard(): FlyCameraInputsManager;
  45840. /**
  45841. * Add mouse input support to the input manager.
  45842. * @param touchEnabled Enable touch screen support.
  45843. * @returns the new FlyCameraMouseInput().
  45844. */
  45845. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45846. }
  45847. }
  45848. declare module "babylonjs/Cameras/flyCamera" {
  45849. import { Scene } from "babylonjs/scene";
  45850. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45852. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45853. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45854. /**
  45855. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45856. * such as in a 3D Space Shooter or a Flight Simulator.
  45857. */
  45858. export class FlyCamera extends TargetCamera {
  45859. /**
  45860. * Define the collision ellipsoid of the camera.
  45861. * This is helpful for simulating a camera body, like a player's body.
  45862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45863. */
  45864. ellipsoid: Vector3;
  45865. /**
  45866. * Define an offset for the position of the ellipsoid around the camera.
  45867. * This can be helpful if the camera is attached away from the player's body center,
  45868. * such as at its head.
  45869. */
  45870. ellipsoidOffset: Vector3;
  45871. /**
  45872. * Enable or disable collisions of the camera with the rest of the scene objects.
  45873. */
  45874. checkCollisions: boolean;
  45875. /**
  45876. * Enable or disable gravity on the camera.
  45877. */
  45878. applyGravity: boolean;
  45879. /**
  45880. * Define the current direction the camera is moving to.
  45881. */
  45882. cameraDirection: Vector3;
  45883. /**
  45884. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45885. * This overrides and empties cameraRotation.
  45886. */
  45887. rotationQuaternion: Quaternion;
  45888. /**
  45889. * Track Roll to maintain the wanted Rolling when looking around.
  45890. */
  45891. _trackRoll: number;
  45892. /**
  45893. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45894. */
  45895. rollCorrect: number;
  45896. /**
  45897. * Mimic a banked turn, Rolling the camera when Yawing.
  45898. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45899. */
  45900. bankedTurn: boolean;
  45901. /**
  45902. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45903. */
  45904. bankedTurnLimit: number;
  45905. /**
  45906. * Value of 0 disables the banked Roll.
  45907. * Value of 1 is equal to the Yaw angle in radians.
  45908. */
  45909. bankedTurnMultiplier: number;
  45910. /**
  45911. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45912. */
  45913. inputs: FlyCameraInputsManager;
  45914. /**
  45915. * Gets the input sensibility for mouse input.
  45916. * Higher values reduce sensitivity.
  45917. */
  45918. get angularSensibility(): number;
  45919. /**
  45920. * Sets the input sensibility for a mouse input.
  45921. * Higher values reduce sensitivity.
  45922. */
  45923. set angularSensibility(value: number);
  45924. /**
  45925. * Get the keys for camera movement forward.
  45926. */
  45927. get keysForward(): number[];
  45928. /**
  45929. * Set the keys for camera movement forward.
  45930. */
  45931. set keysForward(value: number[]);
  45932. /**
  45933. * Get the keys for camera movement backward.
  45934. */
  45935. get keysBackward(): number[];
  45936. set keysBackward(value: number[]);
  45937. /**
  45938. * Get the keys for camera movement up.
  45939. */
  45940. get keysUp(): number[];
  45941. /**
  45942. * Set the keys for camera movement up.
  45943. */
  45944. set keysUp(value: number[]);
  45945. /**
  45946. * Get the keys for camera movement down.
  45947. */
  45948. get keysDown(): number[];
  45949. /**
  45950. * Set the keys for camera movement down.
  45951. */
  45952. set keysDown(value: number[]);
  45953. /**
  45954. * Get the keys for camera movement left.
  45955. */
  45956. get keysLeft(): number[];
  45957. /**
  45958. * Set the keys for camera movement left.
  45959. */
  45960. set keysLeft(value: number[]);
  45961. /**
  45962. * Set the keys for camera movement right.
  45963. */
  45964. get keysRight(): number[];
  45965. /**
  45966. * Set the keys for camera movement right.
  45967. */
  45968. set keysRight(value: number[]);
  45969. /**
  45970. * Event raised when the camera collides with a mesh in the scene.
  45971. */
  45972. onCollide: (collidedMesh: AbstractMesh) => void;
  45973. private _collider;
  45974. private _needMoveForGravity;
  45975. private _oldPosition;
  45976. private _diffPosition;
  45977. private _newPosition;
  45978. /** @hidden */
  45979. _localDirection: Vector3;
  45980. /** @hidden */
  45981. _transformedDirection: Vector3;
  45982. /**
  45983. * Instantiates a FlyCamera.
  45984. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45985. * such as in a 3D Space Shooter or a Flight Simulator.
  45986. * @param name Define the name of the camera in the scene.
  45987. * @param position Define the starting position of the camera in the scene.
  45988. * @param scene Define the scene the camera belongs to.
  45989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45990. */
  45991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45992. /**
  45993. * Attach a control to the HTML DOM element.
  45994. * @param element Defines the element that listens to the input events.
  45995. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45996. */
  45997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45998. /**
  45999. * Detach a control from the HTML DOM element.
  46000. * The camera will stop reacting to that input.
  46001. * @param element Defines the element that listens to the input events.
  46002. */
  46003. detachControl(element: HTMLElement): void;
  46004. private _collisionMask;
  46005. /**
  46006. * Get the mask that the camera ignores in collision events.
  46007. */
  46008. get collisionMask(): number;
  46009. /**
  46010. * Set the mask that the camera ignores in collision events.
  46011. */
  46012. set collisionMask(mask: number);
  46013. /** @hidden */
  46014. _collideWithWorld(displacement: Vector3): void;
  46015. /** @hidden */
  46016. private _onCollisionPositionChange;
  46017. /** @hidden */
  46018. _checkInputs(): void;
  46019. /** @hidden */
  46020. _decideIfNeedsToMove(): boolean;
  46021. /** @hidden */
  46022. _updatePosition(): void;
  46023. /**
  46024. * Restore the Roll to its target value at the rate specified.
  46025. * @param rate - Higher means slower restoring.
  46026. * @hidden
  46027. */
  46028. restoreRoll(rate: number): void;
  46029. /**
  46030. * Destroy the camera and release the current resources held by it.
  46031. */
  46032. dispose(): void;
  46033. /**
  46034. * Get the current object class name.
  46035. * @returns the class name.
  46036. */
  46037. getClassName(): string;
  46038. }
  46039. }
  46040. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46041. import { Nullable } from "babylonjs/types";
  46042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46043. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46044. /**
  46045. * Listen to keyboard events to control the camera.
  46046. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46047. */
  46048. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46049. /**
  46050. * Defines the camera the input is attached to.
  46051. */
  46052. camera: FlyCamera;
  46053. /**
  46054. * The list of keyboard keys used to control the forward move of the camera.
  46055. */
  46056. keysForward: number[];
  46057. /**
  46058. * The list of keyboard keys used to control the backward move of the camera.
  46059. */
  46060. keysBackward: number[];
  46061. /**
  46062. * The list of keyboard keys used to control the forward move of the camera.
  46063. */
  46064. keysUp: number[];
  46065. /**
  46066. * The list of keyboard keys used to control the backward move of the camera.
  46067. */
  46068. keysDown: number[];
  46069. /**
  46070. * The list of keyboard keys used to control the right strafe move of the camera.
  46071. */
  46072. keysRight: number[];
  46073. /**
  46074. * The list of keyboard keys used to control the left strafe move of the camera.
  46075. */
  46076. keysLeft: number[];
  46077. private _keys;
  46078. private _onCanvasBlurObserver;
  46079. private _onKeyboardObserver;
  46080. private _engine;
  46081. private _scene;
  46082. /**
  46083. * Attach the input controls to a specific dom element to get the input from.
  46084. * @param element Defines the element the controls should be listened from
  46085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46086. */
  46087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46088. /**
  46089. * Detach the current controls from the specified dom element.
  46090. * @param element Defines the element to stop listening the inputs from
  46091. */
  46092. detachControl(element: Nullable<HTMLElement>): void;
  46093. /**
  46094. * Gets the class name of the current intput.
  46095. * @returns the class name
  46096. */
  46097. getClassName(): string;
  46098. /** @hidden */
  46099. _onLostFocus(e: FocusEvent): void;
  46100. /**
  46101. * Get the friendly name associated with the input class.
  46102. * @returns the input friendly name
  46103. */
  46104. getSimpleName(): string;
  46105. /**
  46106. * Update the current camera state depending on the inputs that have been used this frame.
  46107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46108. */
  46109. checkInputs(): void;
  46110. }
  46111. }
  46112. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46113. import { Nullable } from "babylonjs/types";
  46114. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46116. /**
  46117. * Manage the mouse wheel inputs to control a follow camera.
  46118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46119. */
  46120. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46121. /**
  46122. * Defines the camera the input is attached to.
  46123. */
  46124. camera: FollowCamera;
  46125. /**
  46126. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46127. */
  46128. axisControlRadius: boolean;
  46129. /**
  46130. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46131. */
  46132. axisControlHeight: boolean;
  46133. /**
  46134. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46135. */
  46136. axisControlRotation: boolean;
  46137. /**
  46138. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46139. * relation to mouseWheel events.
  46140. */
  46141. wheelPrecision: number;
  46142. /**
  46143. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46144. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46145. */
  46146. wheelDeltaPercentage: number;
  46147. private _wheel;
  46148. private _observer;
  46149. /**
  46150. * Attach the input controls to a specific dom element to get the input from.
  46151. * @param element Defines the element the controls should be listened from
  46152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46153. */
  46154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46155. /**
  46156. * Detach the current controls from the specified dom element.
  46157. * @param element Defines the element to stop listening the inputs from
  46158. */
  46159. detachControl(element: Nullable<HTMLElement>): void;
  46160. /**
  46161. * Gets the class name of the current intput.
  46162. * @returns the class name
  46163. */
  46164. getClassName(): string;
  46165. /**
  46166. * Get the friendly name associated with the input class.
  46167. * @returns the input friendly name
  46168. */
  46169. getSimpleName(): string;
  46170. }
  46171. }
  46172. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46173. import { Nullable } from "babylonjs/types";
  46174. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46175. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46176. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46177. /**
  46178. * Manage the pointers inputs to control an follow camera.
  46179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46180. */
  46181. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46182. /**
  46183. * Defines the camera the input is attached to.
  46184. */
  46185. camera: FollowCamera;
  46186. /**
  46187. * Gets the class name of the current input.
  46188. * @returns the class name
  46189. */
  46190. getClassName(): string;
  46191. /**
  46192. * Defines the pointer angular sensibility along the X axis or how fast is
  46193. * the camera rotating.
  46194. * A negative number will reverse the axis direction.
  46195. */
  46196. angularSensibilityX: number;
  46197. /**
  46198. * Defines the pointer angular sensibility along the Y axis or how fast is
  46199. * the camera rotating.
  46200. * A negative number will reverse the axis direction.
  46201. */
  46202. angularSensibilityY: number;
  46203. /**
  46204. * Defines the pointer pinch precision or how fast is the camera zooming.
  46205. * A negative number will reverse the axis direction.
  46206. */
  46207. pinchPrecision: number;
  46208. /**
  46209. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46210. * from 0.
  46211. * It defines the percentage of current camera.radius to use as delta when
  46212. * pinch zoom is used.
  46213. */
  46214. pinchDeltaPercentage: number;
  46215. /**
  46216. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46217. */
  46218. axisXControlRadius: boolean;
  46219. /**
  46220. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46221. */
  46222. axisXControlHeight: boolean;
  46223. /**
  46224. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46225. */
  46226. axisXControlRotation: boolean;
  46227. /**
  46228. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46229. */
  46230. axisYControlRadius: boolean;
  46231. /**
  46232. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46233. */
  46234. axisYControlHeight: boolean;
  46235. /**
  46236. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46237. */
  46238. axisYControlRotation: boolean;
  46239. /**
  46240. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46241. */
  46242. axisPinchControlRadius: boolean;
  46243. /**
  46244. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46245. */
  46246. axisPinchControlHeight: boolean;
  46247. /**
  46248. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46249. */
  46250. axisPinchControlRotation: boolean;
  46251. /**
  46252. * Log error messages if basic misconfiguration has occurred.
  46253. */
  46254. warningEnable: boolean;
  46255. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46256. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46257. private _warningCounter;
  46258. private _warning;
  46259. }
  46260. }
  46261. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46262. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46263. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46264. /**
  46265. * Default Inputs manager for the FollowCamera.
  46266. * It groups all the default supported inputs for ease of use.
  46267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46268. */
  46269. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46270. /**
  46271. * Instantiates a new FollowCameraInputsManager.
  46272. * @param camera Defines the camera the inputs belong to
  46273. */
  46274. constructor(camera: FollowCamera);
  46275. /**
  46276. * Add keyboard input support to the input manager.
  46277. * @returns the current input manager
  46278. */
  46279. addKeyboard(): FollowCameraInputsManager;
  46280. /**
  46281. * Add mouse wheel input support to the input manager.
  46282. * @returns the current input manager
  46283. */
  46284. addMouseWheel(): FollowCameraInputsManager;
  46285. /**
  46286. * Add pointers input support to the input manager.
  46287. * @returns the current input manager
  46288. */
  46289. addPointers(): FollowCameraInputsManager;
  46290. /**
  46291. * Add orientation input support to the input manager.
  46292. * @returns the current input manager
  46293. */
  46294. addVRDeviceOrientation(): FollowCameraInputsManager;
  46295. }
  46296. }
  46297. declare module "babylonjs/Cameras/followCamera" {
  46298. import { Nullable } from "babylonjs/types";
  46299. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46300. import { Scene } from "babylonjs/scene";
  46301. import { Vector3 } from "babylonjs/Maths/math.vector";
  46302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46303. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46304. /**
  46305. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46306. * an arc rotate version arcFollowCamera are available.
  46307. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46308. */
  46309. export class FollowCamera extends TargetCamera {
  46310. /**
  46311. * Distance the follow camera should follow an object at
  46312. */
  46313. radius: number;
  46314. /**
  46315. * Minimum allowed distance of the camera to the axis of rotation
  46316. * (The camera can not get closer).
  46317. * This can help limiting how the Camera is able to move in the scene.
  46318. */
  46319. lowerRadiusLimit: Nullable<number>;
  46320. /**
  46321. * Maximum allowed distance of the camera to the axis of rotation
  46322. * (The camera can not get further).
  46323. * This can help limiting how the Camera is able to move in the scene.
  46324. */
  46325. upperRadiusLimit: Nullable<number>;
  46326. /**
  46327. * Define a rotation offset between the camera and the object it follows
  46328. */
  46329. rotationOffset: number;
  46330. /**
  46331. * Minimum allowed angle to camera position relative to target object.
  46332. * This can help limiting how the Camera is able to move in the scene.
  46333. */
  46334. lowerRotationOffsetLimit: Nullable<number>;
  46335. /**
  46336. * Maximum allowed angle to camera position relative to target object.
  46337. * This can help limiting how the Camera is able to move in the scene.
  46338. */
  46339. upperRotationOffsetLimit: Nullable<number>;
  46340. /**
  46341. * Define a height offset between the camera and the object it follows.
  46342. * It can help following an object from the top (like a car chaing a plane)
  46343. */
  46344. heightOffset: number;
  46345. /**
  46346. * Minimum allowed height of camera position relative to target object.
  46347. * This can help limiting how the Camera is able to move in the scene.
  46348. */
  46349. lowerHeightOffsetLimit: Nullable<number>;
  46350. /**
  46351. * Maximum allowed height of camera position relative to target object.
  46352. * This can help limiting how the Camera is able to move in the scene.
  46353. */
  46354. upperHeightOffsetLimit: Nullable<number>;
  46355. /**
  46356. * Define how fast the camera can accelerate to follow it s target.
  46357. */
  46358. cameraAcceleration: number;
  46359. /**
  46360. * Define the speed limit of the camera following an object.
  46361. */
  46362. maxCameraSpeed: number;
  46363. /**
  46364. * Define the target of the camera.
  46365. */
  46366. lockedTarget: Nullable<AbstractMesh>;
  46367. /**
  46368. * Defines the input associated with the camera.
  46369. */
  46370. inputs: FollowCameraInputsManager;
  46371. /**
  46372. * Instantiates the follow camera.
  46373. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46374. * @param name Define the name of the camera in the scene
  46375. * @param position Define the position of the camera
  46376. * @param scene Define the scene the camera belong to
  46377. * @param lockedTarget Define the target of the camera
  46378. */
  46379. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46380. private _follow;
  46381. /**
  46382. * Attached controls to the current camera.
  46383. * @param element Defines the element the controls should be listened from
  46384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46385. */
  46386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46387. /**
  46388. * Detach the current controls from the camera.
  46389. * The camera will stop reacting to inputs.
  46390. * @param element Defines the element to stop listening the inputs from
  46391. */
  46392. detachControl(element: HTMLElement): void;
  46393. /** @hidden */
  46394. _checkInputs(): void;
  46395. private _checkLimits;
  46396. /**
  46397. * Gets the camera class name.
  46398. * @returns the class name
  46399. */
  46400. getClassName(): string;
  46401. }
  46402. /**
  46403. * Arc Rotate version of the follow camera.
  46404. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46405. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46406. */
  46407. export class ArcFollowCamera extends TargetCamera {
  46408. /** The longitudinal angle of the camera */
  46409. alpha: number;
  46410. /** The latitudinal angle of the camera */
  46411. beta: number;
  46412. /** The radius of the camera from its target */
  46413. radius: number;
  46414. private _cartesianCoordinates;
  46415. /** Define the camera target (the mesh it should follow) */
  46416. private _meshTarget;
  46417. /**
  46418. * Instantiates a new ArcFollowCamera
  46419. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46420. * @param name Define the name of the camera
  46421. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46422. * @param beta Define the rotation angle of the camera around the elevation axis
  46423. * @param radius Define the radius of the camera from its target point
  46424. * @param target Define the target of the camera
  46425. * @param scene Define the scene the camera belongs to
  46426. */
  46427. constructor(name: string,
  46428. /** The longitudinal angle of the camera */
  46429. alpha: number,
  46430. /** The latitudinal angle of the camera */
  46431. beta: number,
  46432. /** The radius of the camera from its target */
  46433. radius: number,
  46434. /** Define the camera target (the mesh it should follow) */
  46435. target: Nullable<AbstractMesh>, scene: Scene);
  46436. private _follow;
  46437. /** @hidden */
  46438. _checkInputs(): void;
  46439. /**
  46440. * Returns the class name of the object.
  46441. * It is mostly used internally for serialization purposes.
  46442. */
  46443. getClassName(): string;
  46444. }
  46445. }
  46446. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46448. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46449. import { Nullable } from "babylonjs/types";
  46450. /**
  46451. * Manage the keyboard inputs to control the movement of a follow camera.
  46452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46453. */
  46454. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46455. /**
  46456. * Defines the camera the input is attached to.
  46457. */
  46458. camera: FollowCamera;
  46459. /**
  46460. * Defines the list of key codes associated with the up action (increase heightOffset)
  46461. */
  46462. keysHeightOffsetIncr: number[];
  46463. /**
  46464. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46465. */
  46466. keysHeightOffsetDecr: number[];
  46467. /**
  46468. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46469. */
  46470. keysHeightOffsetModifierAlt: boolean;
  46471. /**
  46472. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46473. */
  46474. keysHeightOffsetModifierCtrl: boolean;
  46475. /**
  46476. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46477. */
  46478. keysHeightOffsetModifierShift: boolean;
  46479. /**
  46480. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46481. */
  46482. keysRotationOffsetIncr: number[];
  46483. /**
  46484. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46485. */
  46486. keysRotationOffsetDecr: number[];
  46487. /**
  46488. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46489. */
  46490. keysRotationOffsetModifierAlt: boolean;
  46491. /**
  46492. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46493. */
  46494. keysRotationOffsetModifierCtrl: boolean;
  46495. /**
  46496. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46497. */
  46498. keysRotationOffsetModifierShift: boolean;
  46499. /**
  46500. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46501. */
  46502. keysRadiusIncr: number[];
  46503. /**
  46504. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46505. */
  46506. keysRadiusDecr: number[];
  46507. /**
  46508. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46509. */
  46510. keysRadiusModifierAlt: boolean;
  46511. /**
  46512. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46513. */
  46514. keysRadiusModifierCtrl: boolean;
  46515. /**
  46516. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46517. */
  46518. keysRadiusModifierShift: boolean;
  46519. /**
  46520. * Defines the rate of change of heightOffset.
  46521. */
  46522. heightSensibility: number;
  46523. /**
  46524. * Defines the rate of change of rotationOffset.
  46525. */
  46526. rotationSensibility: number;
  46527. /**
  46528. * Defines the rate of change of radius.
  46529. */
  46530. radiusSensibility: number;
  46531. private _keys;
  46532. private _ctrlPressed;
  46533. private _altPressed;
  46534. private _shiftPressed;
  46535. private _onCanvasBlurObserver;
  46536. private _onKeyboardObserver;
  46537. private _engine;
  46538. private _scene;
  46539. /**
  46540. * Attach the input controls to a specific dom element to get the input from.
  46541. * @param element Defines the element the controls should be listened from
  46542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46543. */
  46544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46545. /**
  46546. * Detach the current controls from the specified dom element.
  46547. * @param element Defines the element to stop listening the inputs from
  46548. */
  46549. detachControl(element: Nullable<HTMLElement>): void;
  46550. /**
  46551. * Update the current camera state depending on the inputs that have been used this frame.
  46552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46553. */
  46554. checkInputs(): void;
  46555. /**
  46556. * Gets the class name of the current input.
  46557. * @returns the class name
  46558. */
  46559. getClassName(): string;
  46560. /**
  46561. * Get the friendly name associated with the input class.
  46562. * @returns the input friendly name
  46563. */
  46564. getSimpleName(): string;
  46565. /**
  46566. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46567. * allow modification of the heightOffset value.
  46568. */
  46569. private _modifierHeightOffset;
  46570. /**
  46571. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46572. * allow modification of the rotationOffset value.
  46573. */
  46574. private _modifierRotationOffset;
  46575. /**
  46576. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46577. * allow modification of the radius value.
  46578. */
  46579. private _modifierRadius;
  46580. }
  46581. }
  46582. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46583. import { Nullable } from "babylonjs/types";
  46584. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46585. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46586. import { Observable } from "babylonjs/Misc/observable";
  46587. module "babylonjs/Cameras/freeCameraInputsManager" {
  46588. interface FreeCameraInputsManager {
  46589. /**
  46590. * @hidden
  46591. */
  46592. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46593. /**
  46594. * Add orientation input support to the input manager.
  46595. * @returns the current input manager
  46596. */
  46597. addDeviceOrientation(): FreeCameraInputsManager;
  46598. }
  46599. }
  46600. /**
  46601. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46602. * Screen rotation is taken into account.
  46603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46604. */
  46605. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46606. private _camera;
  46607. private _screenOrientationAngle;
  46608. private _constantTranform;
  46609. private _screenQuaternion;
  46610. private _alpha;
  46611. private _beta;
  46612. private _gamma;
  46613. /**
  46614. * Can be used to detect if a device orientation sensor is available on a device
  46615. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46616. * @returns a promise that will resolve on orientation change
  46617. */
  46618. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46619. /**
  46620. * @hidden
  46621. */
  46622. _onDeviceOrientationChangedObservable: Observable<void>;
  46623. /**
  46624. * Instantiates a new input
  46625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46626. */
  46627. constructor();
  46628. /**
  46629. * Define the camera controlled by the input.
  46630. */
  46631. get camera(): FreeCamera;
  46632. set camera(camera: FreeCamera);
  46633. /**
  46634. * Attach the input controls to a specific dom element to get the input from.
  46635. * @param element Defines the element the controls should be listened from
  46636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46637. */
  46638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46639. private _orientationChanged;
  46640. private _deviceOrientation;
  46641. /**
  46642. * Detach the current controls from the specified dom element.
  46643. * @param element Defines the element to stop listening the inputs from
  46644. */
  46645. detachControl(element: Nullable<HTMLElement>): void;
  46646. /**
  46647. * Update the current camera state depending on the inputs that have been used this frame.
  46648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46649. */
  46650. checkInputs(): void;
  46651. /**
  46652. * Gets the class name of the current intput.
  46653. * @returns the class name
  46654. */
  46655. getClassName(): string;
  46656. /**
  46657. * Get the friendly name associated with the input class.
  46658. * @returns the input friendly name
  46659. */
  46660. getSimpleName(): string;
  46661. }
  46662. }
  46663. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46664. import { Nullable } from "babylonjs/types";
  46665. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46667. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46668. /**
  46669. * Manage the gamepad inputs to control a free camera.
  46670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46671. */
  46672. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46673. /**
  46674. * Define the camera the input is attached to.
  46675. */
  46676. camera: FreeCamera;
  46677. /**
  46678. * Define the Gamepad controlling the input
  46679. */
  46680. gamepad: Nullable<Gamepad>;
  46681. /**
  46682. * Defines the gamepad rotation sensiblity.
  46683. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46684. */
  46685. gamepadAngularSensibility: number;
  46686. /**
  46687. * Defines the gamepad move sensiblity.
  46688. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46689. */
  46690. gamepadMoveSensibility: number;
  46691. private _yAxisScale;
  46692. /**
  46693. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46694. */
  46695. get invertYAxis(): boolean;
  46696. set invertYAxis(value: boolean);
  46697. private _onGamepadConnectedObserver;
  46698. private _onGamepadDisconnectedObserver;
  46699. private _cameraTransform;
  46700. private _deltaTransform;
  46701. private _vector3;
  46702. private _vector2;
  46703. /**
  46704. * Attach the input controls to a specific dom element to get the input from.
  46705. * @param element Defines the element the controls should be listened from
  46706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46707. */
  46708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46709. /**
  46710. * Detach the current controls from the specified dom element.
  46711. * @param element Defines the element to stop listening the inputs from
  46712. */
  46713. detachControl(element: Nullable<HTMLElement>): void;
  46714. /**
  46715. * Update the current camera state depending on the inputs that have been used this frame.
  46716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46717. */
  46718. checkInputs(): void;
  46719. /**
  46720. * Gets the class name of the current intput.
  46721. * @returns the class name
  46722. */
  46723. getClassName(): string;
  46724. /**
  46725. * Get the friendly name associated with the input class.
  46726. * @returns the input friendly name
  46727. */
  46728. getSimpleName(): string;
  46729. }
  46730. }
  46731. declare module "babylonjs/Misc/virtualJoystick" {
  46732. import { Nullable } from "babylonjs/types";
  46733. import { Vector3 } from "babylonjs/Maths/math.vector";
  46734. /**
  46735. * Defines the potential axis of a Joystick
  46736. */
  46737. export enum JoystickAxis {
  46738. /** X axis */
  46739. X = 0,
  46740. /** Y axis */
  46741. Y = 1,
  46742. /** Z axis */
  46743. Z = 2
  46744. }
  46745. /**
  46746. * Represents the different customization options available
  46747. * for VirtualJoystick
  46748. */
  46749. interface VirtualJoystickCustomizations {
  46750. /**
  46751. * Size of the joystick's puck
  46752. */
  46753. puckSize: number;
  46754. /**
  46755. * Size of the joystick's container
  46756. */
  46757. containerSize: number;
  46758. /**
  46759. * Color of the joystick && puck
  46760. */
  46761. color: string;
  46762. /**
  46763. * Image URL for the joystick's puck
  46764. */
  46765. puckImage?: string;
  46766. /**
  46767. * Image URL for the joystick's container
  46768. */
  46769. containerImage?: string;
  46770. /**
  46771. * Defines the unmoving position of the joystick container
  46772. */
  46773. position?: {
  46774. x: number;
  46775. y: number;
  46776. };
  46777. /**
  46778. * Defines whether or not the joystick container is always visible
  46779. */
  46780. alwaysVisible: boolean;
  46781. /**
  46782. * Defines whether or not to limit the movement of the puck to the joystick's container
  46783. */
  46784. limitToContainer: boolean;
  46785. }
  46786. /**
  46787. * Class used to define virtual joystick (used in touch mode)
  46788. */
  46789. export class VirtualJoystick {
  46790. /**
  46791. * Gets or sets a boolean indicating that left and right values must be inverted
  46792. */
  46793. reverseLeftRight: boolean;
  46794. /**
  46795. * Gets or sets a boolean indicating that up and down values must be inverted
  46796. */
  46797. reverseUpDown: boolean;
  46798. /**
  46799. * Gets the offset value for the position (ie. the change of the position value)
  46800. */
  46801. deltaPosition: Vector3;
  46802. /**
  46803. * Gets a boolean indicating if the virtual joystick was pressed
  46804. */
  46805. pressed: boolean;
  46806. /**
  46807. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46808. */
  46809. static Canvas: Nullable<HTMLCanvasElement>;
  46810. /**
  46811. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46812. */
  46813. limitToContainer: boolean;
  46814. private static _globalJoystickIndex;
  46815. private static _alwaysVisibleSticks;
  46816. private static vjCanvasContext;
  46817. private static vjCanvasWidth;
  46818. private static vjCanvasHeight;
  46819. private static halfWidth;
  46820. private static _GetDefaultOptions;
  46821. private _action;
  46822. private _axisTargetedByLeftAndRight;
  46823. private _axisTargetedByUpAndDown;
  46824. private _joystickSensibility;
  46825. private _inversedSensibility;
  46826. private _joystickPointerID;
  46827. private _joystickColor;
  46828. private _joystickPointerPos;
  46829. private _joystickPreviousPointerPos;
  46830. private _joystickPointerStartPos;
  46831. private _deltaJoystickVector;
  46832. private _leftJoystick;
  46833. private _touches;
  46834. private _joystickPosition;
  46835. private _alwaysVisible;
  46836. private _puckImage;
  46837. private _containerImage;
  46838. private _joystickPuckSize;
  46839. private _joystickContainerSize;
  46840. private _clearPuckSize;
  46841. private _clearContainerSize;
  46842. private _clearPuckSizeOffset;
  46843. private _clearContainerSizeOffset;
  46844. private _onPointerDownHandlerRef;
  46845. private _onPointerMoveHandlerRef;
  46846. private _onPointerUpHandlerRef;
  46847. private _onResize;
  46848. /**
  46849. * Creates a new virtual joystick
  46850. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46851. * @param customizations Defines the options we want to customize the VirtualJoystick
  46852. */
  46853. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46854. /**
  46855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46856. * @param newJoystickSensibility defines the new sensibility
  46857. */
  46858. setJoystickSensibility(newJoystickSensibility: number): void;
  46859. private _onPointerDown;
  46860. private _onPointerMove;
  46861. private _onPointerUp;
  46862. /**
  46863. * Change the color of the virtual joystick
  46864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46865. */
  46866. setJoystickColor(newColor: string): void;
  46867. /**
  46868. * Size of the joystick's container
  46869. */
  46870. set containerSize(newSize: number);
  46871. get containerSize(): number;
  46872. /**
  46873. * Size of the joystick's puck
  46874. */
  46875. set puckSize(newSize: number);
  46876. get puckSize(): number;
  46877. /**
  46878. * Clears the set position of the joystick
  46879. */
  46880. clearPosition(): void;
  46881. /**
  46882. * Defines whether or not the joystick container is always visible
  46883. */
  46884. set alwaysVisible(value: boolean);
  46885. get alwaysVisible(): boolean;
  46886. /**
  46887. * Sets the constant position of the Joystick container
  46888. * @param x X axis coordinate
  46889. * @param y Y axis coordinate
  46890. */
  46891. setPosition(x: number, y: number): void;
  46892. /**
  46893. * Defines a callback to call when the joystick is touched
  46894. * @param action defines the callback
  46895. */
  46896. setActionOnTouch(action: () => any): void;
  46897. /**
  46898. * Defines which axis you'd like to control for left & right
  46899. * @param axis defines the axis to use
  46900. */
  46901. setAxisForLeftRight(axis: JoystickAxis): void;
  46902. /**
  46903. * Defines which axis you'd like to control for up & down
  46904. * @param axis defines the axis to use
  46905. */
  46906. setAxisForUpDown(axis: JoystickAxis): void;
  46907. /**
  46908. * Clears the canvas from the previous puck / container draw
  46909. */
  46910. private _clearPreviousDraw;
  46911. /**
  46912. * Loads `urlPath` to be used for the container's image
  46913. * @param urlPath defines the urlPath of an image to use
  46914. */
  46915. setContainerImage(urlPath: string): void;
  46916. /**
  46917. * Loads `urlPath` to be used for the puck's image
  46918. * @param urlPath defines the urlPath of an image to use
  46919. */
  46920. setPuckImage(urlPath: string): void;
  46921. /**
  46922. * Draws the Virtual Joystick's container
  46923. */
  46924. private _drawContainer;
  46925. /**
  46926. * Draws the Virtual Joystick's puck
  46927. */
  46928. private _drawPuck;
  46929. private _drawVirtualJoystick;
  46930. /**
  46931. * Release internal HTML canvas
  46932. */
  46933. releaseCanvas(): void;
  46934. }
  46935. }
  46936. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46937. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46938. import { Nullable } from "babylonjs/types";
  46939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46940. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46941. module "babylonjs/Cameras/freeCameraInputsManager" {
  46942. interface FreeCameraInputsManager {
  46943. /**
  46944. * Add virtual joystick input support to the input manager.
  46945. * @returns the current input manager
  46946. */
  46947. addVirtualJoystick(): FreeCameraInputsManager;
  46948. }
  46949. }
  46950. /**
  46951. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46952. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46953. */
  46954. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46955. /**
  46956. * Defines the camera the input is attached to.
  46957. */
  46958. camera: FreeCamera;
  46959. private _leftjoystick;
  46960. private _rightjoystick;
  46961. /**
  46962. * Gets the left stick of the virtual joystick.
  46963. * @returns The virtual Joystick
  46964. */
  46965. getLeftJoystick(): VirtualJoystick;
  46966. /**
  46967. * Gets the right stick of the virtual joystick.
  46968. * @returns The virtual Joystick
  46969. */
  46970. getRightJoystick(): VirtualJoystick;
  46971. /**
  46972. * Update the current camera state depending on the inputs that have been used this frame.
  46973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46974. */
  46975. checkInputs(): void;
  46976. /**
  46977. * Attach the input controls to a specific dom element to get the input from.
  46978. * @param element Defines the element the controls should be listened from
  46979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46980. */
  46981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46982. /**
  46983. * Detach the current controls from the specified dom element.
  46984. * @param element Defines the element to stop listening the inputs from
  46985. */
  46986. detachControl(element: Nullable<HTMLElement>): void;
  46987. /**
  46988. * Gets the class name of the current intput.
  46989. * @returns the class name
  46990. */
  46991. getClassName(): string;
  46992. /**
  46993. * Get the friendly name associated with the input class.
  46994. * @returns the input friendly name
  46995. */
  46996. getSimpleName(): string;
  46997. }
  46998. }
  46999. declare module "babylonjs/Cameras/Inputs/index" {
  47000. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47001. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47002. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47003. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47005. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47006. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47007. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47008. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47009. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47010. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47011. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47012. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47013. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47016. }
  47017. declare module "babylonjs/Cameras/touchCamera" {
  47018. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47019. import { Scene } from "babylonjs/scene";
  47020. import { Vector3 } from "babylonjs/Maths/math.vector";
  47021. /**
  47022. * This represents a FPS type of camera controlled by touch.
  47023. * This is like a universal camera minus the Gamepad controls.
  47024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47025. */
  47026. export class TouchCamera extends FreeCamera {
  47027. /**
  47028. * Defines the touch sensibility for rotation.
  47029. * The higher the faster.
  47030. */
  47031. get touchAngularSensibility(): number;
  47032. set touchAngularSensibility(value: number);
  47033. /**
  47034. * Defines the touch sensibility for move.
  47035. * The higher the faster.
  47036. */
  47037. get touchMoveSensibility(): number;
  47038. set touchMoveSensibility(value: number);
  47039. /**
  47040. * Instantiates a new touch camera.
  47041. * This represents a FPS type of camera controlled by touch.
  47042. * This is like a universal camera minus the Gamepad controls.
  47043. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47044. * @param name Define the name of the camera in the scene
  47045. * @param position Define the start position of the camera in the scene
  47046. * @param scene Define the scene the camera belongs to
  47047. */
  47048. constructor(name: string, position: Vector3, scene: Scene);
  47049. /**
  47050. * Gets the current object class name.
  47051. * @return the class name
  47052. */
  47053. getClassName(): string;
  47054. /** @hidden */
  47055. _setupInputs(): void;
  47056. }
  47057. }
  47058. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47059. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47060. import { Scene } from "babylonjs/scene";
  47061. import { Vector3 } from "babylonjs/Maths/math.vector";
  47062. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47063. import { Axis } from "babylonjs/Maths/math.axis";
  47064. /**
  47065. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47066. * being tilted forward or back and left or right.
  47067. */
  47068. export class DeviceOrientationCamera extends FreeCamera {
  47069. private _initialQuaternion;
  47070. private _quaternionCache;
  47071. private _tmpDragQuaternion;
  47072. private _disablePointerInputWhenUsingDeviceOrientation;
  47073. /**
  47074. * Creates a new device orientation camera
  47075. * @param name The name of the camera
  47076. * @param position The start position camera
  47077. * @param scene The scene the camera belongs to
  47078. */
  47079. constructor(name: string, position: Vector3, scene: Scene);
  47080. /**
  47081. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47082. */
  47083. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47084. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47085. private _dragFactor;
  47086. /**
  47087. * Enabled turning on the y axis when the orientation sensor is active
  47088. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47089. */
  47090. enableHorizontalDragging(dragFactor?: number): void;
  47091. /**
  47092. * Gets the current instance class name ("DeviceOrientationCamera").
  47093. * This helps avoiding instanceof at run time.
  47094. * @returns the class name
  47095. */
  47096. getClassName(): string;
  47097. /**
  47098. * @hidden
  47099. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47100. */
  47101. _checkInputs(): void;
  47102. /**
  47103. * Reset the camera to its default orientation on the specified axis only.
  47104. * @param axis The axis to reset
  47105. */
  47106. resetToCurrentRotation(axis?: Axis): void;
  47107. }
  47108. }
  47109. declare module "babylonjs/Gamepads/xboxGamepad" {
  47110. import { Observable } from "babylonjs/Misc/observable";
  47111. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47112. /**
  47113. * Defines supported buttons for XBox360 compatible gamepads
  47114. */
  47115. export enum Xbox360Button {
  47116. /** A */
  47117. A = 0,
  47118. /** B */
  47119. B = 1,
  47120. /** X */
  47121. X = 2,
  47122. /** Y */
  47123. Y = 3,
  47124. /** Left button */
  47125. LB = 4,
  47126. /** Right button */
  47127. RB = 5,
  47128. /** Back */
  47129. Back = 8,
  47130. /** Start */
  47131. Start = 9,
  47132. /** Left stick */
  47133. LeftStick = 10,
  47134. /** Right stick */
  47135. RightStick = 11
  47136. }
  47137. /** Defines values for XBox360 DPad */
  47138. export enum Xbox360Dpad {
  47139. /** Up */
  47140. Up = 12,
  47141. /** Down */
  47142. Down = 13,
  47143. /** Left */
  47144. Left = 14,
  47145. /** Right */
  47146. Right = 15
  47147. }
  47148. /**
  47149. * Defines a XBox360 gamepad
  47150. */
  47151. export class Xbox360Pad extends Gamepad {
  47152. private _leftTrigger;
  47153. private _rightTrigger;
  47154. private _onlefttriggerchanged;
  47155. private _onrighttriggerchanged;
  47156. private _onbuttondown;
  47157. private _onbuttonup;
  47158. private _ondpaddown;
  47159. private _ondpadup;
  47160. /** Observable raised when a button is pressed */
  47161. onButtonDownObservable: Observable<Xbox360Button>;
  47162. /** Observable raised when a button is released */
  47163. onButtonUpObservable: Observable<Xbox360Button>;
  47164. /** Observable raised when a pad is pressed */
  47165. onPadDownObservable: Observable<Xbox360Dpad>;
  47166. /** Observable raised when a pad is released */
  47167. onPadUpObservable: Observable<Xbox360Dpad>;
  47168. private _buttonA;
  47169. private _buttonB;
  47170. private _buttonX;
  47171. private _buttonY;
  47172. private _buttonBack;
  47173. private _buttonStart;
  47174. private _buttonLB;
  47175. private _buttonRB;
  47176. private _buttonLeftStick;
  47177. private _buttonRightStick;
  47178. private _dPadUp;
  47179. private _dPadDown;
  47180. private _dPadLeft;
  47181. private _dPadRight;
  47182. private _isXboxOnePad;
  47183. /**
  47184. * Creates a new XBox360 gamepad object
  47185. * @param id defines the id of this gamepad
  47186. * @param index defines its index
  47187. * @param gamepad defines the internal HTML gamepad object
  47188. * @param xboxOne defines if it is a XBox One gamepad
  47189. */
  47190. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47191. /**
  47192. * Defines the callback to call when left trigger is pressed
  47193. * @param callback defines the callback to use
  47194. */
  47195. onlefttriggerchanged(callback: (value: number) => void): void;
  47196. /**
  47197. * Defines the callback to call when right trigger is pressed
  47198. * @param callback defines the callback to use
  47199. */
  47200. onrighttriggerchanged(callback: (value: number) => void): void;
  47201. /**
  47202. * Gets the left trigger value
  47203. */
  47204. get leftTrigger(): number;
  47205. /**
  47206. * Sets the left trigger value
  47207. */
  47208. set leftTrigger(newValue: number);
  47209. /**
  47210. * Gets the right trigger value
  47211. */
  47212. get rightTrigger(): number;
  47213. /**
  47214. * Sets the right trigger value
  47215. */
  47216. set rightTrigger(newValue: number);
  47217. /**
  47218. * Defines the callback to call when a button is pressed
  47219. * @param callback defines the callback to use
  47220. */
  47221. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47222. /**
  47223. * Defines the callback to call when a button is released
  47224. * @param callback defines the callback to use
  47225. */
  47226. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47227. /**
  47228. * Defines the callback to call when a pad is pressed
  47229. * @param callback defines the callback to use
  47230. */
  47231. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47232. /**
  47233. * Defines the callback to call when a pad is released
  47234. * @param callback defines the callback to use
  47235. */
  47236. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47237. private _setButtonValue;
  47238. private _setDPadValue;
  47239. /**
  47240. * Gets the value of the `A` button
  47241. */
  47242. get buttonA(): number;
  47243. /**
  47244. * Sets the value of the `A` button
  47245. */
  47246. set buttonA(value: number);
  47247. /**
  47248. * Gets the value of the `B` button
  47249. */
  47250. get buttonB(): number;
  47251. /**
  47252. * Sets the value of the `B` button
  47253. */
  47254. set buttonB(value: number);
  47255. /**
  47256. * Gets the value of the `X` button
  47257. */
  47258. get buttonX(): number;
  47259. /**
  47260. * Sets the value of the `X` button
  47261. */
  47262. set buttonX(value: number);
  47263. /**
  47264. * Gets the value of the `Y` button
  47265. */
  47266. get buttonY(): number;
  47267. /**
  47268. * Sets the value of the `Y` button
  47269. */
  47270. set buttonY(value: number);
  47271. /**
  47272. * Gets the value of the `Start` button
  47273. */
  47274. get buttonStart(): number;
  47275. /**
  47276. * Sets the value of the `Start` button
  47277. */
  47278. set buttonStart(value: number);
  47279. /**
  47280. * Gets the value of the `Back` button
  47281. */
  47282. get buttonBack(): number;
  47283. /**
  47284. * Sets the value of the `Back` button
  47285. */
  47286. set buttonBack(value: number);
  47287. /**
  47288. * Gets the value of the `Left` button
  47289. */
  47290. get buttonLB(): number;
  47291. /**
  47292. * Sets the value of the `Left` button
  47293. */
  47294. set buttonLB(value: number);
  47295. /**
  47296. * Gets the value of the `Right` button
  47297. */
  47298. get buttonRB(): number;
  47299. /**
  47300. * Sets the value of the `Right` button
  47301. */
  47302. set buttonRB(value: number);
  47303. /**
  47304. * Gets the value of the Left joystick
  47305. */
  47306. get buttonLeftStick(): number;
  47307. /**
  47308. * Sets the value of the Left joystick
  47309. */
  47310. set buttonLeftStick(value: number);
  47311. /**
  47312. * Gets the value of the Right joystick
  47313. */
  47314. get buttonRightStick(): number;
  47315. /**
  47316. * Sets the value of the Right joystick
  47317. */
  47318. set buttonRightStick(value: number);
  47319. /**
  47320. * Gets the value of D-pad up
  47321. */
  47322. get dPadUp(): number;
  47323. /**
  47324. * Sets the value of D-pad up
  47325. */
  47326. set dPadUp(value: number);
  47327. /**
  47328. * Gets the value of D-pad down
  47329. */
  47330. get dPadDown(): number;
  47331. /**
  47332. * Sets the value of D-pad down
  47333. */
  47334. set dPadDown(value: number);
  47335. /**
  47336. * Gets the value of D-pad left
  47337. */
  47338. get dPadLeft(): number;
  47339. /**
  47340. * Sets the value of D-pad left
  47341. */
  47342. set dPadLeft(value: number);
  47343. /**
  47344. * Gets the value of D-pad right
  47345. */
  47346. get dPadRight(): number;
  47347. /**
  47348. * Sets the value of D-pad right
  47349. */
  47350. set dPadRight(value: number);
  47351. /**
  47352. * Force the gamepad to synchronize with device values
  47353. */
  47354. update(): void;
  47355. /**
  47356. * Disposes the gamepad
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47362. import { Observable } from "babylonjs/Misc/observable";
  47363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47364. /**
  47365. * Defines supported buttons for DualShock compatible gamepads
  47366. */
  47367. export enum DualShockButton {
  47368. /** Cross */
  47369. Cross = 0,
  47370. /** Circle */
  47371. Circle = 1,
  47372. /** Square */
  47373. Square = 2,
  47374. /** Triangle */
  47375. Triangle = 3,
  47376. /** L1 */
  47377. L1 = 4,
  47378. /** R1 */
  47379. R1 = 5,
  47380. /** Share */
  47381. Share = 8,
  47382. /** Options */
  47383. Options = 9,
  47384. /** Left stick */
  47385. LeftStick = 10,
  47386. /** Right stick */
  47387. RightStick = 11
  47388. }
  47389. /** Defines values for DualShock DPad */
  47390. export enum DualShockDpad {
  47391. /** Up */
  47392. Up = 12,
  47393. /** Down */
  47394. Down = 13,
  47395. /** Left */
  47396. Left = 14,
  47397. /** Right */
  47398. Right = 15
  47399. }
  47400. /**
  47401. * Defines a DualShock gamepad
  47402. */
  47403. export class DualShockPad extends Gamepad {
  47404. private _leftTrigger;
  47405. private _rightTrigger;
  47406. private _onlefttriggerchanged;
  47407. private _onrighttriggerchanged;
  47408. private _onbuttondown;
  47409. private _onbuttonup;
  47410. private _ondpaddown;
  47411. private _ondpadup;
  47412. /** Observable raised when a button is pressed */
  47413. onButtonDownObservable: Observable<DualShockButton>;
  47414. /** Observable raised when a button is released */
  47415. onButtonUpObservable: Observable<DualShockButton>;
  47416. /** Observable raised when a pad is pressed */
  47417. onPadDownObservable: Observable<DualShockDpad>;
  47418. /** Observable raised when a pad is released */
  47419. onPadUpObservable: Observable<DualShockDpad>;
  47420. private _buttonCross;
  47421. private _buttonCircle;
  47422. private _buttonSquare;
  47423. private _buttonTriangle;
  47424. private _buttonShare;
  47425. private _buttonOptions;
  47426. private _buttonL1;
  47427. private _buttonR1;
  47428. private _buttonLeftStick;
  47429. private _buttonRightStick;
  47430. private _dPadUp;
  47431. private _dPadDown;
  47432. private _dPadLeft;
  47433. private _dPadRight;
  47434. /**
  47435. * Creates a new DualShock gamepad object
  47436. * @param id defines the id of this gamepad
  47437. * @param index defines its index
  47438. * @param gamepad defines the internal HTML gamepad object
  47439. */
  47440. constructor(id: string, index: number, gamepad: any);
  47441. /**
  47442. * Defines the callback to call when left trigger is pressed
  47443. * @param callback defines the callback to use
  47444. */
  47445. onlefttriggerchanged(callback: (value: number) => void): void;
  47446. /**
  47447. * Defines the callback to call when right trigger is pressed
  47448. * @param callback defines the callback to use
  47449. */
  47450. onrighttriggerchanged(callback: (value: number) => void): void;
  47451. /**
  47452. * Gets the left trigger value
  47453. */
  47454. get leftTrigger(): number;
  47455. /**
  47456. * Sets the left trigger value
  47457. */
  47458. set leftTrigger(newValue: number);
  47459. /**
  47460. * Gets the right trigger value
  47461. */
  47462. get rightTrigger(): number;
  47463. /**
  47464. * Sets the right trigger value
  47465. */
  47466. set rightTrigger(newValue: number);
  47467. /**
  47468. * Defines the callback to call when a button is pressed
  47469. * @param callback defines the callback to use
  47470. */
  47471. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47472. /**
  47473. * Defines the callback to call when a button is released
  47474. * @param callback defines the callback to use
  47475. */
  47476. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47477. /**
  47478. * Defines the callback to call when a pad is pressed
  47479. * @param callback defines the callback to use
  47480. */
  47481. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47482. /**
  47483. * Defines the callback to call when a pad is released
  47484. * @param callback defines the callback to use
  47485. */
  47486. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47487. private _setButtonValue;
  47488. private _setDPadValue;
  47489. /**
  47490. * Gets the value of the `Cross` button
  47491. */
  47492. get buttonCross(): number;
  47493. /**
  47494. * Sets the value of the `Cross` button
  47495. */
  47496. set buttonCross(value: number);
  47497. /**
  47498. * Gets the value of the `Circle` button
  47499. */
  47500. get buttonCircle(): number;
  47501. /**
  47502. * Sets the value of the `Circle` button
  47503. */
  47504. set buttonCircle(value: number);
  47505. /**
  47506. * Gets the value of the `Square` button
  47507. */
  47508. get buttonSquare(): number;
  47509. /**
  47510. * Sets the value of the `Square` button
  47511. */
  47512. set buttonSquare(value: number);
  47513. /**
  47514. * Gets the value of the `Triangle` button
  47515. */
  47516. get buttonTriangle(): number;
  47517. /**
  47518. * Sets the value of the `Triangle` button
  47519. */
  47520. set buttonTriangle(value: number);
  47521. /**
  47522. * Gets the value of the `Options` button
  47523. */
  47524. get buttonOptions(): number;
  47525. /**
  47526. * Sets the value of the `Options` button
  47527. */
  47528. set buttonOptions(value: number);
  47529. /**
  47530. * Gets the value of the `Share` button
  47531. */
  47532. get buttonShare(): number;
  47533. /**
  47534. * Sets the value of the `Share` button
  47535. */
  47536. set buttonShare(value: number);
  47537. /**
  47538. * Gets the value of the `L1` button
  47539. */
  47540. get buttonL1(): number;
  47541. /**
  47542. * Sets the value of the `L1` button
  47543. */
  47544. set buttonL1(value: number);
  47545. /**
  47546. * Gets the value of the `R1` button
  47547. */
  47548. get buttonR1(): number;
  47549. /**
  47550. * Sets the value of the `R1` button
  47551. */
  47552. set buttonR1(value: number);
  47553. /**
  47554. * Gets the value of the Left joystick
  47555. */
  47556. get buttonLeftStick(): number;
  47557. /**
  47558. * Sets the value of the Left joystick
  47559. */
  47560. set buttonLeftStick(value: number);
  47561. /**
  47562. * Gets the value of the Right joystick
  47563. */
  47564. get buttonRightStick(): number;
  47565. /**
  47566. * Sets the value of the Right joystick
  47567. */
  47568. set buttonRightStick(value: number);
  47569. /**
  47570. * Gets the value of D-pad up
  47571. */
  47572. get dPadUp(): number;
  47573. /**
  47574. * Sets the value of D-pad up
  47575. */
  47576. set dPadUp(value: number);
  47577. /**
  47578. * Gets the value of D-pad down
  47579. */
  47580. get dPadDown(): number;
  47581. /**
  47582. * Sets the value of D-pad down
  47583. */
  47584. set dPadDown(value: number);
  47585. /**
  47586. * Gets the value of D-pad left
  47587. */
  47588. get dPadLeft(): number;
  47589. /**
  47590. * Sets the value of D-pad left
  47591. */
  47592. set dPadLeft(value: number);
  47593. /**
  47594. * Gets the value of D-pad right
  47595. */
  47596. get dPadRight(): number;
  47597. /**
  47598. * Sets the value of D-pad right
  47599. */
  47600. set dPadRight(value: number);
  47601. /**
  47602. * Force the gamepad to synchronize with device values
  47603. */
  47604. update(): void;
  47605. /**
  47606. * Disposes the gamepad
  47607. */
  47608. dispose(): void;
  47609. }
  47610. }
  47611. declare module "babylonjs/Gamepads/gamepadManager" {
  47612. import { Observable } from "babylonjs/Misc/observable";
  47613. import { Nullable } from "babylonjs/types";
  47614. import { Scene } from "babylonjs/scene";
  47615. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47616. /**
  47617. * Manager for handling gamepads
  47618. */
  47619. export class GamepadManager {
  47620. private _scene?;
  47621. private _babylonGamepads;
  47622. private _oneGamepadConnected;
  47623. /** @hidden */
  47624. _isMonitoring: boolean;
  47625. private _gamepadEventSupported;
  47626. private _gamepadSupport?;
  47627. /**
  47628. * observable to be triggered when the gamepad controller has been connected
  47629. */
  47630. onGamepadConnectedObservable: Observable<Gamepad>;
  47631. /**
  47632. * observable to be triggered when the gamepad controller has been disconnected
  47633. */
  47634. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47635. private _onGamepadConnectedEvent;
  47636. private _onGamepadDisconnectedEvent;
  47637. /**
  47638. * Initializes the gamepad manager
  47639. * @param _scene BabylonJS scene
  47640. */
  47641. constructor(_scene?: Scene | undefined);
  47642. /**
  47643. * The gamepads in the game pad manager
  47644. */
  47645. get gamepads(): Gamepad[];
  47646. /**
  47647. * Get the gamepad controllers based on type
  47648. * @param type The type of gamepad controller
  47649. * @returns Nullable gamepad
  47650. */
  47651. getGamepadByType(type?: number): Nullable<Gamepad>;
  47652. /**
  47653. * Disposes the gamepad manager
  47654. */
  47655. dispose(): void;
  47656. private _addNewGamepad;
  47657. private _startMonitoringGamepads;
  47658. private _stopMonitoringGamepads;
  47659. /** @hidden */
  47660. _checkGamepadsStatus(): void;
  47661. private _updateGamepadObjects;
  47662. }
  47663. }
  47664. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47665. import { Nullable } from "babylonjs/types";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { ISceneComponent } from "babylonjs/sceneComponent";
  47668. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47669. module "babylonjs/scene" {
  47670. interface Scene {
  47671. /** @hidden */
  47672. _gamepadManager: Nullable<GamepadManager>;
  47673. /**
  47674. * Gets the gamepad manager associated with the scene
  47675. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47676. */
  47677. gamepadManager: GamepadManager;
  47678. }
  47679. }
  47680. module "babylonjs/Cameras/freeCameraInputsManager" {
  47681. /**
  47682. * Interface representing a free camera inputs manager
  47683. */
  47684. interface FreeCameraInputsManager {
  47685. /**
  47686. * Adds gamepad input support to the FreeCameraInputsManager.
  47687. * @returns the FreeCameraInputsManager
  47688. */
  47689. addGamepad(): FreeCameraInputsManager;
  47690. }
  47691. }
  47692. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47693. /**
  47694. * Interface representing an arc rotate camera inputs manager
  47695. */
  47696. interface ArcRotateCameraInputsManager {
  47697. /**
  47698. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47699. * @returns the camera inputs manager
  47700. */
  47701. addGamepad(): ArcRotateCameraInputsManager;
  47702. }
  47703. }
  47704. /**
  47705. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47706. */
  47707. export class GamepadSystemSceneComponent implements ISceneComponent {
  47708. /**
  47709. * The component name helpfull to identify the component in the list of scene components.
  47710. */
  47711. readonly name: string;
  47712. /**
  47713. * The scene the component belongs to.
  47714. */
  47715. scene: Scene;
  47716. /**
  47717. * Creates a new instance of the component for the given scene
  47718. * @param scene Defines the scene to register the component in
  47719. */
  47720. constructor(scene: Scene);
  47721. /**
  47722. * Registers the component in a given scene
  47723. */
  47724. register(): void;
  47725. /**
  47726. * Rebuilds the elements related to this component in case of
  47727. * context lost for instance.
  47728. */
  47729. rebuild(): void;
  47730. /**
  47731. * Disposes the component and the associated ressources
  47732. */
  47733. dispose(): void;
  47734. private _beforeCameraUpdate;
  47735. }
  47736. }
  47737. declare module "babylonjs/Cameras/universalCamera" {
  47738. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47739. import { Scene } from "babylonjs/scene";
  47740. import { Vector3 } from "babylonjs/Maths/math.vector";
  47741. import "babylonjs/Gamepads/gamepadSceneComponent";
  47742. /**
  47743. * 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,
  47744. * which still works and will still be found in many Playgrounds.
  47745. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47746. */
  47747. export class UniversalCamera extends TouchCamera {
  47748. /**
  47749. * Defines the gamepad rotation sensiblity.
  47750. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47751. */
  47752. get gamepadAngularSensibility(): number;
  47753. set gamepadAngularSensibility(value: number);
  47754. /**
  47755. * Defines the gamepad move sensiblity.
  47756. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47757. */
  47758. get gamepadMoveSensibility(): number;
  47759. set gamepadMoveSensibility(value: number);
  47760. /**
  47761. * 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,
  47762. * which still works and will still be found in many Playgrounds.
  47763. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47764. * @param name Define the name of the camera in the scene
  47765. * @param position Define the start position of the camera in the scene
  47766. * @param scene Define the scene the camera belongs to
  47767. */
  47768. constructor(name: string, position: Vector3, scene: Scene);
  47769. /**
  47770. * Gets the current object class name.
  47771. * @return the class name
  47772. */
  47773. getClassName(): string;
  47774. }
  47775. }
  47776. declare module "babylonjs/Cameras/gamepadCamera" {
  47777. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47778. import { Scene } from "babylonjs/scene";
  47779. import { Vector3 } from "babylonjs/Maths/math.vector";
  47780. /**
  47781. * This represents a FPS type of camera. This is only here for back compat purpose.
  47782. * Please use the UniversalCamera instead as both are identical.
  47783. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47784. */
  47785. export class GamepadCamera extends UniversalCamera {
  47786. /**
  47787. * Instantiates a new Gamepad Camera
  47788. * This represents a FPS type of camera. This is only here for back compat purpose.
  47789. * Please use the UniversalCamera instead as both are identical.
  47790. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47791. * @param name Define the name of the camera in the scene
  47792. * @param position Define the start position of the camera in the scene
  47793. * @param scene Define the scene the camera belongs to
  47794. */
  47795. constructor(name: string, position: Vector3, scene: Scene);
  47796. /**
  47797. * Gets the current object class name.
  47798. * @return the class name
  47799. */
  47800. getClassName(): string;
  47801. }
  47802. }
  47803. declare module "babylonjs/Shaders/pass.fragment" {
  47804. /** @hidden */
  47805. export var passPixelShader: {
  47806. name: string;
  47807. shader: string;
  47808. };
  47809. }
  47810. declare module "babylonjs/Shaders/passCube.fragment" {
  47811. /** @hidden */
  47812. export var passCubePixelShader: {
  47813. name: string;
  47814. shader: string;
  47815. };
  47816. }
  47817. declare module "babylonjs/PostProcesses/passPostProcess" {
  47818. import { Nullable } from "babylonjs/types";
  47819. import { Camera } from "babylonjs/Cameras/camera";
  47820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47821. import { Engine } from "babylonjs/Engines/engine";
  47822. import "babylonjs/Shaders/pass.fragment";
  47823. import "babylonjs/Shaders/passCube.fragment";
  47824. import { Scene } from "babylonjs/scene";
  47825. /**
  47826. * PassPostProcess which produces an output the same as it's input
  47827. */
  47828. export class PassPostProcess extends PostProcess {
  47829. /**
  47830. * Gets a string identifying the name of the class
  47831. * @returns "PassPostProcess" string
  47832. */
  47833. getClassName(): string;
  47834. /**
  47835. * Creates the PassPostProcess
  47836. * @param name The name of the effect.
  47837. * @param options The required width/height ratio to downsize to before computing the render pass.
  47838. * @param camera The camera to apply the render pass to.
  47839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47840. * @param engine The engine which the post process will be applied. (default: current engine)
  47841. * @param reusable If the post process can be reused on the same frame. (default: false)
  47842. * @param textureType The type of texture to be used when performing the post processing.
  47843. * @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)
  47844. */
  47845. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47846. /** @hidden */
  47847. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47848. }
  47849. /**
  47850. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47851. */
  47852. export class PassCubePostProcess extends PostProcess {
  47853. private _face;
  47854. /**
  47855. * Gets or sets the cube face to display.
  47856. * * 0 is +X
  47857. * * 1 is -X
  47858. * * 2 is +Y
  47859. * * 3 is -Y
  47860. * * 4 is +Z
  47861. * * 5 is -Z
  47862. */
  47863. get face(): number;
  47864. set face(value: number);
  47865. /**
  47866. * Gets a string identifying the name of the class
  47867. * @returns "PassCubePostProcess" string
  47868. */
  47869. getClassName(): string;
  47870. /**
  47871. * Creates the PassCubePostProcess
  47872. * @param name The name of the effect.
  47873. * @param options The required width/height ratio to downsize to before computing the render pass.
  47874. * @param camera The camera to apply the render pass to.
  47875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47876. * @param engine The engine which the post process will be applied. (default: current engine)
  47877. * @param reusable If the post process can be reused on the same frame. (default: false)
  47878. * @param textureType The type of texture to be used when performing the post processing.
  47879. * @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)
  47880. */
  47881. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47882. /** @hidden */
  47883. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47884. }
  47885. }
  47886. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47887. /** @hidden */
  47888. export var anaglyphPixelShader: {
  47889. name: string;
  47890. shader: string;
  47891. };
  47892. }
  47893. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47894. import { Engine } from "babylonjs/Engines/engine";
  47895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47896. import { Camera } from "babylonjs/Cameras/camera";
  47897. import "babylonjs/Shaders/anaglyph.fragment";
  47898. /**
  47899. * Postprocess used to generate anaglyphic rendering
  47900. */
  47901. export class AnaglyphPostProcess extends PostProcess {
  47902. private _passedProcess;
  47903. /**
  47904. * Gets a string identifying the name of the class
  47905. * @returns "AnaglyphPostProcess" string
  47906. */
  47907. getClassName(): string;
  47908. /**
  47909. * Creates a new AnaglyphPostProcess
  47910. * @param name defines postprocess name
  47911. * @param options defines creation options or target ratio scale
  47912. * @param rigCameras defines cameras using this postprocess
  47913. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47914. * @param engine defines hosting engine
  47915. * @param reusable defines if the postprocess will be reused multiple times per frame
  47916. */
  47917. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47918. }
  47919. }
  47920. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47921. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47922. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47923. import { Scene } from "babylonjs/scene";
  47924. import { Vector3 } from "babylonjs/Maths/math.vector";
  47925. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47926. /**
  47927. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47928. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47929. */
  47930. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47931. /**
  47932. * Creates a new AnaglyphArcRotateCamera
  47933. * @param name defines camera name
  47934. * @param alpha defines alpha angle (in radians)
  47935. * @param beta defines beta angle (in radians)
  47936. * @param radius defines radius
  47937. * @param target defines camera target
  47938. * @param interaxialDistance defines distance between each color axis
  47939. * @param scene defines the hosting scene
  47940. */
  47941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47942. /**
  47943. * Gets camera class name
  47944. * @returns AnaglyphArcRotateCamera
  47945. */
  47946. getClassName(): string;
  47947. }
  47948. }
  47949. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47950. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47951. import { Scene } from "babylonjs/scene";
  47952. import { Vector3 } from "babylonjs/Maths/math.vector";
  47953. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47954. /**
  47955. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47956. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47957. */
  47958. export class AnaglyphFreeCamera extends FreeCamera {
  47959. /**
  47960. * Creates a new AnaglyphFreeCamera
  47961. * @param name defines camera name
  47962. * @param position defines initial position
  47963. * @param interaxialDistance defines distance between each color axis
  47964. * @param scene defines the hosting scene
  47965. */
  47966. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47967. /**
  47968. * Gets camera class name
  47969. * @returns AnaglyphFreeCamera
  47970. */
  47971. getClassName(): string;
  47972. }
  47973. }
  47974. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47975. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Vector3 } from "babylonjs/Maths/math.vector";
  47978. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47979. /**
  47980. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47981. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47982. */
  47983. export class AnaglyphGamepadCamera extends GamepadCamera {
  47984. /**
  47985. * Creates a new AnaglyphGamepadCamera
  47986. * @param name defines camera name
  47987. * @param position defines initial position
  47988. * @param interaxialDistance defines distance between each color axis
  47989. * @param scene defines the hosting scene
  47990. */
  47991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47992. /**
  47993. * Gets camera class name
  47994. * @returns AnaglyphGamepadCamera
  47995. */
  47996. getClassName(): string;
  47997. }
  47998. }
  47999. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48000. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48001. import { Scene } from "babylonjs/scene";
  48002. import { Vector3 } from "babylonjs/Maths/math.vector";
  48003. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48004. /**
  48005. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48006. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48007. */
  48008. export class AnaglyphUniversalCamera extends UniversalCamera {
  48009. /**
  48010. * Creates a new AnaglyphUniversalCamera
  48011. * @param name defines camera name
  48012. * @param position defines initial position
  48013. * @param interaxialDistance defines distance between each color axis
  48014. * @param scene defines the hosting scene
  48015. */
  48016. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48017. /**
  48018. * Gets camera class name
  48019. * @returns AnaglyphUniversalCamera
  48020. */
  48021. getClassName(): string;
  48022. }
  48023. }
  48024. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48025. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48026. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48027. import { Scene } from "babylonjs/scene";
  48028. import { Vector3 } from "babylonjs/Maths/math.vector";
  48029. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48030. /**
  48031. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48032. * @see https://doc.babylonjs.com/features/cameras
  48033. */
  48034. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48035. /**
  48036. * Creates a new StereoscopicArcRotateCamera
  48037. * @param name defines camera name
  48038. * @param alpha defines alpha angle (in radians)
  48039. * @param beta defines beta angle (in radians)
  48040. * @param radius defines radius
  48041. * @param target defines camera target
  48042. * @param interaxialDistance defines distance between each color axis
  48043. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48044. * @param scene defines the hosting scene
  48045. */
  48046. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48047. /**
  48048. * Gets camera class name
  48049. * @returns StereoscopicArcRotateCamera
  48050. */
  48051. getClassName(): string;
  48052. }
  48053. }
  48054. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48056. import { Scene } from "babylonjs/scene";
  48057. import { Vector3 } from "babylonjs/Maths/math.vector";
  48058. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48059. /**
  48060. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48061. * @see https://doc.babylonjs.com/features/cameras
  48062. */
  48063. export class StereoscopicFreeCamera extends FreeCamera {
  48064. /**
  48065. * Creates a new StereoscopicFreeCamera
  48066. * @param name defines camera name
  48067. * @param position defines initial position
  48068. * @param interaxialDistance defines distance between each color axis
  48069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48070. * @param scene defines the hosting scene
  48071. */
  48072. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48073. /**
  48074. * Gets camera class name
  48075. * @returns StereoscopicFreeCamera
  48076. */
  48077. getClassName(): string;
  48078. }
  48079. }
  48080. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48081. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48082. import { Scene } from "babylonjs/scene";
  48083. import { Vector3 } from "babylonjs/Maths/math.vector";
  48084. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48085. /**
  48086. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48087. * @see https://doc.babylonjs.com/features/cameras
  48088. */
  48089. export class StereoscopicGamepadCamera extends GamepadCamera {
  48090. /**
  48091. * Creates a new StereoscopicGamepadCamera
  48092. * @param name defines camera name
  48093. * @param position defines initial position
  48094. * @param interaxialDistance defines distance between each color axis
  48095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48096. * @param scene defines the hosting scene
  48097. */
  48098. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48099. /**
  48100. * Gets camera class name
  48101. * @returns StereoscopicGamepadCamera
  48102. */
  48103. getClassName(): string;
  48104. }
  48105. }
  48106. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48107. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48108. import { Scene } from "babylonjs/scene";
  48109. import { Vector3 } from "babylonjs/Maths/math.vector";
  48110. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48111. /**
  48112. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48113. * @see https://doc.babylonjs.com/features/cameras
  48114. */
  48115. export class StereoscopicUniversalCamera extends UniversalCamera {
  48116. /**
  48117. * Creates a new StereoscopicUniversalCamera
  48118. * @param name defines camera name
  48119. * @param position defines initial position
  48120. * @param interaxialDistance defines distance between each color axis
  48121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48122. * @param scene defines the hosting scene
  48123. */
  48124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48125. /**
  48126. * Gets camera class name
  48127. * @returns StereoscopicUniversalCamera
  48128. */
  48129. getClassName(): string;
  48130. }
  48131. }
  48132. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48133. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48134. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48135. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48136. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48137. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48141. }
  48142. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48143. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48144. import { Scene } from "babylonjs/scene";
  48145. import { Vector3 } from "babylonjs/Maths/math.vector";
  48146. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48147. /**
  48148. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48149. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48150. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48151. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48152. */
  48153. export class VirtualJoysticksCamera extends FreeCamera {
  48154. /**
  48155. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48156. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48157. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48158. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48159. * @param name Define the name of the camera in the scene
  48160. * @param position Define the start position of the camera in the scene
  48161. * @param scene Define the scene the camera belongs to
  48162. */
  48163. constructor(name: string, position: Vector3, scene: Scene);
  48164. /**
  48165. * Gets the current object class name.
  48166. * @return the class name
  48167. */
  48168. getClassName(): string;
  48169. }
  48170. }
  48171. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48172. import { Matrix } from "babylonjs/Maths/math.vector";
  48173. /**
  48174. * This represents all the required metrics to create a VR camera.
  48175. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48176. */
  48177. export class VRCameraMetrics {
  48178. /**
  48179. * Define the horizontal resolution off the screen.
  48180. */
  48181. hResolution: number;
  48182. /**
  48183. * Define the vertical resolution off the screen.
  48184. */
  48185. vResolution: number;
  48186. /**
  48187. * Define the horizontal screen size.
  48188. */
  48189. hScreenSize: number;
  48190. /**
  48191. * Define the vertical screen size.
  48192. */
  48193. vScreenSize: number;
  48194. /**
  48195. * Define the vertical screen center position.
  48196. */
  48197. vScreenCenter: number;
  48198. /**
  48199. * Define the distance of the eyes to the screen.
  48200. */
  48201. eyeToScreenDistance: number;
  48202. /**
  48203. * Define the distance between both lenses
  48204. */
  48205. lensSeparationDistance: number;
  48206. /**
  48207. * Define the distance between both viewer's eyes.
  48208. */
  48209. interpupillaryDistance: number;
  48210. /**
  48211. * Define the distortion factor of the VR postprocess.
  48212. * Please, touch with care.
  48213. */
  48214. distortionK: number[];
  48215. /**
  48216. * Define the chromatic aberration correction factors for the VR post process.
  48217. */
  48218. chromaAbCorrection: number[];
  48219. /**
  48220. * Define the scale factor of the post process.
  48221. * The smaller the better but the slower.
  48222. */
  48223. postProcessScaleFactor: number;
  48224. /**
  48225. * Define an offset for the lens center.
  48226. */
  48227. lensCenterOffset: number;
  48228. /**
  48229. * Define if the current vr camera should compensate the distortion of the lense or not.
  48230. */
  48231. compensateDistortion: boolean;
  48232. /**
  48233. * Defines if multiview should be enabled when rendering (Default: false)
  48234. */
  48235. multiviewEnabled: boolean;
  48236. /**
  48237. * Gets the rendering aspect ratio based on the provided resolutions.
  48238. */
  48239. get aspectRatio(): number;
  48240. /**
  48241. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48242. */
  48243. get aspectRatioFov(): number;
  48244. /**
  48245. * @hidden
  48246. */
  48247. get leftHMatrix(): Matrix;
  48248. /**
  48249. * @hidden
  48250. */
  48251. get rightHMatrix(): Matrix;
  48252. /**
  48253. * @hidden
  48254. */
  48255. get leftPreViewMatrix(): Matrix;
  48256. /**
  48257. * @hidden
  48258. */
  48259. get rightPreViewMatrix(): Matrix;
  48260. /**
  48261. * Get the default VRMetrics based on the most generic setup.
  48262. * @returns the default vr metrics
  48263. */
  48264. static GetDefault(): VRCameraMetrics;
  48265. }
  48266. }
  48267. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48268. /** @hidden */
  48269. export var vrDistortionCorrectionPixelShader: {
  48270. name: string;
  48271. shader: string;
  48272. };
  48273. }
  48274. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48275. import { Camera } from "babylonjs/Cameras/camera";
  48276. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48278. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48279. /**
  48280. * VRDistortionCorrectionPostProcess used for mobile VR
  48281. */
  48282. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48283. private _isRightEye;
  48284. private _distortionFactors;
  48285. private _postProcessScaleFactor;
  48286. private _lensCenterOffset;
  48287. private _scaleIn;
  48288. private _scaleFactor;
  48289. private _lensCenter;
  48290. /**
  48291. * Gets a string identifying the name of the class
  48292. * @returns "VRDistortionCorrectionPostProcess" string
  48293. */
  48294. getClassName(): string;
  48295. /**
  48296. * Initializes the VRDistortionCorrectionPostProcess
  48297. * @param name The name of the effect.
  48298. * @param camera The camera to apply the render pass to.
  48299. * @param isRightEye If this is for the right eye distortion
  48300. * @param vrMetrics All the required metrics for the VR camera
  48301. */
  48302. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48303. }
  48304. }
  48305. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48306. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48308. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Vector3 } from "babylonjs/Maths/math.vector";
  48311. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48312. import "babylonjs/Cameras/RigModes/vrRigMode";
  48313. /**
  48314. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48315. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48316. */
  48317. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48318. /**
  48319. * Creates a new VRDeviceOrientationArcRotateCamera
  48320. * @param name defines camera name
  48321. * @param alpha defines the camera rotation along the logitudinal axis
  48322. * @param beta defines the camera rotation along the latitudinal axis
  48323. * @param radius defines the camera distance from its target
  48324. * @param target defines the camera target
  48325. * @param scene defines the scene the camera belongs to
  48326. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48327. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48328. */
  48329. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48330. /**
  48331. * Gets camera class name
  48332. * @returns VRDeviceOrientationArcRotateCamera
  48333. */
  48334. getClassName(): string;
  48335. }
  48336. }
  48337. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48338. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48339. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48340. import { Scene } from "babylonjs/scene";
  48341. import { Vector3 } from "babylonjs/Maths/math.vector";
  48342. import "babylonjs/Cameras/RigModes/vrRigMode";
  48343. /**
  48344. * Camera used to simulate VR rendering (based on FreeCamera)
  48345. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48346. */
  48347. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48348. /**
  48349. * Creates a new VRDeviceOrientationFreeCamera
  48350. * @param name defines camera name
  48351. * @param position defines the start position of the camera
  48352. * @param scene defines the scene the camera belongs to
  48353. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48354. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48355. */
  48356. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48357. /**
  48358. * Gets camera class name
  48359. * @returns VRDeviceOrientationFreeCamera
  48360. */
  48361. getClassName(): string;
  48362. }
  48363. }
  48364. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48365. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48366. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48367. import { Scene } from "babylonjs/scene";
  48368. import { Vector3 } from "babylonjs/Maths/math.vector";
  48369. import "babylonjs/Gamepads/gamepadSceneComponent";
  48370. /**
  48371. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48372. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48373. */
  48374. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48375. /**
  48376. * Creates a new VRDeviceOrientationGamepadCamera
  48377. * @param name defines camera name
  48378. * @param position defines the start position of the camera
  48379. * @param scene defines the scene the camera belongs to
  48380. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48381. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48382. */
  48383. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48384. /**
  48385. * Gets camera class name
  48386. * @returns VRDeviceOrientationGamepadCamera
  48387. */
  48388. getClassName(): string;
  48389. }
  48390. }
  48391. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48392. import { Scene } from "babylonjs/scene";
  48393. import { Texture } from "babylonjs/Materials/Textures/texture";
  48394. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48395. /**
  48396. * A class extending Texture allowing drawing on a texture
  48397. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48398. */
  48399. export class DynamicTexture extends Texture {
  48400. private _generateMipMaps;
  48401. private _canvas;
  48402. private _context;
  48403. /**
  48404. * Creates a DynamicTexture
  48405. * @param name defines the name of the texture
  48406. * @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
  48407. * @param scene defines the scene where you want the texture
  48408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48411. */
  48412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48413. /**
  48414. * Get the current class name of the texture useful for serialization or dynamic coding.
  48415. * @returns "DynamicTexture"
  48416. */
  48417. getClassName(): string;
  48418. /**
  48419. * Gets the current state of canRescale
  48420. */
  48421. get canRescale(): boolean;
  48422. private _recreate;
  48423. /**
  48424. * Scales the texture
  48425. * @param ratio the scale factor to apply to both width and height
  48426. */
  48427. scale(ratio: number): void;
  48428. /**
  48429. * Resizes the texture
  48430. * @param width the new width
  48431. * @param height the new height
  48432. */
  48433. scaleTo(width: number, height: number): void;
  48434. /**
  48435. * Gets the context of the canvas used by the texture
  48436. * @returns the canvas context of the dynamic texture
  48437. */
  48438. getContext(): CanvasRenderingContext2D;
  48439. /**
  48440. * Clears the texture
  48441. */
  48442. clear(): void;
  48443. /**
  48444. * Updates the texture
  48445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48447. */
  48448. update(invertY?: boolean, premulAlpha?: boolean): void;
  48449. /**
  48450. * Draws text onto the texture
  48451. * @param text defines the text to be drawn
  48452. * @param x defines the placement of the text from the left
  48453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48454. * @param font defines the font to be used with font-style, font-size, font-name
  48455. * @param color defines the color used for the text
  48456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48458. * @param update defines whether texture is immediately update (default is true)
  48459. */
  48460. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48461. /**
  48462. * Clones the texture
  48463. * @returns the clone of the texture.
  48464. */
  48465. clone(): DynamicTexture;
  48466. /**
  48467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48468. * @returns a serialized dynamic texture object
  48469. */
  48470. serialize(): any;
  48471. private _IsCanvasElement;
  48472. /** @hidden */
  48473. _rebuild(): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48477. import { Scene } from "babylonjs/scene";
  48478. import { Color3 } from "babylonjs/Maths/math.color";
  48479. import { Mesh } from "babylonjs/Meshes/mesh";
  48480. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48481. import { Nullable } from "babylonjs/types";
  48482. /**
  48483. * Class containing static functions to help procedurally build meshes
  48484. */
  48485. export class GroundBuilder {
  48486. /**
  48487. * Creates a ground mesh
  48488. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48489. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48491. * @param name defines the name of the mesh
  48492. * @param options defines the options used to create the mesh
  48493. * @param scene defines the hosting scene
  48494. * @returns the ground mesh
  48495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48496. */
  48497. static CreateGround(name: string, options: {
  48498. width?: number;
  48499. height?: number;
  48500. subdivisions?: number;
  48501. subdivisionsX?: number;
  48502. subdivisionsY?: number;
  48503. updatable?: boolean;
  48504. }, scene: any): Mesh;
  48505. /**
  48506. * Creates a tiled ground mesh
  48507. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48508. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48509. * * 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
  48510. * * 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
  48511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48512. * @param name defines the name of the mesh
  48513. * @param options defines the options used to create the mesh
  48514. * @param scene defines the hosting scene
  48515. * @returns the tiled ground mesh
  48516. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48517. */
  48518. static CreateTiledGround(name: string, options: {
  48519. xmin: number;
  48520. zmin: number;
  48521. xmax: number;
  48522. zmax: number;
  48523. subdivisions?: {
  48524. w: number;
  48525. h: number;
  48526. };
  48527. precision?: {
  48528. w: number;
  48529. h: number;
  48530. };
  48531. updatable?: boolean;
  48532. }, scene?: Nullable<Scene>): Mesh;
  48533. /**
  48534. * Creates a ground mesh from a height map
  48535. * * The parameter `url` sets the URL of the height map image resource.
  48536. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48537. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48538. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48539. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48540. * * 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.
  48541. * * 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).
  48542. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48544. * @param name defines the name of the mesh
  48545. * @param url defines the url to the height map
  48546. * @param options defines the options used to create the mesh
  48547. * @param scene defines the hosting scene
  48548. * @returns the ground mesh
  48549. * @see https://doc.babylonjs.com/babylon101/height_map
  48550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48551. */
  48552. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48553. width?: number;
  48554. height?: number;
  48555. subdivisions?: number;
  48556. minHeight?: number;
  48557. maxHeight?: number;
  48558. colorFilter?: Color3;
  48559. alphaFilter?: number;
  48560. updatable?: boolean;
  48561. onReady?: (mesh: GroundMesh) => void;
  48562. }, scene?: Nullable<Scene>): GroundMesh;
  48563. }
  48564. }
  48565. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48566. import { Vector4 } from "babylonjs/Maths/math.vector";
  48567. import { Mesh } from "babylonjs/Meshes/mesh";
  48568. /**
  48569. * Class containing static functions to help procedurally build meshes
  48570. */
  48571. export class TorusBuilder {
  48572. /**
  48573. * Creates a torus mesh
  48574. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48575. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48576. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48580. * @param name defines the name of the mesh
  48581. * @param options defines the options used to create the mesh
  48582. * @param scene defines the hosting scene
  48583. * @returns the torus mesh
  48584. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48585. */
  48586. static CreateTorus(name: string, options: {
  48587. diameter?: number;
  48588. thickness?: number;
  48589. tessellation?: number;
  48590. updatable?: boolean;
  48591. sideOrientation?: number;
  48592. frontUVs?: Vector4;
  48593. backUVs?: Vector4;
  48594. }, scene: any): Mesh;
  48595. }
  48596. }
  48597. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48598. import { Vector4 } from "babylonjs/Maths/math.vector";
  48599. import { Color4 } from "babylonjs/Maths/math.color";
  48600. import { Mesh } from "babylonjs/Meshes/mesh";
  48601. /**
  48602. * Class containing static functions to help procedurally build meshes
  48603. */
  48604. export class CylinderBuilder {
  48605. /**
  48606. * Creates a cylinder or a cone mesh
  48607. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48608. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48609. * * 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.
  48610. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48611. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48612. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48613. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48614. * * 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).
  48615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48616. * * 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).
  48617. * * 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
  48618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48619. * * 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
  48620. * * 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.
  48621. * * If `enclose` is false, a ring surface is one element.
  48622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48623. * * 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
  48624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48627. * @param name defines the name of the mesh
  48628. * @param options defines the options used to create the mesh
  48629. * @param scene defines the hosting scene
  48630. * @returns the cylinder mesh
  48631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48632. */
  48633. static CreateCylinder(name: string, options: {
  48634. height?: number;
  48635. diameterTop?: number;
  48636. diameterBottom?: number;
  48637. diameter?: number;
  48638. tessellation?: number;
  48639. subdivisions?: number;
  48640. arc?: number;
  48641. faceColors?: Color4[];
  48642. faceUV?: Vector4[];
  48643. updatable?: boolean;
  48644. hasRings?: boolean;
  48645. enclose?: boolean;
  48646. cap?: number;
  48647. sideOrientation?: number;
  48648. frontUVs?: Vector4;
  48649. backUVs?: Vector4;
  48650. }, scene: any): Mesh;
  48651. }
  48652. }
  48653. declare module "babylonjs/XR/webXRTypes" {
  48654. import { Nullable } from "babylonjs/types";
  48655. import { IDisposable } from "babylonjs/scene";
  48656. /**
  48657. * States of the webXR experience
  48658. */
  48659. export enum WebXRState {
  48660. /**
  48661. * Transitioning to being in XR mode
  48662. */
  48663. ENTERING_XR = 0,
  48664. /**
  48665. * Transitioning to non XR mode
  48666. */
  48667. EXITING_XR = 1,
  48668. /**
  48669. * In XR mode and presenting
  48670. */
  48671. IN_XR = 2,
  48672. /**
  48673. * Not entered XR mode
  48674. */
  48675. NOT_IN_XR = 3
  48676. }
  48677. /**
  48678. * Abstraction of the XR render target
  48679. */
  48680. export interface WebXRRenderTarget extends IDisposable {
  48681. /**
  48682. * xrpresent context of the canvas which can be used to display/mirror xr content
  48683. */
  48684. canvasContext: WebGLRenderingContext;
  48685. /**
  48686. * xr layer for the canvas
  48687. */
  48688. xrLayer: Nullable<XRWebGLLayer>;
  48689. /**
  48690. * Initializes the xr layer for the session
  48691. * @param xrSession xr session
  48692. * @returns a promise that will resolve once the XR Layer has been created
  48693. */
  48694. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48695. }
  48696. }
  48697. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48698. import { Nullable } from "babylonjs/types";
  48699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48700. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48701. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48702. import { Observable } from "babylonjs/Misc/observable";
  48703. /**
  48704. * COnfiguration object for WebXR output canvas
  48705. */
  48706. export class WebXRManagedOutputCanvasOptions {
  48707. /**
  48708. * An optional canvas in case you wish to create it yourself and provide it here.
  48709. * If not provided, a new canvas will be created
  48710. */
  48711. canvasElement?: HTMLCanvasElement;
  48712. /**
  48713. * Options for this XR Layer output
  48714. */
  48715. canvasOptions?: XRWebGLLayerOptions;
  48716. /**
  48717. * CSS styling for a newly created canvas (if not provided)
  48718. */
  48719. newCanvasCssStyle?: string;
  48720. /**
  48721. * Get the default values of the configuration object
  48722. * @param engine defines the engine to use (can be null)
  48723. * @returns default values of this configuration object
  48724. */
  48725. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48726. }
  48727. /**
  48728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48729. */
  48730. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48731. private _options;
  48732. private _canvas;
  48733. private _engine;
  48734. private _originalCanvasSize;
  48735. /**
  48736. * Rendering context of the canvas which can be used to display/mirror xr content
  48737. */
  48738. canvasContext: WebGLRenderingContext;
  48739. /**
  48740. * xr layer for the canvas
  48741. */
  48742. xrLayer: Nullable<XRWebGLLayer>;
  48743. /**
  48744. * Obseervers registered here will be triggered when the xr layer was initialized
  48745. */
  48746. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48747. /**
  48748. * Initializes the canvas to be added/removed upon entering/exiting xr
  48749. * @param _xrSessionManager The XR Session manager
  48750. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48751. */
  48752. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48753. /**
  48754. * Disposes of the object
  48755. */
  48756. dispose(): void;
  48757. /**
  48758. * Initializes the xr layer for the session
  48759. * @param xrSession xr session
  48760. * @returns a promise that will resolve once the XR Layer has been created
  48761. */
  48762. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48763. private _addCanvas;
  48764. private _removeCanvas;
  48765. private _setCanvasSize;
  48766. private _setManagedOutputCanvas;
  48767. }
  48768. }
  48769. declare module "babylonjs/XR/webXRSessionManager" {
  48770. import { Observable } from "babylonjs/Misc/observable";
  48771. import { Nullable } from "babylonjs/types";
  48772. import { IDisposable, Scene } from "babylonjs/scene";
  48773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48774. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48775. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48776. /**
  48777. * Manages an XRSession to work with Babylon's engine
  48778. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48779. */
  48780. export class WebXRSessionManager implements IDisposable {
  48781. /** The scene which the session should be created for */
  48782. scene: Scene;
  48783. private _referenceSpace;
  48784. private _rttProvider;
  48785. private _sessionEnded;
  48786. private _xrNavigator;
  48787. private baseLayer;
  48788. /**
  48789. * The base reference space from which the session started. good if you want to reset your
  48790. * reference space
  48791. */
  48792. baseReferenceSpace: XRReferenceSpace;
  48793. /**
  48794. * Current XR frame
  48795. */
  48796. currentFrame: Nullable<XRFrame>;
  48797. /** WebXR timestamp updated every frame */
  48798. currentTimestamp: number;
  48799. /**
  48800. * Used just in case of a failure to initialize an immersive session.
  48801. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48802. */
  48803. defaultHeightCompensation: number;
  48804. /**
  48805. * Fires every time a new xrFrame arrives which can be used to update the camera
  48806. */
  48807. onXRFrameObservable: Observable<XRFrame>;
  48808. /**
  48809. * Fires when the reference space changed
  48810. */
  48811. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48812. /**
  48813. * Fires when the xr session is ended either by the device or manually done
  48814. */
  48815. onXRSessionEnded: Observable<any>;
  48816. /**
  48817. * Fires when the xr session is ended either by the device or manually done
  48818. */
  48819. onXRSessionInit: Observable<XRSession>;
  48820. /**
  48821. * Underlying xr session
  48822. */
  48823. session: XRSession;
  48824. /**
  48825. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48826. * or get the offset the player is currently at.
  48827. */
  48828. viewerReferenceSpace: XRReferenceSpace;
  48829. /**
  48830. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48831. * @param scene The scene which the session should be created for
  48832. */
  48833. constructor(
  48834. /** The scene which the session should be created for */
  48835. scene: Scene);
  48836. /**
  48837. * The current reference space used in this session. This reference space can constantly change!
  48838. * It is mainly used to offset the camera's position.
  48839. */
  48840. get referenceSpace(): XRReferenceSpace;
  48841. /**
  48842. * Set a new reference space and triggers the observable
  48843. */
  48844. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48845. /**
  48846. * Disposes of the session manager
  48847. */
  48848. dispose(): void;
  48849. /**
  48850. * Stops the xrSession and restores the render loop
  48851. * @returns Promise which resolves after it exits XR
  48852. */
  48853. exitXRAsync(): Promise<void>;
  48854. /**
  48855. * Gets the correct render target texture to be rendered this frame for this eye
  48856. * @param eye the eye for which to get the render target
  48857. * @returns the render target for the specified eye
  48858. */
  48859. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48860. /**
  48861. * Creates a WebXRRenderTarget object for the XR session
  48862. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48863. * @param options optional options to provide when creating a new render target
  48864. * @returns a WebXR render target to which the session can render
  48865. */
  48866. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48867. /**
  48868. * Initializes the manager
  48869. * After initialization enterXR can be called to start an XR session
  48870. * @returns Promise which resolves after it is initialized
  48871. */
  48872. initializeAsync(): Promise<void>;
  48873. /**
  48874. * Initializes an xr session
  48875. * @param xrSessionMode mode to initialize
  48876. * @param xrSessionInit defines optional and required values to pass to the session builder
  48877. * @returns a promise which will resolve once the session has been initialized
  48878. */
  48879. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48880. /**
  48881. * Checks if a session would be supported for the creation options specified
  48882. * @param sessionMode session mode to check if supported eg. immersive-vr
  48883. * @returns A Promise that resolves to true if supported and false if not
  48884. */
  48885. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48886. /**
  48887. * Resets the reference space to the one started the session
  48888. */
  48889. resetReferenceSpace(): void;
  48890. /**
  48891. * Starts rendering to the xr layer
  48892. */
  48893. runXRRenderLoop(): void;
  48894. /**
  48895. * Sets the reference space on the xr session
  48896. * @param referenceSpaceType space to set
  48897. * @returns a promise that will resolve once the reference space has been set
  48898. */
  48899. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48900. /**
  48901. * Updates the render state of the session
  48902. * @param state state to set
  48903. * @returns a promise that resolves once the render state has been updated
  48904. */
  48905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48906. /**
  48907. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48908. * @param sessionMode defines the session to test
  48909. * @returns a promise with boolean as final value
  48910. */
  48911. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48912. private _createRenderTargetTexture;
  48913. }
  48914. }
  48915. declare module "babylonjs/XR/webXRCamera" {
  48916. import { Vector3 } from "babylonjs/Maths/math.vector";
  48917. import { Scene } from "babylonjs/scene";
  48918. import { Camera } from "babylonjs/Cameras/camera";
  48919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48920. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48921. import { Observable } from "babylonjs/Misc/observable";
  48922. /**
  48923. * WebXR Camera which holds the views for the xrSession
  48924. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48925. */
  48926. export class WebXRCamera extends FreeCamera {
  48927. private _xrSessionManager;
  48928. private _firstFrame;
  48929. private _referenceQuaternion;
  48930. private _referencedPosition;
  48931. private _xrInvPositionCache;
  48932. private _xrInvQuaternionCache;
  48933. /**
  48934. * Observable raised before camera teleportation
  48935. */
  48936. onBeforeCameraTeleport: Observable<Vector3>;
  48937. /**
  48938. * Observable raised after camera teleportation
  48939. */
  48940. onAfterCameraTeleport: Observable<Vector3>;
  48941. /**
  48942. * Should position compensation execute on first frame.
  48943. * This is used when copying the position from a native (non XR) camera
  48944. */
  48945. compensateOnFirstFrame: boolean;
  48946. /**
  48947. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48948. * @param name the name of the camera
  48949. * @param scene the scene to add the camera to
  48950. * @param _xrSessionManager a constructed xr session manager
  48951. */
  48952. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48953. /**
  48954. * Return the user's height, unrelated to the current ground.
  48955. * This will be the y position of this camera, when ground level is 0.
  48956. */
  48957. get realWorldHeight(): number;
  48958. /** @hidden */
  48959. _updateForDualEyeDebugging(): void;
  48960. /**
  48961. * Sets this camera's transformation based on a non-vr camera
  48962. * @param otherCamera the non-vr camera to copy the transformation from
  48963. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48964. */
  48965. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48966. /**
  48967. * Gets the current instance class name ("WebXRCamera").
  48968. * @returns the class name
  48969. */
  48970. getClassName(): string;
  48971. private _rotate180;
  48972. private _updateFromXRSession;
  48973. private _updateNumberOfRigCameras;
  48974. private _updateReferenceSpace;
  48975. private _updateReferenceSpaceOffset;
  48976. }
  48977. }
  48978. declare module "babylonjs/XR/webXRFeaturesManager" {
  48979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48980. import { IDisposable } from "babylonjs/scene";
  48981. /**
  48982. * Defining the interface required for a (webxr) feature
  48983. */
  48984. export interface IWebXRFeature extends IDisposable {
  48985. /**
  48986. * Is this feature attached
  48987. */
  48988. attached: boolean;
  48989. /**
  48990. * Should auto-attach be disabled?
  48991. */
  48992. disableAutoAttach: boolean;
  48993. /**
  48994. * Attach the feature to the session
  48995. * Will usually be called by the features manager
  48996. *
  48997. * @param force should attachment be forced (even when already attached)
  48998. * @returns true if successful.
  48999. */
  49000. attach(force?: boolean): boolean;
  49001. /**
  49002. * Detach the feature from the session
  49003. * Will usually be called by the features manager
  49004. *
  49005. * @returns true if successful.
  49006. */
  49007. detach(): boolean;
  49008. /**
  49009. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49010. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49011. *
  49012. * @returns whether or not the feature is compatible in this environment
  49013. */
  49014. isCompatible(): boolean;
  49015. /**
  49016. * Was this feature disposed;
  49017. */
  49018. isDisposed: boolean;
  49019. /**
  49020. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49021. */
  49022. xrNativeFeatureName?: string;
  49023. /**
  49024. * A list of (Babylon WebXR) features this feature depends on
  49025. */
  49026. dependsOn?: string[];
  49027. }
  49028. /**
  49029. * A list of the currently available features without referencing them
  49030. */
  49031. export class WebXRFeatureName {
  49032. /**
  49033. * The name of the anchor system feature
  49034. */
  49035. static readonly ANCHOR_SYSTEM: string;
  49036. /**
  49037. * The name of the background remover feature
  49038. */
  49039. static readonly BACKGROUND_REMOVER: string;
  49040. /**
  49041. * The name of the hit test feature
  49042. */
  49043. static readonly HIT_TEST: string;
  49044. /**
  49045. * physics impostors for xr controllers feature
  49046. */
  49047. static readonly PHYSICS_CONTROLLERS: string;
  49048. /**
  49049. * The name of the plane detection feature
  49050. */
  49051. static readonly PLANE_DETECTION: string;
  49052. /**
  49053. * The name of the pointer selection feature
  49054. */
  49055. static readonly POINTER_SELECTION: string;
  49056. /**
  49057. * The name of the teleportation feature
  49058. */
  49059. static readonly TELEPORTATION: string;
  49060. /**
  49061. * The name of the feature points feature.
  49062. */
  49063. static readonly FEATURE_POINTS: string;
  49064. /**
  49065. * The name of the hand tracking feature.
  49066. */
  49067. static readonly HAND_TRACKING: string;
  49068. }
  49069. /**
  49070. * Defining the constructor of a feature. Used to register the modules.
  49071. */
  49072. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49073. /**
  49074. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49075. * It is mainly used in AR sessions.
  49076. *
  49077. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49078. */
  49079. export class WebXRFeaturesManager implements IDisposable {
  49080. private _xrSessionManager;
  49081. private static readonly _AvailableFeatures;
  49082. private _features;
  49083. /**
  49084. * constructs a new features manages.
  49085. *
  49086. * @param _xrSessionManager an instance of WebXRSessionManager
  49087. */
  49088. constructor(_xrSessionManager: WebXRSessionManager);
  49089. /**
  49090. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49091. * Mainly used internally.
  49092. *
  49093. * @param featureName the name of the feature to register
  49094. * @param constructorFunction the function used to construct the module
  49095. * @param version the (babylon) version of the module
  49096. * @param stable is that a stable version of this module
  49097. */
  49098. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49099. /**
  49100. * Returns a constructor of a specific feature.
  49101. *
  49102. * @param featureName the name of the feature to construct
  49103. * @param version the version of the feature to load
  49104. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49105. * @param options optional options provided to the module.
  49106. * @returns a function that, when called, will return a new instance of this feature
  49107. */
  49108. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49109. /**
  49110. * Can be used to return the list of features currently registered
  49111. *
  49112. * @returns an Array of available features
  49113. */
  49114. static GetAvailableFeatures(): string[];
  49115. /**
  49116. * Gets the versions available for a specific feature
  49117. * @param featureName the name of the feature
  49118. * @returns an array with the available versions
  49119. */
  49120. static GetAvailableVersions(featureName: string): string[];
  49121. /**
  49122. * Return the latest unstable version of this feature
  49123. * @param featureName the name of the feature to search
  49124. * @returns the version number. if not found will return -1
  49125. */
  49126. static GetLatestVersionOfFeature(featureName: string): number;
  49127. /**
  49128. * Return the latest stable version of this feature
  49129. * @param featureName the name of the feature to search
  49130. * @returns the version number. if not found will return -1
  49131. */
  49132. static GetStableVersionOfFeature(featureName: string): number;
  49133. /**
  49134. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49135. * Can be used during a session to start a feature
  49136. * @param featureName the name of feature to attach
  49137. */
  49138. attachFeature(featureName: string): void;
  49139. /**
  49140. * Can be used inside a session or when the session ends to detach a specific feature
  49141. * @param featureName the name of the feature to detach
  49142. */
  49143. detachFeature(featureName: string): void;
  49144. /**
  49145. * Used to disable an already-enabled feature
  49146. * The feature will be disposed and will be recreated once enabled.
  49147. * @param featureName the feature to disable
  49148. * @returns true if disable was successful
  49149. */
  49150. disableFeature(featureName: string | {
  49151. Name: string;
  49152. }): boolean;
  49153. /**
  49154. * dispose this features manager
  49155. */
  49156. dispose(): void;
  49157. /**
  49158. * 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.
  49159. * 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.
  49160. *
  49161. * @param featureName the name of the feature to load or the class of the feature
  49162. * @param version optional version to load. if not provided the latest version will be enabled
  49163. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49164. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49165. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49166. * @returns a new constructed feature or throws an error if feature not found.
  49167. */
  49168. enableFeature(featureName: string | {
  49169. Name: string;
  49170. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49171. /**
  49172. * get the implementation of an enabled feature.
  49173. * @param featureName the name of the feature to load
  49174. * @returns the feature class, if found
  49175. */
  49176. getEnabledFeature(featureName: string): IWebXRFeature;
  49177. /**
  49178. * Get the list of enabled features
  49179. * @returns an array of enabled features
  49180. */
  49181. getEnabledFeatures(): string[];
  49182. /**
  49183. * This function will exten the session creation configuration object with enabled features.
  49184. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49185. * according to the defined "required" variable, provided during enableFeature call
  49186. * @param xrSessionInit the xr Session init object to extend
  49187. *
  49188. * @returns an extended XRSessionInit object
  49189. */
  49190. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49191. }
  49192. }
  49193. declare module "babylonjs/XR/webXRExperienceHelper" {
  49194. import { Observable } from "babylonjs/Misc/observable";
  49195. import { IDisposable, Scene } from "babylonjs/scene";
  49196. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49197. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49198. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49199. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49200. /**
  49201. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49202. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49203. */
  49204. export class WebXRExperienceHelper implements IDisposable {
  49205. private scene;
  49206. private _nonVRCamera;
  49207. private _originalSceneAutoClear;
  49208. private _supported;
  49209. /**
  49210. * Camera used to render xr content
  49211. */
  49212. camera: WebXRCamera;
  49213. /** A features manager for this xr session */
  49214. featuresManager: WebXRFeaturesManager;
  49215. /**
  49216. * Observers registered here will be triggered after the camera's initial transformation is set
  49217. * This can be used to set a different ground level or an extra rotation.
  49218. *
  49219. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49220. * to the position set after this observable is done executing.
  49221. */
  49222. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49223. /**
  49224. * Fires when the state of the experience helper has changed
  49225. */
  49226. onStateChangedObservable: Observable<WebXRState>;
  49227. /** Session manager used to keep track of xr session */
  49228. sessionManager: WebXRSessionManager;
  49229. /**
  49230. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49231. */
  49232. state: WebXRState;
  49233. /**
  49234. * Creates a WebXRExperienceHelper
  49235. * @param scene The scene the helper should be created in
  49236. */
  49237. private constructor();
  49238. /**
  49239. * Creates the experience helper
  49240. * @param scene the scene to attach the experience helper to
  49241. * @returns a promise for the experience helper
  49242. */
  49243. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49244. /**
  49245. * Disposes of the experience helper
  49246. */
  49247. dispose(): void;
  49248. /**
  49249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49250. * @param sessionMode options for the XR session
  49251. * @param referenceSpaceType frame of reference of the XR session
  49252. * @param renderTarget the output canvas that will be used to enter XR mode
  49253. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49254. * @returns promise that resolves after xr mode has entered
  49255. */
  49256. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49257. /**
  49258. * Exits XR mode and returns the scene to its original state
  49259. * @returns promise that resolves after xr mode has exited
  49260. */
  49261. exitXRAsync(): Promise<void>;
  49262. private _nonXRToXRCamera;
  49263. private _setState;
  49264. }
  49265. }
  49266. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49267. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49268. import { Observable } from "babylonjs/Misc/observable";
  49269. import { IDisposable } from "babylonjs/scene";
  49270. /**
  49271. * X-Y values for axes in WebXR
  49272. */
  49273. export interface IWebXRMotionControllerAxesValue {
  49274. /**
  49275. * The value of the x axis
  49276. */
  49277. x: number;
  49278. /**
  49279. * The value of the y-axis
  49280. */
  49281. y: number;
  49282. }
  49283. /**
  49284. * changed / previous values for the values of this component
  49285. */
  49286. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49287. /**
  49288. * current (this frame) value
  49289. */
  49290. current: T;
  49291. /**
  49292. * previous (last change) value
  49293. */
  49294. previous: T;
  49295. }
  49296. /**
  49297. * Represents changes in the component between current frame and last values recorded
  49298. */
  49299. export interface IWebXRMotionControllerComponentChanges {
  49300. /**
  49301. * will be populated with previous and current values if axes changed
  49302. */
  49303. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49304. /**
  49305. * will be populated with previous and current values if pressed changed
  49306. */
  49307. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49308. /**
  49309. * will be populated with previous and current values if touched changed
  49310. */
  49311. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49312. /**
  49313. * will be populated with previous and current values if value changed
  49314. */
  49315. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49316. }
  49317. /**
  49318. * This class represents a single component (for example button or thumbstick) of a motion controller
  49319. */
  49320. export class WebXRControllerComponent implements IDisposable {
  49321. /**
  49322. * the id of this component
  49323. */
  49324. id: string;
  49325. /**
  49326. * the type of the component
  49327. */
  49328. type: MotionControllerComponentType;
  49329. private _buttonIndex;
  49330. private _axesIndices;
  49331. private _axes;
  49332. private _changes;
  49333. private _currentValue;
  49334. private _hasChanges;
  49335. private _pressed;
  49336. private _touched;
  49337. /**
  49338. * button component type
  49339. */
  49340. static BUTTON_TYPE: MotionControllerComponentType;
  49341. /**
  49342. * squeeze component type
  49343. */
  49344. static SQUEEZE_TYPE: MotionControllerComponentType;
  49345. /**
  49346. * Thumbstick component type
  49347. */
  49348. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49349. /**
  49350. * Touchpad component type
  49351. */
  49352. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49353. /**
  49354. * trigger component type
  49355. */
  49356. static TRIGGER_TYPE: MotionControllerComponentType;
  49357. /**
  49358. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49359. * the axes data changes
  49360. */
  49361. onAxisValueChangedObservable: Observable<{
  49362. x: number;
  49363. y: number;
  49364. }>;
  49365. /**
  49366. * Observers registered here will be triggered when the state of a button changes
  49367. * State change is either pressed / touched / value
  49368. */
  49369. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49370. /**
  49371. * Creates a new component for a motion controller.
  49372. * It is created by the motion controller itself
  49373. *
  49374. * @param id the id of this component
  49375. * @param type the type of the component
  49376. * @param _buttonIndex index in the buttons array of the gamepad
  49377. * @param _axesIndices indices of the values in the axes array of the gamepad
  49378. */
  49379. constructor(
  49380. /**
  49381. * the id of this component
  49382. */
  49383. id: string,
  49384. /**
  49385. * the type of the component
  49386. */
  49387. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49388. /**
  49389. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49390. */
  49391. get axes(): IWebXRMotionControllerAxesValue;
  49392. /**
  49393. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49394. */
  49395. get changes(): IWebXRMotionControllerComponentChanges;
  49396. /**
  49397. * Return whether or not the component changed the last frame
  49398. */
  49399. get hasChanges(): boolean;
  49400. /**
  49401. * is the button currently pressed
  49402. */
  49403. get pressed(): boolean;
  49404. /**
  49405. * is the button currently touched
  49406. */
  49407. get touched(): boolean;
  49408. /**
  49409. * Get the current value of this component
  49410. */
  49411. get value(): number;
  49412. /**
  49413. * Dispose this component
  49414. */
  49415. dispose(): void;
  49416. /**
  49417. * Are there axes correlating to this component
  49418. * @return true is axes data is available
  49419. */
  49420. isAxes(): boolean;
  49421. /**
  49422. * Is this component a button (hence - pressable)
  49423. * @returns true if can be pressed
  49424. */
  49425. isButton(): boolean;
  49426. /**
  49427. * update this component using the gamepad object it is in. Called on every frame
  49428. * @param nativeController the native gamepad controller object
  49429. */
  49430. update(nativeController: IMinimalMotionControllerObject): void;
  49431. }
  49432. }
  49433. declare module "babylonjs/Loading/sceneLoader" {
  49434. import { Observable } from "babylonjs/Misc/observable";
  49435. import { Nullable } from "babylonjs/types";
  49436. import { Scene } from "babylonjs/scene";
  49437. import { Engine } from "babylonjs/Engines/engine";
  49438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49439. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49440. import { AssetContainer } from "babylonjs/assetContainer";
  49441. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49442. import { Skeleton } from "babylonjs/Bones/skeleton";
  49443. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49444. import { WebRequest } from "babylonjs/Misc/webRequest";
  49445. /**
  49446. * Interface used to represent data loading progression
  49447. */
  49448. export interface ISceneLoaderProgressEvent {
  49449. /**
  49450. * Defines if data length to load can be evaluated
  49451. */
  49452. readonly lengthComputable: boolean;
  49453. /**
  49454. * Defines the loaded data length
  49455. */
  49456. readonly loaded: number;
  49457. /**
  49458. * Defines the data length to load
  49459. */
  49460. readonly total: number;
  49461. }
  49462. /**
  49463. * Interface used by SceneLoader plugins to define supported file extensions
  49464. */
  49465. export interface ISceneLoaderPluginExtensions {
  49466. /**
  49467. * Defines the list of supported extensions
  49468. */
  49469. [extension: string]: {
  49470. isBinary: boolean;
  49471. };
  49472. }
  49473. /**
  49474. * Interface used by SceneLoader plugin factory
  49475. */
  49476. export interface ISceneLoaderPluginFactory {
  49477. /**
  49478. * Defines the name of the factory
  49479. */
  49480. name: string;
  49481. /**
  49482. * Function called to create a new plugin
  49483. * @return the new plugin
  49484. */
  49485. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49486. /**
  49487. * The callback that returns true if the data can be directly loaded.
  49488. * @param data string containing the file data
  49489. * @returns if the data can be loaded directly
  49490. */
  49491. canDirectLoad?(data: string): boolean;
  49492. }
  49493. /**
  49494. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49495. */
  49496. export interface ISceneLoaderPluginBase {
  49497. /**
  49498. * The friendly name of this plugin.
  49499. */
  49500. name: string;
  49501. /**
  49502. * The file extensions supported by this plugin.
  49503. */
  49504. extensions: string | ISceneLoaderPluginExtensions;
  49505. /**
  49506. * The callback called when loading from a url.
  49507. * @param scene scene loading this url
  49508. * @param url url to load
  49509. * @param onSuccess callback called when the file successfully loads
  49510. * @param onProgress callback called while file is loading (if the server supports this mode)
  49511. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49512. * @param onError callback called when the file fails to load
  49513. * @returns a file request object
  49514. */
  49515. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49516. /**
  49517. * The callback called when loading from a file object.
  49518. * @param scene scene loading this file
  49519. * @param file defines the file to load
  49520. * @param onSuccess defines the callback to call when data is loaded
  49521. * @param onProgress defines the callback to call during loading process
  49522. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49523. * @param onError defines the callback to call when an error occurs
  49524. * @returns a file request object
  49525. */
  49526. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49527. /**
  49528. * The callback that returns true if the data can be directly loaded.
  49529. * @param data string containing the file data
  49530. * @returns if the data can be loaded directly
  49531. */
  49532. canDirectLoad?(data: string): boolean;
  49533. /**
  49534. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49535. * @param scene scene loading this data
  49536. * @param data string containing the data
  49537. * @returns data to pass to the plugin
  49538. */
  49539. directLoad?(scene: Scene, data: string): any;
  49540. /**
  49541. * The callback that allows custom handling of the root url based on the response url.
  49542. * @param rootUrl the original root url
  49543. * @param responseURL the response url if available
  49544. * @returns the new root url
  49545. */
  49546. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49547. }
  49548. /**
  49549. * Interface used to define a SceneLoader plugin
  49550. */
  49551. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49552. /**
  49553. * Import meshes into a scene.
  49554. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49555. * @param scene The scene to import into
  49556. * @param data The data to import
  49557. * @param rootUrl The root url for scene and resources
  49558. * @param meshes The meshes array to import into
  49559. * @param particleSystems The particle systems array to import into
  49560. * @param skeletons The skeletons array to import into
  49561. * @param onError The callback when import fails
  49562. * @returns True if successful or false otherwise
  49563. */
  49564. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49565. /**
  49566. * Load into a scene.
  49567. * @param scene The scene to load into
  49568. * @param data The data to import
  49569. * @param rootUrl The root url for scene and resources
  49570. * @param onError The callback when import fails
  49571. * @returns True if successful or false otherwise
  49572. */
  49573. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49574. /**
  49575. * Load into an asset container.
  49576. * @param scene The scene to load into
  49577. * @param data The data to import
  49578. * @param rootUrl The root url for scene and resources
  49579. * @param onError The callback when import fails
  49580. * @returns The loaded asset container
  49581. */
  49582. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49583. }
  49584. /**
  49585. * Interface used to define an async SceneLoader plugin
  49586. */
  49587. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49588. /**
  49589. * Import meshes into a scene.
  49590. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49591. * @param scene The scene to import into
  49592. * @param data The data to import
  49593. * @param rootUrl The root url for scene and resources
  49594. * @param onProgress The callback when the load progresses
  49595. * @param fileName Defines the name of the file to load
  49596. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49597. */
  49598. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49599. meshes: AbstractMesh[];
  49600. particleSystems: IParticleSystem[];
  49601. skeletons: Skeleton[];
  49602. animationGroups: AnimationGroup[];
  49603. }>;
  49604. /**
  49605. * Load into a scene.
  49606. * @param scene The scene to load into
  49607. * @param data The data to import
  49608. * @param rootUrl The root url for scene and resources
  49609. * @param onProgress The callback when the load progresses
  49610. * @param fileName Defines the name of the file to load
  49611. * @returns Nothing
  49612. */
  49613. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49614. /**
  49615. * Load into an asset container.
  49616. * @param scene The scene to load into
  49617. * @param data The data to import
  49618. * @param rootUrl The root url for scene and resources
  49619. * @param onProgress The callback when the load progresses
  49620. * @param fileName Defines the name of the file to load
  49621. * @returns The loaded asset container
  49622. */
  49623. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49624. }
  49625. /**
  49626. * Mode that determines how to handle old animation groups before loading new ones.
  49627. */
  49628. export enum SceneLoaderAnimationGroupLoadingMode {
  49629. /**
  49630. * Reset all old animations to initial state then dispose them.
  49631. */
  49632. Clean = 0,
  49633. /**
  49634. * Stop all old animations.
  49635. */
  49636. Stop = 1,
  49637. /**
  49638. * Restart old animations from first frame.
  49639. */
  49640. Sync = 2,
  49641. /**
  49642. * Old animations remains untouched.
  49643. */
  49644. NoSync = 3
  49645. }
  49646. /**
  49647. * Defines a plugin registered by the SceneLoader
  49648. */
  49649. interface IRegisteredPlugin {
  49650. /**
  49651. * Defines the plugin to use
  49652. */
  49653. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49654. /**
  49655. * Defines if the plugin supports binary data
  49656. */
  49657. isBinary: boolean;
  49658. }
  49659. /**
  49660. * Class used to load scene from various file formats using registered plugins
  49661. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49662. */
  49663. export class SceneLoader {
  49664. /**
  49665. * No logging while loading
  49666. */
  49667. static readonly NO_LOGGING: number;
  49668. /**
  49669. * Minimal logging while loading
  49670. */
  49671. static readonly MINIMAL_LOGGING: number;
  49672. /**
  49673. * Summary logging while loading
  49674. */
  49675. static readonly SUMMARY_LOGGING: number;
  49676. /**
  49677. * Detailled logging while loading
  49678. */
  49679. static readonly DETAILED_LOGGING: number;
  49680. /**
  49681. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49682. */
  49683. static get ForceFullSceneLoadingForIncremental(): boolean;
  49684. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49685. /**
  49686. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49687. */
  49688. static get ShowLoadingScreen(): boolean;
  49689. static set ShowLoadingScreen(value: boolean);
  49690. /**
  49691. * Defines the current logging level (while loading the scene)
  49692. * @ignorenaming
  49693. */
  49694. static get loggingLevel(): number;
  49695. static set loggingLevel(value: number);
  49696. /**
  49697. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49698. */
  49699. static get CleanBoneMatrixWeights(): boolean;
  49700. static set CleanBoneMatrixWeights(value: boolean);
  49701. /**
  49702. * Event raised when a plugin is used to load a scene
  49703. */
  49704. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49705. private static _registeredPlugins;
  49706. private static _showingLoadingScreen;
  49707. /**
  49708. * Gets the default plugin (used to load Babylon files)
  49709. * @returns the .babylon plugin
  49710. */
  49711. static GetDefaultPlugin(): IRegisteredPlugin;
  49712. private static _GetPluginForExtension;
  49713. private static _GetPluginForDirectLoad;
  49714. private static _GetPluginForFilename;
  49715. private static _GetDirectLoad;
  49716. private static _LoadData;
  49717. private static _GetFileInfo;
  49718. /**
  49719. * Gets a plugin that can load the given extension
  49720. * @param extension defines the extension to load
  49721. * @returns a plugin or null if none works
  49722. */
  49723. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49724. /**
  49725. * Gets a boolean indicating that the given extension can be loaded
  49726. * @param extension defines the extension to load
  49727. * @returns true if the extension is supported
  49728. */
  49729. static IsPluginForExtensionAvailable(extension: string): boolean;
  49730. /**
  49731. * Adds a new plugin to the list of registered plugins
  49732. * @param plugin defines the plugin to add
  49733. */
  49734. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49735. /**
  49736. * Import meshes into a scene
  49737. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49738. * @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)
  49739. * @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)
  49740. * @param scene the instance of BABYLON.Scene to append to
  49741. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49742. * @param onProgress a callback with a progress event for each file being loaded
  49743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49744. * @param pluginExtension the extension used to determine the plugin
  49745. * @returns The loaded plugin
  49746. */
  49747. 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>;
  49748. /**
  49749. * Import meshes into a scene
  49750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49751. * @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)
  49752. * @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)
  49753. * @param scene the instance of BABYLON.Scene to append to
  49754. * @param onProgress a callback with a progress event for each file being loaded
  49755. * @param pluginExtension the extension used to determine the plugin
  49756. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49757. */
  49758. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49759. meshes: AbstractMesh[];
  49760. particleSystems: IParticleSystem[];
  49761. skeletons: Skeleton[];
  49762. animationGroups: AnimationGroup[];
  49763. }>;
  49764. /**
  49765. * Load a scene
  49766. * @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)
  49767. * @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)
  49768. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49769. * @param onSuccess a callback with the scene when import succeeds
  49770. * @param onProgress a callback with a progress event for each file being loaded
  49771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49772. * @param pluginExtension the extension used to determine the plugin
  49773. * @returns The loaded plugin
  49774. */
  49775. 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>;
  49776. /**
  49777. * Load a scene
  49778. * @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)
  49779. * @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)
  49780. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49781. * @param onProgress a callback with a progress event for each file being loaded
  49782. * @param pluginExtension the extension used to determine the plugin
  49783. * @returns The loaded scene
  49784. */
  49785. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49786. /**
  49787. * Append a scene
  49788. * @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)
  49789. * @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)
  49790. * @param scene is the instance of BABYLON.Scene to append to
  49791. * @param onSuccess a callback with the scene when import succeeds
  49792. * @param onProgress a callback with a progress event for each file being loaded
  49793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49794. * @param pluginExtension the extension used to determine the plugin
  49795. * @returns The loaded plugin
  49796. */
  49797. 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>;
  49798. /**
  49799. * Append a scene
  49800. * @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)
  49801. * @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)
  49802. * @param scene is the instance of BABYLON.Scene to append to
  49803. * @param onProgress a callback with a progress event for each file being loaded
  49804. * @param pluginExtension the extension used to determine the plugin
  49805. * @returns The given scene
  49806. */
  49807. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49808. /**
  49809. * Load a scene into an asset container
  49810. * @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)
  49811. * @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)
  49812. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49813. * @param onSuccess a callback with the scene when import succeeds
  49814. * @param onProgress a callback with a progress event for each file being loaded
  49815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49816. * @param pluginExtension the extension used to determine the plugin
  49817. * @returns The loaded plugin
  49818. */
  49819. 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>;
  49820. /**
  49821. * Load a scene into an asset container
  49822. * @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)
  49823. * @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)
  49824. * @param scene is the instance of Scene to append to
  49825. * @param onProgress a callback with a progress event for each file being loaded
  49826. * @param pluginExtension the extension used to determine the plugin
  49827. * @returns The loaded asset container
  49828. */
  49829. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49830. /**
  49831. * Import animations from a file into a scene
  49832. * @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)
  49833. * @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)
  49834. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49835. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49836. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49837. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49838. * @param onSuccess a callback with the scene when import succeeds
  49839. * @param onProgress a callback with a progress event for each file being loaded
  49840. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49841. * @param pluginExtension the extension used to determine the plugin
  49842. */
  49843. 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;
  49844. /**
  49845. * Import animations from a file into a scene
  49846. * @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)
  49847. * @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)
  49848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49849. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49850. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49851. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49852. * @param onSuccess a callback with the scene when import succeeds
  49853. * @param onProgress a callback with a progress event for each file being loaded
  49854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49855. * @param pluginExtension the extension used to determine the plugin
  49856. * @returns the updated scene with imported animations
  49857. */
  49858. 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>;
  49859. }
  49860. }
  49861. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49862. import { IDisposable, Scene } from "babylonjs/scene";
  49863. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49864. import { Observable } from "babylonjs/Misc/observable";
  49865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49866. import { Nullable } from "babylonjs/types";
  49867. /**
  49868. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49869. */
  49870. export type MotionControllerHandedness = "none" | "left" | "right";
  49871. /**
  49872. * The type of components available in motion controllers.
  49873. * This is not the name of the component.
  49874. */
  49875. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49876. /**
  49877. * The state of a controller component
  49878. */
  49879. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49880. /**
  49881. * The schema of motion controller layout.
  49882. * No object will be initialized using this interface
  49883. * This is used just to define the profile.
  49884. */
  49885. export interface IMotionControllerLayout {
  49886. /**
  49887. * Path to load the assets. Usually relative to the base path
  49888. */
  49889. assetPath: string;
  49890. /**
  49891. * Available components (unsorted)
  49892. */
  49893. components: {
  49894. /**
  49895. * A map of component Ids
  49896. */
  49897. [componentId: string]: {
  49898. /**
  49899. * The type of input the component outputs
  49900. */
  49901. type: MotionControllerComponentType;
  49902. /**
  49903. * The indices of this component in the gamepad object
  49904. */
  49905. gamepadIndices: {
  49906. /**
  49907. * Index of button
  49908. */
  49909. button?: number;
  49910. /**
  49911. * If available, index of x-axis
  49912. */
  49913. xAxis?: number;
  49914. /**
  49915. * If available, index of y-axis
  49916. */
  49917. yAxis?: number;
  49918. };
  49919. /**
  49920. * The mesh's root node name
  49921. */
  49922. rootNodeName: string;
  49923. /**
  49924. * Animation definitions for this model
  49925. */
  49926. visualResponses: {
  49927. [stateKey: string]: {
  49928. /**
  49929. * What property will be animated
  49930. */
  49931. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49932. /**
  49933. * What states influence this visual response
  49934. */
  49935. states: MotionControllerComponentStateType[];
  49936. /**
  49937. * Type of animation - movement or visibility
  49938. */
  49939. valueNodeProperty: "transform" | "visibility";
  49940. /**
  49941. * Base node name to move. Its position will be calculated according to the min and max nodes
  49942. */
  49943. valueNodeName?: string;
  49944. /**
  49945. * Minimum movement node
  49946. */
  49947. minNodeName?: string;
  49948. /**
  49949. * Max movement node
  49950. */
  49951. maxNodeName?: string;
  49952. };
  49953. };
  49954. /**
  49955. * If touch enabled, what is the name of node to display user feedback
  49956. */
  49957. touchPointNodeName?: string;
  49958. };
  49959. };
  49960. /**
  49961. * Is it xr standard mapping or not
  49962. */
  49963. gamepadMapping: "" | "xr-standard";
  49964. /**
  49965. * Base root node of this entire model
  49966. */
  49967. rootNodeName: string;
  49968. /**
  49969. * Defines the main button component id
  49970. */
  49971. selectComponentId: string;
  49972. }
  49973. /**
  49974. * A definition for the layout map in the input profile
  49975. */
  49976. export interface IMotionControllerLayoutMap {
  49977. /**
  49978. * Layouts with handedness type as a key
  49979. */
  49980. [handedness: string]: IMotionControllerLayout;
  49981. }
  49982. /**
  49983. * The XR Input profile schema
  49984. * Profiles can be found here:
  49985. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49986. */
  49987. export interface IMotionControllerProfile {
  49988. /**
  49989. * fallback profiles for this profileId
  49990. */
  49991. fallbackProfileIds: string[];
  49992. /**
  49993. * The layout map, with handedness as key
  49994. */
  49995. layouts: IMotionControllerLayoutMap;
  49996. /**
  49997. * The id of this profile
  49998. * correlates to the profile(s) in the xrInput.profiles array
  49999. */
  50000. profileId: string;
  50001. }
  50002. /**
  50003. * A helper-interface for the 3 meshes needed for controller button animation
  50004. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50005. */
  50006. export interface IMotionControllerButtonMeshMap {
  50007. /**
  50008. * the mesh that defines the pressed value mesh position.
  50009. * This is used to find the max-position of this button
  50010. */
  50011. pressedMesh: AbstractMesh;
  50012. /**
  50013. * the mesh that defines the unpressed value mesh position.
  50014. * This is used to find the min (or initial) position of this button
  50015. */
  50016. unpressedMesh: AbstractMesh;
  50017. /**
  50018. * The mesh that will be changed when value changes
  50019. */
  50020. valueMesh: AbstractMesh;
  50021. }
  50022. /**
  50023. * A helper-interface for the 3 meshes needed for controller axis animation.
  50024. * This will be expanded when touchpad animations are fully supported
  50025. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50026. */
  50027. export interface IMotionControllerMeshMap {
  50028. /**
  50029. * the mesh that defines the maximum value mesh position.
  50030. */
  50031. maxMesh?: AbstractMesh;
  50032. /**
  50033. * the mesh that defines the minimum value mesh position.
  50034. */
  50035. minMesh?: AbstractMesh;
  50036. /**
  50037. * The mesh that will be changed when axis value changes
  50038. */
  50039. valueMesh?: AbstractMesh;
  50040. }
  50041. /**
  50042. * The elements needed for change-detection of the gamepad objects in motion controllers
  50043. */
  50044. export interface IMinimalMotionControllerObject {
  50045. /**
  50046. * Available axes of this controller
  50047. */
  50048. axes: number[];
  50049. /**
  50050. * An array of available buttons
  50051. */
  50052. buttons: Array<{
  50053. /**
  50054. * Value of the button/trigger
  50055. */
  50056. value: number;
  50057. /**
  50058. * If the button/trigger is currently touched
  50059. */
  50060. touched: boolean;
  50061. /**
  50062. * If the button/trigger is currently pressed
  50063. */
  50064. pressed: boolean;
  50065. }>;
  50066. /**
  50067. * EXPERIMENTAL haptic support.
  50068. */
  50069. hapticActuators?: Array<{
  50070. pulse: (value: number, duration: number) => Promise<boolean>;
  50071. }>;
  50072. }
  50073. /**
  50074. * An Abstract Motion controller
  50075. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50076. * Each component has an observable to check for changes in value and state
  50077. */
  50078. export abstract class WebXRAbstractMotionController implements IDisposable {
  50079. protected scene: Scene;
  50080. protected layout: IMotionControllerLayout;
  50081. /**
  50082. * The gamepad object correlating to this controller
  50083. */
  50084. gamepadObject: IMinimalMotionControllerObject;
  50085. /**
  50086. * handedness (left/right/none) of this controller
  50087. */
  50088. handedness: MotionControllerHandedness;
  50089. private _initComponent;
  50090. private _modelReady;
  50091. /**
  50092. * A map of components (WebXRControllerComponent) in this motion controller
  50093. * Components have a ComponentType and can also have both button and axis definitions
  50094. */
  50095. readonly components: {
  50096. [id: string]: WebXRControllerComponent;
  50097. };
  50098. /**
  50099. * Disable the model's animation. Can be set at any time.
  50100. */
  50101. disableAnimation: boolean;
  50102. /**
  50103. * Observers registered here will be triggered when the model of this controller is done loading
  50104. */
  50105. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50106. /**
  50107. * The profile id of this motion controller
  50108. */
  50109. abstract profileId: string;
  50110. /**
  50111. * The root mesh of the model. It is null if the model was not yet initialized
  50112. */
  50113. rootMesh: Nullable<AbstractMesh>;
  50114. /**
  50115. * constructs a new abstract motion controller
  50116. * @param scene the scene to which the model of the controller will be added
  50117. * @param layout The profile layout to load
  50118. * @param gamepadObject The gamepad object correlating to this controller
  50119. * @param handedness handedness (left/right/none) of this controller
  50120. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50121. */
  50122. constructor(scene: Scene, layout: IMotionControllerLayout,
  50123. /**
  50124. * The gamepad object correlating to this controller
  50125. */
  50126. gamepadObject: IMinimalMotionControllerObject,
  50127. /**
  50128. * handedness (left/right/none) of this controller
  50129. */
  50130. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50131. /**
  50132. * Dispose this controller, the model mesh and all its components
  50133. */
  50134. dispose(): void;
  50135. /**
  50136. * Returns all components of specific type
  50137. * @param type the type to search for
  50138. * @return an array of components with this type
  50139. */
  50140. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50141. /**
  50142. * get a component based an its component id as defined in layout.components
  50143. * @param id the id of the component
  50144. * @returns the component correlates to the id or undefined if not found
  50145. */
  50146. getComponent(id: string): WebXRControllerComponent;
  50147. /**
  50148. * Get the list of components available in this motion controller
  50149. * @returns an array of strings correlating to available components
  50150. */
  50151. getComponentIds(): string[];
  50152. /**
  50153. * Get the first component of specific type
  50154. * @param type type of component to find
  50155. * @return a controller component or null if not found
  50156. */
  50157. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50158. /**
  50159. * Get the main (Select) component of this controller as defined in the layout
  50160. * @returns the main component of this controller
  50161. */
  50162. getMainComponent(): WebXRControllerComponent;
  50163. /**
  50164. * Loads the model correlating to this controller
  50165. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50166. * @returns A promise fulfilled with the result of the model loading
  50167. */
  50168. loadModel(): Promise<boolean>;
  50169. /**
  50170. * Update this model using the current XRFrame
  50171. * @param xrFrame the current xr frame to use and update the model
  50172. */
  50173. updateFromXRFrame(xrFrame: XRFrame): void;
  50174. /**
  50175. * Backwards compatibility due to a deeply-integrated typo
  50176. */
  50177. get handness(): XREye;
  50178. /**
  50179. * Pulse (vibrate) this controller
  50180. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50181. * Consecutive calls to this function will cancel the last pulse call
  50182. *
  50183. * @param value the strength of the pulse in 0.0...1.0 range
  50184. * @param duration Duration of the pulse in milliseconds
  50185. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50186. * @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
  50187. */
  50188. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50189. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50190. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50191. /**
  50192. * Moves the axis on the controller mesh based on its current state
  50193. * @param axis the index of the axis
  50194. * @param axisValue the value of the axis which determines the meshes new position
  50195. * @hidden
  50196. */
  50197. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50198. /**
  50199. * Update the model itself with the current frame data
  50200. * @param xrFrame the frame to use for updating the model mesh
  50201. */
  50202. protected updateModel(xrFrame: XRFrame): void;
  50203. /**
  50204. * Get the filename and path for this controller's model
  50205. * @returns a map of filename and path
  50206. */
  50207. protected abstract _getFilenameAndPath(): {
  50208. filename: string;
  50209. path: string;
  50210. };
  50211. /**
  50212. * This function is called before the mesh is loaded. It checks for loading constraints.
  50213. * For example, this function can check if the GLB loader is available
  50214. * If this function returns false, the generic controller will be loaded instead
  50215. * @returns Is the client ready to load the mesh
  50216. */
  50217. protected abstract _getModelLoadingConstraints(): boolean;
  50218. /**
  50219. * This function will be called after the model was successfully loaded and can be used
  50220. * for mesh transformations before it is available for the user
  50221. * @param meshes the loaded meshes
  50222. */
  50223. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50224. /**
  50225. * Set the root mesh for this controller. Important for the WebXR controller class
  50226. * @param meshes the loaded meshes
  50227. */
  50228. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50229. /**
  50230. * A function executed each frame that updates the mesh (if needed)
  50231. * @param xrFrame the current xrFrame
  50232. */
  50233. protected abstract _updateModel(xrFrame: XRFrame): void;
  50234. private _getGenericFilenameAndPath;
  50235. private _getGenericParentMesh;
  50236. }
  50237. }
  50238. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50239. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50241. import { Scene } from "babylonjs/scene";
  50242. /**
  50243. * A generic trigger-only motion controller for WebXR
  50244. */
  50245. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50246. /**
  50247. * Static version of the profile id of this controller
  50248. */
  50249. static ProfileId: string;
  50250. profileId: string;
  50251. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50252. protected _getFilenameAndPath(): {
  50253. filename: string;
  50254. path: string;
  50255. };
  50256. protected _getModelLoadingConstraints(): boolean;
  50257. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50259. protected _updateModel(): void;
  50260. }
  50261. }
  50262. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50263. import { Vector4 } from "babylonjs/Maths/math.vector";
  50264. import { Mesh } from "babylonjs/Meshes/mesh";
  50265. import { Scene } from "babylonjs/scene";
  50266. import { Nullable } from "babylonjs/types";
  50267. /**
  50268. * Class containing static functions to help procedurally build meshes
  50269. */
  50270. export class SphereBuilder {
  50271. /**
  50272. * Creates a sphere mesh
  50273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50274. * * 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`)
  50275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50276. * * 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
  50277. * * 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)
  50278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50281. * @param name defines the name of the mesh
  50282. * @param options defines the options used to create the mesh
  50283. * @param scene defines the hosting scene
  50284. * @returns the sphere mesh
  50285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50286. */
  50287. static CreateSphere(name: string, options: {
  50288. segments?: number;
  50289. diameter?: number;
  50290. diameterX?: number;
  50291. diameterY?: number;
  50292. diameterZ?: number;
  50293. arc?: number;
  50294. slice?: number;
  50295. sideOrientation?: number;
  50296. frontUVs?: Vector4;
  50297. backUVs?: Vector4;
  50298. updatable?: boolean;
  50299. }, scene?: Nullable<Scene>): Mesh;
  50300. }
  50301. }
  50302. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50304. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50305. import { Scene } from "babylonjs/scene";
  50306. /**
  50307. * A profiled motion controller has its profile loaded from an online repository.
  50308. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50309. */
  50310. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50311. private _repositoryUrl;
  50312. private _buttonMeshMapping;
  50313. private _touchDots;
  50314. /**
  50315. * The profile ID of this controller. Will be populated when the controller initializes.
  50316. */
  50317. profileId: string;
  50318. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50319. dispose(): void;
  50320. protected _getFilenameAndPath(): {
  50321. filename: string;
  50322. path: string;
  50323. };
  50324. protected _getModelLoadingConstraints(): boolean;
  50325. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50326. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50327. protected _updateModel(_xrFrame: XRFrame): void;
  50328. }
  50329. }
  50330. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50331. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50332. import { Scene } from "babylonjs/scene";
  50333. /**
  50334. * A construction function type to create a new controller based on an xrInput object
  50335. */
  50336. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50337. /**
  50338. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50339. *
  50340. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50341. * it should be replaced with auto-loaded controllers.
  50342. *
  50343. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50344. */
  50345. export class WebXRMotionControllerManager {
  50346. private static _AvailableControllers;
  50347. private static _Fallbacks;
  50348. private static _ProfileLoadingPromises;
  50349. private static _ProfilesList;
  50350. /**
  50351. * The base URL of the online controller repository. Can be changed at any time.
  50352. */
  50353. static BaseRepositoryUrl: string;
  50354. /**
  50355. * Which repository gets priority - local or online
  50356. */
  50357. static PrioritizeOnlineRepository: boolean;
  50358. /**
  50359. * Use the online repository, or use only locally-defined controllers
  50360. */
  50361. static UseOnlineRepository: boolean;
  50362. /**
  50363. * Clear the cache used for profile loading and reload when requested again
  50364. */
  50365. static ClearProfilesCache(): void;
  50366. /**
  50367. * Register the default fallbacks.
  50368. * This function is called automatically when this file is imported.
  50369. */
  50370. static DefaultFallbacks(): void;
  50371. /**
  50372. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50373. * @param profileId the profile to which a fallback needs to be found
  50374. * @return an array with corresponding fallback profiles
  50375. */
  50376. static FindFallbackWithProfileId(profileId: string): string[];
  50377. /**
  50378. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50379. * The order of search:
  50380. *
  50381. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50382. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50383. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50384. * 4) return the generic trigger controller if none were found
  50385. *
  50386. * @param xrInput the xrInput to which a new controller is initialized
  50387. * @param scene the scene to which the model will be added
  50388. * @param forceProfile force a certain profile for this controller
  50389. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50390. */
  50391. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50392. /**
  50393. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50394. *
  50395. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50396. *
  50397. * @param type the profile type to register
  50398. * @param constructFunction the function to be called when loading this profile
  50399. */
  50400. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50401. /**
  50402. * Register a fallback to a specific profile.
  50403. * @param profileId the profileId that will receive the fallbacks
  50404. * @param fallbacks A list of fallback profiles
  50405. */
  50406. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50407. /**
  50408. * Will update the list of profiles available in the repository
  50409. * @return a promise that resolves to a map of profiles available online
  50410. */
  50411. static UpdateProfilesList(): Promise<{
  50412. [profile: string]: string;
  50413. }>;
  50414. private static _LoadProfileFromRepository;
  50415. private static _LoadProfilesFromAvailableControllers;
  50416. }
  50417. }
  50418. declare module "babylonjs/XR/webXRInputSource" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50421. import { Ray } from "babylonjs/Culling/ray";
  50422. import { Scene } from "babylonjs/scene";
  50423. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50424. /**
  50425. * Configuration options for the WebXR controller creation
  50426. */
  50427. export interface IWebXRControllerOptions {
  50428. /**
  50429. * Should the controller mesh be animated when a user interacts with it
  50430. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50431. */
  50432. disableMotionControllerAnimation?: boolean;
  50433. /**
  50434. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50435. */
  50436. doNotLoadControllerMesh?: boolean;
  50437. /**
  50438. * Force a specific controller type for this controller.
  50439. * This can be used when creating your own profile or when testing different controllers
  50440. */
  50441. forceControllerProfile?: string;
  50442. /**
  50443. * Defines a rendering group ID for meshes that will be loaded.
  50444. * This is for the default controllers only.
  50445. */
  50446. renderingGroupId?: number;
  50447. }
  50448. /**
  50449. * Represents an XR controller
  50450. */
  50451. export class WebXRInputSource {
  50452. private _scene;
  50453. /** The underlying input source for the controller */
  50454. inputSource: XRInputSource;
  50455. private _options;
  50456. private _tmpVector;
  50457. private _uniqueId;
  50458. private _disposed;
  50459. /**
  50460. * 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
  50461. */
  50462. grip?: AbstractMesh;
  50463. /**
  50464. * If available, this is the gamepad object related to this controller.
  50465. * Using this object it is possible to get click events and trackpad changes of the
  50466. * webxr controller that is currently being used.
  50467. */
  50468. motionController?: WebXRAbstractMotionController;
  50469. /**
  50470. * Event that fires when the controller is removed/disposed.
  50471. * The object provided as event data is this controller, after associated assets were disposed.
  50472. * uniqueId is still available.
  50473. */
  50474. onDisposeObservable: Observable<WebXRInputSource>;
  50475. /**
  50476. * Will be triggered when the mesh associated with the motion controller is done loading.
  50477. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50478. * A shortened version of controller -> motion controller -> on mesh loaded.
  50479. */
  50480. onMeshLoadedObservable: Observable<AbstractMesh>;
  50481. /**
  50482. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50483. */
  50484. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50485. /**
  50486. * Pointer which can be used to select objects or attach a visible laser to
  50487. */
  50488. pointer: AbstractMesh;
  50489. /**
  50490. * Creates the input source object
  50491. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50492. * @param _scene the scene which the controller should be associated to
  50493. * @param inputSource the underlying input source for the controller
  50494. * @param _options options for this controller creation
  50495. */
  50496. constructor(_scene: Scene,
  50497. /** The underlying input source for the controller */
  50498. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50499. /**
  50500. * Get this controllers unique id
  50501. */
  50502. get uniqueId(): string;
  50503. /**
  50504. * Disposes of the object
  50505. */
  50506. dispose(): void;
  50507. /**
  50508. * Gets a world space ray coming from the pointer or grip
  50509. * @param result the resulting ray
  50510. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50511. */
  50512. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50513. /**
  50514. * Updates the controller pose based on the given XRFrame
  50515. * @param xrFrame xr frame to update the pose with
  50516. * @param referenceSpace reference space to use
  50517. */
  50518. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50519. }
  50520. }
  50521. declare module "babylonjs/XR/webXRInput" {
  50522. import { Observable } from "babylonjs/Misc/observable";
  50523. import { IDisposable } from "babylonjs/scene";
  50524. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50525. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50526. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50527. /**
  50528. * The schema for initialization options of the XR Input class
  50529. */
  50530. export interface IWebXRInputOptions {
  50531. /**
  50532. * If set to true no model will be automatically loaded
  50533. */
  50534. doNotLoadControllerMeshes?: boolean;
  50535. /**
  50536. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50537. * If not found, the xr input profile data will be used.
  50538. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50539. */
  50540. forceInputProfile?: string;
  50541. /**
  50542. * Do not send a request to the controller repository to load the profile.
  50543. *
  50544. * Instead, use the controllers available in babylon itself.
  50545. */
  50546. disableOnlineControllerRepository?: boolean;
  50547. /**
  50548. * A custom URL for the controllers repository
  50549. */
  50550. customControllersRepositoryURL?: string;
  50551. /**
  50552. * Should the controller model's components not move according to the user input
  50553. */
  50554. disableControllerAnimation?: boolean;
  50555. /**
  50556. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50557. */
  50558. controllerOptions?: IWebXRControllerOptions;
  50559. }
  50560. /**
  50561. * XR input used to track XR inputs such as controllers/rays
  50562. */
  50563. export class WebXRInput implements IDisposable {
  50564. /**
  50565. * the xr session manager for this session
  50566. */
  50567. xrSessionManager: WebXRSessionManager;
  50568. /**
  50569. * the WebXR camera for this session. Mainly used for teleportation
  50570. */
  50571. xrCamera: WebXRCamera;
  50572. private readonly options;
  50573. /**
  50574. * XR controllers being tracked
  50575. */
  50576. controllers: Array<WebXRInputSource>;
  50577. private _frameObserver;
  50578. private _sessionEndedObserver;
  50579. private _sessionInitObserver;
  50580. /**
  50581. * Event when a controller has been connected/added
  50582. */
  50583. onControllerAddedObservable: Observable<WebXRInputSource>;
  50584. /**
  50585. * Event when a controller has been removed/disconnected
  50586. */
  50587. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50588. /**
  50589. * Initializes the WebXRInput
  50590. * @param xrSessionManager the xr session manager for this session
  50591. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50592. * @param options = initialization options for this xr input
  50593. */
  50594. constructor(
  50595. /**
  50596. * the xr session manager for this session
  50597. */
  50598. xrSessionManager: WebXRSessionManager,
  50599. /**
  50600. * the WebXR camera for this session. Mainly used for teleportation
  50601. */
  50602. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50603. private _onInputSourcesChange;
  50604. private _addAndRemoveControllers;
  50605. /**
  50606. * Disposes of the object
  50607. */
  50608. dispose(): void;
  50609. }
  50610. }
  50611. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50612. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50613. import { Observable, EventState } from "babylonjs/Misc/observable";
  50614. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50615. /**
  50616. * This is the base class for all WebXR features.
  50617. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50618. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50619. */
  50620. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50621. protected _xrSessionManager: WebXRSessionManager;
  50622. private _attached;
  50623. private _removeOnDetach;
  50624. /**
  50625. * Is this feature disposed?
  50626. */
  50627. isDisposed: boolean;
  50628. /**
  50629. * Should auto-attach be disabled?
  50630. */
  50631. disableAutoAttach: boolean;
  50632. /**
  50633. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50634. */
  50635. xrNativeFeatureName: string;
  50636. /**
  50637. * Construct a new (abstract) WebXR feature
  50638. * @param _xrSessionManager the xr session manager for this feature
  50639. */
  50640. constructor(_xrSessionManager: WebXRSessionManager);
  50641. /**
  50642. * Is this feature attached
  50643. */
  50644. get attached(): boolean;
  50645. /**
  50646. * attach this feature
  50647. *
  50648. * @param force should attachment be forced (even when already attached)
  50649. * @returns true if successful, false is failed or already attached
  50650. */
  50651. attach(force?: boolean): boolean;
  50652. /**
  50653. * detach this feature.
  50654. *
  50655. * @returns true if successful, false if failed or already detached
  50656. */
  50657. detach(): boolean;
  50658. /**
  50659. * Dispose this feature and all of the resources attached
  50660. */
  50661. dispose(): void;
  50662. /**
  50663. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50664. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50665. *
  50666. * @returns whether or not the feature is compatible in this environment
  50667. */
  50668. isCompatible(): boolean;
  50669. /**
  50670. * This is used to register callbacks that will automatically be removed when detach is called.
  50671. * @param observable the observable to which the observer will be attached
  50672. * @param callback the callback to register
  50673. */
  50674. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50675. /**
  50676. * Code in this function will be executed on each xrFrame received from the browser.
  50677. * This function will not execute after the feature is detached.
  50678. * @param _xrFrame the current frame
  50679. */
  50680. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50681. }
  50682. }
  50683. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50684. import { IDisposable, Scene } from "babylonjs/scene";
  50685. import { Nullable } from "babylonjs/types";
  50686. import { Observable } from "babylonjs/Misc/observable";
  50687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50688. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50689. import { Camera } from "babylonjs/Cameras/camera";
  50690. /**
  50691. * Renders a layer on top of an existing scene
  50692. */
  50693. export class UtilityLayerRenderer implements IDisposable {
  50694. /** the original scene that will be rendered on top of */
  50695. originalScene: Scene;
  50696. private _pointerCaptures;
  50697. private _lastPointerEvents;
  50698. private static _DefaultUtilityLayer;
  50699. private static _DefaultKeepDepthUtilityLayer;
  50700. private _sharedGizmoLight;
  50701. private _renderCamera;
  50702. /**
  50703. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50704. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50705. * @returns the camera that is used when rendering the utility layer
  50706. */
  50707. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50708. /**
  50709. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50710. * @param cam the camera that should be used when rendering the utility layer
  50711. */
  50712. setRenderCamera(cam: Nullable<Camera>): void;
  50713. /**
  50714. * @hidden
  50715. * Light which used by gizmos to get light shading
  50716. */
  50717. _getSharedGizmoLight(): HemisphericLight;
  50718. /**
  50719. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50720. */
  50721. pickUtilitySceneFirst: boolean;
  50722. /**
  50723. * 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)
  50724. */
  50725. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50726. /**
  50727. * 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)
  50728. */
  50729. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50730. /**
  50731. * The scene that is rendered on top of the original scene
  50732. */
  50733. utilityLayerScene: Scene;
  50734. /**
  50735. * If the utility layer should automatically be rendered on top of existing scene
  50736. */
  50737. shouldRender: boolean;
  50738. /**
  50739. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50740. */
  50741. onlyCheckPointerDownEvents: boolean;
  50742. /**
  50743. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50744. */
  50745. processAllEvents: boolean;
  50746. /**
  50747. * Observable raised when the pointer move from the utility layer scene to the main scene
  50748. */
  50749. onPointerOutObservable: Observable<number>;
  50750. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50751. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50752. private _afterRenderObserver;
  50753. private _sceneDisposeObserver;
  50754. private _originalPointerObserver;
  50755. /**
  50756. * Instantiates a UtilityLayerRenderer
  50757. * @param originalScene the original scene that will be rendered on top of
  50758. * @param handleEvents boolean indicating if the utility layer should handle events
  50759. */
  50760. constructor(
  50761. /** the original scene that will be rendered on top of */
  50762. originalScene: Scene, handleEvents?: boolean);
  50763. private _notifyObservers;
  50764. /**
  50765. * Renders the utility layers scene on top of the original scene
  50766. */
  50767. render(): void;
  50768. /**
  50769. * Disposes of the renderer
  50770. */
  50771. dispose(): void;
  50772. private _updateCamera;
  50773. }
  50774. }
  50775. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50778. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50779. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50780. import { Scene } from "babylonjs/scene";
  50781. import { Nullable } from "babylonjs/types";
  50782. import { Color3 } from "babylonjs/Maths/math.color";
  50783. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50784. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50785. /**
  50786. * Options interface for the pointer selection module
  50787. */
  50788. export interface IWebXRControllerPointerSelectionOptions {
  50789. /**
  50790. * if provided, this scene will be used to render meshes.
  50791. */
  50792. customUtilityLayerScene?: Scene;
  50793. /**
  50794. * 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)
  50795. * If not disabled, the last picked point will be used to execute a pointer up event
  50796. * If disabled, pointer up event will be triggered right after the pointer down event.
  50797. * Used in screen and gaze target ray mode only
  50798. */
  50799. disablePointerUpOnTouchOut: boolean;
  50800. /**
  50801. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50802. */
  50803. forceGazeMode: boolean;
  50804. /**
  50805. * 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
  50806. * to start a new countdown to the pointer down event.
  50807. * Defaults to 1.
  50808. */
  50809. gazeModePointerMovedFactor?: number;
  50810. /**
  50811. * Different button type to use instead of the main component
  50812. */
  50813. overrideButtonId?: string;
  50814. /**
  50815. * use this rendering group id for the meshes (optional)
  50816. */
  50817. renderingGroupId?: number;
  50818. /**
  50819. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50820. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50821. * 3000 means 3 seconds between pointing at something and selecting it
  50822. */
  50823. timeToSelect?: number;
  50824. /**
  50825. * Should meshes created here be added to a utility layer or the main scene
  50826. */
  50827. useUtilityLayer?: boolean;
  50828. /**
  50829. * Optional WebXR camera to be used for gaze selection
  50830. */
  50831. gazeCamera?: WebXRCamera;
  50832. /**
  50833. * the xr input to use with this pointer selection
  50834. */
  50835. xrInput: WebXRInput;
  50836. }
  50837. /**
  50838. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50839. */
  50840. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50841. private readonly _options;
  50842. private static _idCounter;
  50843. private _attachController;
  50844. private _controllers;
  50845. private _scene;
  50846. private _tmpVectorForPickCompare;
  50847. /**
  50848. * The module's name
  50849. */
  50850. static readonly Name: string;
  50851. /**
  50852. * The (Babylon) version of this module.
  50853. * This is an integer representing the implementation version.
  50854. * This number does not correspond to the WebXR specs version
  50855. */
  50856. static readonly Version: number;
  50857. /**
  50858. * Disable lighting on the laser pointer (so it will always be visible)
  50859. */
  50860. disablePointerLighting: boolean;
  50861. /**
  50862. * Disable lighting on the selection mesh (so it will always be visible)
  50863. */
  50864. disableSelectionMeshLighting: boolean;
  50865. /**
  50866. * Should the laser pointer be displayed
  50867. */
  50868. displayLaserPointer: boolean;
  50869. /**
  50870. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50871. */
  50872. displaySelectionMesh: boolean;
  50873. /**
  50874. * This color will be set to the laser pointer when selection is triggered
  50875. */
  50876. laserPointerPickedColor: Color3;
  50877. /**
  50878. * Default color of the laser pointer
  50879. */
  50880. laserPointerDefaultColor: Color3;
  50881. /**
  50882. * default color of the selection ring
  50883. */
  50884. selectionMeshDefaultColor: Color3;
  50885. /**
  50886. * This color will be applied to the selection ring when selection is triggered
  50887. */
  50888. selectionMeshPickedColor: Color3;
  50889. /**
  50890. * Optional filter to be used for ray selection. This predicate shares behavior with
  50891. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50892. */
  50893. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50894. /**
  50895. * constructs a new background remover module
  50896. * @param _xrSessionManager the session manager for this module
  50897. * @param _options read-only options to be used in this module
  50898. */
  50899. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50900. /**
  50901. * attach this feature
  50902. * Will usually be called by the features manager
  50903. *
  50904. * @returns true if successful.
  50905. */
  50906. attach(): boolean;
  50907. /**
  50908. * detach this feature.
  50909. * Will usually be called by the features manager
  50910. *
  50911. * @returns true if successful.
  50912. */
  50913. detach(): boolean;
  50914. /**
  50915. * Will get the mesh under a specific pointer.
  50916. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50917. * @param controllerId the controllerId to check
  50918. * @returns The mesh under pointer or null if no mesh is under the pointer
  50919. */
  50920. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50921. /**
  50922. * Get the xr controller that correlates to the pointer id in the pointer event
  50923. *
  50924. * @param id the pointer id to search for
  50925. * @returns the controller that correlates to this id or null if not found
  50926. */
  50927. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50928. protected _onXRFrame(_xrFrame: XRFrame): void;
  50929. private _attachGazeMode;
  50930. private _attachScreenRayMode;
  50931. private _attachTrackedPointerRayMode;
  50932. private _convertNormalToDirectionOfRay;
  50933. private _detachController;
  50934. private _generateNewMeshPair;
  50935. private _pickingMoved;
  50936. private _updatePointerDistance;
  50937. /** @hidden */
  50938. get lasterPointerDefaultColor(): Color3;
  50939. }
  50940. }
  50941. declare module "babylonjs/XR/webXREnterExitUI" {
  50942. import { Nullable } from "babylonjs/types";
  50943. import { Observable } from "babylonjs/Misc/observable";
  50944. import { IDisposable, Scene } from "babylonjs/scene";
  50945. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50946. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50947. /**
  50948. * Button which can be used to enter a different mode of XR
  50949. */
  50950. export class WebXREnterExitUIButton {
  50951. /** button element */
  50952. element: HTMLElement;
  50953. /** XR initialization options for the button */
  50954. sessionMode: XRSessionMode;
  50955. /** Reference space type */
  50956. referenceSpaceType: XRReferenceSpaceType;
  50957. /**
  50958. * Creates a WebXREnterExitUIButton
  50959. * @param element button element
  50960. * @param sessionMode XR initialization session mode
  50961. * @param referenceSpaceType the type of reference space to be used
  50962. */
  50963. constructor(
  50964. /** button element */
  50965. element: HTMLElement,
  50966. /** XR initialization options for the button */
  50967. sessionMode: XRSessionMode,
  50968. /** Reference space type */
  50969. referenceSpaceType: XRReferenceSpaceType);
  50970. /**
  50971. * Extendable function which can be used to update the button's visuals when the state changes
  50972. * @param activeButton the current active button in the UI
  50973. */
  50974. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50975. }
  50976. /**
  50977. * Options to create the webXR UI
  50978. */
  50979. export class WebXREnterExitUIOptions {
  50980. /**
  50981. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50982. */
  50983. customButtons?: Array<WebXREnterExitUIButton>;
  50984. /**
  50985. * A reference space type to use when creating the default button.
  50986. * Default is local-floor
  50987. */
  50988. referenceSpaceType?: XRReferenceSpaceType;
  50989. /**
  50990. * Context to enter xr with
  50991. */
  50992. renderTarget?: Nullable<WebXRRenderTarget>;
  50993. /**
  50994. * A session mode to use when creating the default button.
  50995. * Default is immersive-vr
  50996. */
  50997. sessionMode?: XRSessionMode;
  50998. /**
  50999. * A list of optional features to init the session with
  51000. */
  51001. optionalFeatures?: string[];
  51002. /**
  51003. * A list of optional features to init the session with
  51004. */
  51005. requiredFeatures?: string[];
  51006. }
  51007. /**
  51008. * UI to allow the user to enter/exit XR mode
  51009. */
  51010. export class WebXREnterExitUI implements IDisposable {
  51011. private scene;
  51012. /** version of the options passed to this UI */
  51013. options: WebXREnterExitUIOptions;
  51014. private _activeButton;
  51015. private _buttons;
  51016. /**
  51017. * The HTML Div Element to which buttons are added.
  51018. */
  51019. readonly overlay: HTMLDivElement;
  51020. /**
  51021. * Fired every time the active button is changed.
  51022. *
  51023. * When xr is entered via a button that launches xr that button will be the callback parameter
  51024. *
  51025. * When exiting xr the callback parameter will be null)
  51026. */
  51027. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51028. /**
  51029. *
  51030. * @param scene babylon scene object to use
  51031. * @param options (read-only) version of the options passed to this UI
  51032. */
  51033. private constructor();
  51034. /**
  51035. * Creates UI to allow the user to enter/exit XR mode
  51036. * @param scene the scene to add the ui to
  51037. * @param helper the xr experience helper to enter/exit xr with
  51038. * @param options options to configure the UI
  51039. * @returns the created ui
  51040. */
  51041. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51042. /**
  51043. * Disposes of the XR UI component
  51044. */
  51045. dispose(): void;
  51046. private _updateButtons;
  51047. }
  51048. }
  51049. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51050. import { Vector3 } from "babylonjs/Maths/math.vector";
  51051. import { Color4 } from "babylonjs/Maths/math.color";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51054. import { Scene } from "babylonjs/scene";
  51055. /**
  51056. * Class containing static functions to help procedurally build meshes
  51057. */
  51058. export class LinesBuilder {
  51059. /**
  51060. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51061. * * 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
  51062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51063. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51064. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51065. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51067. * * 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
  51068. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51071. * @param name defines the name of the new line system
  51072. * @param options defines the options used to create the line system
  51073. * @param scene defines the hosting scene
  51074. * @returns a new line system mesh
  51075. */
  51076. static CreateLineSystem(name: string, options: {
  51077. lines: Vector3[][];
  51078. updatable?: boolean;
  51079. instance?: Nullable<LinesMesh>;
  51080. colors?: Nullable<Color4[][]>;
  51081. useVertexAlpha?: boolean;
  51082. }, scene: Nullable<Scene>): LinesMesh;
  51083. /**
  51084. * Creates a line mesh
  51085. * 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
  51086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51087. * * The parameter `points` is an array successive Vector3
  51088. * * 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
  51089. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51091. * * When updating an instance, remember that only point positions can change, not the number of points
  51092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51094. * @param name defines the name of the new line system
  51095. * @param options defines the options used to create the line system
  51096. * @param scene defines the hosting scene
  51097. * @returns a new line mesh
  51098. */
  51099. static CreateLines(name: string, options: {
  51100. points: Vector3[];
  51101. updatable?: boolean;
  51102. instance?: Nullable<LinesMesh>;
  51103. colors?: Color4[];
  51104. useVertexAlpha?: boolean;
  51105. }, scene?: Nullable<Scene>): LinesMesh;
  51106. /**
  51107. * Creates a dashed line mesh
  51108. * * 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
  51109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51110. * * The parameter `points` is an array successive Vector3
  51111. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51112. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51113. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51114. * * 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
  51115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51116. * * When updating an instance, remember that only point positions can change, not the number of points
  51117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51118. * @param name defines the name of the mesh
  51119. * @param options defines the options used to create the mesh
  51120. * @param scene defines the hosting scene
  51121. * @returns the dashed line mesh
  51122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51123. */
  51124. static CreateDashedLines(name: string, options: {
  51125. points: Vector3[];
  51126. dashSize?: number;
  51127. gapSize?: number;
  51128. dashNb?: number;
  51129. updatable?: boolean;
  51130. instance?: LinesMesh;
  51131. useVertexAlpha?: boolean;
  51132. }, scene?: Nullable<Scene>): LinesMesh;
  51133. }
  51134. }
  51135. declare module "babylonjs/Misc/timer" {
  51136. import { Observable, Observer } from "babylonjs/Misc/observable";
  51137. import { Nullable } from "babylonjs/types";
  51138. import { IDisposable } from "babylonjs/scene";
  51139. /**
  51140. * Construction options for a timer
  51141. */
  51142. export interface ITimerOptions<T> {
  51143. /**
  51144. * Time-to-end
  51145. */
  51146. timeout: number;
  51147. /**
  51148. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51149. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51150. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51151. */
  51152. contextObservable: Observable<T>;
  51153. /**
  51154. * Optional parameters when adding an observer to the observable
  51155. */
  51156. observableParameters?: {
  51157. mask?: number;
  51158. insertFirst?: boolean;
  51159. scope?: any;
  51160. };
  51161. /**
  51162. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51163. */
  51164. breakCondition?: (data?: ITimerData<T>) => boolean;
  51165. /**
  51166. * Will be triggered when the time condition has met
  51167. */
  51168. onEnded?: (data: ITimerData<any>) => void;
  51169. /**
  51170. * Will be triggered when the break condition has met (prematurely ended)
  51171. */
  51172. onAborted?: (data: ITimerData<any>) => void;
  51173. /**
  51174. * Optional function to execute on each tick (or count)
  51175. */
  51176. onTick?: (data: ITimerData<any>) => void;
  51177. }
  51178. /**
  51179. * An interface defining the data sent by the timer
  51180. */
  51181. export interface ITimerData<T> {
  51182. /**
  51183. * When did it start
  51184. */
  51185. startTime: number;
  51186. /**
  51187. * Time now
  51188. */
  51189. currentTime: number;
  51190. /**
  51191. * Time passed since started
  51192. */
  51193. deltaTime: number;
  51194. /**
  51195. * How much is completed, in [0.0...1.0].
  51196. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51197. */
  51198. completeRate: number;
  51199. /**
  51200. * What the registered observable sent in the last count
  51201. */
  51202. payload: T;
  51203. }
  51204. /**
  51205. * The current state of the timer
  51206. */
  51207. export enum TimerState {
  51208. /**
  51209. * Timer initialized, not yet started
  51210. */
  51211. INIT = 0,
  51212. /**
  51213. * Timer started and counting
  51214. */
  51215. STARTED = 1,
  51216. /**
  51217. * Timer ended (whether aborted or time reached)
  51218. */
  51219. ENDED = 2
  51220. }
  51221. /**
  51222. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51223. *
  51224. * @param options options with which to initialize this timer
  51225. */
  51226. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51227. /**
  51228. * An advanced implementation of a timer class
  51229. */
  51230. export class AdvancedTimer<T = any> implements IDisposable {
  51231. /**
  51232. * Will notify each time the timer calculates the remaining time
  51233. */
  51234. onEachCountObservable: Observable<ITimerData<T>>;
  51235. /**
  51236. * Will trigger when the timer was aborted due to the break condition
  51237. */
  51238. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51239. /**
  51240. * Will trigger when the timer ended successfully
  51241. */
  51242. onTimerEndedObservable: Observable<ITimerData<T>>;
  51243. /**
  51244. * Will trigger when the timer state has changed
  51245. */
  51246. onStateChangedObservable: Observable<TimerState>;
  51247. private _observer;
  51248. private _contextObservable;
  51249. private _observableParameters;
  51250. private _startTime;
  51251. private _timer;
  51252. private _state;
  51253. private _breakCondition;
  51254. private _timeToEnd;
  51255. private _breakOnNextTick;
  51256. /**
  51257. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51258. * @param options construction options for this advanced timer
  51259. */
  51260. constructor(options: ITimerOptions<T>);
  51261. /**
  51262. * set a breaking condition for this timer. Default is to never break during count
  51263. * @param predicate the new break condition. Returns true to break, false otherwise
  51264. */
  51265. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51266. /**
  51267. * Reset ALL associated observables in this advanced timer
  51268. */
  51269. clearObservables(): void;
  51270. /**
  51271. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51272. *
  51273. * @param timeToEnd how much time to measure until timer ended
  51274. */
  51275. start(timeToEnd?: number): void;
  51276. /**
  51277. * Will force a stop on the next tick.
  51278. */
  51279. stop(): void;
  51280. /**
  51281. * Dispose this timer, clearing all resources
  51282. */
  51283. dispose(): void;
  51284. private _setState;
  51285. private _tick;
  51286. private _stop;
  51287. }
  51288. }
  51289. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51290. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51291. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51292. import { Nullable } from "babylonjs/types";
  51293. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51295. import { Vector3 } from "babylonjs/Maths/math.vector";
  51296. import { Material } from "babylonjs/Materials/material";
  51297. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51298. import { Scene } from "babylonjs/scene";
  51299. /**
  51300. * The options container for the teleportation module
  51301. */
  51302. export interface IWebXRTeleportationOptions {
  51303. /**
  51304. * if provided, this scene will be used to render meshes.
  51305. */
  51306. customUtilityLayerScene?: Scene;
  51307. /**
  51308. * Values to configure the default target mesh
  51309. */
  51310. defaultTargetMeshOptions?: {
  51311. /**
  51312. * Fill color of the teleportation area
  51313. */
  51314. teleportationFillColor?: string;
  51315. /**
  51316. * Border color for the teleportation area
  51317. */
  51318. teleportationBorderColor?: string;
  51319. /**
  51320. * Disable the mesh's animation sequence
  51321. */
  51322. disableAnimation?: boolean;
  51323. /**
  51324. * Disable lighting on the material or the ring and arrow
  51325. */
  51326. disableLighting?: boolean;
  51327. /**
  51328. * Override the default material of the torus and arrow
  51329. */
  51330. torusArrowMaterial?: Material;
  51331. };
  51332. /**
  51333. * A list of meshes to use as floor meshes.
  51334. * Meshes can be added and removed after initializing the feature using the
  51335. * addFloorMesh and removeFloorMesh functions
  51336. * If empty, rotation will still work
  51337. */
  51338. floorMeshes?: AbstractMesh[];
  51339. /**
  51340. * use this rendering group id for the meshes (optional)
  51341. */
  51342. renderingGroupId?: number;
  51343. /**
  51344. * Should teleportation move only to snap points
  51345. */
  51346. snapPointsOnly?: boolean;
  51347. /**
  51348. * An array of points to which the teleportation will snap to.
  51349. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51350. */
  51351. snapPositions?: Vector3[];
  51352. /**
  51353. * How close should the teleportation ray be in order to snap to position.
  51354. * Default to 0.8 units (meters)
  51355. */
  51356. snapToPositionRadius?: number;
  51357. /**
  51358. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51359. * If you want to support rotation, make sure your mesh has a direction indicator.
  51360. *
  51361. * When left untouched, the default mesh will be initialized.
  51362. */
  51363. teleportationTargetMesh?: AbstractMesh;
  51364. /**
  51365. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51366. */
  51367. timeToTeleport?: number;
  51368. /**
  51369. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51370. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51371. */
  51372. useMainComponentOnly?: boolean;
  51373. /**
  51374. * Should meshes created here be added to a utility layer or the main scene
  51375. */
  51376. useUtilityLayer?: boolean;
  51377. /**
  51378. * Babylon XR Input class for controller
  51379. */
  51380. xrInput: WebXRInput;
  51381. /**
  51382. * Meshes that the teleportation ray cannot go through
  51383. */
  51384. pickBlockerMeshes?: AbstractMesh[];
  51385. }
  51386. /**
  51387. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51388. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51389. * the input of the attached controllers.
  51390. */
  51391. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51392. private _options;
  51393. private _controllers;
  51394. private _currentTeleportationControllerId;
  51395. private _floorMeshes;
  51396. private _quadraticBezierCurve;
  51397. private _selectionFeature;
  51398. private _snapToPositions;
  51399. private _snappedToPoint;
  51400. private _teleportationRingMaterial?;
  51401. private _tmpRay;
  51402. private _tmpVector;
  51403. private _tmpQuaternion;
  51404. /**
  51405. * The module's name
  51406. */
  51407. static readonly Name: string;
  51408. /**
  51409. * The (Babylon) version of this module.
  51410. * This is an integer representing the implementation version.
  51411. * This number does not correspond to the webxr specs version
  51412. */
  51413. static readonly Version: number;
  51414. /**
  51415. * Is movement backwards enabled
  51416. */
  51417. backwardsMovementEnabled: boolean;
  51418. /**
  51419. * Distance to travel when moving backwards
  51420. */
  51421. backwardsTeleportationDistance: number;
  51422. /**
  51423. * The distance from the user to the inspection point in the direction of the controller
  51424. * A higher number will allow the user to move further
  51425. * defaults to 5 (meters, in xr units)
  51426. */
  51427. parabolicCheckRadius: number;
  51428. /**
  51429. * Should the module support parabolic ray on top of direct ray
  51430. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51431. * Very helpful when moving between floors / different heights
  51432. */
  51433. parabolicRayEnabled: boolean;
  51434. /**
  51435. * How much rotation should be applied when rotating right and left
  51436. */
  51437. rotationAngle: number;
  51438. /**
  51439. * Is rotation enabled when moving forward?
  51440. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51441. */
  51442. rotationEnabled: boolean;
  51443. /**
  51444. * constructs a new anchor system
  51445. * @param _xrSessionManager an instance of WebXRSessionManager
  51446. * @param _options configuration object for this feature
  51447. */
  51448. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51449. /**
  51450. * Get the snapPointsOnly flag
  51451. */
  51452. get snapPointsOnly(): boolean;
  51453. /**
  51454. * Sets the snapPointsOnly flag
  51455. * @param snapToPoints should teleportation be exclusively to snap points
  51456. */
  51457. set snapPointsOnly(snapToPoints: boolean);
  51458. /**
  51459. * Add a new mesh to the floor meshes array
  51460. * @param mesh the mesh to use as floor mesh
  51461. */
  51462. addFloorMesh(mesh: AbstractMesh): void;
  51463. /**
  51464. * Add a new snap-to point to fix teleportation to this position
  51465. * @param newSnapPoint The new Snap-To point
  51466. */
  51467. addSnapPoint(newSnapPoint: Vector3): void;
  51468. attach(): boolean;
  51469. detach(): boolean;
  51470. dispose(): void;
  51471. /**
  51472. * Remove a mesh from the floor meshes array
  51473. * @param mesh the mesh to remove
  51474. */
  51475. removeFloorMesh(mesh: AbstractMesh): void;
  51476. /**
  51477. * Remove a mesh from the floor meshes array using its name
  51478. * @param name the mesh name to remove
  51479. */
  51480. removeFloorMeshByName(name: string): void;
  51481. /**
  51482. * 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
  51483. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51484. * @returns was the point found and removed or not
  51485. */
  51486. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51487. /**
  51488. * This function sets a selection feature that will be disabled when
  51489. * the forward ray is shown and will be reattached when hidden.
  51490. * This is used to remove the selection rays when moving.
  51491. * @param selectionFeature the feature to disable when forward movement is enabled
  51492. */
  51493. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51494. protected _onXRFrame(_xrFrame: XRFrame): void;
  51495. private _attachController;
  51496. private _createDefaultTargetMesh;
  51497. private _detachController;
  51498. private _findClosestSnapPointWithRadius;
  51499. private _setTargetMeshPosition;
  51500. private _setTargetMeshVisibility;
  51501. private _showParabolicPath;
  51502. private _teleportForward;
  51503. }
  51504. }
  51505. declare module "babylonjs/XR/webXRDefaultExperience" {
  51506. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51507. import { Scene } from "babylonjs/scene";
  51508. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51509. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51510. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51511. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51513. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51514. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51515. /**
  51516. * Options for the default xr helper
  51517. */
  51518. export class WebXRDefaultExperienceOptions {
  51519. /**
  51520. * Enable or disable default UI to enter XR
  51521. */
  51522. disableDefaultUI?: boolean;
  51523. /**
  51524. * Should teleportation not initialize. defaults to false.
  51525. */
  51526. disableTeleportation?: boolean;
  51527. /**
  51528. * Floor meshes that will be used for teleport
  51529. */
  51530. floorMeshes?: Array<AbstractMesh>;
  51531. /**
  51532. * If set to true, the first frame will not be used to reset position
  51533. * The first frame is mainly used when copying transformation from the old camera
  51534. * Mainly used in AR
  51535. */
  51536. ignoreNativeCameraTransformation?: boolean;
  51537. /**
  51538. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51539. */
  51540. inputOptions?: IWebXRInputOptions;
  51541. /**
  51542. * optional configuration for the output canvas
  51543. */
  51544. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51545. /**
  51546. * optional UI options. This can be used among other to change session mode and reference space type
  51547. */
  51548. uiOptions?: WebXREnterExitUIOptions;
  51549. /**
  51550. * When loading teleportation and pointer select, use stable versions instead of latest.
  51551. */
  51552. useStablePlugins?: boolean;
  51553. /**
  51554. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51555. */
  51556. renderingGroupId?: number;
  51557. /**
  51558. * A list of optional features to init the session with
  51559. * If set to true, all features we support will be added
  51560. */
  51561. optionalFeatures?: boolean | string[];
  51562. }
  51563. /**
  51564. * Default experience which provides a similar setup to the previous webVRExperience
  51565. */
  51566. export class WebXRDefaultExperience {
  51567. /**
  51568. * Base experience
  51569. */
  51570. baseExperience: WebXRExperienceHelper;
  51571. /**
  51572. * Enables ui for entering/exiting xr
  51573. */
  51574. enterExitUI: WebXREnterExitUI;
  51575. /**
  51576. * Input experience extension
  51577. */
  51578. input: WebXRInput;
  51579. /**
  51580. * Enables laser pointer and selection
  51581. */
  51582. pointerSelection: WebXRControllerPointerSelection;
  51583. /**
  51584. * Default target xr should render to
  51585. */
  51586. renderTarget: WebXRRenderTarget;
  51587. /**
  51588. * Enables teleportation
  51589. */
  51590. teleportation: WebXRMotionControllerTeleportation;
  51591. private constructor();
  51592. /**
  51593. * Creates the default xr experience
  51594. * @param scene scene
  51595. * @param options options for basic configuration
  51596. * @returns resulting WebXRDefaultExperience
  51597. */
  51598. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51599. /**
  51600. * DIsposes of the experience helper
  51601. */
  51602. dispose(): void;
  51603. }
  51604. }
  51605. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51606. import { Observable } from "babylonjs/Misc/observable";
  51607. import { Nullable } from "babylonjs/types";
  51608. import { Camera } from "babylonjs/Cameras/camera";
  51609. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51610. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51611. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51612. import { Scene } from "babylonjs/scene";
  51613. import { Vector3 } from "babylonjs/Maths/math.vector";
  51614. import { Color3 } from "babylonjs/Maths/math.color";
  51615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51617. import { Mesh } from "babylonjs/Meshes/mesh";
  51618. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51619. import { EasingFunction } from "babylonjs/Animations/easing";
  51620. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51621. import "babylonjs/Meshes/Builders/groundBuilder";
  51622. import "babylonjs/Meshes/Builders/torusBuilder";
  51623. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51624. import "babylonjs/Gamepads/gamepadSceneComponent";
  51625. import "babylonjs/Animations/animatable";
  51626. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51627. /**
  51628. * Options to modify the vr teleportation behavior.
  51629. */
  51630. export interface VRTeleportationOptions {
  51631. /**
  51632. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51633. */
  51634. floorMeshName?: string;
  51635. /**
  51636. * A list of meshes to be used as the teleportation floor. (default: empty)
  51637. */
  51638. floorMeshes?: Mesh[];
  51639. /**
  51640. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51641. */
  51642. teleportationMode?: number;
  51643. /**
  51644. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51645. */
  51646. teleportationTime?: number;
  51647. /**
  51648. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51649. */
  51650. teleportationSpeed?: number;
  51651. /**
  51652. * The easing function used in the animation or null for Linear. (default CircleEase)
  51653. */
  51654. easingFunction?: EasingFunction;
  51655. }
  51656. /**
  51657. * Options to modify the vr experience helper's behavior.
  51658. */
  51659. export interface VRExperienceHelperOptions extends WebVROptions {
  51660. /**
  51661. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51662. */
  51663. createDeviceOrientationCamera?: boolean;
  51664. /**
  51665. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51666. */
  51667. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51668. /**
  51669. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51670. */
  51671. laserToggle?: boolean;
  51672. /**
  51673. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51674. */
  51675. floorMeshes?: Mesh[];
  51676. /**
  51677. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51678. */
  51679. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51680. /**
  51681. * Defines if WebXR should be used instead of WebVR (if available)
  51682. */
  51683. useXR?: boolean;
  51684. }
  51685. /**
  51686. * Event containing information after VR has been entered
  51687. */
  51688. export class OnAfterEnteringVRObservableEvent {
  51689. /**
  51690. * If entering vr was successful
  51691. */
  51692. success: boolean;
  51693. }
  51694. /**
  51695. * Helps to quickly add VR support to an existing scene.
  51696. * See https://doc.babylonjs.com/how_to/webvr_helper
  51697. */
  51698. export class VRExperienceHelper {
  51699. /** Options to modify the vr experience helper's behavior. */
  51700. webVROptions: VRExperienceHelperOptions;
  51701. private _scene;
  51702. private _position;
  51703. private _btnVR;
  51704. private _btnVRDisplayed;
  51705. private _webVRsupported;
  51706. private _webVRready;
  51707. private _webVRrequesting;
  51708. private _webVRpresenting;
  51709. private _hasEnteredVR;
  51710. private _fullscreenVRpresenting;
  51711. private _inputElement;
  51712. private _webVRCamera;
  51713. private _vrDeviceOrientationCamera;
  51714. private _deviceOrientationCamera;
  51715. private _existingCamera;
  51716. private _onKeyDown;
  51717. private _onVrDisplayPresentChange;
  51718. private _onVRDisplayChanged;
  51719. private _onVRRequestPresentStart;
  51720. private _onVRRequestPresentComplete;
  51721. /**
  51722. * 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)
  51723. */
  51724. enableGazeEvenWhenNoPointerLock: boolean;
  51725. /**
  51726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51727. */
  51728. exitVROnDoubleTap: boolean;
  51729. /**
  51730. * Observable raised right before entering VR.
  51731. */
  51732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51733. /**
  51734. * Observable raised when entering VR has completed.
  51735. */
  51736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51737. /**
  51738. * Observable raised when exiting VR.
  51739. */
  51740. onExitingVRObservable: Observable<VRExperienceHelper>;
  51741. /**
  51742. * Observable raised when controller mesh is loaded.
  51743. */
  51744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51745. /** Return this.onEnteringVRObservable
  51746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51747. */
  51748. get onEnteringVR(): Observable<VRExperienceHelper>;
  51749. /** Return this.onExitingVRObservable
  51750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51751. */
  51752. get onExitingVR(): Observable<VRExperienceHelper>;
  51753. /** Return this.onControllerMeshLoadedObservable
  51754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51755. */
  51756. get onControllerMeshLoaded(): Observable<WebVRController>;
  51757. private _rayLength;
  51758. private _useCustomVRButton;
  51759. private _teleportationRequested;
  51760. private _teleportActive;
  51761. private _floorMeshName;
  51762. private _floorMeshesCollection;
  51763. private _teleportationMode;
  51764. private _teleportationTime;
  51765. private _teleportationSpeed;
  51766. private _teleportationEasing;
  51767. private _rotationAllowed;
  51768. private _teleportBackwardsVector;
  51769. private _teleportationTarget;
  51770. private _isDefaultTeleportationTarget;
  51771. private _postProcessMove;
  51772. private _teleportationFillColor;
  51773. private _teleportationBorderColor;
  51774. private _rotationAngle;
  51775. private _haloCenter;
  51776. private _cameraGazer;
  51777. private _padSensibilityUp;
  51778. private _padSensibilityDown;
  51779. private _leftController;
  51780. private _rightController;
  51781. private _gazeColor;
  51782. private _laserColor;
  51783. private _pickedLaserColor;
  51784. private _pickedGazeColor;
  51785. /**
  51786. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51787. */
  51788. onNewMeshSelected: Observable<AbstractMesh>;
  51789. /**
  51790. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51791. * This observable will provide the mesh and the controller used to select the mesh
  51792. */
  51793. onMeshSelectedWithController: Observable<{
  51794. mesh: AbstractMesh;
  51795. controller: WebVRController;
  51796. }>;
  51797. /**
  51798. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51799. */
  51800. onNewMeshPicked: Observable<PickingInfo>;
  51801. private _circleEase;
  51802. /**
  51803. * Observable raised before camera teleportation
  51804. */
  51805. onBeforeCameraTeleport: Observable<Vector3>;
  51806. /**
  51807. * Observable raised after camera teleportation
  51808. */
  51809. onAfterCameraTeleport: Observable<Vector3>;
  51810. /**
  51811. * Observable raised when current selected mesh gets unselected
  51812. */
  51813. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51814. private _raySelectionPredicate;
  51815. /**
  51816. * To be optionaly changed by user to define custom ray selection
  51817. */
  51818. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51819. /**
  51820. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51821. */
  51822. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51823. /**
  51824. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51825. */
  51826. teleportationEnabled: boolean;
  51827. private _defaultHeight;
  51828. private _teleportationInitialized;
  51829. private _interactionsEnabled;
  51830. private _interactionsRequested;
  51831. private _displayGaze;
  51832. private _displayLaserPointer;
  51833. /**
  51834. * The mesh used to display where the user is going to teleport.
  51835. */
  51836. get teleportationTarget(): Mesh;
  51837. /**
  51838. * Sets the mesh to be used to display where the user is going to teleport.
  51839. */
  51840. set teleportationTarget(value: Mesh);
  51841. /**
  51842. * 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
  51843. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51844. * See https://doc.babylonjs.com/resources/baking_transformations
  51845. */
  51846. get gazeTrackerMesh(): Mesh;
  51847. set gazeTrackerMesh(value: Mesh);
  51848. /**
  51849. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51850. */
  51851. updateGazeTrackerScale: boolean;
  51852. /**
  51853. * If the gaze trackers color should be updated when selecting meshes
  51854. */
  51855. updateGazeTrackerColor: boolean;
  51856. /**
  51857. * If the controller laser color should be updated when selecting meshes
  51858. */
  51859. updateControllerLaserColor: boolean;
  51860. /**
  51861. * The gaze tracking mesh corresponding to the left controller
  51862. */
  51863. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51864. /**
  51865. * The gaze tracking mesh corresponding to the right controller
  51866. */
  51867. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51868. /**
  51869. * If the ray of the gaze should be displayed.
  51870. */
  51871. get displayGaze(): boolean;
  51872. /**
  51873. * Sets if the ray of the gaze should be displayed.
  51874. */
  51875. set displayGaze(value: boolean);
  51876. /**
  51877. * If the ray of the LaserPointer should be displayed.
  51878. */
  51879. get displayLaserPointer(): boolean;
  51880. /**
  51881. * Sets if the ray of the LaserPointer should be displayed.
  51882. */
  51883. set displayLaserPointer(value: boolean);
  51884. /**
  51885. * The deviceOrientationCamera used as the camera when not in VR.
  51886. */
  51887. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51888. /**
  51889. * Based on the current WebVR support, returns the current VR camera used.
  51890. */
  51891. get currentVRCamera(): Nullable<Camera>;
  51892. /**
  51893. * The webVRCamera which is used when in VR.
  51894. */
  51895. get webVRCamera(): WebVRFreeCamera;
  51896. /**
  51897. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51898. */
  51899. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51900. /**
  51901. * The html button that is used to trigger entering into VR.
  51902. */
  51903. get vrButton(): Nullable<HTMLButtonElement>;
  51904. private get _teleportationRequestInitiated();
  51905. /**
  51906. * Defines whether or not Pointer lock should be requested when switching to
  51907. * full screen.
  51908. */
  51909. requestPointerLockOnFullScreen: boolean;
  51910. /**
  51911. * If asking to force XR, this will be populated with the default xr experience
  51912. */
  51913. xr: WebXRDefaultExperience;
  51914. /**
  51915. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51916. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51917. */
  51918. xrTestDone: boolean;
  51919. /**
  51920. * Instantiates a VRExperienceHelper.
  51921. * Helps to quickly add VR support to an existing scene.
  51922. * @param scene The scene the VRExperienceHelper belongs to.
  51923. * @param webVROptions Options to modify the vr experience helper's behavior.
  51924. */
  51925. constructor(scene: Scene,
  51926. /** Options to modify the vr experience helper's behavior. */
  51927. webVROptions?: VRExperienceHelperOptions);
  51928. private completeVRInit;
  51929. private _onDefaultMeshLoaded;
  51930. private _onResize;
  51931. private _onFullscreenChange;
  51932. /**
  51933. * Gets a value indicating if we are currently in VR mode.
  51934. */
  51935. get isInVRMode(): boolean;
  51936. private onVrDisplayPresentChange;
  51937. private onVRDisplayChanged;
  51938. private moveButtonToBottomRight;
  51939. private displayVRButton;
  51940. private updateButtonVisibility;
  51941. private _cachedAngularSensibility;
  51942. /**
  51943. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51944. * Otherwise, will use the fullscreen API.
  51945. */
  51946. enterVR(): void;
  51947. /**
  51948. * Attempt to exit VR, or fullscreen.
  51949. */
  51950. exitVR(): void;
  51951. /**
  51952. * The position of the vr experience helper.
  51953. */
  51954. get position(): Vector3;
  51955. /**
  51956. * Sets the position of the vr experience helper.
  51957. */
  51958. set position(value: Vector3);
  51959. /**
  51960. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51961. */
  51962. enableInteractions(): void;
  51963. private get _noControllerIsActive();
  51964. private beforeRender;
  51965. private _isTeleportationFloor;
  51966. /**
  51967. * Adds a floor mesh to be used for teleportation.
  51968. * @param floorMesh the mesh to be used for teleportation.
  51969. */
  51970. addFloorMesh(floorMesh: Mesh): void;
  51971. /**
  51972. * Removes a floor mesh from being used for teleportation.
  51973. * @param floorMesh the mesh to be removed.
  51974. */
  51975. removeFloorMesh(floorMesh: Mesh): void;
  51976. /**
  51977. * Enables interactions and teleportation using the VR controllers and gaze.
  51978. * @param vrTeleportationOptions options to modify teleportation behavior.
  51979. */
  51980. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51981. private _onNewGamepadConnected;
  51982. private _tryEnableInteractionOnController;
  51983. private _onNewGamepadDisconnected;
  51984. private _enableInteractionOnController;
  51985. private _checkTeleportWithRay;
  51986. private _checkRotate;
  51987. private _checkTeleportBackwards;
  51988. private _enableTeleportationOnController;
  51989. private _createTeleportationCircles;
  51990. private _displayTeleportationTarget;
  51991. private _hideTeleportationTarget;
  51992. private _rotateCamera;
  51993. private _moveTeleportationSelectorTo;
  51994. private _workingVector;
  51995. private _workingQuaternion;
  51996. private _workingMatrix;
  51997. /**
  51998. * Time Constant Teleportation Mode
  51999. */
  52000. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52001. /**
  52002. * Speed Constant Teleportation Mode
  52003. */
  52004. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52005. /**
  52006. * Teleports the users feet to the desired location
  52007. * @param location The location where the user's feet should be placed
  52008. */
  52009. teleportCamera(location: Vector3): void;
  52010. private _convertNormalToDirectionOfRay;
  52011. private _castRayAndSelectObject;
  52012. private _notifySelectedMeshUnselected;
  52013. /**
  52014. * Permanently set new colors for the laser pointer
  52015. * @param color the new laser color
  52016. * @param pickedColor the new laser color when picked mesh detected
  52017. */
  52018. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52019. /**
  52020. * Set lighting enabled / disabled on the laser pointer of both controllers
  52021. * @param enabled should the lighting be enabled on the laser pointer
  52022. */
  52023. setLaserLightingState(enabled?: boolean): void;
  52024. /**
  52025. * Permanently set new colors for the gaze pointer
  52026. * @param color the new gaze color
  52027. * @param pickedColor the new gaze color when picked mesh detected
  52028. */
  52029. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52030. /**
  52031. * Sets the color of the laser ray from the vr controllers.
  52032. * @param color new color for the ray.
  52033. */
  52034. changeLaserColor(color: Color3): void;
  52035. /**
  52036. * Sets the color of the ray from the vr headsets gaze.
  52037. * @param color new color for the ray.
  52038. */
  52039. changeGazeColor(color: Color3): void;
  52040. /**
  52041. * Exits VR and disposes of the vr experience helper
  52042. */
  52043. dispose(): void;
  52044. /**
  52045. * Gets the name of the VRExperienceHelper class
  52046. * @returns "VRExperienceHelper"
  52047. */
  52048. getClassName(): string;
  52049. }
  52050. }
  52051. declare module "babylonjs/Cameras/VR/index" {
  52052. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52053. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52056. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52057. export * from "babylonjs/Cameras/VR/webVRCamera";
  52058. }
  52059. declare module "babylonjs/Cameras/RigModes/index" {
  52060. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52061. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52062. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52063. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52064. }
  52065. declare module "babylonjs/Cameras/index" {
  52066. export * from "babylonjs/Cameras/Inputs/index";
  52067. export * from "babylonjs/Cameras/cameraInputsManager";
  52068. export * from "babylonjs/Cameras/camera";
  52069. export * from "babylonjs/Cameras/targetCamera";
  52070. export * from "babylonjs/Cameras/freeCamera";
  52071. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52072. export * from "babylonjs/Cameras/touchCamera";
  52073. export * from "babylonjs/Cameras/arcRotateCamera";
  52074. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52075. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52076. export * from "babylonjs/Cameras/flyCamera";
  52077. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52078. export * from "babylonjs/Cameras/followCamera";
  52079. export * from "babylonjs/Cameras/followCameraInputsManager";
  52080. export * from "babylonjs/Cameras/gamepadCamera";
  52081. export * from "babylonjs/Cameras/Stereoscopic/index";
  52082. export * from "babylonjs/Cameras/universalCamera";
  52083. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52084. export * from "babylonjs/Cameras/VR/index";
  52085. export * from "babylonjs/Cameras/RigModes/index";
  52086. }
  52087. declare module "babylonjs/Collisions/index" {
  52088. export * from "babylonjs/Collisions/collider";
  52089. export * from "babylonjs/Collisions/collisionCoordinator";
  52090. export * from "babylonjs/Collisions/pickingInfo";
  52091. export * from "babylonjs/Collisions/intersectionInfo";
  52092. export * from "babylonjs/Collisions/meshCollisionData";
  52093. }
  52094. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52095. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52096. import { Vector3 } from "babylonjs/Maths/math.vector";
  52097. import { Ray } from "babylonjs/Culling/ray";
  52098. import { Plane } from "babylonjs/Maths/math.plane";
  52099. /**
  52100. * Contains an array of blocks representing the octree
  52101. */
  52102. export interface IOctreeContainer<T> {
  52103. /**
  52104. * Blocks within the octree
  52105. */
  52106. blocks: Array<OctreeBlock<T>>;
  52107. }
  52108. /**
  52109. * Class used to store a cell in an octree
  52110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52111. */
  52112. export class OctreeBlock<T> {
  52113. /**
  52114. * Gets the content of the current block
  52115. */
  52116. entries: T[];
  52117. /**
  52118. * Gets the list of block children
  52119. */
  52120. blocks: Array<OctreeBlock<T>>;
  52121. private _depth;
  52122. private _maxDepth;
  52123. private _capacity;
  52124. private _minPoint;
  52125. private _maxPoint;
  52126. private _boundingVectors;
  52127. private _creationFunc;
  52128. /**
  52129. * Creates a new block
  52130. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52131. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52132. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52133. * @param depth defines the current depth of this block in the octree
  52134. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52135. * @param creationFunc defines a callback to call when an element is added to the block
  52136. */
  52137. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52138. /**
  52139. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52140. */
  52141. get capacity(): number;
  52142. /**
  52143. * Gets the minimum vector (in world space) of the block's bounding box
  52144. */
  52145. get minPoint(): Vector3;
  52146. /**
  52147. * Gets the maximum vector (in world space) of the block's bounding box
  52148. */
  52149. get maxPoint(): Vector3;
  52150. /**
  52151. * Add a new element to this block
  52152. * @param entry defines the element to add
  52153. */
  52154. addEntry(entry: T): void;
  52155. /**
  52156. * Remove an element from this block
  52157. * @param entry defines the element to remove
  52158. */
  52159. removeEntry(entry: T): void;
  52160. /**
  52161. * Add an array of elements to this block
  52162. * @param entries defines the array of elements to add
  52163. */
  52164. addEntries(entries: T[]): void;
  52165. /**
  52166. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52167. * @param frustumPlanes defines the frustum planes to test
  52168. * @param selection defines the array to store current content if selection is positive
  52169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52170. */
  52171. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52172. /**
  52173. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52174. * @param sphereCenter defines the bounding sphere center
  52175. * @param sphereRadius defines the bounding sphere radius
  52176. * @param selection defines the array to store current content if selection is positive
  52177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52178. */
  52179. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52180. /**
  52181. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52182. * @param ray defines the ray to test with
  52183. * @param selection defines the array to store current content if selection is positive
  52184. */
  52185. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52186. /**
  52187. * Subdivide the content into child blocks (this block will then be empty)
  52188. */
  52189. createInnerBlocks(): void;
  52190. /**
  52191. * @hidden
  52192. */
  52193. 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;
  52194. }
  52195. }
  52196. declare module "babylonjs/Culling/Octrees/octree" {
  52197. import { SmartArray } from "babylonjs/Misc/smartArray";
  52198. import { Vector3 } from "babylonjs/Maths/math.vector";
  52199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52201. import { Ray } from "babylonjs/Culling/ray";
  52202. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52203. import { Plane } from "babylonjs/Maths/math.plane";
  52204. /**
  52205. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52207. */
  52208. export class Octree<T> {
  52209. /** 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.) */
  52210. maxDepth: number;
  52211. /**
  52212. * Blocks within the octree containing objects
  52213. */
  52214. blocks: Array<OctreeBlock<T>>;
  52215. /**
  52216. * Content stored in the octree
  52217. */
  52218. dynamicContent: T[];
  52219. private _maxBlockCapacity;
  52220. private _selectionContent;
  52221. private _creationFunc;
  52222. /**
  52223. * Creates a octree
  52224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52225. * @param creationFunc function to be used to instatiate the octree
  52226. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52227. * @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.)
  52228. */
  52229. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52230. /** 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.) */
  52231. maxDepth?: number);
  52232. /**
  52233. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52234. * @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);
  52235. * @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);
  52236. * @param entries meshes to be added to the octree blocks
  52237. */
  52238. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52239. /**
  52240. * Adds a mesh to the octree
  52241. * @param entry Mesh to add to the octree
  52242. */
  52243. addMesh(entry: T): void;
  52244. /**
  52245. * Remove an element from the octree
  52246. * @param entry defines the element to remove
  52247. */
  52248. removeMesh(entry: T): void;
  52249. /**
  52250. * Selects an array of meshes within the frustum
  52251. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52252. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52253. * @returns array of meshes within the frustum
  52254. */
  52255. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52256. /**
  52257. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52258. * @param sphereCenter defines the bounding sphere center
  52259. * @param sphereRadius defines the bounding sphere radius
  52260. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52261. * @returns an array of objects that intersect the sphere
  52262. */
  52263. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52264. /**
  52265. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52266. * @param ray defines the ray to test with
  52267. * @returns array of intersected objects
  52268. */
  52269. intersectsRay(ray: Ray): SmartArray<T>;
  52270. /**
  52271. * Adds a mesh into the octree block if it intersects the block
  52272. */
  52273. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52274. /**
  52275. * Adds a submesh into the octree block if it intersects the block
  52276. */
  52277. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52278. }
  52279. }
  52280. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52281. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52282. import { Scene } from "babylonjs/scene";
  52283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52285. import { Ray } from "babylonjs/Culling/ray";
  52286. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52287. import { Collider } from "babylonjs/Collisions/collider";
  52288. module "babylonjs/scene" {
  52289. interface Scene {
  52290. /**
  52291. * @hidden
  52292. * Backing Filed
  52293. */
  52294. _selectionOctree: Octree<AbstractMesh>;
  52295. /**
  52296. * Gets the octree used to boost mesh selection (picking)
  52297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52298. */
  52299. selectionOctree: Octree<AbstractMesh>;
  52300. /**
  52301. * Creates or updates the octree used to boost selection (picking)
  52302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52303. * @param maxCapacity defines the maximum capacity per leaf
  52304. * @param maxDepth defines the maximum depth of the octree
  52305. * @returns an octree of AbstractMesh
  52306. */
  52307. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52308. }
  52309. }
  52310. module "babylonjs/Meshes/abstractMesh" {
  52311. interface AbstractMesh {
  52312. /**
  52313. * @hidden
  52314. * Backing Field
  52315. */
  52316. _submeshesOctree: Octree<SubMesh>;
  52317. /**
  52318. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52320. * @param maxCapacity defines the maximum size of each block (64 by default)
  52321. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52322. * @returns the new octree
  52323. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52325. */
  52326. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52327. }
  52328. }
  52329. /**
  52330. * Defines the octree scene component responsible to manage any octrees
  52331. * in a given scene.
  52332. */
  52333. export class OctreeSceneComponent {
  52334. /**
  52335. * The component name help to identify the component in the list of scene components.
  52336. */
  52337. readonly name: string;
  52338. /**
  52339. * The scene the component belongs to.
  52340. */
  52341. scene: Scene;
  52342. /**
  52343. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52344. */
  52345. readonly checksIsEnabled: boolean;
  52346. /**
  52347. * Creates a new instance of the component for the given scene
  52348. * @param scene Defines the scene to register the component in
  52349. */
  52350. constructor(scene: Scene);
  52351. /**
  52352. * Registers the component in a given scene
  52353. */
  52354. register(): void;
  52355. /**
  52356. * Return the list of active meshes
  52357. * @returns the list of active meshes
  52358. */
  52359. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52360. /**
  52361. * Return the list of active sub meshes
  52362. * @param mesh The mesh to get the candidates sub meshes from
  52363. * @returns the list of active sub meshes
  52364. */
  52365. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52366. private _tempRay;
  52367. /**
  52368. * Return the list of sub meshes intersecting with a given local ray
  52369. * @param mesh defines the mesh to find the submesh for
  52370. * @param localRay defines the ray in local space
  52371. * @returns the list of intersecting sub meshes
  52372. */
  52373. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52374. /**
  52375. * Return the list of sub meshes colliding with a collider
  52376. * @param mesh defines the mesh to find the submesh for
  52377. * @param collider defines the collider to evaluate the collision against
  52378. * @returns the list of colliding sub meshes
  52379. */
  52380. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52381. /**
  52382. * Rebuilds the elements related to this component in case of
  52383. * context lost for instance.
  52384. */
  52385. rebuild(): void;
  52386. /**
  52387. * Disposes the component and the associated ressources.
  52388. */
  52389. dispose(): void;
  52390. }
  52391. }
  52392. declare module "babylonjs/Culling/Octrees/index" {
  52393. export * from "babylonjs/Culling/Octrees/octree";
  52394. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52395. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52396. }
  52397. declare module "babylonjs/Culling/index" {
  52398. export * from "babylonjs/Culling/boundingBox";
  52399. export * from "babylonjs/Culling/boundingInfo";
  52400. export * from "babylonjs/Culling/boundingSphere";
  52401. export * from "babylonjs/Culling/Octrees/index";
  52402. export * from "babylonjs/Culling/ray";
  52403. }
  52404. declare module "babylonjs/Gizmos/gizmo" {
  52405. import { Nullable } from "babylonjs/types";
  52406. import { IDisposable } from "babylonjs/scene";
  52407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52408. import { Mesh } from "babylonjs/Meshes/mesh";
  52409. import { Node } from "babylonjs/node";
  52410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52411. /**
  52412. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52413. */
  52414. export class Gizmo implements IDisposable {
  52415. /** The utility layer the gizmo will be added to */
  52416. gizmoLayer: UtilityLayerRenderer;
  52417. /**
  52418. * The root mesh of the gizmo
  52419. */
  52420. _rootMesh: Mesh;
  52421. private _attachedMesh;
  52422. private _attachedNode;
  52423. /**
  52424. * Ratio for the scale of the gizmo (Default: 1)
  52425. */
  52426. protected _scaleRatio: number;
  52427. /**
  52428. * boolean updated by pointermove when a gizmo mesh is hovered
  52429. */
  52430. protected _isHovered: boolean;
  52431. /**
  52432. * Ratio for the scale of the gizmo (Default: 1)
  52433. */
  52434. set scaleRatio(value: number);
  52435. get scaleRatio(): number;
  52436. /**
  52437. * True when the mouse pointer is hovered a gizmo mesh
  52438. */
  52439. get isHovered(): boolean;
  52440. /**
  52441. * If a custom mesh has been set (Default: false)
  52442. */
  52443. protected _customMeshSet: boolean;
  52444. /**
  52445. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52446. * * When set, interactions will be enabled
  52447. */
  52448. get attachedMesh(): Nullable<AbstractMesh>;
  52449. set attachedMesh(value: Nullable<AbstractMesh>);
  52450. /**
  52451. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52452. * * When set, interactions will be enabled
  52453. */
  52454. get attachedNode(): Nullable<Node>;
  52455. set attachedNode(value: Nullable<Node>);
  52456. /**
  52457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52458. * @param mesh The mesh to replace the default mesh of the gizmo
  52459. */
  52460. setCustomMesh(mesh: Mesh): void;
  52461. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52462. /**
  52463. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52464. */
  52465. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52466. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52467. /**
  52468. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52469. */
  52470. updateGizmoPositionToMatchAttachedMesh: boolean;
  52471. /**
  52472. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52473. */
  52474. updateScale: boolean;
  52475. protected _interactionsEnabled: boolean;
  52476. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52477. private _beforeRenderObserver;
  52478. private _tempQuaternion;
  52479. private _tempVector;
  52480. private _tempVector2;
  52481. private _tempMatrix1;
  52482. private _tempMatrix2;
  52483. private _rightHandtoLeftHandMatrix;
  52484. /**
  52485. * Creates a gizmo
  52486. * @param gizmoLayer The utility layer the gizmo will be added to
  52487. */
  52488. constructor(
  52489. /** The utility layer the gizmo will be added to */
  52490. gizmoLayer?: UtilityLayerRenderer);
  52491. /**
  52492. * Updates the gizmo to match the attached mesh's position/rotation
  52493. */
  52494. protected _update(): void;
  52495. /**
  52496. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52497. * @param value Node, TransformNode or mesh
  52498. */
  52499. protected _matrixChanged(): void;
  52500. /**
  52501. * Disposes of the gizmo
  52502. */
  52503. dispose(): void;
  52504. }
  52505. }
  52506. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. import { Nullable } from "babylonjs/types";
  52509. import { Vector3 } from "babylonjs/Maths/math.vector";
  52510. import { Color3 } from "babylonjs/Maths/math.color";
  52511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52512. import { Node } from "babylonjs/node";
  52513. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52514. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52516. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52517. import { Scene } from "babylonjs/scene";
  52518. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52519. /**
  52520. * Single plane drag gizmo
  52521. */
  52522. export class PlaneDragGizmo extends Gizmo {
  52523. /**
  52524. * Drag behavior responsible for the gizmos dragging interactions
  52525. */
  52526. dragBehavior: PointerDragBehavior;
  52527. private _pointerObserver;
  52528. /**
  52529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52530. */
  52531. snapDistance: number;
  52532. /**
  52533. * Event that fires each time the gizmo snaps to a new location.
  52534. * * snapDistance is the the change in distance
  52535. */
  52536. onSnapObservable: Observable<{
  52537. snapDistance: number;
  52538. }>;
  52539. private _plane;
  52540. private _coloredMaterial;
  52541. private _hoverMaterial;
  52542. private _isEnabled;
  52543. private _parent;
  52544. /** @hidden */
  52545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52546. /** @hidden */
  52547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52548. /**
  52549. * Creates a PlaneDragGizmo
  52550. * @param gizmoLayer The utility layer the gizmo will be added to
  52551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52552. * @param color The color of the gizmo
  52553. */
  52554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52555. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52556. /**
  52557. * If the gizmo is enabled
  52558. */
  52559. set isEnabled(value: boolean);
  52560. get isEnabled(): boolean;
  52561. /**
  52562. * Disposes of the gizmo
  52563. */
  52564. dispose(): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Gizmos/positionGizmo" {
  52568. import { Observable } from "babylonjs/Misc/observable";
  52569. import { Nullable } from "babylonjs/types";
  52570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52571. import { Node } from "babylonjs/node";
  52572. import { Mesh } from "babylonjs/Meshes/mesh";
  52573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52574. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52575. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52577. /**
  52578. * Gizmo that enables dragging a mesh along 3 axis
  52579. */
  52580. export class PositionGizmo extends Gizmo {
  52581. /**
  52582. * Internal gizmo used for interactions on the x axis
  52583. */
  52584. xGizmo: AxisDragGizmo;
  52585. /**
  52586. * Internal gizmo used for interactions on the y axis
  52587. */
  52588. yGizmo: AxisDragGizmo;
  52589. /**
  52590. * Internal gizmo used for interactions on the z axis
  52591. */
  52592. zGizmo: AxisDragGizmo;
  52593. /**
  52594. * Internal gizmo used for interactions on the yz plane
  52595. */
  52596. xPlaneGizmo: PlaneDragGizmo;
  52597. /**
  52598. * Internal gizmo used for interactions on the xz plane
  52599. */
  52600. yPlaneGizmo: PlaneDragGizmo;
  52601. /**
  52602. * Internal gizmo used for interactions on the xy plane
  52603. */
  52604. zPlaneGizmo: PlaneDragGizmo;
  52605. /**
  52606. * private variables
  52607. */
  52608. private _meshAttached;
  52609. private _nodeAttached;
  52610. private _snapDistance;
  52611. /** Fires an event when any of it's sub gizmos are dragged */
  52612. onDragStartObservable: Observable<unknown>;
  52613. /** Fires an event when any of it's sub gizmos are released from dragging */
  52614. onDragEndObservable: Observable<unknown>;
  52615. /**
  52616. * If set to true, planar drag is enabled
  52617. */
  52618. private _planarGizmoEnabled;
  52619. get attachedMesh(): Nullable<AbstractMesh>;
  52620. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52621. get attachedNode(): Nullable<Node>;
  52622. set attachedNode(node: Nullable<Node>);
  52623. /**
  52624. * True when the mouse pointer is hovering a gizmo mesh
  52625. */
  52626. get isHovered(): boolean;
  52627. /**
  52628. * Creates a PositionGizmo
  52629. * @param gizmoLayer The utility layer the gizmo will be added to
  52630. @param thickness display gizmo axis thickness
  52631. */
  52632. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52633. /**
  52634. * If the planar drag gizmo is enabled
  52635. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52636. */
  52637. set planarGizmoEnabled(value: boolean);
  52638. get planarGizmoEnabled(): boolean;
  52639. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52640. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52641. /**
  52642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52643. */
  52644. set snapDistance(value: number);
  52645. get snapDistance(): number;
  52646. /**
  52647. * Ratio for the scale of the gizmo (Default: 1)
  52648. */
  52649. set scaleRatio(value: number);
  52650. get scaleRatio(): number;
  52651. /**
  52652. * Disposes of the gizmo
  52653. */
  52654. dispose(): void;
  52655. /**
  52656. * CustomMeshes are not supported by this gizmo
  52657. * @param mesh The mesh to replace the default mesh of the gizmo
  52658. */
  52659. setCustomMesh(mesh: Mesh): void;
  52660. }
  52661. }
  52662. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52663. import { Observable } from "babylonjs/Misc/observable";
  52664. import { Nullable } from "babylonjs/types";
  52665. import { Vector3 } from "babylonjs/Maths/math.vector";
  52666. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52667. import { Node } from "babylonjs/node";
  52668. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52671. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52672. import { Scene } from "babylonjs/scene";
  52673. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52674. import { Color3 } from "babylonjs/Maths/math.color";
  52675. /**
  52676. * Single axis drag gizmo
  52677. */
  52678. export class AxisDragGizmo extends Gizmo {
  52679. /**
  52680. * Drag behavior responsible for the gizmos dragging interactions
  52681. */
  52682. dragBehavior: PointerDragBehavior;
  52683. private _pointerObserver;
  52684. /**
  52685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52686. */
  52687. snapDistance: number;
  52688. /**
  52689. * Event that fires each time the gizmo snaps to a new location.
  52690. * * snapDistance is the the change in distance
  52691. */
  52692. onSnapObservable: Observable<{
  52693. snapDistance: number;
  52694. }>;
  52695. private _isEnabled;
  52696. private _parent;
  52697. private _arrow;
  52698. private _coloredMaterial;
  52699. private _hoverMaterial;
  52700. /** @hidden */
  52701. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52702. /** @hidden */
  52703. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52704. /**
  52705. * Creates an AxisDragGizmo
  52706. * @param gizmoLayer The utility layer the gizmo will be added to
  52707. * @param dragAxis The axis which the gizmo will be able to drag on
  52708. * @param color The color of the gizmo
  52709. * @param thickness display gizmo axis thickness
  52710. */
  52711. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52712. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52713. /**
  52714. * If the gizmo is enabled
  52715. */
  52716. set isEnabled(value: boolean);
  52717. get isEnabled(): boolean;
  52718. /**
  52719. * Disposes of the gizmo
  52720. */
  52721. dispose(): void;
  52722. }
  52723. }
  52724. declare module "babylonjs/Debug/axesViewer" {
  52725. import { Vector3 } from "babylonjs/Maths/math.vector";
  52726. import { Nullable } from "babylonjs/types";
  52727. import { Scene } from "babylonjs/scene";
  52728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52729. /**
  52730. * The Axes viewer will show 3 axes in a specific point in space
  52731. */
  52732. export class AxesViewer {
  52733. private _xAxis;
  52734. private _yAxis;
  52735. private _zAxis;
  52736. private _scaleLinesFactor;
  52737. private _instanced;
  52738. /**
  52739. * Gets the hosting scene
  52740. */
  52741. scene: Nullable<Scene>;
  52742. /**
  52743. * Gets or sets a number used to scale line length
  52744. */
  52745. scaleLines: number;
  52746. /** Gets the node hierarchy used to render x-axis */
  52747. get xAxis(): TransformNode;
  52748. /** Gets the node hierarchy used to render y-axis */
  52749. get yAxis(): TransformNode;
  52750. /** Gets the node hierarchy used to render z-axis */
  52751. get zAxis(): TransformNode;
  52752. /**
  52753. * Creates a new AxesViewer
  52754. * @param scene defines the hosting scene
  52755. * @param scaleLines defines a number used to scale line length (1 by default)
  52756. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52757. * @param xAxis defines the node hierarchy used to render the x-axis
  52758. * @param yAxis defines the node hierarchy used to render the y-axis
  52759. * @param zAxis defines the node hierarchy used to render the z-axis
  52760. */
  52761. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52762. /**
  52763. * Force the viewer to update
  52764. * @param position defines the position of the viewer
  52765. * @param xaxis defines the x axis of the viewer
  52766. * @param yaxis defines the y axis of the viewer
  52767. * @param zaxis defines the z axis of the viewer
  52768. */
  52769. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52770. /**
  52771. * Creates an instance of this axes viewer.
  52772. * @returns a new axes viewer with instanced meshes
  52773. */
  52774. createInstance(): AxesViewer;
  52775. /** Releases resources */
  52776. dispose(): void;
  52777. private static _SetRenderingGroupId;
  52778. }
  52779. }
  52780. declare module "babylonjs/Debug/boneAxesViewer" {
  52781. import { Nullable } from "babylonjs/types";
  52782. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52783. import { Vector3 } from "babylonjs/Maths/math.vector";
  52784. import { Mesh } from "babylonjs/Meshes/mesh";
  52785. import { Bone } from "babylonjs/Bones/bone";
  52786. import { Scene } from "babylonjs/scene";
  52787. /**
  52788. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52789. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52790. */
  52791. export class BoneAxesViewer extends AxesViewer {
  52792. /**
  52793. * Gets or sets the target mesh where to display the axes viewer
  52794. */
  52795. mesh: Nullable<Mesh>;
  52796. /**
  52797. * Gets or sets the target bone where to display the axes viewer
  52798. */
  52799. bone: Nullable<Bone>;
  52800. /** Gets current position */
  52801. pos: Vector3;
  52802. /** Gets direction of X axis */
  52803. xaxis: Vector3;
  52804. /** Gets direction of Y axis */
  52805. yaxis: Vector3;
  52806. /** Gets direction of Z axis */
  52807. zaxis: Vector3;
  52808. /**
  52809. * Creates a new BoneAxesViewer
  52810. * @param scene defines the hosting scene
  52811. * @param bone defines the target bone
  52812. * @param mesh defines the target mesh
  52813. * @param scaleLines defines a scaling factor for line length (1 by default)
  52814. */
  52815. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52816. /**
  52817. * Force the viewer to update
  52818. */
  52819. update(): void;
  52820. /** Releases resources */
  52821. dispose(): void;
  52822. }
  52823. }
  52824. declare module "babylonjs/Debug/debugLayer" {
  52825. import { Scene } from "babylonjs/scene";
  52826. /**
  52827. * Interface used to define scene explorer extensibility option
  52828. */
  52829. export interface IExplorerExtensibilityOption {
  52830. /**
  52831. * Define the option label
  52832. */
  52833. label: string;
  52834. /**
  52835. * Defines the action to execute on click
  52836. */
  52837. action: (entity: any) => void;
  52838. }
  52839. /**
  52840. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52841. */
  52842. export interface IExplorerExtensibilityGroup {
  52843. /**
  52844. * Defines a predicate to test if a given type mut be extended
  52845. */
  52846. predicate: (entity: any) => boolean;
  52847. /**
  52848. * Gets the list of options added to a type
  52849. */
  52850. entries: IExplorerExtensibilityOption[];
  52851. }
  52852. /**
  52853. * Interface used to define the options to use to create the Inspector
  52854. */
  52855. export interface IInspectorOptions {
  52856. /**
  52857. * Display in overlay mode (default: false)
  52858. */
  52859. overlay?: boolean;
  52860. /**
  52861. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52862. */
  52863. globalRoot?: HTMLElement;
  52864. /**
  52865. * Display the Scene explorer
  52866. */
  52867. showExplorer?: boolean;
  52868. /**
  52869. * Display the property inspector
  52870. */
  52871. showInspector?: boolean;
  52872. /**
  52873. * Display in embed mode (both panes on the right)
  52874. */
  52875. embedMode?: boolean;
  52876. /**
  52877. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52878. */
  52879. handleResize?: boolean;
  52880. /**
  52881. * Allow the panes to popup (default: true)
  52882. */
  52883. enablePopup?: boolean;
  52884. /**
  52885. * Allow the panes to be closed by users (default: true)
  52886. */
  52887. enableClose?: boolean;
  52888. /**
  52889. * Optional list of extensibility entries
  52890. */
  52891. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52892. /**
  52893. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52894. */
  52895. inspectorURL?: string;
  52896. /**
  52897. * Optional initial tab (default to DebugLayerTab.Properties)
  52898. */
  52899. initialTab?: DebugLayerTab;
  52900. }
  52901. module "babylonjs/scene" {
  52902. interface Scene {
  52903. /**
  52904. * @hidden
  52905. * Backing field
  52906. */
  52907. _debugLayer: DebugLayer;
  52908. /**
  52909. * Gets the debug layer (aka Inspector) associated with the scene
  52910. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52911. */
  52912. debugLayer: DebugLayer;
  52913. }
  52914. }
  52915. /**
  52916. * Enum of inspector action tab
  52917. */
  52918. export enum DebugLayerTab {
  52919. /**
  52920. * Properties tag (default)
  52921. */
  52922. Properties = 0,
  52923. /**
  52924. * Debug tab
  52925. */
  52926. Debug = 1,
  52927. /**
  52928. * Statistics tab
  52929. */
  52930. Statistics = 2,
  52931. /**
  52932. * Tools tab
  52933. */
  52934. Tools = 3,
  52935. /**
  52936. * Settings tab
  52937. */
  52938. Settings = 4
  52939. }
  52940. /**
  52941. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52942. * what is happening in your scene
  52943. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52944. */
  52945. export class DebugLayer {
  52946. /**
  52947. * Define the url to get the inspector script from.
  52948. * By default it uses the babylonjs CDN.
  52949. * @ignoreNaming
  52950. */
  52951. static InspectorURL: string;
  52952. private _scene;
  52953. private BJSINSPECTOR;
  52954. private _onPropertyChangedObservable?;
  52955. /**
  52956. * Observable triggered when a property is changed through the inspector.
  52957. */
  52958. get onPropertyChangedObservable(): any;
  52959. /**
  52960. * Instantiates a new debug layer.
  52961. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52962. * what is happening in your scene
  52963. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52964. * @param scene Defines the scene to inspect
  52965. */
  52966. constructor(scene: Scene);
  52967. /** Creates the inspector window. */
  52968. private _createInspector;
  52969. /**
  52970. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52971. * @param entity defines the entity to select
  52972. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52973. */
  52974. select(entity: any, lineContainerTitles?: string | string[]): void;
  52975. /** Get the inspector from bundle or global */
  52976. private _getGlobalInspector;
  52977. /**
  52978. * Get if the inspector is visible or not.
  52979. * @returns true if visible otherwise, false
  52980. */
  52981. isVisible(): boolean;
  52982. /**
  52983. * Hide the inspector and close its window.
  52984. */
  52985. hide(): void;
  52986. /**
  52987. * Update the scene in the inspector
  52988. */
  52989. setAsActiveScene(): void;
  52990. /**
  52991. * Launch the debugLayer.
  52992. * @param config Define the configuration of the inspector
  52993. * @return a promise fulfilled when the debug layer is visible
  52994. */
  52995. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52996. }
  52997. }
  52998. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52999. import { Nullable } from "babylonjs/types";
  53000. import { Scene } from "babylonjs/scene";
  53001. import { Vector4 } from "babylonjs/Maths/math.vector";
  53002. import { Color4 } from "babylonjs/Maths/math.color";
  53003. import { Mesh } from "babylonjs/Meshes/mesh";
  53004. /**
  53005. * Class containing static functions to help procedurally build meshes
  53006. */
  53007. export class BoxBuilder {
  53008. /**
  53009. * Creates a box mesh
  53010. * * The parameter `size` sets the size (float) of each box side (default 1)
  53011. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53012. * * 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)
  53013. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53017. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53018. * @param name defines the name of the mesh
  53019. * @param options defines the options used to create the mesh
  53020. * @param scene defines the hosting scene
  53021. * @returns the box mesh
  53022. */
  53023. static CreateBox(name: string, options: {
  53024. size?: number;
  53025. width?: number;
  53026. height?: number;
  53027. depth?: number;
  53028. faceUV?: Vector4[];
  53029. faceColors?: Color4[];
  53030. sideOrientation?: number;
  53031. frontUVs?: Vector4;
  53032. backUVs?: Vector4;
  53033. wrap?: boolean;
  53034. topBaseAt?: number;
  53035. bottomBaseAt?: number;
  53036. updatable?: boolean;
  53037. }, scene?: Nullable<Scene>): Mesh;
  53038. }
  53039. }
  53040. declare module "babylonjs/Debug/physicsViewer" {
  53041. import { Nullable } from "babylonjs/types";
  53042. import { Scene } from "babylonjs/scene";
  53043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53044. import { Mesh } from "babylonjs/Meshes/mesh";
  53045. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53046. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53047. /**
  53048. * Used to show the physics impostor around the specific mesh
  53049. */
  53050. export class PhysicsViewer {
  53051. /** @hidden */
  53052. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53053. /** @hidden */
  53054. protected _meshes: Array<Nullable<AbstractMesh>>;
  53055. /** @hidden */
  53056. protected _scene: Nullable<Scene>;
  53057. /** @hidden */
  53058. protected _numMeshes: number;
  53059. /** @hidden */
  53060. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53061. private _renderFunction;
  53062. private _utilityLayer;
  53063. private _debugBoxMesh;
  53064. private _debugSphereMesh;
  53065. private _debugCylinderMesh;
  53066. private _debugMaterial;
  53067. private _debugMeshMeshes;
  53068. /**
  53069. * Creates a new PhysicsViewer
  53070. * @param scene defines the hosting scene
  53071. */
  53072. constructor(scene: Scene);
  53073. /** @hidden */
  53074. protected _updateDebugMeshes(): void;
  53075. /**
  53076. * Renders a specified physic impostor
  53077. * @param impostor defines the impostor to render
  53078. * @param targetMesh defines the mesh represented by the impostor
  53079. * @returns the new debug mesh used to render the impostor
  53080. */
  53081. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53082. /**
  53083. * Hides a specified physic impostor
  53084. * @param impostor defines the impostor to hide
  53085. */
  53086. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53087. private _getDebugMaterial;
  53088. private _getDebugBoxMesh;
  53089. private _getDebugSphereMesh;
  53090. private _getDebugCylinderMesh;
  53091. private _getDebugMeshMesh;
  53092. private _getDebugMesh;
  53093. /** Releases all resources */
  53094. dispose(): void;
  53095. }
  53096. }
  53097. declare module "babylonjs/Debug/rayHelper" {
  53098. import { Nullable } from "babylonjs/types";
  53099. import { Ray } from "babylonjs/Culling/ray";
  53100. import { Vector3 } from "babylonjs/Maths/math.vector";
  53101. import { Color3 } from "babylonjs/Maths/math.color";
  53102. import { Scene } from "babylonjs/scene";
  53103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53104. import "babylonjs/Meshes/Builders/linesBuilder";
  53105. /**
  53106. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53107. * in order to better appreciate the issue one might have.
  53108. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53109. */
  53110. export class RayHelper {
  53111. /**
  53112. * Defines the ray we are currently tryin to visualize.
  53113. */
  53114. ray: Nullable<Ray>;
  53115. private _renderPoints;
  53116. private _renderLine;
  53117. private _renderFunction;
  53118. private _scene;
  53119. private _onAfterRenderObserver;
  53120. private _onAfterStepObserver;
  53121. private _attachedToMesh;
  53122. private _meshSpaceDirection;
  53123. private _meshSpaceOrigin;
  53124. /**
  53125. * Helper function to create a colored helper in a scene in one line.
  53126. * @param ray Defines the ray we are currently tryin to visualize
  53127. * @param scene Defines the scene the ray is used in
  53128. * @param color Defines the color we want to see the ray in
  53129. * @returns The newly created ray helper.
  53130. */
  53131. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53132. /**
  53133. * Instantiate a new ray helper.
  53134. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53135. * in order to better appreciate the issue one might have.
  53136. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53137. * @param ray Defines the ray we are currently tryin to visualize
  53138. */
  53139. constructor(ray: Ray);
  53140. /**
  53141. * Shows the ray we are willing to debug.
  53142. * @param scene Defines the scene the ray needs to be rendered in
  53143. * @param color Defines the color the ray needs to be rendered in
  53144. */
  53145. show(scene: Scene, color?: Color3): void;
  53146. /**
  53147. * Hides the ray we are debugging.
  53148. */
  53149. hide(): void;
  53150. private _render;
  53151. /**
  53152. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53153. * @param mesh Defines the mesh we want the helper attached to
  53154. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53155. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53156. * @param length Defines the length of the ray
  53157. */
  53158. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53159. /**
  53160. * Detach the ray helper from the mesh it has previously been attached to.
  53161. */
  53162. detachFromMesh(): void;
  53163. private _updateToMesh;
  53164. /**
  53165. * Dispose the helper and release its associated resources.
  53166. */
  53167. dispose(): void;
  53168. }
  53169. }
  53170. declare module "babylonjs/Debug/ISkeletonViewer" {
  53171. import { Skeleton } from "babylonjs/Bones/skeleton";
  53172. import { Color3 } from "babylonjs/Maths/math.color";
  53173. /**
  53174. * Defines the options associated with the creation of a SkeletonViewer.
  53175. */
  53176. export interface ISkeletonViewerOptions {
  53177. /** Should the system pause animations before building the Viewer? */
  53178. pauseAnimations: boolean;
  53179. /** Should the system return the skeleton to rest before building? */
  53180. returnToRest: boolean;
  53181. /** public Display Mode of the Viewer */
  53182. displayMode: number;
  53183. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53184. displayOptions: ISkeletonViewerDisplayOptions;
  53185. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53186. computeBonesUsingShaders: boolean;
  53187. /** Flag ignore non weighted bones */
  53188. useAllBones: boolean;
  53189. }
  53190. /**
  53191. * Defines how to display the various bone meshes for the viewer.
  53192. */
  53193. export interface ISkeletonViewerDisplayOptions {
  53194. /** How far down to start tapering the bone spurs */
  53195. midStep?: number;
  53196. /** How big is the midStep? */
  53197. midStepFactor?: number;
  53198. /** Base for the Sphere Size */
  53199. sphereBaseSize?: number;
  53200. /** The ratio of the sphere to the longest bone in units */
  53201. sphereScaleUnit?: number;
  53202. /** Ratio for the Sphere Size */
  53203. sphereFactor?: number;
  53204. /** Whether to show local axes or not */
  53205. showLocalAxes?: boolean;
  53206. /** Length of each local axis */
  53207. localAxesSize?: number;
  53208. }
  53209. /**
  53210. * Defines the constructor options for the BoneWeight Shader.
  53211. */
  53212. export interface IBoneWeightShaderOptions {
  53213. /** Skeleton to Map */
  53214. skeleton: Skeleton;
  53215. /** Colors for Uninfluenced bones */
  53216. colorBase?: Color3;
  53217. /** Colors for 0.0-0.25 Weight bones */
  53218. colorZero?: Color3;
  53219. /** Color for 0.25-0.5 Weight Influence */
  53220. colorQuarter?: Color3;
  53221. /** Color for 0.5-0.75 Weight Influence */
  53222. colorHalf?: Color3;
  53223. /** Color for 0.75-1 Weight Influence */
  53224. colorFull?: Color3;
  53225. /** Color for Zero Weight Influence */
  53226. targetBoneIndex?: number;
  53227. }
  53228. /**
  53229. * Simple structure of the gradient steps for the Color Map.
  53230. */
  53231. export interface ISkeletonMapShaderColorMapKnot {
  53232. /** Color of the Knot */
  53233. color: Color3;
  53234. /** Location of the Knot */
  53235. location: number;
  53236. }
  53237. /**
  53238. * Defines the constructor options for the SkeletonMap Shader.
  53239. */
  53240. export interface ISkeletonMapShaderOptions {
  53241. /** Skeleton to Map */
  53242. skeleton: Skeleton;
  53243. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53244. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53245. }
  53246. }
  53247. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53248. import { Nullable } from "babylonjs/types";
  53249. import { Scene } from "babylonjs/scene";
  53250. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53251. import { Color4 } from "babylonjs/Maths/math.color";
  53252. import { Mesh } from "babylonjs/Meshes/mesh";
  53253. /**
  53254. * Class containing static functions to help procedurally build meshes
  53255. */
  53256. export class RibbonBuilder {
  53257. /**
  53258. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53259. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53260. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53261. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53262. * * 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
  53263. * * 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
  53264. * * 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
  53265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53268. * * 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
  53269. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53270. * * 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
  53271. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53273. * @param name defines the name of the mesh
  53274. * @param options defines the options used to create the mesh
  53275. * @param scene defines the hosting scene
  53276. * @returns the ribbon mesh
  53277. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53279. */
  53280. static CreateRibbon(name: string, options: {
  53281. pathArray: Vector3[][];
  53282. closeArray?: boolean;
  53283. closePath?: boolean;
  53284. offset?: number;
  53285. updatable?: boolean;
  53286. sideOrientation?: number;
  53287. frontUVs?: Vector4;
  53288. backUVs?: Vector4;
  53289. instance?: Mesh;
  53290. invertUV?: boolean;
  53291. uvs?: Vector2[];
  53292. colors?: Color4[];
  53293. }, scene?: Nullable<Scene>): Mesh;
  53294. }
  53295. }
  53296. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53297. import { Nullable } from "babylonjs/types";
  53298. import { Scene } from "babylonjs/scene";
  53299. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53300. import { Mesh } from "babylonjs/Meshes/mesh";
  53301. /**
  53302. * Class containing static functions to help procedurally build meshes
  53303. */
  53304. export class ShapeBuilder {
  53305. /**
  53306. * 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.
  53307. * * 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.
  53308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53309. * * 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.
  53310. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53311. * * 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
  53312. * * 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
  53313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53318. * @param name defines the name of the mesh
  53319. * @param options defines the options used to create the mesh
  53320. * @param scene defines the hosting scene
  53321. * @returns the extruded shape mesh
  53322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53324. */
  53325. static ExtrudeShape(name: string, options: {
  53326. shape: Vector3[];
  53327. path: Vector3[];
  53328. scale?: number;
  53329. rotation?: number;
  53330. cap?: number;
  53331. updatable?: boolean;
  53332. sideOrientation?: number;
  53333. frontUVs?: Vector4;
  53334. backUVs?: Vector4;
  53335. instance?: Mesh;
  53336. invertUV?: boolean;
  53337. }, scene?: Nullable<Scene>): Mesh;
  53338. /**
  53339. * Creates an custom extruded shape mesh.
  53340. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53341. * * 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.
  53342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53343. * * 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
  53344. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53345. * * 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
  53346. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53347. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53348. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53349. * * 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
  53350. * * 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
  53351. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53356. * @param name defines the name of the mesh
  53357. * @param options defines the options used to create the mesh
  53358. * @param scene defines the hosting scene
  53359. * @returns the custom extruded shape mesh
  53360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53363. */
  53364. static ExtrudeShapeCustom(name: string, options: {
  53365. shape: Vector3[];
  53366. path: Vector3[];
  53367. scaleFunction?: any;
  53368. rotationFunction?: any;
  53369. ribbonCloseArray?: boolean;
  53370. ribbonClosePath?: boolean;
  53371. cap?: number;
  53372. updatable?: boolean;
  53373. sideOrientation?: number;
  53374. frontUVs?: Vector4;
  53375. backUVs?: Vector4;
  53376. instance?: Mesh;
  53377. invertUV?: boolean;
  53378. }, scene?: Nullable<Scene>): Mesh;
  53379. private static _ExtrudeShapeGeneric;
  53380. }
  53381. }
  53382. declare module "babylonjs/Debug/skeletonViewer" {
  53383. import { Color3 } from "babylonjs/Maths/math.color";
  53384. import { Scene } from "babylonjs/scene";
  53385. import { Nullable } from "babylonjs/types";
  53386. import { Skeleton } from "babylonjs/Bones/skeleton";
  53387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53388. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53390. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53391. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53392. /**
  53393. * Class used to render a debug view of a given skeleton
  53394. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53395. */
  53396. export class SkeletonViewer {
  53397. /** defines the skeleton to render */
  53398. skeleton: Skeleton;
  53399. /** defines the mesh attached to the skeleton */
  53400. mesh: AbstractMesh;
  53401. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53402. autoUpdateBonesMatrices: boolean;
  53403. /** defines the rendering group id to use with the viewer */
  53404. renderingGroupId: number;
  53405. /** is the options for the viewer */
  53406. options: Partial<ISkeletonViewerOptions>;
  53407. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53408. static readonly DISPLAY_LINES: number;
  53409. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53410. static readonly DISPLAY_SPHERES: number;
  53411. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53412. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53413. /** public static method to create a BoneWeight Shader
  53414. * @param options The constructor options
  53415. * @param scene The scene that the shader is scoped to
  53416. * @returns The created ShaderMaterial
  53417. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53418. */
  53419. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53420. /** public static method to create a BoneWeight Shader
  53421. * @param options The constructor options
  53422. * @param scene The scene that the shader is scoped to
  53423. * @returns The created ShaderMaterial
  53424. */
  53425. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53426. /** private static method to create a BoneWeight Shader
  53427. * @param size The size of the buffer to create (usually the bone count)
  53428. * @param colorMap The gradient data to generate
  53429. * @param scene The scene that the shader is scoped to
  53430. * @returns an Array of floats from the color gradient values
  53431. */
  53432. private static _CreateBoneMapColorBuffer;
  53433. /** If SkeletonViewer scene scope. */
  53434. private _scene;
  53435. /** Gets or sets the color used to render the skeleton */
  53436. color: Color3;
  53437. /** Array of the points of the skeleton fo the line view. */
  53438. private _debugLines;
  53439. /** The SkeletonViewers Mesh. */
  53440. private _debugMesh;
  53441. /** The local axes Meshes. */
  53442. private _localAxes;
  53443. /** If SkeletonViewer is enabled. */
  53444. private _isEnabled;
  53445. /** If SkeletonViewer is ready. */
  53446. private _ready;
  53447. /** SkeletonViewer render observable. */
  53448. private _obs;
  53449. /** The Utility Layer to render the gizmos in. */
  53450. private _utilityLayer;
  53451. private _boneIndices;
  53452. /** Gets the Scene. */
  53453. get scene(): Scene;
  53454. /** Gets the utilityLayer. */
  53455. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53456. /** Checks Ready Status. */
  53457. get isReady(): Boolean;
  53458. /** Sets Ready Status. */
  53459. set ready(value: boolean);
  53460. /** Gets the debugMesh */
  53461. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53462. /** Sets the debugMesh */
  53463. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53464. /** Gets the displayMode */
  53465. get displayMode(): number;
  53466. /** Sets the displayMode */
  53467. set displayMode(value: number);
  53468. /**
  53469. * Creates a new SkeletonViewer
  53470. * @param skeleton defines the skeleton to render
  53471. * @param mesh defines the mesh attached to the skeleton
  53472. * @param scene defines the hosting scene
  53473. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53474. * @param renderingGroupId defines the rendering group id to use with the viewer
  53475. * @param options All of the extra constructor options for the SkeletonViewer
  53476. */
  53477. constructor(
  53478. /** defines the skeleton to render */
  53479. skeleton: Skeleton,
  53480. /** defines the mesh attached to the skeleton */
  53481. mesh: AbstractMesh,
  53482. /** The Scene scope*/
  53483. scene: Scene,
  53484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53485. autoUpdateBonesMatrices?: boolean,
  53486. /** defines the rendering group id to use with the viewer */
  53487. renderingGroupId?: number,
  53488. /** is the options for the viewer */
  53489. options?: Partial<ISkeletonViewerOptions>);
  53490. /** The Dynamic bindings for the update functions */
  53491. private _bindObs;
  53492. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53493. update(): void;
  53494. /** Gets or sets a boolean indicating if the viewer is enabled */
  53495. set isEnabled(value: boolean);
  53496. get isEnabled(): boolean;
  53497. private _getBonePosition;
  53498. private _getLinesForBonesWithLength;
  53499. private _getLinesForBonesNoLength;
  53500. /** function to revert the mesh and scene back to the initial state. */
  53501. private _revert;
  53502. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53503. private _getAbsoluteBindPoseToRef;
  53504. /** function to build and bind sphere joint points and spur bone representations. */
  53505. private _buildSpheresAndSpurs;
  53506. private _buildLocalAxes;
  53507. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53508. private _displayLinesUpdate;
  53509. /** Changes the displayMode of the skeleton viewer
  53510. * @param mode The displayMode numerical value
  53511. */
  53512. changeDisplayMode(mode: number): void;
  53513. /** Sets a display option of the skeleton viewer
  53514. *
  53515. * | Option | Type | Default | Description |
  53516. * | --------------- | ------- | ------- | ----------- |
  53517. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53518. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53519. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53520. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53521. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53522. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53523. *
  53524. * @param option String of the option name
  53525. * @param value The numerical option value
  53526. */
  53527. changeDisplayOptions(option: string, value: number): void;
  53528. /** Release associated resources */
  53529. dispose(): void;
  53530. }
  53531. }
  53532. declare module "babylonjs/Debug/index" {
  53533. export * from "babylonjs/Debug/axesViewer";
  53534. export * from "babylonjs/Debug/boneAxesViewer";
  53535. export * from "babylonjs/Debug/debugLayer";
  53536. export * from "babylonjs/Debug/physicsViewer";
  53537. export * from "babylonjs/Debug/rayHelper";
  53538. export * from "babylonjs/Debug/skeletonViewer";
  53539. export * from "babylonjs/Debug/ISkeletonViewer";
  53540. }
  53541. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53542. /**
  53543. * Enum for Device Types
  53544. */
  53545. export enum DeviceType {
  53546. /** Generic */
  53547. Generic = 0,
  53548. /** Keyboard */
  53549. Keyboard = 1,
  53550. /** Mouse */
  53551. Mouse = 2,
  53552. /** Touch Pointers */
  53553. Touch = 3,
  53554. /** PS4 Dual Shock */
  53555. DualShock = 4,
  53556. /** Xbox */
  53557. Xbox = 5,
  53558. /** Switch Controller */
  53559. Switch = 6
  53560. }
  53561. /**
  53562. * Enum for All Pointers (Touch/Mouse)
  53563. */
  53564. export enum PointerInput {
  53565. /** Horizontal Axis */
  53566. Horizontal = 0,
  53567. /** Vertical Axis */
  53568. Vertical = 1,
  53569. /** Left Click or Touch */
  53570. LeftClick = 2,
  53571. /** Middle Click */
  53572. MiddleClick = 3,
  53573. /** Right Click */
  53574. RightClick = 4,
  53575. /** Browser Back */
  53576. BrowserBack = 5,
  53577. /** Browser Forward */
  53578. BrowserForward = 6
  53579. }
  53580. /**
  53581. * Enum for Dual Shock Gamepad
  53582. */
  53583. export enum DualShockInput {
  53584. /** Cross */
  53585. Cross = 0,
  53586. /** Circle */
  53587. Circle = 1,
  53588. /** Square */
  53589. Square = 2,
  53590. /** Triangle */
  53591. Triangle = 3,
  53592. /** L1 */
  53593. L1 = 4,
  53594. /** R1 */
  53595. R1 = 5,
  53596. /** L2 */
  53597. L2 = 6,
  53598. /** R2 */
  53599. R2 = 7,
  53600. /** Share */
  53601. Share = 8,
  53602. /** Options */
  53603. Options = 9,
  53604. /** L3 */
  53605. L3 = 10,
  53606. /** R3 */
  53607. R3 = 11,
  53608. /** DPadUp */
  53609. DPadUp = 12,
  53610. /** DPadDown */
  53611. DPadDown = 13,
  53612. /** DPadLeft */
  53613. DPadLeft = 14,
  53614. /** DRight */
  53615. DPadRight = 15,
  53616. /** Home */
  53617. Home = 16,
  53618. /** TouchPad */
  53619. TouchPad = 17,
  53620. /** LStickXAxis */
  53621. LStickXAxis = 18,
  53622. /** LStickYAxis */
  53623. LStickYAxis = 19,
  53624. /** RStickXAxis */
  53625. RStickXAxis = 20,
  53626. /** RStickYAxis */
  53627. RStickYAxis = 21
  53628. }
  53629. /**
  53630. * Enum for Xbox Gamepad
  53631. */
  53632. export enum XboxInput {
  53633. /** A */
  53634. A = 0,
  53635. /** B */
  53636. B = 1,
  53637. /** X */
  53638. X = 2,
  53639. /** Y */
  53640. Y = 3,
  53641. /** LB */
  53642. LB = 4,
  53643. /** RB */
  53644. RB = 5,
  53645. /** LT */
  53646. LT = 6,
  53647. /** RT */
  53648. RT = 7,
  53649. /** Back */
  53650. Back = 8,
  53651. /** Start */
  53652. Start = 9,
  53653. /** LS */
  53654. LS = 10,
  53655. /** RS */
  53656. RS = 11,
  53657. /** DPadUp */
  53658. DPadUp = 12,
  53659. /** DPadDown */
  53660. DPadDown = 13,
  53661. /** DPadLeft */
  53662. DPadLeft = 14,
  53663. /** DRight */
  53664. DPadRight = 15,
  53665. /** Home */
  53666. Home = 16,
  53667. /** LStickXAxis */
  53668. LStickXAxis = 17,
  53669. /** LStickYAxis */
  53670. LStickYAxis = 18,
  53671. /** RStickXAxis */
  53672. RStickXAxis = 19,
  53673. /** RStickYAxis */
  53674. RStickYAxis = 20
  53675. }
  53676. /**
  53677. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53678. */
  53679. export enum SwitchInput {
  53680. /** B */
  53681. B = 0,
  53682. /** A */
  53683. A = 1,
  53684. /** Y */
  53685. Y = 2,
  53686. /** X */
  53687. X = 3,
  53688. /** L */
  53689. L = 4,
  53690. /** R */
  53691. R = 5,
  53692. /** ZL */
  53693. ZL = 6,
  53694. /** ZR */
  53695. ZR = 7,
  53696. /** Minus */
  53697. Minus = 8,
  53698. /** Plus */
  53699. Plus = 9,
  53700. /** LS */
  53701. LS = 10,
  53702. /** RS */
  53703. RS = 11,
  53704. /** DPadUp */
  53705. DPadUp = 12,
  53706. /** DPadDown */
  53707. DPadDown = 13,
  53708. /** DPadLeft */
  53709. DPadLeft = 14,
  53710. /** DRight */
  53711. DPadRight = 15,
  53712. /** Home */
  53713. Home = 16,
  53714. /** Capture */
  53715. Capture = 17,
  53716. /** LStickXAxis */
  53717. LStickXAxis = 18,
  53718. /** LStickYAxis */
  53719. LStickYAxis = 19,
  53720. /** RStickXAxis */
  53721. RStickXAxis = 20,
  53722. /** RStickYAxis */
  53723. RStickYAxis = 21
  53724. }
  53725. }
  53726. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53727. import { Engine } from "babylonjs/Engines/engine";
  53728. import { IDisposable } from "babylonjs/scene";
  53729. import { Nullable } from "babylonjs/types";
  53730. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53731. /**
  53732. * This class will take all inputs from Keyboard, Pointer, and
  53733. * any Gamepads and provide a polling system that all devices
  53734. * will use. This class assumes that there will only be one
  53735. * pointer device and one keyboard.
  53736. */
  53737. export class DeviceInputSystem implements IDisposable {
  53738. /**
  53739. * Callback to be triggered when a device is connected
  53740. */
  53741. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53742. /**
  53743. * Callback to be triggered when a device is disconnected
  53744. */
  53745. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53746. /**
  53747. * Callback to be triggered when event driven input is updated
  53748. */
  53749. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53750. private _inputs;
  53751. private _gamepads;
  53752. private _keyboardActive;
  53753. private _pointerActive;
  53754. private _elementToAttachTo;
  53755. private _keyboardDownEvent;
  53756. private _keyboardUpEvent;
  53757. private _pointerMoveEvent;
  53758. private _pointerDownEvent;
  53759. private _pointerUpEvent;
  53760. private _gamepadConnectedEvent;
  53761. private _gamepadDisconnectedEvent;
  53762. private static _MAX_KEYCODES;
  53763. private static _MAX_POINTER_INPUTS;
  53764. private constructor();
  53765. /**
  53766. * Creates a new DeviceInputSystem instance
  53767. * @param engine Engine to pull input element from
  53768. * @returns The new instance
  53769. */
  53770. static Create(engine: Engine): DeviceInputSystem;
  53771. /**
  53772. * Checks for current device input value, given an id and input index
  53773. * @param deviceName Id of connected device
  53774. * @param inputIndex Index of device input
  53775. * @returns Current value of input
  53776. */
  53777. /**
  53778. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53779. * @param deviceType Enum specifiying device type
  53780. * @param deviceSlot "Slot" or index that device is referenced in
  53781. * @param inputIndex Id of input to be checked
  53782. * @returns Current value of input
  53783. */
  53784. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53785. /**
  53786. * Dispose of all the eventlisteners
  53787. */
  53788. dispose(): void;
  53789. /**
  53790. * Add device and inputs to device array
  53791. * @param deviceType Enum specifiying device type
  53792. * @param deviceSlot "Slot" or index that device is referenced in
  53793. * @param numberOfInputs Number of input entries to create for given device
  53794. */
  53795. private _registerDevice;
  53796. /**
  53797. * Given a specific device name, remove that device from the device map
  53798. * @param deviceType Enum specifiying device type
  53799. * @param deviceSlot "Slot" or index that device is referenced in
  53800. */
  53801. private _unregisterDevice;
  53802. /**
  53803. * Handle all actions that come from keyboard interaction
  53804. */
  53805. private _handleKeyActions;
  53806. /**
  53807. * Handle all actions that come from pointer interaction
  53808. */
  53809. private _handlePointerActions;
  53810. /**
  53811. * Handle all actions that come from gamepad interaction
  53812. */
  53813. private _handleGamepadActions;
  53814. /**
  53815. * Update all non-event based devices with each frame
  53816. * @param deviceType Enum specifiying device type
  53817. * @param deviceSlot "Slot" or index that device is referenced in
  53818. * @param inputIndex Id of input to be checked
  53819. */
  53820. private _updateDevice;
  53821. /**
  53822. * Gets DeviceType from the device name
  53823. * @param deviceName Name of Device from DeviceInputSystem
  53824. * @returns DeviceType enum value
  53825. */
  53826. private _getGamepadDeviceType;
  53827. }
  53828. }
  53829. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53830. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53831. /**
  53832. * Type to handle enforcement of inputs
  53833. */
  53834. 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;
  53835. }
  53836. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53837. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53838. import { Engine } from "babylonjs/Engines/engine";
  53839. import { IDisposable } from "babylonjs/scene";
  53840. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53841. import { Nullable } from "babylonjs/types";
  53842. import { Observable } from "babylonjs/Misc/observable";
  53843. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53844. /**
  53845. * Class that handles all input for a specific device
  53846. */
  53847. export class DeviceSource<T extends DeviceType> {
  53848. /** Type of device */
  53849. readonly deviceType: DeviceType;
  53850. /** "Slot" or index that device is referenced in */
  53851. readonly deviceSlot: number;
  53852. /**
  53853. * Observable to handle device input changes per device
  53854. */
  53855. readonly onInputChangedObservable: Observable<{
  53856. inputIndex: DeviceInput<T>;
  53857. previousState: Nullable<number>;
  53858. currentState: Nullable<number>;
  53859. }>;
  53860. private readonly _deviceInputSystem;
  53861. /**
  53862. * Default Constructor
  53863. * @param deviceInputSystem Reference to DeviceInputSystem
  53864. * @param deviceType Type of device
  53865. * @param deviceSlot "Slot" or index that device is referenced in
  53866. */
  53867. constructor(deviceInputSystem: DeviceInputSystem,
  53868. /** Type of device */
  53869. deviceType: DeviceType,
  53870. /** "Slot" or index that device is referenced in */
  53871. deviceSlot?: number);
  53872. /**
  53873. * Get input for specific input
  53874. * @param inputIndex index of specific input on device
  53875. * @returns Input value from DeviceInputSystem
  53876. */
  53877. getInput(inputIndex: DeviceInput<T>): number;
  53878. }
  53879. /**
  53880. * Class to keep track of devices
  53881. */
  53882. export class DeviceSourceManager implements IDisposable {
  53883. /**
  53884. * Observable to be triggered when before a device is connected
  53885. */
  53886. readonly onBeforeDeviceConnectedObservable: Observable<{
  53887. deviceType: DeviceType;
  53888. deviceSlot: number;
  53889. }>;
  53890. /**
  53891. * Observable to be triggered when before a device is disconnected
  53892. */
  53893. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53894. deviceType: DeviceType;
  53895. deviceSlot: number;
  53896. }>;
  53897. /**
  53898. * Observable to be triggered when after a device is connected
  53899. */
  53900. readonly onAfterDeviceConnectedObservable: Observable<{
  53901. deviceType: DeviceType;
  53902. deviceSlot: number;
  53903. }>;
  53904. /**
  53905. * Observable to be triggered when after a device is disconnected
  53906. */
  53907. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53908. deviceType: DeviceType;
  53909. deviceSlot: number;
  53910. }>;
  53911. private readonly _devices;
  53912. private readonly _firstDevice;
  53913. private readonly _deviceInputSystem;
  53914. /**
  53915. * Default Constructor
  53916. * @param engine engine to pull input element from
  53917. */
  53918. constructor(engine: Engine);
  53919. /**
  53920. * Gets a DeviceSource, given a type and slot
  53921. * @param deviceType Enum specifying device type
  53922. * @param deviceSlot "Slot" or index that device is referenced in
  53923. * @returns DeviceSource object
  53924. */
  53925. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53926. /**
  53927. * Gets an array of DeviceSource objects for a given device type
  53928. * @param deviceType Enum specifying device type
  53929. * @returns Array of DeviceSource objects
  53930. */
  53931. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53932. /**
  53933. * Dispose of DeviceInputSystem and other parts
  53934. */
  53935. dispose(): void;
  53936. /**
  53937. * Function to add device name to device list
  53938. * @param deviceType Enum specifying device type
  53939. * @param deviceSlot "Slot" or index that device is referenced in
  53940. */
  53941. private _addDevice;
  53942. /**
  53943. * Function to remove device name to device list
  53944. * @param deviceType Enum specifying device type
  53945. * @param deviceSlot "Slot" or index that device is referenced in
  53946. */
  53947. private _removeDevice;
  53948. /**
  53949. * Updates array storing first connected device of each type
  53950. * @param type Type of Device
  53951. */
  53952. private _updateFirstDevices;
  53953. }
  53954. }
  53955. declare module "babylonjs/DeviceInput/index" {
  53956. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53957. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53958. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53959. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53960. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53961. }
  53962. declare module "babylonjs/Engines/nullEngine" {
  53963. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53964. import { Engine } from "babylonjs/Engines/engine";
  53965. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53966. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53968. import { Effect } from "babylonjs/Materials/effect";
  53969. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53970. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53971. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53972. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53973. /**
  53974. * Options to create the null engine
  53975. */
  53976. export class NullEngineOptions {
  53977. /**
  53978. * Render width (Default: 512)
  53979. */
  53980. renderWidth: number;
  53981. /**
  53982. * Render height (Default: 256)
  53983. */
  53984. renderHeight: number;
  53985. /**
  53986. * Texture size (Default: 512)
  53987. */
  53988. textureSize: number;
  53989. /**
  53990. * If delta time between frames should be constant
  53991. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53992. */
  53993. deterministicLockstep: boolean;
  53994. /**
  53995. * Maximum about of steps between frames (Default: 4)
  53996. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53997. */
  53998. lockstepMaxSteps: number;
  53999. /**
  54000. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54001. */
  54002. useHighPrecisionMatrix?: boolean;
  54003. }
  54004. /**
  54005. * The null engine class provides support for headless version of babylon.js.
  54006. * This can be used in server side scenario or for testing purposes
  54007. */
  54008. export class NullEngine extends Engine {
  54009. private _options;
  54010. /**
  54011. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54012. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54013. * @returns true if engine is in deterministic lock step mode
  54014. */
  54015. isDeterministicLockStep(): boolean;
  54016. /**
  54017. * Gets the max steps when engine is running in deterministic lock step
  54018. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54019. * @returns the max steps
  54020. */
  54021. getLockstepMaxSteps(): number;
  54022. /**
  54023. * Gets the current hardware scaling level.
  54024. * By default the hardware scaling level is computed from the window device ratio.
  54025. * 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.
  54026. * @returns a number indicating the current hardware scaling level
  54027. */
  54028. getHardwareScalingLevel(): number;
  54029. constructor(options?: NullEngineOptions);
  54030. /**
  54031. * Creates a vertex buffer
  54032. * @param vertices the data for the vertex buffer
  54033. * @returns the new WebGL static buffer
  54034. */
  54035. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54036. /**
  54037. * Creates a new index buffer
  54038. * @param indices defines the content of the index buffer
  54039. * @param updatable defines if the index buffer must be updatable
  54040. * @returns a new webGL buffer
  54041. */
  54042. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54043. /**
  54044. * Clear the current render buffer or the current render target (if any is set up)
  54045. * @param color defines the color to use
  54046. * @param backBuffer defines if the back buffer must be cleared
  54047. * @param depth defines if the depth buffer must be cleared
  54048. * @param stencil defines if the stencil buffer must be cleared
  54049. */
  54050. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54051. /**
  54052. * Gets the current render width
  54053. * @param useScreen defines if screen size must be used (or the current render target if any)
  54054. * @returns a number defining the current render width
  54055. */
  54056. getRenderWidth(useScreen?: boolean): number;
  54057. /**
  54058. * Gets the current render height
  54059. * @param useScreen defines if screen size must be used (or the current render target if any)
  54060. * @returns a number defining the current render height
  54061. */
  54062. getRenderHeight(useScreen?: boolean): number;
  54063. /**
  54064. * Set the WebGL's viewport
  54065. * @param viewport defines the viewport element to be used
  54066. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54067. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54068. */
  54069. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54070. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54071. /**
  54072. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54073. * @param pipelineContext defines the pipeline context to use
  54074. * @param uniformsNames defines the list of uniform names
  54075. * @returns an array of webGL uniform locations
  54076. */
  54077. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54078. /**
  54079. * Gets the lsit of active attributes for a given webGL program
  54080. * @param pipelineContext defines the pipeline context to use
  54081. * @param attributesNames defines the list of attribute names to get
  54082. * @returns an array of indices indicating the offset of each attribute
  54083. */
  54084. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54085. /**
  54086. * Binds an effect to the webGL context
  54087. * @param effect defines the effect to bind
  54088. */
  54089. bindSamplers(effect: Effect): void;
  54090. /**
  54091. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54092. * @param effect defines the effect to activate
  54093. */
  54094. enableEffect(effect: Effect): void;
  54095. /**
  54096. * Set various states to the webGL context
  54097. * @param culling defines backface culling state
  54098. * @param zOffset defines the value to apply to zOffset (0 by default)
  54099. * @param force defines if states must be applied even if cache is up to date
  54100. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54101. */
  54102. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54103. /**
  54104. * Set the value of an uniform to an array of int32
  54105. * @param uniform defines the webGL uniform location where to store the value
  54106. * @param array defines the array of int32 to store
  54107. * @returns true if value was set
  54108. */
  54109. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54110. /**
  54111. * Set the value of an uniform to an array of int32 (stored as vec2)
  54112. * @param uniform defines the webGL uniform location where to store the value
  54113. * @param array defines the array of int32 to store
  54114. * @returns true if value was set
  54115. */
  54116. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54117. /**
  54118. * Set the value of an uniform to an array of int32 (stored as vec3)
  54119. * @param uniform defines the webGL uniform location where to store the value
  54120. * @param array defines the array of int32 to store
  54121. * @returns true if value was set
  54122. */
  54123. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54124. /**
  54125. * Set the value of an uniform to an array of int32 (stored as vec4)
  54126. * @param uniform defines the webGL uniform location where to store the value
  54127. * @param array defines the array of int32 to store
  54128. * @returns true if value was set
  54129. */
  54130. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54131. /**
  54132. * Set the value of an uniform to an array of float32
  54133. * @param uniform defines the webGL uniform location where to store the value
  54134. * @param array defines the array of float32 to store
  54135. * @returns true if value was set
  54136. */
  54137. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54138. /**
  54139. * Set the value of an uniform to an array of float32 (stored as vec2)
  54140. * @param uniform defines the webGL uniform location where to store the value
  54141. * @param array defines the array of float32 to store
  54142. * @returns true if value was set
  54143. */
  54144. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54145. /**
  54146. * Set the value of an uniform to an array of float32 (stored as vec3)
  54147. * @param uniform defines the webGL uniform location where to store the value
  54148. * @param array defines the array of float32 to store
  54149. * @returns true if value was set
  54150. */
  54151. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54152. /**
  54153. * Set the value of an uniform to an array of float32 (stored as vec4)
  54154. * @param uniform defines the webGL uniform location where to store the value
  54155. * @param array defines the array of float32 to store
  54156. * @returns true if value was set
  54157. */
  54158. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54159. /**
  54160. * Set the value of an uniform to an array of number
  54161. * @param uniform defines the webGL uniform location where to store the value
  54162. * @param array defines the array of number to store
  54163. * @returns true if value was set
  54164. */
  54165. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54166. /**
  54167. * Set the value of an uniform to an array of number (stored as vec2)
  54168. * @param uniform defines the webGL uniform location where to store the value
  54169. * @param array defines the array of number to store
  54170. * @returns true if value was set
  54171. */
  54172. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54173. /**
  54174. * Set the value of an uniform to an array of number (stored as vec3)
  54175. * @param uniform defines the webGL uniform location where to store the value
  54176. * @param array defines the array of number to store
  54177. * @returns true if value was set
  54178. */
  54179. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54180. /**
  54181. * Set the value of an uniform to an array of number (stored as vec4)
  54182. * @param uniform defines the webGL uniform location where to store the value
  54183. * @param array defines the array of number to store
  54184. * @returns true if value was set
  54185. */
  54186. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54187. /**
  54188. * Set the value of an uniform to an array of float32 (stored as matrices)
  54189. * @param uniform defines the webGL uniform location where to store the value
  54190. * @param matrices defines the array of float32 to store
  54191. * @returns true if value was set
  54192. */
  54193. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54194. /**
  54195. * Set the value of an uniform to a matrix (3x3)
  54196. * @param uniform defines the webGL uniform location where to store the value
  54197. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54198. * @returns true if value was set
  54199. */
  54200. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54201. /**
  54202. * Set the value of an uniform to a matrix (2x2)
  54203. * @param uniform defines the webGL uniform location where to store the value
  54204. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54205. * @returns true if value was set
  54206. */
  54207. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54208. /**
  54209. * Set the value of an uniform to a number (float)
  54210. * @param uniform defines the webGL uniform location where to store the value
  54211. * @param value defines the float number to store
  54212. * @returns true if value was set
  54213. */
  54214. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54215. /**
  54216. * Set the value of an uniform to a vec2
  54217. * @param uniform defines the webGL uniform location where to store the value
  54218. * @param x defines the 1st component of the value
  54219. * @param y defines the 2nd component of the value
  54220. * @returns true if value was set
  54221. */
  54222. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54223. /**
  54224. * Set the value of an uniform to a vec3
  54225. * @param uniform defines the webGL uniform location where to store the value
  54226. * @param x defines the 1st component of the value
  54227. * @param y defines the 2nd component of the value
  54228. * @param z defines the 3rd component of the value
  54229. * @returns true if value was set
  54230. */
  54231. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54232. /**
  54233. * Set the value of an uniform to a boolean
  54234. * @param uniform defines the webGL uniform location where to store the value
  54235. * @param bool defines the boolean to store
  54236. * @returns true if value was set
  54237. */
  54238. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54239. /**
  54240. * Set the value of an uniform to a vec4
  54241. * @param uniform defines the webGL uniform location where to store the value
  54242. * @param x defines the 1st component of the value
  54243. * @param y defines the 2nd component of the value
  54244. * @param z defines the 3rd component of the value
  54245. * @param w defines the 4th component of the value
  54246. * @returns true if value was set
  54247. */
  54248. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54249. /**
  54250. * Sets the current alpha mode
  54251. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54252. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54253. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54254. */
  54255. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54256. /**
  54257. * Bind webGl buffers directly to the webGL context
  54258. * @param vertexBuffers defines the vertex buffer to bind
  54259. * @param indexBuffer defines the index buffer to bind
  54260. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54261. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54262. * @param effect defines the effect associated with the vertex buffer
  54263. */
  54264. bindBuffers(vertexBuffers: {
  54265. [key: string]: VertexBuffer;
  54266. }, indexBuffer: DataBuffer, effect: Effect): void;
  54267. /**
  54268. * Force the entire cache to be cleared
  54269. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54270. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54271. */
  54272. wipeCaches(bruteForce?: boolean): void;
  54273. /**
  54274. * Send a draw order
  54275. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54276. * @param indexStart defines the starting index
  54277. * @param indexCount defines the number of index to draw
  54278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54279. */
  54280. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54281. /**
  54282. * Draw a list of indexed primitives
  54283. * @param fillMode defines the primitive to use
  54284. * @param indexStart defines the starting index
  54285. * @param indexCount defines the number of index to draw
  54286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54287. */
  54288. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54289. /**
  54290. * Draw a list of unindexed primitives
  54291. * @param fillMode defines the primitive to use
  54292. * @param verticesStart defines the index of first vertex to draw
  54293. * @param verticesCount defines the count of vertices to draw
  54294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54295. */
  54296. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54297. /** @hidden */
  54298. _createTexture(): WebGLTexture;
  54299. /** @hidden */
  54300. _releaseTexture(texture: InternalTexture): void;
  54301. /**
  54302. * Usually called from Texture.ts.
  54303. * Passed information to create a WebGLTexture
  54304. * @param urlArg defines a value which contains one of the following:
  54305. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54306. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54307. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54308. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54309. * @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)
  54310. * @param scene needed for loading to the correct scene
  54311. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54312. * @param onLoad optional callback to be called upon successful completion
  54313. * @param onError optional callback to be called upon failure
  54314. * @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
  54315. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54316. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54317. * @param forcedExtension defines the extension to use to pick the right loader
  54318. * @param mimeType defines an optional mime type
  54319. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54320. */
  54321. 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;
  54322. /**
  54323. * Creates a new render target texture
  54324. * @param size defines the size of the texture
  54325. * @param options defines the options used to create the texture
  54326. * @returns a new render target texture stored in an InternalTexture
  54327. */
  54328. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54329. /**
  54330. * Update the sampling mode of a given texture
  54331. * @param samplingMode defines the required sampling mode
  54332. * @param texture defines the texture to update
  54333. */
  54334. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54335. /**
  54336. * Binds the frame buffer to the specified texture.
  54337. * @param texture The texture to render to or null for the default canvas
  54338. * @param faceIndex The face of the texture to render to in case of cube texture
  54339. * @param requiredWidth The width of the target to render to
  54340. * @param requiredHeight The height of the target to render to
  54341. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54342. * @param lodLevel defines le lod level to bind to the frame buffer
  54343. */
  54344. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54345. /**
  54346. * Unbind the current render target texture from the webGL context
  54347. * @param texture defines the render target texture to unbind
  54348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54350. */
  54351. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54352. /**
  54353. * Creates a dynamic vertex buffer
  54354. * @param vertices the data for the dynamic vertex buffer
  54355. * @returns the new WebGL dynamic buffer
  54356. */
  54357. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54358. /**
  54359. * Update the content of a dynamic texture
  54360. * @param texture defines the texture to update
  54361. * @param canvas defines the canvas containing the source
  54362. * @param invertY defines if data must be stored with Y axis inverted
  54363. * @param premulAlpha defines if alpha is stored as premultiplied
  54364. * @param format defines the format of the data
  54365. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54366. */
  54367. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54368. /**
  54369. * Gets a boolean indicating if all created effects are ready
  54370. * @returns true if all effects are ready
  54371. */
  54372. areAllEffectsReady(): boolean;
  54373. /**
  54374. * @hidden
  54375. * Get the current error code of the webGL context
  54376. * @returns the error code
  54377. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54378. */
  54379. getError(): number;
  54380. /** @hidden */
  54381. _getUnpackAlignement(): number;
  54382. /** @hidden */
  54383. _unpackFlipY(value: boolean): void;
  54384. /**
  54385. * Update a dynamic index buffer
  54386. * @param indexBuffer defines the target index buffer
  54387. * @param indices defines the data to update
  54388. * @param offset defines the offset in the target index buffer where update should start
  54389. */
  54390. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54391. /**
  54392. * Updates a dynamic vertex buffer.
  54393. * @param vertexBuffer the vertex buffer to update
  54394. * @param vertices the data used to update the vertex buffer
  54395. * @param byteOffset the byte offset of the data (optional)
  54396. * @param byteLength the byte length of the data (optional)
  54397. */
  54398. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54399. /** @hidden */
  54400. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54401. /** @hidden */
  54402. _bindTexture(channel: number, texture: InternalTexture): void;
  54403. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54404. /**
  54405. * 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
  54406. */
  54407. releaseEffects(): void;
  54408. displayLoadingUI(): void;
  54409. hideLoadingUI(): void;
  54410. /** @hidden */
  54411. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54412. /** @hidden */
  54413. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54414. /** @hidden */
  54415. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54416. /** @hidden */
  54417. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54418. }
  54419. }
  54420. declare module "babylonjs/Instrumentation/timeToken" {
  54421. import { Nullable } from "babylonjs/types";
  54422. /**
  54423. * @hidden
  54424. **/
  54425. export class _TimeToken {
  54426. _startTimeQuery: Nullable<WebGLQuery>;
  54427. _endTimeQuery: Nullable<WebGLQuery>;
  54428. _timeElapsedQuery: Nullable<WebGLQuery>;
  54429. _timeElapsedQueryEnded: boolean;
  54430. }
  54431. }
  54432. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54433. import { Nullable, int } from "babylonjs/types";
  54434. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54435. /** @hidden */
  54436. export class _OcclusionDataStorage {
  54437. /** @hidden */
  54438. occlusionInternalRetryCounter: number;
  54439. /** @hidden */
  54440. isOcclusionQueryInProgress: boolean;
  54441. /** @hidden */
  54442. isOccluded: boolean;
  54443. /** @hidden */
  54444. occlusionRetryCount: number;
  54445. /** @hidden */
  54446. occlusionType: number;
  54447. /** @hidden */
  54448. occlusionQueryAlgorithmType: number;
  54449. }
  54450. module "babylonjs/Engines/engine" {
  54451. interface Engine {
  54452. /**
  54453. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54454. * @return the new query
  54455. */
  54456. createQuery(): WebGLQuery;
  54457. /**
  54458. * Delete and release a webGL query
  54459. * @param query defines the query to delete
  54460. * @return the current engine
  54461. */
  54462. deleteQuery(query: WebGLQuery): Engine;
  54463. /**
  54464. * Check if a given query has resolved and got its value
  54465. * @param query defines the query to check
  54466. * @returns true if the query got its value
  54467. */
  54468. isQueryResultAvailable(query: WebGLQuery): boolean;
  54469. /**
  54470. * Gets the value of a given query
  54471. * @param query defines the query to check
  54472. * @returns the value of the query
  54473. */
  54474. getQueryResult(query: WebGLQuery): number;
  54475. /**
  54476. * Initiates an occlusion query
  54477. * @param algorithmType defines the algorithm to use
  54478. * @param query defines the query to use
  54479. * @returns the current engine
  54480. * @see https://doc.babylonjs.com/features/occlusionquery
  54481. */
  54482. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54483. /**
  54484. * Ends an occlusion query
  54485. * @see https://doc.babylonjs.com/features/occlusionquery
  54486. * @param algorithmType defines the algorithm to use
  54487. * @returns the current engine
  54488. */
  54489. endOcclusionQuery(algorithmType: number): Engine;
  54490. /**
  54491. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54492. * Please note that only one query can be issued at a time
  54493. * @returns a time token used to track the time span
  54494. */
  54495. startTimeQuery(): Nullable<_TimeToken>;
  54496. /**
  54497. * Ends a time query
  54498. * @param token defines the token used to measure the time span
  54499. * @returns the time spent (in ns)
  54500. */
  54501. endTimeQuery(token: _TimeToken): int;
  54502. /** @hidden */
  54503. _currentNonTimestampToken: Nullable<_TimeToken>;
  54504. /** @hidden */
  54505. _createTimeQuery(): WebGLQuery;
  54506. /** @hidden */
  54507. _deleteTimeQuery(query: WebGLQuery): void;
  54508. /** @hidden */
  54509. _getGlAlgorithmType(algorithmType: number): number;
  54510. /** @hidden */
  54511. _getTimeQueryResult(query: WebGLQuery): any;
  54512. /** @hidden */
  54513. _getTimeQueryAvailability(query: WebGLQuery): any;
  54514. }
  54515. }
  54516. module "babylonjs/Meshes/abstractMesh" {
  54517. interface AbstractMesh {
  54518. /**
  54519. * Backing filed
  54520. * @hidden
  54521. */
  54522. __occlusionDataStorage: _OcclusionDataStorage;
  54523. /**
  54524. * Access property
  54525. * @hidden
  54526. */
  54527. _occlusionDataStorage: _OcclusionDataStorage;
  54528. /**
  54529. * 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.
  54530. * The default value is -1 which means don't break the query and wait till the result
  54531. * @see https://doc.babylonjs.com/features/occlusionquery
  54532. */
  54533. occlusionRetryCount: number;
  54534. /**
  54535. * 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:
  54536. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54537. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54538. * * 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.
  54539. * @see https://doc.babylonjs.com/features/occlusionquery
  54540. */
  54541. occlusionType: number;
  54542. /**
  54543. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54544. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54545. * * 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.
  54546. * @see https://doc.babylonjs.com/features/occlusionquery
  54547. */
  54548. occlusionQueryAlgorithmType: number;
  54549. /**
  54550. * 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
  54551. * @see https://doc.babylonjs.com/features/occlusionquery
  54552. */
  54553. isOccluded: boolean;
  54554. /**
  54555. * Flag to check the progress status of the query
  54556. * @see https://doc.babylonjs.com/features/occlusionquery
  54557. */
  54558. isOcclusionQueryInProgress: boolean;
  54559. }
  54560. }
  54561. }
  54562. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54563. import { Nullable } from "babylonjs/types";
  54564. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54565. /** @hidden */
  54566. export var _forceTransformFeedbackToBundle: boolean;
  54567. module "babylonjs/Engines/engine" {
  54568. interface Engine {
  54569. /**
  54570. * Creates a webGL transform feedback object
  54571. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54572. * @returns the webGL transform feedback object
  54573. */
  54574. createTransformFeedback(): WebGLTransformFeedback;
  54575. /**
  54576. * Delete a webGL transform feedback object
  54577. * @param value defines the webGL transform feedback object to delete
  54578. */
  54579. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54580. /**
  54581. * Bind a webGL transform feedback object to the webgl context
  54582. * @param value defines the webGL transform feedback object to bind
  54583. */
  54584. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54585. /**
  54586. * Begins a transform feedback operation
  54587. * @param usePoints defines if points or triangles must be used
  54588. */
  54589. beginTransformFeedback(usePoints: boolean): void;
  54590. /**
  54591. * Ends a transform feedback operation
  54592. */
  54593. endTransformFeedback(): void;
  54594. /**
  54595. * Specify the varyings to use with transform feedback
  54596. * @param program defines the associated webGL program
  54597. * @param value defines the list of strings representing the varying names
  54598. */
  54599. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54600. /**
  54601. * Bind a webGL buffer for a transform feedback operation
  54602. * @param value defines the webGL buffer to bind
  54603. */
  54604. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54605. }
  54606. }
  54607. }
  54608. declare module "babylonjs/Engines/Extensions/engine.views" {
  54609. import { Camera } from "babylonjs/Cameras/camera";
  54610. import { Nullable } from "babylonjs/types";
  54611. /**
  54612. * Class used to define an additional view for the engine
  54613. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54614. */
  54615. export class EngineView {
  54616. /** Defines the canvas where to render the view */
  54617. target: HTMLCanvasElement;
  54618. /** Defines an optional camera used to render the view (will use active camera else) */
  54619. camera?: Camera;
  54620. }
  54621. module "babylonjs/Engines/engine" {
  54622. interface Engine {
  54623. /**
  54624. * Gets or sets the HTML element to use for attaching events
  54625. */
  54626. inputElement: Nullable<HTMLElement>;
  54627. /**
  54628. * Gets the current engine view
  54629. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54630. */
  54631. activeView: Nullable<EngineView>;
  54632. /** Gets or sets the list of views */
  54633. views: EngineView[];
  54634. /**
  54635. * Register a new child canvas
  54636. * @param canvas defines the canvas to register
  54637. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54638. * @returns the associated view
  54639. */
  54640. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54641. /**
  54642. * Remove a registered child canvas
  54643. * @param canvas defines the canvas to remove
  54644. * @returns the current engine
  54645. */
  54646. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54647. }
  54648. }
  54649. }
  54650. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54651. import { Nullable } from "babylonjs/types";
  54652. module "babylonjs/Engines/engine" {
  54653. interface Engine {
  54654. /** @hidden */
  54655. _excludedCompressedTextures: string[];
  54656. /** @hidden */
  54657. _textureFormatInUse: string;
  54658. /**
  54659. * Gets the list of texture formats supported
  54660. */
  54661. readonly texturesSupported: Array<string>;
  54662. /**
  54663. * Gets the texture format in use
  54664. */
  54665. readonly textureFormatInUse: Nullable<string>;
  54666. /**
  54667. * Set the compressed texture extensions or file names to skip.
  54668. *
  54669. * @param skippedFiles defines the list of those texture files you want to skip
  54670. * Example: [".dds", ".env", "myfile.png"]
  54671. */
  54672. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54673. /**
  54674. * Set the compressed texture format to use, based on the formats you have, and the formats
  54675. * supported by the hardware / browser.
  54676. *
  54677. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54678. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54679. * to API arguments needed to compressed textures. This puts the burden on the container
  54680. * generator to house the arcane code for determining these for current & future formats.
  54681. *
  54682. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54683. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54684. *
  54685. * Note: The result of this call is not taken into account when a texture is base64.
  54686. *
  54687. * @param formatsAvailable defines the list of those format families you have created
  54688. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54689. *
  54690. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54691. * @returns The extension selected.
  54692. */
  54693. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54694. }
  54695. }
  54696. }
  54697. declare module "babylonjs/Engines/Extensions/index" {
  54698. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54699. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54700. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54701. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54702. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54703. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54704. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54705. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54706. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54707. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54708. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54709. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54710. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54711. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54712. export * from "babylonjs/Engines/Extensions/engine.views";
  54713. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54714. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54715. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54716. }
  54717. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54718. import { Nullable } from "babylonjs/types";
  54719. /**
  54720. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54721. */
  54722. export interface CubeMapInfo {
  54723. /**
  54724. * The pixel array for the front face.
  54725. * This is stored in format, left to right, up to down format.
  54726. */
  54727. front: Nullable<ArrayBufferView>;
  54728. /**
  54729. * The pixel array for the back face.
  54730. * This is stored in format, left to right, up to down format.
  54731. */
  54732. back: Nullable<ArrayBufferView>;
  54733. /**
  54734. * The pixel array for the left face.
  54735. * This is stored in format, left to right, up to down format.
  54736. */
  54737. left: Nullable<ArrayBufferView>;
  54738. /**
  54739. * The pixel array for the right face.
  54740. * This is stored in format, left to right, up to down format.
  54741. */
  54742. right: Nullable<ArrayBufferView>;
  54743. /**
  54744. * The pixel array for the up face.
  54745. * This is stored in format, left to right, up to down format.
  54746. */
  54747. up: Nullable<ArrayBufferView>;
  54748. /**
  54749. * The pixel array for the down face.
  54750. * This is stored in format, left to right, up to down format.
  54751. */
  54752. down: Nullable<ArrayBufferView>;
  54753. /**
  54754. * The size of the cubemap stored.
  54755. *
  54756. * Each faces will be size * size pixels.
  54757. */
  54758. size: number;
  54759. /**
  54760. * The format of the texture.
  54761. *
  54762. * RGBA, RGB.
  54763. */
  54764. format: number;
  54765. /**
  54766. * The type of the texture data.
  54767. *
  54768. * UNSIGNED_INT, FLOAT.
  54769. */
  54770. type: number;
  54771. /**
  54772. * Specifies whether the texture is in gamma space.
  54773. */
  54774. gammaSpace: boolean;
  54775. }
  54776. /**
  54777. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54778. */
  54779. export class PanoramaToCubeMapTools {
  54780. private static FACE_LEFT;
  54781. private static FACE_RIGHT;
  54782. private static FACE_FRONT;
  54783. private static FACE_BACK;
  54784. private static FACE_DOWN;
  54785. private static FACE_UP;
  54786. /**
  54787. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54788. *
  54789. * @param float32Array The source data.
  54790. * @param inputWidth The width of the input panorama.
  54791. * @param inputHeight The height of the input panorama.
  54792. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54793. * @return The cubemap data
  54794. */
  54795. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54796. private static CreateCubemapTexture;
  54797. private static CalcProjectionSpherical;
  54798. }
  54799. }
  54800. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54801. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54803. import { Nullable } from "babylonjs/types";
  54804. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54805. /**
  54806. * Helper class dealing with the extraction of spherical polynomial dataArray
  54807. * from a cube map.
  54808. */
  54809. export class CubeMapToSphericalPolynomialTools {
  54810. private static FileFaces;
  54811. /**
  54812. * Converts a texture to the according Spherical Polynomial data.
  54813. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54814. *
  54815. * @param texture The texture to extract the information from.
  54816. * @return The Spherical Polynomial data.
  54817. */
  54818. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54819. /**
  54820. * Converts a cubemap to the according Spherical Polynomial data.
  54821. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54822. *
  54823. * @param cubeInfo The Cube map to extract the information from.
  54824. * @return The Spherical Polynomial data.
  54825. */
  54826. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54832. module "babylonjs/Materials/Textures/baseTexture" {
  54833. interface BaseTexture {
  54834. /**
  54835. * Get the polynomial representation of the texture data.
  54836. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54837. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54838. */
  54839. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54840. }
  54841. }
  54842. }
  54843. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54844. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54845. /** @hidden */
  54846. export var rgbdEncodePixelShader: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54852. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54853. /** @hidden */
  54854. export var rgbdDecodePixelShader: {
  54855. name: string;
  54856. shader: string;
  54857. };
  54858. }
  54859. declare module "babylonjs/Misc/environmentTextureTools" {
  54860. import { Nullable } from "babylonjs/types";
  54861. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54864. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54865. import "babylonjs/Engines/Extensions/engine.readTexture";
  54866. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54867. import "babylonjs/Shaders/rgbdEncode.fragment";
  54868. import "babylonjs/Shaders/rgbdDecode.fragment";
  54869. /**
  54870. * Raw texture data and descriptor sufficient for WebGL texture upload
  54871. */
  54872. export interface EnvironmentTextureInfo {
  54873. /**
  54874. * Version of the environment map
  54875. */
  54876. version: number;
  54877. /**
  54878. * Width of image
  54879. */
  54880. width: number;
  54881. /**
  54882. * Irradiance information stored in the file.
  54883. */
  54884. irradiance: any;
  54885. /**
  54886. * Specular information stored in the file.
  54887. */
  54888. specular: any;
  54889. }
  54890. /**
  54891. * Defines One Image in the file. It requires only the position in the file
  54892. * as well as the length.
  54893. */
  54894. interface BufferImageData {
  54895. /**
  54896. * Length of the image data.
  54897. */
  54898. length: number;
  54899. /**
  54900. * Position of the data from the null terminator delimiting the end of the JSON.
  54901. */
  54902. position: number;
  54903. }
  54904. /**
  54905. * Defines the specular data enclosed in the file.
  54906. * This corresponds to the version 1 of the data.
  54907. */
  54908. export interface EnvironmentTextureSpecularInfoV1 {
  54909. /**
  54910. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54911. */
  54912. specularDataPosition?: number;
  54913. /**
  54914. * This contains all the images data needed to reconstruct the cubemap.
  54915. */
  54916. mipmaps: Array<BufferImageData>;
  54917. /**
  54918. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54919. */
  54920. lodGenerationScale: number;
  54921. }
  54922. /**
  54923. * Sets of helpers addressing the serialization and deserialization of environment texture
  54924. * stored in a BabylonJS env file.
  54925. * Those files are usually stored as .env files.
  54926. */
  54927. export class EnvironmentTextureTools {
  54928. /**
  54929. * Magic number identifying the env file.
  54930. */
  54931. private static _MagicBytes;
  54932. /**
  54933. * Gets the environment info from an env file.
  54934. * @param data The array buffer containing the .env bytes.
  54935. * @returns the environment file info (the json header) if successfully parsed.
  54936. */
  54937. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54938. /**
  54939. * Creates an environment texture from a loaded cube texture.
  54940. * @param texture defines the cube texture to convert in env file
  54941. * @return a promise containing the environment data if succesfull.
  54942. */
  54943. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54944. /**
  54945. * Creates a JSON representation of the spherical data.
  54946. * @param texture defines the texture containing the polynomials
  54947. * @return the JSON representation of the spherical info
  54948. */
  54949. private static _CreateEnvTextureIrradiance;
  54950. /**
  54951. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54952. * @param data the image data
  54953. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54954. * @return the views described by info providing access to the underlying buffer
  54955. */
  54956. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54957. /**
  54958. * Uploads the texture info contained in the env file to the GPU.
  54959. * @param texture defines the internal texture to upload to
  54960. * @param data defines the data to load
  54961. * @param info defines the texture info retrieved through the GetEnvInfo method
  54962. * @returns a promise
  54963. */
  54964. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54965. private static _OnImageReadyAsync;
  54966. /**
  54967. * Uploads the levels of image data to the GPU.
  54968. * @param texture defines the internal texture to upload to
  54969. * @param imageData defines the array buffer views of image data [mipmap][face]
  54970. * @returns a promise
  54971. */
  54972. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54973. /**
  54974. * Uploads spherical polynomials information to the texture.
  54975. * @param texture defines the texture we are trying to upload the information to
  54976. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54977. */
  54978. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54979. /** @hidden */
  54980. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54981. }
  54982. }
  54983. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54984. /**
  54985. * Class used to inline functions in shader code
  54986. */
  54987. export class ShaderCodeInliner {
  54988. private static readonly _RegexpFindFunctionNameAndType;
  54989. private _sourceCode;
  54990. private _functionDescr;
  54991. private _numMaxIterations;
  54992. /** Gets or sets the token used to mark the functions to inline */
  54993. inlineToken: string;
  54994. /** Gets or sets the debug mode */
  54995. debug: boolean;
  54996. /** Gets the code after the inlining process */
  54997. get code(): string;
  54998. /**
  54999. * Initializes the inliner
  55000. * @param sourceCode shader code source to inline
  55001. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55002. */
  55003. constructor(sourceCode: string, numMaxIterations?: number);
  55004. /**
  55005. * Start the processing of the shader code
  55006. */
  55007. processCode(): void;
  55008. private _collectFunctions;
  55009. private _processInlining;
  55010. private _extractBetweenMarkers;
  55011. private _skipWhitespaces;
  55012. private _removeComments;
  55013. private _replaceFunctionCallsByCode;
  55014. private _findBackward;
  55015. private _escapeRegExp;
  55016. private _replaceNames;
  55017. }
  55018. }
  55019. declare module "babylonjs/Engines/nativeEngine" {
  55020. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55021. import { Engine } from "babylonjs/Engines/engine";
  55022. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55025. import { Effect } from "babylonjs/Materials/effect";
  55026. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55027. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55028. import { IColor4Like } from "babylonjs/Maths/math.like";
  55029. import { Scene } from "babylonjs/scene";
  55030. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55031. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55032. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55033. /**
  55034. * Container for accessors for natively-stored mesh data buffers.
  55035. */
  55036. class NativeDataBuffer extends DataBuffer {
  55037. /**
  55038. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55039. */
  55040. nativeIndexBuffer?: any;
  55041. /**
  55042. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55043. */
  55044. nativeVertexBuffer?: any;
  55045. }
  55046. /** @hidden */
  55047. class NativeTexture extends InternalTexture {
  55048. getInternalTexture(): InternalTexture;
  55049. getViewCount(): number;
  55050. }
  55051. /** @hidden */
  55052. export class NativeEngine extends Engine {
  55053. private readonly _native;
  55054. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55055. private readonly INVALID_HANDLE;
  55056. private _boundBuffersVertexArray;
  55057. private _currentDepthTest;
  55058. getHardwareScalingLevel(): number;
  55059. constructor();
  55060. dispose(): void;
  55061. /**
  55062. * Can be used to override the current requestAnimationFrame requester.
  55063. * @hidden
  55064. */
  55065. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55066. /**
  55067. * Override default engine behavior.
  55068. * @param color
  55069. * @param backBuffer
  55070. * @param depth
  55071. * @param stencil
  55072. */
  55073. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55074. /**
  55075. * Gets host document
  55076. * @returns the host document object
  55077. */
  55078. getHostDocument(): Nullable<Document>;
  55079. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55080. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55081. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55082. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55083. [key: string]: VertexBuffer;
  55084. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55085. bindBuffers(vertexBuffers: {
  55086. [key: string]: VertexBuffer;
  55087. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55088. recordVertexArrayObject(vertexBuffers: {
  55089. [key: string]: VertexBuffer;
  55090. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55091. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55092. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55093. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55094. /**
  55095. * Draw a list of indexed primitives
  55096. * @param fillMode defines the primitive to use
  55097. * @param indexStart defines the starting index
  55098. * @param indexCount defines the number of index to draw
  55099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55100. */
  55101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55102. /**
  55103. * Draw a list of unindexed primitives
  55104. * @param fillMode defines the primitive to use
  55105. * @param verticesStart defines the index of first vertex to draw
  55106. * @param verticesCount defines the count of vertices to draw
  55107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55108. */
  55109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55110. createPipelineContext(): IPipelineContext;
  55111. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55112. /** @hidden */
  55113. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55114. /** @hidden */
  55115. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55116. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55117. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55118. protected _setProgram(program: WebGLProgram): void;
  55119. _releaseEffect(effect: Effect): void;
  55120. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55121. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55122. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55123. bindSamplers(effect: Effect): void;
  55124. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55125. getRenderWidth(useScreen?: boolean): number;
  55126. getRenderHeight(useScreen?: boolean): number;
  55127. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55128. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55129. /**
  55130. * Set the z offset to apply to current rendering
  55131. * @param value defines the offset to apply
  55132. */
  55133. setZOffset(value: number): void;
  55134. /**
  55135. * Gets the current value of the zOffset
  55136. * @returns the current zOffset state
  55137. */
  55138. getZOffset(): number;
  55139. /**
  55140. * Enable or disable depth buffering
  55141. * @param enable defines the state to set
  55142. */
  55143. setDepthBuffer(enable: boolean): void;
  55144. /**
  55145. * Gets a boolean indicating if depth writing is enabled
  55146. * @returns the current depth writing state
  55147. */
  55148. getDepthWrite(): boolean;
  55149. setDepthFunctionToGreater(): void;
  55150. setDepthFunctionToGreaterOrEqual(): void;
  55151. setDepthFunctionToLess(): void;
  55152. setDepthFunctionToLessOrEqual(): void;
  55153. /**
  55154. * Enable or disable depth writing
  55155. * @param enable defines the state to set
  55156. */
  55157. setDepthWrite(enable: boolean): void;
  55158. /**
  55159. * Enable or disable color writing
  55160. * @param enable defines the state to set
  55161. */
  55162. setColorWrite(enable: boolean): void;
  55163. /**
  55164. * Gets a boolean indicating if color writing is enabled
  55165. * @returns the current color writing state
  55166. */
  55167. getColorWrite(): boolean;
  55168. /**
  55169. * Sets alpha constants used by some alpha blending modes
  55170. * @param r defines the red component
  55171. * @param g defines the green component
  55172. * @param b defines the blue component
  55173. * @param a defines the alpha component
  55174. */
  55175. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55176. /**
  55177. * Sets the current alpha mode
  55178. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55179. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55180. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55181. */
  55182. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55183. /**
  55184. * Gets the current alpha mode
  55185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55186. * @returns the current alpha mode
  55187. */
  55188. getAlphaMode(): number;
  55189. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55190. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55191. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55192. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55193. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55194. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55195. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55196. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55197. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55198. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55199. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55200. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55201. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55202. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55203. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55204. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55205. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55206. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55207. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55208. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55209. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55210. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55211. wipeCaches(bruteForce?: boolean): void;
  55212. _createTexture(): WebGLTexture;
  55213. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55214. /**
  55215. * Usually called from Texture.ts.
  55216. * Passed information to create a WebGLTexture
  55217. * @param url defines a value which contains one of the following:
  55218. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55219. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55220. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55221. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55222. * @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)
  55223. * @param scene needed for loading to the correct scene
  55224. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55225. * @param onLoad optional callback to be called upon successful completion
  55226. * @param onError optional callback to be called upon failure
  55227. * @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
  55228. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55229. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55230. * @param forcedExtension defines the extension to use to pick the right loader
  55231. * @param mimeType defines an optional mime type
  55232. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55233. */
  55234. 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;
  55235. /**
  55236. * Creates a cube texture
  55237. * @param rootUrl defines the url where the files to load is located
  55238. * @param scene defines the current scene
  55239. * @param files defines the list of files to load (1 per face)
  55240. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55241. * @param onLoad defines an optional callback raised when the texture is loaded
  55242. * @param onError defines an optional callback raised if there is an issue to load the texture
  55243. * @param format defines the format of the data
  55244. * @param forcedExtension defines the extension to use to pick the right loader
  55245. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55248. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55249. * @returns the cube texture as an InternalTexture
  55250. */
  55251. 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;
  55252. private _getSamplingFilter;
  55253. private static _GetNativeTextureFormat;
  55254. createRenderTargetTexture(size: number | {
  55255. width: number;
  55256. height: number;
  55257. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55258. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55259. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55260. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55261. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55262. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55263. /**
  55264. * Updates a dynamic vertex buffer.
  55265. * @param vertexBuffer the vertex buffer to update
  55266. * @param data the data used to update the vertex buffer
  55267. * @param byteOffset the byte offset of the data (optional)
  55268. * @param byteLength the byte length of the data (optional)
  55269. */
  55270. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55271. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55272. private _updateAnisotropicLevel;
  55273. private _getAddressMode;
  55274. /** @hidden */
  55275. _bindTexture(channel: number, texture: InternalTexture): void;
  55276. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55277. releaseEffects(): void;
  55278. /** @hidden */
  55279. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55280. /** @hidden */
  55281. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55282. /** @hidden */
  55283. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55284. /** @hidden */
  55285. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55286. }
  55287. }
  55288. declare module "babylonjs/Engines/index" {
  55289. export * from "babylonjs/Engines/constants";
  55290. export * from "babylonjs/Engines/engineCapabilities";
  55291. export * from "babylonjs/Engines/instancingAttributeInfo";
  55292. export * from "babylonjs/Engines/thinEngine";
  55293. export * from "babylonjs/Engines/engine";
  55294. export * from "babylonjs/Engines/engineStore";
  55295. export * from "babylonjs/Engines/nullEngine";
  55296. export * from "babylonjs/Engines/Extensions/index";
  55297. export * from "babylonjs/Engines/IPipelineContext";
  55298. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55299. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55300. export * from "babylonjs/Engines/nativeEngine";
  55301. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55302. export * from "babylonjs/Engines/performanceConfigurator";
  55303. }
  55304. declare module "babylonjs/Events/clipboardEvents" {
  55305. /**
  55306. * Gather the list of clipboard event types as constants.
  55307. */
  55308. export class ClipboardEventTypes {
  55309. /**
  55310. * The clipboard event is fired when a copy command is active (pressed).
  55311. */
  55312. static readonly COPY: number;
  55313. /**
  55314. * The clipboard event is fired when a cut command is active (pressed).
  55315. */
  55316. static readonly CUT: number;
  55317. /**
  55318. * The clipboard event is fired when a paste command is active (pressed).
  55319. */
  55320. static readonly PASTE: number;
  55321. }
  55322. /**
  55323. * This class is used to store clipboard related info for the onClipboardObservable event.
  55324. */
  55325. export class ClipboardInfo {
  55326. /**
  55327. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55328. */
  55329. type: number;
  55330. /**
  55331. * Defines the related dom event
  55332. */
  55333. event: ClipboardEvent;
  55334. /**
  55335. *Creates an instance of ClipboardInfo.
  55336. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55337. * @param event Defines the related dom event
  55338. */
  55339. constructor(
  55340. /**
  55341. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55342. */
  55343. type: number,
  55344. /**
  55345. * Defines the related dom event
  55346. */
  55347. event: ClipboardEvent);
  55348. /**
  55349. * Get the clipboard event's type from the keycode.
  55350. * @param keyCode Defines the keyCode for the current keyboard event.
  55351. * @return {number}
  55352. */
  55353. static GetTypeFromCharacter(keyCode: number): number;
  55354. }
  55355. }
  55356. declare module "babylonjs/Events/index" {
  55357. export * from "babylonjs/Events/keyboardEvents";
  55358. export * from "babylonjs/Events/pointerEvents";
  55359. export * from "babylonjs/Events/clipboardEvents";
  55360. }
  55361. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55362. import { Scene } from "babylonjs/scene";
  55363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55364. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55365. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55366. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55367. /**
  55368. * Google Daydream controller
  55369. */
  55370. export class DaydreamController extends WebVRController {
  55371. /**
  55372. * Base Url for the controller model.
  55373. */
  55374. static MODEL_BASE_URL: string;
  55375. /**
  55376. * File name for the controller model.
  55377. */
  55378. static MODEL_FILENAME: string;
  55379. /**
  55380. * Gamepad Id prefix used to identify Daydream Controller.
  55381. */
  55382. static readonly GAMEPAD_ID_PREFIX: string;
  55383. /**
  55384. * Creates a new DaydreamController from a gamepad
  55385. * @param vrGamepad the gamepad that the controller should be created from
  55386. */
  55387. constructor(vrGamepad: any);
  55388. /**
  55389. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55390. * @param scene scene in which to add meshes
  55391. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55392. */
  55393. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55394. /**
  55395. * Called once for each button that changed state since the last frame
  55396. * @param buttonIdx Which button index changed
  55397. * @param state New state of the button
  55398. * @param changes Which properties on the state changed since last frame
  55399. */
  55400. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55401. }
  55402. }
  55403. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55404. import { Scene } from "babylonjs/scene";
  55405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55406. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55407. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55408. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55409. /**
  55410. * Gear VR Controller
  55411. */
  55412. export class GearVRController extends WebVRController {
  55413. /**
  55414. * Base Url for the controller model.
  55415. */
  55416. static MODEL_BASE_URL: string;
  55417. /**
  55418. * File name for the controller model.
  55419. */
  55420. static MODEL_FILENAME: string;
  55421. /**
  55422. * Gamepad Id prefix used to identify this controller.
  55423. */
  55424. static readonly GAMEPAD_ID_PREFIX: string;
  55425. private readonly _buttonIndexToObservableNameMap;
  55426. /**
  55427. * Creates a new GearVRController from a gamepad
  55428. * @param vrGamepad the gamepad that the controller should be created from
  55429. */
  55430. constructor(vrGamepad: any);
  55431. /**
  55432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55433. * @param scene scene in which to add meshes
  55434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55435. */
  55436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55437. /**
  55438. * Called once for each button that changed state since the last frame
  55439. * @param buttonIdx Which button index changed
  55440. * @param state New state of the button
  55441. * @param changes Which properties on the state changed since last frame
  55442. */
  55443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55444. }
  55445. }
  55446. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55447. import { Scene } from "babylonjs/scene";
  55448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55449. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55450. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55451. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55452. /**
  55453. * Generic Controller
  55454. */
  55455. export class GenericController extends WebVRController {
  55456. /**
  55457. * Base Url for the controller model.
  55458. */
  55459. static readonly MODEL_BASE_URL: string;
  55460. /**
  55461. * File name for the controller model.
  55462. */
  55463. static readonly MODEL_FILENAME: string;
  55464. /**
  55465. * Creates a new GenericController from a gamepad
  55466. * @param vrGamepad the gamepad that the controller should be created from
  55467. */
  55468. constructor(vrGamepad: any);
  55469. /**
  55470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55471. * @param scene scene in which to add meshes
  55472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55473. */
  55474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55475. /**
  55476. * Called once for each button that changed state since the last frame
  55477. * @param buttonIdx Which button index changed
  55478. * @param state New state of the button
  55479. * @param changes Which properties on the state changed since last frame
  55480. */
  55481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55482. }
  55483. }
  55484. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55485. import { Observable } from "babylonjs/Misc/observable";
  55486. import { Scene } from "babylonjs/scene";
  55487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55488. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55489. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55490. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55491. /**
  55492. * Oculus Touch Controller
  55493. */
  55494. export class OculusTouchController extends WebVRController {
  55495. /**
  55496. * Base Url for the controller model.
  55497. */
  55498. static MODEL_BASE_URL: string;
  55499. /**
  55500. * File name for the left controller model.
  55501. */
  55502. static MODEL_LEFT_FILENAME: string;
  55503. /**
  55504. * File name for the right controller model.
  55505. */
  55506. static MODEL_RIGHT_FILENAME: string;
  55507. /**
  55508. * Base Url for the Quest controller model.
  55509. */
  55510. static QUEST_MODEL_BASE_URL: string;
  55511. /**
  55512. * @hidden
  55513. * If the controllers are running on a device that needs the updated Quest controller models
  55514. */
  55515. static _IsQuest: boolean;
  55516. /**
  55517. * Fired when the secondary trigger on this controller is modified
  55518. */
  55519. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55520. /**
  55521. * Fired when the thumb rest on this controller is modified
  55522. */
  55523. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55524. /**
  55525. * Creates a new OculusTouchController from a gamepad
  55526. * @param vrGamepad the gamepad that the controller should be created from
  55527. */
  55528. constructor(vrGamepad: any);
  55529. /**
  55530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55531. * @param scene scene in which to add meshes
  55532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55533. */
  55534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55535. /**
  55536. * Fired when the A button on this controller is modified
  55537. */
  55538. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55539. /**
  55540. * Fired when the B button on this controller is modified
  55541. */
  55542. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55543. /**
  55544. * Fired when the X button on this controller is modified
  55545. */
  55546. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55547. /**
  55548. * Fired when the Y button on this controller is modified
  55549. */
  55550. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55551. /**
  55552. * Called once for each button that changed state since the last frame
  55553. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55554. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55555. * 2) secondary trigger (same)
  55556. * 3) A (right) X (left), touch, pressed = value
  55557. * 4) B / Y
  55558. * 5) thumb rest
  55559. * @param buttonIdx Which button index changed
  55560. * @param state New state of the button
  55561. * @param changes Which properties on the state changed since last frame
  55562. */
  55563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55564. }
  55565. }
  55566. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55567. import { Scene } from "babylonjs/scene";
  55568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55569. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55570. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55571. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55572. import { Observable } from "babylonjs/Misc/observable";
  55573. /**
  55574. * Vive Controller
  55575. */
  55576. export class ViveController extends WebVRController {
  55577. /**
  55578. * Base Url for the controller model.
  55579. */
  55580. static MODEL_BASE_URL: string;
  55581. /**
  55582. * File name for the controller model.
  55583. */
  55584. static MODEL_FILENAME: string;
  55585. /**
  55586. * Creates a new ViveController from a gamepad
  55587. * @param vrGamepad the gamepad that the controller should be created from
  55588. */
  55589. constructor(vrGamepad: any);
  55590. /**
  55591. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55592. * @param scene scene in which to add meshes
  55593. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55594. */
  55595. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55596. /**
  55597. * Fired when the left button on this controller is modified
  55598. */
  55599. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55600. /**
  55601. * Fired when the right button on this controller is modified
  55602. */
  55603. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55604. /**
  55605. * Fired when the menu button on this controller is modified
  55606. */
  55607. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55608. /**
  55609. * Called once for each button that changed state since the last frame
  55610. * Vive mapping:
  55611. * 0: touchpad
  55612. * 1: trigger
  55613. * 2: left AND right buttons
  55614. * 3: menu button
  55615. * @param buttonIdx Which button index changed
  55616. * @param state New state of the button
  55617. * @param changes Which properties on the state changed since last frame
  55618. */
  55619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55620. }
  55621. }
  55622. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55623. import { Observable } from "babylonjs/Misc/observable";
  55624. import { Scene } from "babylonjs/scene";
  55625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55626. import { Ray } from "babylonjs/Culling/ray";
  55627. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55628. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55629. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55630. /**
  55631. * Defines the WindowsMotionController object that the state of the windows motion controller
  55632. */
  55633. export class WindowsMotionController extends WebVRController {
  55634. /**
  55635. * The base url used to load the left and right controller models
  55636. */
  55637. static MODEL_BASE_URL: string;
  55638. /**
  55639. * The name of the left controller model file
  55640. */
  55641. static MODEL_LEFT_FILENAME: string;
  55642. /**
  55643. * The name of the right controller model file
  55644. */
  55645. static MODEL_RIGHT_FILENAME: string;
  55646. /**
  55647. * The controller name prefix for this controller type
  55648. */
  55649. static readonly GAMEPAD_ID_PREFIX: string;
  55650. /**
  55651. * The controller id pattern for this controller type
  55652. */
  55653. private static readonly GAMEPAD_ID_PATTERN;
  55654. private _loadedMeshInfo;
  55655. protected readonly _mapping: {
  55656. buttons: string[];
  55657. buttonMeshNames: {
  55658. trigger: string;
  55659. menu: string;
  55660. grip: string;
  55661. thumbstick: string;
  55662. trackpad: string;
  55663. };
  55664. buttonObservableNames: {
  55665. trigger: string;
  55666. menu: string;
  55667. grip: string;
  55668. thumbstick: string;
  55669. trackpad: string;
  55670. };
  55671. axisMeshNames: string[];
  55672. pointingPoseMeshName: string;
  55673. };
  55674. /**
  55675. * Fired when the trackpad on this controller is clicked
  55676. */
  55677. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55678. /**
  55679. * Fired when the trackpad on this controller is modified
  55680. */
  55681. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55682. /**
  55683. * The current x and y values of this controller's trackpad
  55684. */
  55685. trackpad: StickValues;
  55686. /**
  55687. * Creates a new WindowsMotionController from a gamepad
  55688. * @param vrGamepad the gamepad that the controller should be created from
  55689. */
  55690. constructor(vrGamepad: any);
  55691. /**
  55692. * Fired when the trigger on this controller is modified
  55693. */
  55694. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55695. /**
  55696. * Fired when the menu button on this controller is modified
  55697. */
  55698. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55699. /**
  55700. * Fired when the grip button on this controller is modified
  55701. */
  55702. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55703. /**
  55704. * Fired when the thumbstick button on this controller is modified
  55705. */
  55706. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55707. /**
  55708. * Fired when the touchpad button on this controller is modified
  55709. */
  55710. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55711. /**
  55712. * Fired when the touchpad values on this controller are modified
  55713. */
  55714. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55715. protected _updateTrackpad(): void;
  55716. /**
  55717. * Called once per frame by the engine.
  55718. */
  55719. update(): void;
  55720. /**
  55721. * Called once for each button that changed state since the last frame
  55722. * @param buttonIdx Which button index changed
  55723. * @param state New state of the button
  55724. * @param changes Which properties on the state changed since last frame
  55725. */
  55726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55727. /**
  55728. * Moves the buttons on the controller mesh based on their current state
  55729. * @param buttonName the name of the button to move
  55730. * @param buttonValue the value of the button which determines the buttons new position
  55731. */
  55732. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55733. /**
  55734. * Moves the axis on the controller mesh based on its current state
  55735. * @param axis the index of the axis
  55736. * @param axisValue the value of the axis which determines the meshes new position
  55737. * @hidden
  55738. */
  55739. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55740. /**
  55741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55742. * @param scene scene in which to add meshes
  55743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55744. */
  55745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55746. /**
  55747. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55748. * can be transformed by button presses and axes values, based on this._mapping.
  55749. *
  55750. * @param scene scene in which the meshes exist
  55751. * @param meshes list of meshes that make up the controller model to process
  55752. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55753. */
  55754. private processModel;
  55755. private createMeshInfo;
  55756. /**
  55757. * Gets the ray of the controller in the direction the controller is pointing
  55758. * @param length the length the resulting ray should be
  55759. * @returns a ray in the direction the controller is pointing
  55760. */
  55761. getForwardRay(length?: number): Ray;
  55762. /**
  55763. * Disposes of the controller
  55764. */
  55765. dispose(): void;
  55766. }
  55767. /**
  55768. * This class represents a new windows motion controller in XR.
  55769. */
  55770. export class XRWindowsMotionController extends WindowsMotionController {
  55771. /**
  55772. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55773. */
  55774. protected readonly _mapping: {
  55775. buttons: string[];
  55776. buttonMeshNames: {
  55777. trigger: string;
  55778. menu: string;
  55779. grip: string;
  55780. thumbstick: string;
  55781. trackpad: string;
  55782. };
  55783. buttonObservableNames: {
  55784. trigger: string;
  55785. menu: string;
  55786. grip: string;
  55787. thumbstick: string;
  55788. trackpad: string;
  55789. };
  55790. axisMeshNames: string[];
  55791. pointingPoseMeshName: string;
  55792. };
  55793. /**
  55794. * Construct a new XR-Based windows motion controller
  55795. *
  55796. * @param gamepadInfo the gamepad object from the browser
  55797. */
  55798. constructor(gamepadInfo: any);
  55799. /**
  55800. * holds the thumbstick values (X,Y)
  55801. */
  55802. thumbstickValues: StickValues;
  55803. /**
  55804. * Fired when the thumbstick on this controller is clicked
  55805. */
  55806. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55807. /**
  55808. * Fired when the thumbstick on this controller is modified
  55809. */
  55810. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55811. /**
  55812. * Fired when the touchpad button on this controller is modified
  55813. */
  55814. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55815. /**
  55816. * Fired when the touchpad values on this controller are modified
  55817. */
  55818. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55819. /**
  55820. * Fired when the thumbstick button on this controller is modified
  55821. * here to prevent breaking changes
  55822. */
  55823. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55824. /**
  55825. * updating the thumbstick(!) and not the trackpad.
  55826. * This is named this way due to the difference between WebVR and XR and to avoid
  55827. * changing the parent class.
  55828. */
  55829. protected _updateTrackpad(): void;
  55830. /**
  55831. * Disposes the class with joy
  55832. */
  55833. dispose(): void;
  55834. }
  55835. }
  55836. declare module "babylonjs/Gamepads/Controllers/index" {
  55837. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55838. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55839. export * from "babylonjs/Gamepads/Controllers/genericController";
  55840. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55841. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55842. export * from "babylonjs/Gamepads/Controllers/viveController";
  55843. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55844. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55845. }
  55846. declare module "babylonjs/Gamepads/index" {
  55847. export * from "babylonjs/Gamepads/Controllers/index";
  55848. export * from "babylonjs/Gamepads/gamepad";
  55849. export * from "babylonjs/Gamepads/gamepadManager";
  55850. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55851. export * from "babylonjs/Gamepads/xboxGamepad";
  55852. export * from "babylonjs/Gamepads/dualShockGamepad";
  55853. }
  55854. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55855. import { Scene } from "babylonjs/scene";
  55856. import { Vector4 } from "babylonjs/Maths/math.vector";
  55857. import { Color4 } from "babylonjs/Maths/math.color";
  55858. import { Mesh } from "babylonjs/Meshes/mesh";
  55859. import { Nullable } from "babylonjs/types";
  55860. /**
  55861. * Class containing static functions to help procedurally build meshes
  55862. */
  55863. export class PolyhedronBuilder {
  55864. /**
  55865. * Creates a polyhedron mesh
  55866. * * 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
  55867. * * The parameter `size` (positive float, default 1) sets the polygon size
  55868. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55869. * * 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`
  55870. * * 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
  55871. * * 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)`)
  55872. * * 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
  55873. * * 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
  55874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55877. * @param name defines the name of the mesh
  55878. * @param options defines the options used to create the mesh
  55879. * @param scene defines the hosting scene
  55880. * @returns the polyhedron mesh
  55881. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55882. */
  55883. static CreatePolyhedron(name: string, options: {
  55884. type?: number;
  55885. size?: number;
  55886. sizeX?: number;
  55887. sizeY?: number;
  55888. sizeZ?: number;
  55889. custom?: any;
  55890. faceUV?: Vector4[];
  55891. faceColors?: Color4[];
  55892. flat?: boolean;
  55893. updatable?: boolean;
  55894. sideOrientation?: number;
  55895. frontUVs?: Vector4;
  55896. backUVs?: Vector4;
  55897. }, scene?: Nullable<Scene>): Mesh;
  55898. }
  55899. }
  55900. declare module "babylonjs/Gizmos/scaleGizmo" {
  55901. import { Observable } from "babylonjs/Misc/observable";
  55902. import { Nullable } from "babylonjs/types";
  55903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55904. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55905. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55906. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55907. import { Node } from "babylonjs/node";
  55908. /**
  55909. * Gizmo that enables scaling a mesh along 3 axis
  55910. */
  55911. export class ScaleGizmo extends Gizmo {
  55912. /**
  55913. * Internal gizmo used for interactions on the x axis
  55914. */
  55915. xGizmo: AxisScaleGizmo;
  55916. /**
  55917. * Internal gizmo used for interactions on the y axis
  55918. */
  55919. yGizmo: AxisScaleGizmo;
  55920. /**
  55921. * Internal gizmo used for interactions on the z axis
  55922. */
  55923. zGizmo: AxisScaleGizmo;
  55924. /**
  55925. * Internal gizmo used to scale all axis equally
  55926. */
  55927. uniformScaleGizmo: AxisScaleGizmo;
  55928. private _meshAttached;
  55929. private _nodeAttached;
  55930. private _snapDistance;
  55931. private _uniformScalingMesh;
  55932. private _octahedron;
  55933. private _sensitivity;
  55934. /** Fires an event when any of it's sub gizmos are dragged */
  55935. onDragStartObservable: Observable<unknown>;
  55936. /** Fires an event when any of it's sub gizmos are released from dragging */
  55937. onDragEndObservable: Observable<unknown>;
  55938. get attachedMesh(): Nullable<AbstractMesh>;
  55939. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55940. get attachedNode(): Nullable<Node>;
  55941. set attachedNode(node: Nullable<Node>);
  55942. /**
  55943. * True when the mouse pointer is hovering a gizmo mesh
  55944. */
  55945. get isHovered(): boolean;
  55946. /**
  55947. * Creates a ScaleGizmo
  55948. * @param gizmoLayer The utility layer the gizmo will be added to
  55949. * @param thickness display gizmo axis thickness
  55950. */
  55951. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55952. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55953. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55954. /**
  55955. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55956. */
  55957. set snapDistance(value: number);
  55958. get snapDistance(): number;
  55959. /**
  55960. * Ratio for the scale of the gizmo (Default: 1)
  55961. */
  55962. set scaleRatio(value: number);
  55963. get scaleRatio(): number;
  55964. /**
  55965. * Sensitivity factor for dragging (Default: 1)
  55966. */
  55967. set sensitivity(value: number);
  55968. get sensitivity(): number;
  55969. /**
  55970. * Disposes of the gizmo
  55971. */
  55972. dispose(): void;
  55973. }
  55974. }
  55975. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55976. import { Observable } from "babylonjs/Misc/observable";
  55977. import { Nullable } from "babylonjs/types";
  55978. import { Vector3 } from "babylonjs/Maths/math.vector";
  55979. import { Node } from "babylonjs/node";
  55980. import { Mesh } from "babylonjs/Meshes/mesh";
  55981. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55982. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55983. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55984. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55985. import { Color3 } from "babylonjs/Maths/math.color";
  55986. /**
  55987. * Single axis scale gizmo
  55988. */
  55989. export class AxisScaleGizmo extends Gizmo {
  55990. /**
  55991. * Drag behavior responsible for the gizmos dragging interactions
  55992. */
  55993. dragBehavior: PointerDragBehavior;
  55994. private _pointerObserver;
  55995. /**
  55996. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55997. */
  55998. snapDistance: number;
  55999. /**
  56000. * Event that fires each time the gizmo snaps to a new location.
  56001. * * snapDistance is the the change in distance
  56002. */
  56003. onSnapObservable: Observable<{
  56004. snapDistance: number;
  56005. }>;
  56006. /**
  56007. * If the scaling operation should be done on all axis (default: false)
  56008. */
  56009. uniformScaling: boolean;
  56010. /**
  56011. * Custom sensitivity value for the drag strength
  56012. */
  56013. sensitivity: number;
  56014. private _isEnabled;
  56015. private _parent;
  56016. private _arrow;
  56017. private _coloredMaterial;
  56018. private _hoverMaterial;
  56019. /**
  56020. * Creates an AxisScaleGizmo
  56021. * @param gizmoLayer The utility layer the gizmo will be added to
  56022. * @param dragAxis The axis which the gizmo will be able to scale on
  56023. * @param color The color of the gizmo
  56024. * @param thickness display gizmo axis thickness
  56025. */
  56026. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56027. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56028. /**
  56029. * If the gizmo is enabled
  56030. */
  56031. set isEnabled(value: boolean);
  56032. get isEnabled(): boolean;
  56033. /**
  56034. * Disposes of the gizmo
  56035. */
  56036. dispose(): void;
  56037. /**
  56038. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56039. * @param mesh The mesh to replace the default mesh of the gizmo
  56040. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56041. */
  56042. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56043. }
  56044. }
  56045. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56046. import { Observable } from "babylonjs/Misc/observable";
  56047. import { Nullable } from "babylonjs/types";
  56048. import { Vector3 } from "babylonjs/Maths/math.vector";
  56049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56050. import { Mesh } from "babylonjs/Meshes/mesh";
  56051. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56052. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56053. import { Color3 } from "babylonjs/Maths/math.color";
  56054. import "babylonjs/Meshes/Builders/boxBuilder";
  56055. /**
  56056. * Bounding box gizmo
  56057. */
  56058. export class BoundingBoxGizmo extends Gizmo {
  56059. private _lineBoundingBox;
  56060. private _rotateSpheresParent;
  56061. private _scaleBoxesParent;
  56062. private _boundingDimensions;
  56063. private _renderObserver;
  56064. private _pointerObserver;
  56065. private _scaleDragSpeed;
  56066. private _tmpQuaternion;
  56067. private _tmpVector;
  56068. private _tmpRotationMatrix;
  56069. /**
  56070. * 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)
  56071. */
  56072. ignoreChildren: boolean;
  56073. /**
  56074. * 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)
  56075. */
  56076. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56077. /**
  56078. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56079. */
  56080. rotationSphereSize: number;
  56081. /**
  56082. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56083. */
  56084. scaleBoxSize: number;
  56085. /**
  56086. * 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)
  56087. */
  56088. fixedDragMeshScreenSize: boolean;
  56089. /**
  56090. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56091. */
  56092. fixedDragMeshScreenSizeDistanceFactor: number;
  56093. /**
  56094. * Fired when a rotation sphere or scale box is dragged
  56095. */
  56096. onDragStartObservable: Observable<{}>;
  56097. /**
  56098. * Fired when a scale box is dragged
  56099. */
  56100. onScaleBoxDragObservable: Observable<{}>;
  56101. /**
  56102. * Fired when a scale box drag is ended
  56103. */
  56104. onScaleBoxDragEndObservable: Observable<{}>;
  56105. /**
  56106. * Fired when a rotation sphere is dragged
  56107. */
  56108. onRotationSphereDragObservable: Observable<{}>;
  56109. /**
  56110. * Fired when a rotation sphere drag is ended
  56111. */
  56112. onRotationSphereDragEndObservable: Observable<{}>;
  56113. /**
  56114. * 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)
  56115. */
  56116. scalePivot: Nullable<Vector3>;
  56117. /**
  56118. * Mesh used as a pivot to rotate the attached node
  56119. */
  56120. private _anchorMesh;
  56121. private _existingMeshScale;
  56122. private _dragMesh;
  56123. private pointerDragBehavior;
  56124. private coloredMaterial;
  56125. private hoverColoredMaterial;
  56126. /**
  56127. * Sets the color of the bounding box gizmo
  56128. * @param color the color to set
  56129. */
  56130. setColor(color: Color3): void;
  56131. /**
  56132. * Creates an BoundingBoxGizmo
  56133. * @param gizmoLayer The utility layer the gizmo will be added to
  56134. * @param color The color of the gizmo
  56135. */
  56136. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56137. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56138. private _selectNode;
  56139. /**
  56140. * Updates the bounding box information for the Gizmo
  56141. */
  56142. updateBoundingBox(): void;
  56143. private _updateRotationSpheres;
  56144. private _updateScaleBoxes;
  56145. /**
  56146. * Enables rotation on the specified axis and disables rotation on the others
  56147. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56148. */
  56149. setEnabledRotationAxis(axis: string): void;
  56150. /**
  56151. * Enables/disables scaling
  56152. * @param enable if scaling should be enabled
  56153. * @param homogeneousScaling defines if scaling should only be homogeneous
  56154. */
  56155. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56156. private _updateDummy;
  56157. /**
  56158. * Enables a pointer drag behavior on the bounding box of the gizmo
  56159. */
  56160. enableDragBehavior(): void;
  56161. /**
  56162. * Disposes of the gizmo
  56163. */
  56164. dispose(): void;
  56165. /**
  56166. * 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)
  56167. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56168. * @returns the bounding box mesh with the passed in mesh as a child
  56169. */
  56170. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56171. /**
  56172. * CustomMeshes are not supported by this gizmo
  56173. * @param mesh The mesh to replace the default mesh of the gizmo
  56174. */
  56175. setCustomMesh(mesh: Mesh): void;
  56176. }
  56177. }
  56178. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56179. import { Observable } from "babylonjs/Misc/observable";
  56180. import { Nullable } from "babylonjs/types";
  56181. import { Vector3 } from "babylonjs/Maths/math.vector";
  56182. import { Color3 } from "babylonjs/Maths/math.color";
  56183. import { Node } from "babylonjs/node";
  56184. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56185. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56186. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56187. import "babylonjs/Meshes/Builders/linesBuilder";
  56188. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56189. /**
  56190. * Single plane rotation gizmo
  56191. */
  56192. export class PlaneRotationGizmo extends Gizmo {
  56193. /**
  56194. * Drag behavior responsible for the gizmos dragging interactions
  56195. */
  56196. dragBehavior: PointerDragBehavior;
  56197. private _pointerObserver;
  56198. /**
  56199. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56200. */
  56201. snapDistance: number;
  56202. /**
  56203. * Event that fires each time the gizmo snaps to a new location.
  56204. * * snapDistance is the the change in distance
  56205. */
  56206. onSnapObservable: Observable<{
  56207. snapDistance: number;
  56208. }>;
  56209. private _isEnabled;
  56210. private _parent;
  56211. /**
  56212. * Creates a PlaneRotationGizmo
  56213. * @param gizmoLayer The utility layer the gizmo will be added to
  56214. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56215. * @param color The color of the gizmo
  56216. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56217. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56218. * @param thickness display gizmo axis thickness
  56219. */
  56220. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56221. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56222. /**
  56223. * If the gizmo is enabled
  56224. */
  56225. set isEnabled(value: boolean);
  56226. get isEnabled(): boolean;
  56227. /**
  56228. * Disposes of the gizmo
  56229. */
  56230. dispose(): void;
  56231. }
  56232. }
  56233. declare module "babylonjs/Gizmos/rotationGizmo" {
  56234. import { Observable } from "babylonjs/Misc/observable";
  56235. import { Nullable } from "babylonjs/types";
  56236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56237. import { Mesh } from "babylonjs/Meshes/mesh";
  56238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56239. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56241. import { Node } from "babylonjs/node";
  56242. /**
  56243. * Gizmo that enables rotating a mesh along 3 axis
  56244. */
  56245. export class RotationGizmo extends Gizmo {
  56246. /**
  56247. * Internal gizmo used for interactions on the x axis
  56248. */
  56249. xGizmo: PlaneRotationGizmo;
  56250. /**
  56251. * Internal gizmo used for interactions on the y axis
  56252. */
  56253. yGizmo: PlaneRotationGizmo;
  56254. /**
  56255. * Internal gizmo used for interactions on the z axis
  56256. */
  56257. zGizmo: PlaneRotationGizmo;
  56258. /** Fires an event when any of it's sub gizmos are dragged */
  56259. onDragStartObservable: Observable<unknown>;
  56260. /** Fires an event when any of it's sub gizmos are released from dragging */
  56261. onDragEndObservable: Observable<unknown>;
  56262. private _meshAttached;
  56263. private _nodeAttached;
  56264. get attachedMesh(): Nullable<AbstractMesh>;
  56265. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56266. get attachedNode(): Nullable<Node>;
  56267. set attachedNode(node: Nullable<Node>);
  56268. /**
  56269. * True when the mouse pointer is hovering a gizmo mesh
  56270. */
  56271. get isHovered(): boolean;
  56272. /**
  56273. * Creates a RotationGizmo
  56274. * @param gizmoLayer The utility layer the gizmo will be added to
  56275. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56276. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56277. * @param thickness display gizmo axis thickness
  56278. */
  56279. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56280. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56281. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56282. /**
  56283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56284. */
  56285. set snapDistance(value: number);
  56286. get snapDistance(): number;
  56287. /**
  56288. * Ratio for the scale of the gizmo (Default: 1)
  56289. */
  56290. set scaleRatio(value: number);
  56291. get scaleRatio(): number;
  56292. /**
  56293. * Disposes of the gizmo
  56294. */
  56295. dispose(): void;
  56296. /**
  56297. * CustomMeshes are not supported by this gizmo
  56298. * @param mesh The mesh to replace the default mesh of the gizmo
  56299. */
  56300. setCustomMesh(mesh: Mesh): void;
  56301. }
  56302. }
  56303. declare module "babylonjs/Gizmos/gizmoManager" {
  56304. import { Observable } from "babylonjs/Misc/observable";
  56305. import { Nullable } from "babylonjs/types";
  56306. import { Scene, IDisposable } from "babylonjs/scene";
  56307. import { Node } from "babylonjs/node";
  56308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56309. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56310. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56311. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56312. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56313. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56314. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56315. /**
  56316. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56317. */
  56318. export class GizmoManager implements IDisposable {
  56319. private scene;
  56320. /**
  56321. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56322. */
  56323. gizmos: {
  56324. positionGizmo: Nullable<PositionGizmo>;
  56325. rotationGizmo: Nullable<RotationGizmo>;
  56326. scaleGizmo: Nullable<ScaleGizmo>;
  56327. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56328. };
  56329. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56330. clearGizmoOnEmptyPointerEvent: boolean;
  56331. /** Fires an event when the manager is attached to a mesh */
  56332. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56333. /** Fires an event when the manager is attached to a node */
  56334. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56335. private _gizmosEnabled;
  56336. private _pointerObserver;
  56337. private _attachedMesh;
  56338. private _attachedNode;
  56339. private _boundingBoxColor;
  56340. private _defaultUtilityLayer;
  56341. private _defaultKeepDepthUtilityLayer;
  56342. private _thickness;
  56343. /**
  56344. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56345. */
  56346. boundingBoxDragBehavior: SixDofDragBehavior;
  56347. /**
  56348. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56349. */
  56350. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56351. /**
  56352. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56353. */
  56354. attachableNodes: Nullable<Array<Node>>;
  56355. /**
  56356. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56357. */
  56358. usePointerToAttachGizmos: boolean;
  56359. /**
  56360. * Utility layer that the bounding box gizmo belongs to
  56361. */
  56362. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56363. /**
  56364. * Utility layer that all gizmos besides bounding box belong to
  56365. */
  56366. get utilityLayer(): UtilityLayerRenderer;
  56367. /**
  56368. * True when the mouse pointer is hovering a gizmo mesh
  56369. */
  56370. get isHovered(): boolean;
  56371. /**
  56372. * Instatiates a gizmo manager
  56373. * @param scene the scene to overlay the gizmos on top of
  56374. * @param thickness display gizmo axis thickness
  56375. */
  56376. constructor(scene: Scene, thickness?: number);
  56377. /**
  56378. * Attaches a set of gizmos to the specified mesh
  56379. * @param mesh The mesh the gizmo's should be attached to
  56380. */
  56381. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56382. /**
  56383. * Attaches a set of gizmos to the specified node
  56384. * @param node The node the gizmo's should be attached to
  56385. */
  56386. attachToNode(node: Nullable<Node>): void;
  56387. /**
  56388. * If the position gizmo is enabled
  56389. */
  56390. set positionGizmoEnabled(value: boolean);
  56391. get positionGizmoEnabled(): boolean;
  56392. /**
  56393. * If the rotation gizmo is enabled
  56394. */
  56395. set rotationGizmoEnabled(value: boolean);
  56396. get rotationGizmoEnabled(): boolean;
  56397. /**
  56398. * If the scale gizmo is enabled
  56399. */
  56400. set scaleGizmoEnabled(value: boolean);
  56401. get scaleGizmoEnabled(): boolean;
  56402. /**
  56403. * If the boundingBox gizmo is enabled
  56404. */
  56405. set boundingBoxGizmoEnabled(value: boolean);
  56406. get boundingBoxGizmoEnabled(): boolean;
  56407. /**
  56408. * Disposes of the gizmo manager
  56409. */
  56410. dispose(): void;
  56411. }
  56412. }
  56413. declare module "babylonjs/Lights/directionalLight" {
  56414. import { Camera } from "babylonjs/Cameras/camera";
  56415. import { Scene } from "babylonjs/scene";
  56416. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56418. import { Light } from "babylonjs/Lights/light";
  56419. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56420. import { Effect } from "babylonjs/Materials/effect";
  56421. /**
  56422. * A directional light is defined by a direction (what a surprise!).
  56423. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56424. * 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.
  56425. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56426. */
  56427. export class DirectionalLight extends ShadowLight {
  56428. private _shadowFrustumSize;
  56429. /**
  56430. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56431. */
  56432. get shadowFrustumSize(): number;
  56433. /**
  56434. * Specifies a fix frustum size for the shadow generation.
  56435. */
  56436. set shadowFrustumSize(value: number);
  56437. private _shadowOrthoScale;
  56438. /**
  56439. * Gets the shadow projection scale against the optimal computed one.
  56440. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56441. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56442. */
  56443. get shadowOrthoScale(): number;
  56444. /**
  56445. * Sets the shadow projection scale against the optimal computed one.
  56446. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56447. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56448. */
  56449. set shadowOrthoScale(value: number);
  56450. /**
  56451. * Automatically compute the projection matrix to best fit (including all the casters)
  56452. * on each frame.
  56453. */
  56454. autoUpdateExtends: boolean;
  56455. /**
  56456. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56457. * on each frame. autoUpdateExtends must be set to true for this to work
  56458. */
  56459. autoCalcShadowZBounds: boolean;
  56460. private _orthoLeft;
  56461. private _orthoRight;
  56462. private _orthoTop;
  56463. private _orthoBottom;
  56464. /**
  56465. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56466. * The directional light is emitted from everywhere in the given direction.
  56467. * It can cast shadows.
  56468. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56469. * @param name The friendly name of the light
  56470. * @param direction The direction of the light
  56471. * @param scene The scene the light belongs to
  56472. */
  56473. constructor(name: string, direction: Vector3, scene: Scene);
  56474. /**
  56475. * Returns the string "DirectionalLight".
  56476. * @return The class name
  56477. */
  56478. getClassName(): string;
  56479. /**
  56480. * Returns the integer 1.
  56481. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56482. */
  56483. getTypeID(): number;
  56484. /**
  56485. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56486. * Returns the DirectionalLight Shadow projection matrix.
  56487. */
  56488. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56489. /**
  56490. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56491. * Returns the DirectionalLight Shadow projection matrix.
  56492. */
  56493. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56494. /**
  56495. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56496. * Returns the DirectionalLight Shadow projection matrix.
  56497. */
  56498. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56499. protected _buildUniformLayout(): void;
  56500. /**
  56501. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56502. * @param effect The effect to update
  56503. * @param lightIndex The index of the light in the effect to update
  56504. * @returns The directional light
  56505. */
  56506. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56507. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56508. /**
  56509. * Gets the minZ used for shadow according to both the scene and the light.
  56510. *
  56511. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56512. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56513. * @param activeCamera The camera we are returning the min for
  56514. * @returns the depth min z
  56515. */
  56516. getDepthMinZ(activeCamera: Camera): number;
  56517. /**
  56518. * Gets the maxZ used for shadow according to both the scene and the light.
  56519. *
  56520. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56521. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56522. * @param activeCamera The camera we are returning the max for
  56523. * @returns the depth max z
  56524. */
  56525. getDepthMaxZ(activeCamera: Camera): number;
  56526. /**
  56527. * Prepares the list of defines specific to the light type.
  56528. * @param defines the list of defines
  56529. * @param lightIndex defines the index of the light for the effect
  56530. */
  56531. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56532. }
  56533. }
  56534. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56535. import { Mesh } from "babylonjs/Meshes/mesh";
  56536. /**
  56537. * Class containing static functions to help procedurally build meshes
  56538. */
  56539. export class HemisphereBuilder {
  56540. /**
  56541. * Creates a hemisphere mesh
  56542. * @param name defines the name of the mesh
  56543. * @param options defines the options used to create the mesh
  56544. * @param scene defines the hosting scene
  56545. * @returns the hemisphere mesh
  56546. */
  56547. static CreateHemisphere(name: string, options: {
  56548. segments?: number;
  56549. diameter?: number;
  56550. sideOrientation?: number;
  56551. }, scene: any): Mesh;
  56552. }
  56553. }
  56554. declare module "babylonjs/Lights/spotLight" {
  56555. import { Nullable } from "babylonjs/types";
  56556. import { Scene } from "babylonjs/scene";
  56557. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56559. import { Effect } from "babylonjs/Materials/effect";
  56560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56561. import { Light } from "babylonjs/Lights/light";
  56562. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56563. /**
  56564. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56565. * These values define a cone of light starting from the position, emitting toward the direction.
  56566. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56567. * and the exponent defines the speed of the decay of the light with distance (reach).
  56568. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56569. */
  56570. export class SpotLight extends ShadowLight {
  56571. private _angle;
  56572. private _innerAngle;
  56573. private _cosHalfAngle;
  56574. private _lightAngleScale;
  56575. private _lightAngleOffset;
  56576. /**
  56577. * Gets the cone angle of the spot light in Radians.
  56578. */
  56579. get angle(): number;
  56580. /**
  56581. * Sets the cone angle of the spot light in Radians.
  56582. */
  56583. set angle(value: number);
  56584. /**
  56585. * Only used in gltf falloff mode, this defines the angle where
  56586. * the directional falloff will start before cutting at angle which could be seen
  56587. * as outer angle.
  56588. */
  56589. get innerAngle(): number;
  56590. /**
  56591. * Only used in gltf falloff mode, this defines the angle where
  56592. * the directional falloff will start before cutting at angle which could be seen
  56593. * as outer angle.
  56594. */
  56595. set innerAngle(value: number);
  56596. private _shadowAngleScale;
  56597. /**
  56598. * Allows scaling the angle of the light for shadow generation only.
  56599. */
  56600. get shadowAngleScale(): number;
  56601. /**
  56602. * Allows scaling the angle of the light for shadow generation only.
  56603. */
  56604. set shadowAngleScale(value: number);
  56605. /**
  56606. * The light decay speed with the distance from the emission spot.
  56607. */
  56608. exponent: number;
  56609. private _projectionTextureMatrix;
  56610. /**
  56611. * Allows reading the projecton texture
  56612. */
  56613. get projectionTextureMatrix(): Matrix;
  56614. protected _projectionTextureLightNear: number;
  56615. /**
  56616. * Gets the near clip of the Spotlight for texture projection.
  56617. */
  56618. get projectionTextureLightNear(): number;
  56619. /**
  56620. * Sets the near clip of the Spotlight for texture projection.
  56621. */
  56622. set projectionTextureLightNear(value: number);
  56623. protected _projectionTextureLightFar: number;
  56624. /**
  56625. * Gets the far clip of the Spotlight for texture projection.
  56626. */
  56627. get projectionTextureLightFar(): number;
  56628. /**
  56629. * Sets the far clip of the Spotlight for texture projection.
  56630. */
  56631. set projectionTextureLightFar(value: number);
  56632. protected _projectionTextureUpDirection: Vector3;
  56633. /**
  56634. * Gets the Up vector of the Spotlight for texture projection.
  56635. */
  56636. get projectionTextureUpDirection(): Vector3;
  56637. /**
  56638. * Sets the Up vector of the Spotlight for texture projection.
  56639. */
  56640. set projectionTextureUpDirection(value: Vector3);
  56641. private _projectionTexture;
  56642. /**
  56643. * Gets the projection texture of the light.
  56644. */
  56645. get projectionTexture(): Nullable<BaseTexture>;
  56646. /**
  56647. * Sets the projection texture of the light.
  56648. */
  56649. set projectionTexture(value: Nullable<BaseTexture>);
  56650. private _projectionTextureViewLightDirty;
  56651. private _projectionTextureProjectionLightDirty;
  56652. private _projectionTextureDirty;
  56653. private _projectionTextureViewTargetVector;
  56654. private _projectionTextureViewLightMatrix;
  56655. private _projectionTextureProjectionLightMatrix;
  56656. private _projectionTextureScalingMatrix;
  56657. /**
  56658. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56659. * It can cast shadows.
  56660. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56661. * @param name The light friendly name
  56662. * @param position The position of the spot light in the scene
  56663. * @param direction The direction of the light in the scene
  56664. * @param angle The cone angle of the light in Radians
  56665. * @param exponent The light decay speed with the distance from the emission spot
  56666. * @param scene The scene the lights belongs to
  56667. */
  56668. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56669. /**
  56670. * Returns the string "SpotLight".
  56671. * @returns the class name
  56672. */
  56673. getClassName(): string;
  56674. /**
  56675. * Returns the integer 2.
  56676. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56677. */
  56678. getTypeID(): number;
  56679. /**
  56680. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56681. */
  56682. protected _setDirection(value: Vector3): void;
  56683. /**
  56684. * Overrides the position setter to recompute the projection texture view light Matrix.
  56685. */
  56686. protected _setPosition(value: Vector3): void;
  56687. /**
  56688. * 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.
  56689. * Returns the SpotLight.
  56690. */
  56691. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56692. protected _computeProjectionTextureViewLightMatrix(): void;
  56693. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56694. /**
  56695. * Main function for light texture projection matrix computing.
  56696. */
  56697. protected _computeProjectionTextureMatrix(): void;
  56698. protected _buildUniformLayout(): void;
  56699. private _computeAngleValues;
  56700. /**
  56701. * Sets the passed Effect "effect" with the Light textures.
  56702. * @param effect The effect to update
  56703. * @param lightIndex The index of the light in the effect to update
  56704. * @returns The light
  56705. */
  56706. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56707. /**
  56708. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56709. * @param effect The effect to update
  56710. * @param lightIndex The index of the light in the effect to update
  56711. * @returns The spot light
  56712. */
  56713. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56714. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56715. /**
  56716. * Disposes the light and the associated resources.
  56717. */
  56718. dispose(): void;
  56719. /**
  56720. * Prepares the list of defines specific to the light type.
  56721. * @param defines the list of defines
  56722. * @param lightIndex defines the index of the light for the effect
  56723. */
  56724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56725. }
  56726. }
  56727. declare module "babylonjs/Gizmos/lightGizmo" {
  56728. import { Nullable } from "babylonjs/types";
  56729. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56730. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56731. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56732. import { Light } from "babylonjs/Lights/light";
  56733. import { Observable } from "babylonjs/Misc/observable";
  56734. /**
  56735. * Gizmo that enables viewing a light
  56736. */
  56737. export class LightGizmo extends Gizmo {
  56738. private _lightMesh;
  56739. private _material;
  56740. private _cachedPosition;
  56741. private _cachedForward;
  56742. private _attachedMeshParent;
  56743. private _pointerObserver;
  56744. /**
  56745. * Event that fires each time the gizmo is clicked
  56746. */
  56747. onClickedObservable: Observable<Light>;
  56748. /**
  56749. * Creates a LightGizmo
  56750. * @param gizmoLayer The utility layer the gizmo will be added to
  56751. */
  56752. constructor(gizmoLayer?: UtilityLayerRenderer);
  56753. private _light;
  56754. /**
  56755. * The light that the gizmo is attached to
  56756. */
  56757. set light(light: Nullable<Light>);
  56758. get light(): Nullable<Light>;
  56759. /**
  56760. * Gets the material used to render the light gizmo
  56761. */
  56762. get material(): StandardMaterial;
  56763. /**
  56764. * @hidden
  56765. * Updates the gizmo to match the attached mesh's position/rotation
  56766. */
  56767. protected _update(): void;
  56768. private static _Scale;
  56769. /**
  56770. * Creates the lines for a light mesh
  56771. */
  56772. private static _CreateLightLines;
  56773. /**
  56774. * Disposes of the light gizmo
  56775. */
  56776. dispose(): void;
  56777. private static _CreateHemisphericLightMesh;
  56778. private static _CreatePointLightMesh;
  56779. private static _CreateSpotLightMesh;
  56780. private static _CreateDirectionalLightMesh;
  56781. }
  56782. }
  56783. declare module "babylonjs/Gizmos/cameraGizmo" {
  56784. import { Nullable } from "babylonjs/types";
  56785. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56786. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56787. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56788. import { Camera } from "babylonjs/Cameras/camera";
  56789. import { Observable } from "babylonjs/Misc/observable";
  56790. /**
  56791. * Gizmo that enables viewing a camera
  56792. */
  56793. export class CameraGizmo extends Gizmo {
  56794. private _cameraMesh;
  56795. private _cameraLinesMesh;
  56796. private _material;
  56797. private _pointerObserver;
  56798. /**
  56799. * Event that fires each time the gizmo is clicked
  56800. */
  56801. onClickedObservable: Observable<Camera>;
  56802. /**
  56803. * Creates a CameraGizmo
  56804. * @param gizmoLayer The utility layer the gizmo will be added to
  56805. */
  56806. constructor(gizmoLayer?: UtilityLayerRenderer);
  56807. private _camera;
  56808. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56809. get displayFrustum(): boolean;
  56810. set displayFrustum(value: boolean);
  56811. /**
  56812. * The camera that the gizmo is attached to
  56813. */
  56814. set camera(camera: Nullable<Camera>);
  56815. get camera(): Nullable<Camera>;
  56816. /**
  56817. * Gets the material used to render the camera gizmo
  56818. */
  56819. get material(): StandardMaterial;
  56820. /**
  56821. * @hidden
  56822. * Updates the gizmo to match the attached mesh's position/rotation
  56823. */
  56824. protected _update(): void;
  56825. private static _Scale;
  56826. private _invProjection;
  56827. /**
  56828. * Disposes of the camera gizmo
  56829. */
  56830. dispose(): void;
  56831. private static _CreateCameraMesh;
  56832. private static _CreateCameraFrustum;
  56833. }
  56834. }
  56835. declare module "babylonjs/Gizmos/index" {
  56836. export * from "babylonjs/Gizmos/axisDragGizmo";
  56837. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56838. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56839. export * from "babylonjs/Gizmos/gizmo";
  56840. export * from "babylonjs/Gizmos/gizmoManager";
  56841. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56842. export * from "babylonjs/Gizmos/positionGizmo";
  56843. export * from "babylonjs/Gizmos/rotationGizmo";
  56844. export * from "babylonjs/Gizmos/scaleGizmo";
  56845. export * from "babylonjs/Gizmos/lightGizmo";
  56846. export * from "babylonjs/Gizmos/cameraGizmo";
  56847. export * from "babylonjs/Gizmos/planeDragGizmo";
  56848. }
  56849. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56850. /** @hidden */
  56851. export var backgroundFragmentDeclaration: {
  56852. name: string;
  56853. shader: string;
  56854. };
  56855. }
  56856. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56857. /** @hidden */
  56858. export var backgroundUboDeclaration: {
  56859. name: string;
  56860. shader: string;
  56861. };
  56862. }
  56863. declare module "babylonjs/Shaders/background.fragment" {
  56864. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56867. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56868. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56869. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56871. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56872. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56873. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56874. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56875. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56876. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56877. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56878. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56879. /** @hidden */
  56880. export var backgroundPixelShader: {
  56881. name: string;
  56882. shader: string;
  56883. };
  56884. }
  56885. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56886. /** @hidden */
  56887. export var backgroundVertexDeclaration: {
  56888. name: string;
  56889. shader: string;
  56890. };
  56891. }
  56892. declare module "babylonjs/Shaders/background.vertex" {
  56893. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56894. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56896. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56897. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56898. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56899. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56900. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56901. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56902. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56903. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56904. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56905. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56906. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56907. /** @hidden */
  56908. export var backgroundVertexShader: {
  56909. name: string;
  56910. shader: string;
  56911. };
  56912. }
  56913. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56914. import { Nullable, int, float } from "babylonjs/types";
  56915. import { Scene } from "babylonjs/scene";
  56916. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56919. import { Mesh } from "babylonjs/Meshes/mesh";
  56920. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56921. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56922. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56924. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56925. import { Color3 } from "babylonjs/Maths/math.color";
  56926. import "babylonjs/Shaders/background.fragment";
  56927. import "babylonjs/Shaders/background.vertex";
  56928. /**
  56929. * Background material used to create an efficient environement around your scene.
  56930. */
  56931. export class BackgroundMaterial extends PushMaterial {
  56932. /**
  56933. * Standard reflectance value at parallel view angle.
  56934. */
  56935. static StandardReflectance0: number;
  56936. /**
  56937. * Standard reflectance value at grazing angle.
  56938. */
  56939. static StandardReflectance90: number;
  56940. protected _primaryColor: Color3;
  56941. /**
  56942. * Key light Color (multiply against the environement texture)
  56943. */
  56944. primaryColor: Color3;
  56945. protected __perceptualColor: Nullable<Color3>;
  56946. /**
  56947. * Experimental Internal Use Only.
  56948. *
  56949. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56950. * This acts as a helper to set the primary color to a more "human friendly" value.
  56951. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56952. * output color as close as possible from the chosen value.
  56953. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56954. * part of lighting setup.)
  56955. */
  56956. get _perceptualColor(): Nullable<Color3>;
  56957. set _perceptualColor(value: Nullable<Color3>);
  56958. protected _primaryColorShadowLevel: float;
  56959. /**
  56960. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56961. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56962. */
  56963. get primaryColorShadowLevel(): float;
  56964. set primaryColorShadowLevel(value: float);
  56965. protected _primaryColorHighlightLevel: float;
  56966. /**
  56967. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56968. * The primary color is used at the level chosen to define what the white area would look.
  56969. */
  56970. get primaryColorHighlightLevel(): float;
  56971. set primaryColorHighlightLevel(value: float);
  56972. protected _reflectionTexture: Nullable<BaseTexture>;
  56973. /**
  56974. * Reflection Texture used in the material.
  56975. * Should be author in a specific way for the best result (refer to the documentation).
  56976. */
  56977. reflectionTexture: Nullable<BaseTexture>;
  56978. protected _reflectionBlur: float;
  56979. /**
  56980. * Reflection Texture level of blur.
  56981. *
  56982. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56983. * texture twice.
  56984. */
  56985. reflectionBlur: float;
  56986. protected _diffuseTexture: Nullable<BaseTexture>;
  56987. /**
  56988. * Diffuse Texture used in the material.
  56989. * Should be author in a specific way for the best result (refer to the documentation).
  56990. */
  56991. diffuseTexture: Nullable<BaseTexture>;
  56992. protected _shadowLights: Nullable<IShadowLight[]>;
  56993. /**
  56994. * Specify the list of lights casting shadow on the material.
  56995. * All scene shadow lights will be included if null.
  56996. */
  56997. shadowLights: Nullable<IShadowLight[]>;
  56998. protected _shadowLevel: float;
  56999. /**
  57000. * Helps adjusting the shadow to a softer level if required.
  57001. * 0 means black shadows and 1 means no shadows.
  57002. */
  57003. shadowLevel: float;
  57004. protected _sceneCenter: Vector3;
  57005. /**
  57006. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57007. * It is usually zero but might be interesting to modify according to your setup.
  57008. */
  57009. sceneCenter: Vector3;
  57010. protected _opacityFresnel: boolean;
  57011. /**
  57012. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57013. * This helps ensuring a nice transition when the camera goes under the ground.
  57014. */
  57015. opacityFresnel: boolean;
  57016. protected _reflectionFresnel: boolean;
  57017. /**
  57018. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57019. * This helps adding a mirror texture on the ground.
  57020. */
  57021. reflectionFresnel: boolean;
  57022. protected _reflectionFalloffDistance: number;
  57023. /**
  57024. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57025. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57026. */
  57027. reflectionFalloffDistance: number;
  57028. protected _reflectionAmount: number;
  57029. /**
  57030. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57031. */
  57032. reflectionAmount: number;
  57033. protected _reflectionReflectance0: number;
  57034. /**
  57035. * This specifies the weight of the reflection at grazing angle.
  57036. */
  57037. reflectionReflectance0: number;
  57038. protected _reflectionReflectance90: number;
  57039. /**
  57040. * This specifies the weight of the reflection at a perpendicular point of view.
  57041. */
  57042. reflectionReflectance90: number;
  57043. /**
  57044. * Sets the reflection reflectance fresnel values according to the default standard
  57045. * empirically know to work well :-)
  57046. */
  57047. set reflectionStandardFresnelWeight(value: number);
  57048. protected _useRGBColor: boolean;
  57049. /**
  57050. * Helps to directly use the maps channels instead of their level.
  57051. */
  57052. useRGBColor: boolean;
  57053. protected _enableNoise: boolean;
  57054. /**
  57055. * This helps reducing the banding effect that could occur on the background.
  57056. */
  57057. enableNoise: boolean;
  57058. /**
  57059. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57060. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57061. * Recommended to be keep at 1.0 except for special cases.
  57062. */
  57063. get fovMultiplier(): number;
  57064. set fovMultiplier(value: number);
  57065. private _fovMultiplier;
  57066. /**
  57067. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57068. */
  57069. useEquirectangularFOV: boolean;
  57070. private _maxSimultaneousLights;
  57071. /**
  57072. * Number of Simultaneous lights allowed on the material.
  57073. */
  57074. maxSimultaneousLights: int;
  57075. private _shadowOnly;
  57076. /**
  57077. * Make the material only render shadows
  57078. */
  57079. shadowOnly: boolean;
  57080. /**
  57081. * Default configuration related to image processing available in the Background Material.
  57082. */
  57083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57084. /**
  57085. * Keep track of the image processing observer to allow dispose and replace.
  57086. */
  57087. private _imageProcessingObserver;
  57088. /**
  57089. * Attaches a new image processing configuration to the PBR Material.
  57090. * @param configuration (if null the scene configuration will be use)
  57091. */
  57092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57093. /**
  57094. * Gets the image processing configuration used either in this material.
  57095. */
  57096. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57097. /**
  57098. * Sets the Default image processing configuration used either in the this material.
  57099. *
  57100. * If sets to null, the scene one is in use.
  57101. */
  57102. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57103. /**
  57104. * Gets wether the color curves effect is enabled.
  57105. */
  57106. get cameraColorCurvesEnabled(): boolean;
  57107. /**
  57108. * Sets wether the color curves effect is enabled.
  57109. */
  57110. set cameraColorCurvesEnabled(value: boolean);
  57111. /**
  57112. * Gets wether the color grading effect is enabled.
  57113. */
  57114. get cameraColorGradingEnabled(): boolean;
  57115. /**
  57116. * Gets wether the color grading effect is enabled.
  57117. */
  57118. set cameraColorGradingEnabled(value: boolean);
  57119. /**
  57120. * Gets wether tonemapping is enabled or not.
  57121. */
  57122. get cameraToneMappingEnabled(): boolean;
  57123. /**
  57124. * Sets wether tonemapping is enabled or not
  57125. */
  57126. set cameraToneMappingEnabled(value: boolean);
  57127. /**
  57128. * The camera exposure used on this material.
  57129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57130. * This corresponds to a photographic exposure.
  57131. */
  57132. get cameraExposure(): float;
  57133. /**
  57134. * The camera exposure used on this material.
  57135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57136. * This corresponds to a photographic exposure.
  57137. */
  57138. set cameraExposure(value: float);
  57139. /**
  57140. * Gets The camera contrast used on this material.
  57141. */
  57142. get cameraContrast(): float;
  57143. /**
  57144. * Sets The camera contrast used on this material.
  57145. */
  57146. set cameraContrast(value: float);
  57147. /**
  57148. * Gets the Color Grading 2D Lookup Texture.
  57149. */
  57150. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57151. /**
  57152. * Sets the Color Grading 2D Lookup Texture.
  57153. */
  57154. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57155. /**
  57156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57158. * 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;
  57159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57160. */
  57161. get cameraColorCurves(): Nullable<ColorCurves>;
  57162. /**
  57163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57165. * 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;
  57166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57167. */
  57168. set cameraColorCurves(value: Nullable<ColorCurves>);
  57169. /**
  57170. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57171. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57172. */
  57173. switchToBGR: boolean;
  57174. private _renderTargets;
  57175. private _reflectionControls;
  57176. private _white;
  57177. private _primaryShadowColor;
  57178. private _primaryHighlightColor;
  57179. /**
  57180. * Instantiates a Background Material in the given scene
  57181. * @param name The friendly name of the material
  57182. * @param scene The scene to add the material to
  57183. */
  57184. constructor(name: string, scene: Scene);
  57185. /**
  57186. * Gets a boolean indicating that current material needs to register RTT
  57187. */
  57188. get hasRenderTargetTextures(): boolean;
  57189. /**
  57190. * The entire material has been created in order to prevent overdraw.
  57191. * @returns false
  57192. */
  57193. needAlphaTesting(): boolean;
  57194. /**
  57195. * The entire material has been created in order to prevent overdraw.
  57196. * @returns true if blending is enable
  57197. */
  57198. needAlphaBlending(): boolean;
  57199. /**
  57200. * Checks wether the material is ready to be rendered for a given mesh.
  57201. * @param mesh The mesh to render
  57202. * @param subMesh The submesh to check against
  57203. * @param useInstances Specify wether or not the material is used with instances
  57204. * @returns true if all the dependencies are ready (Textures, Effects...)
  57205. */
  57206. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57207. /**
  57208. * Compute the primary color according to the chosen perceptual color.
  57209. */
  57210. private _computePrimaryColorFromPerceptualColor;
  57211. /**
  57212. * Compute the highlights and shadow colors according to their chosen levels.
  57213. */
  57214. private _computePrimaryColors;
  57215. /**
  57216. * Build the uniform buffer used in the material.
  57217. */
  57218. buildUniformLayout(): void;
  57219. /**
  57220. * Unbind the material.
  57221. */
  57222. unbind(): void;
  57223. /**
  57224. * Bind only the world matrix to the material.
  57225. * @param world The world matrix to bind.
  57226. */
  57227. bindOnlyWorldMatrix(world: Matrix): void;
  57228. /**
  57229. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57230. * @param world The world matrix to bind.
  57231. * @param subMesh The submesh to bind for.
  57232. */
  57233. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57234. /**
  57235. * Checks to see if a texture is used in the material.
  57236. * @param texture - Base texture to use.
  57237. * @returns - Boolean specifying if a texture is used in the material.
  57238. */
  57239. hasTexture(texture: BaseTexture): boolean;
  57240. /**
  57241. * Dispose the material.
  57242. * @param forceDisposeEffect Force disposal of the associated effect.
  57243. * @param forceDisposeTextures Force disposal of the associated textures.
  57244. */
  57245. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57246. /**
  57247. * Clones the material.
  57248. * @param name The cloned name.
  57249. * @returns The cloned material.
  57250. */
  57251. clone(name: string): BackgroundMaterial;
  57252. /**
  57253. * Serializes the current material to its JSON representation.
  57254. * @returns The JSON representation.
  57255. */
  57256. serialize(): any;
  57257. /**
  57258. * Gets the class name of the material
  57259. * @returns "BackgroundMaterial"
  57260. */
  57261. getClassName(): string;
  57262. /**
  57263. * Parse a JSON input to create back a background material.
  57264. * @param source The JSON data to parse
  57265. * @param scene The scene to create the parsed material in
  57266. * @param rootUrl The root url of the assets the material depends upon
  57267. * @returns the instantiated BackgroundMaterial.
  57268. */
  57269. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57270. }
  57271. }
  57272. declare module "babylonjs/Helpers/environmentHelper" {
  57273. import { Observable } from "babylonjs/Misc/observable";
  57274. import { Nullable } from "babylonjs/types";
  57275. import { Scene } from "babylonjs/scene";
  57276. import { Vector3 } from "babylonjs/Maths/math.vector";
  57277. import { Color3 } from "babylonjs/Maths/math.color";
  57278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57279. import { Mesh } from "babylonjs/Meshes/mesh";
  57280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57281. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57282. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57283. import "babylonjs/Meshes/Builders/planeBuilder";
  57284. import "babylonjs/Meshes/Builders/boxBuilder";
  57285. /**
  57286. * Represents the different options available during the creation of
  57287. * a Environment helper.
  57288. *
  57289. * This can control the default ground, skybox and image processing setup of your scene.
  57290. */
  57291. export interface IEnvironmentHelperOptions {
  57292. /**
  57293. * Specifies whether or not to create a ground.
  57294. * True by default.
  57295. */
  57296. createGround: boolean;
  57297. /**
  57298. * Specifies the ground size.
  57299. * 15 by default.
  57300. */
  57301. groundSize: number;
  57302. /**
  57303. * The texture used on the ground for the main color.
  57304. * Comes from the BabylonJS CDN by default.
  57305. *
  57306. * Remarks: Can be either a texture or a url.
  57307. */
  57308. groundTexture: string | BaseTexture;
  57309. /**
  57310. * The color mixed in the ground texture by default.
  57311. * BabylonJS clearColor by default.
  57312. */
  57313. groundColor: Color3;
  57314. /**
  57315. * Specifies the ground opacity.
  57316. * 1 by default.
  57317. */
  57318. groundOpacity: number;
  57319. /**
  57320. * Enables the ground to receive shadows.
  57321. * True by default.
  57322. */
  57323. enableGroundShadow: boolean;
  57324. /**
  57325. * Helps preventing the shadow to be fully black on the ground.
  57326. * 0.5 by default.
  57327. */
  57328. groundShadowLevel: number;
  57329. /**
  57330. * Creates a mirror texture attach to the ground.
  57331. * false by default.
  57332. */
  57333. enableGroundMirror: boolean;
  57334. /**
  57335. * Specifies the ground mirror size ratio.
  57336. * 0.3 by default as the default kernel is 64.
  57337. */
  57338. groundMirrorSizeRatio: number;
  57339. /**
  57340. * Specifies the ground mirror blur kernel size.
  57341. * 64 by default.
  57342. */
  57343. groundMirrorBlurKernel: number;
  57344. /**
  57345. * Specifies the ground mirror visibility amount.
  57346. * 1 by default
  57347. */
  57348. groundMirrorAmount: number;
  57349. /**
  57350. * Specifies the ground mirror reflectance weight.
  57351. * This uses the standard weight of the background material to setup the fresnel effect
  57352. * of the mirror.
  57353. * 1 by default.
  57354. */
  57355. groundMirrorFresnelWeight: number;
  57356. /**
  57357. * Specifies the ground mirror Falloff distance.
  57358. * This can helps reducing the size of the reflection.
  57359. * 0 by Default.
  57360. */
  57361. groundMirrorFallOffDistance: number;
  57362. /**
  57363. * Specifies the ground mirror texture type.
  57364. * Unsigned Int by Default.
  57365. */
  57366. groundMirrorTextureType: number;
  57367. /**
  57368. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57369. * the shown objects.
  57370. */
  57371. groundYBias: number;
  57372. /**
  57373. * Specifies whether or not to create a skybox.
  57374. * True by default.
  57375. */
  57376. createSkybox: boolean;
  57377. /**
  57378. * Specifies the skybox size.
  57379. * 20 by default.
  57380. */
  57381. skyboxSize: number;
  57382. /**
  57383. * The texture used on the skybox for the main color.
  57384. * Comes from the BabylonJS CDN by default.
  57385. *
  57386. * Remarks: Can be either a texture or a url.
  57387. */
  57388. skyboxTexture: string | BaseTexture;
  57389. /**
  57390. * The color mixed in the skybox texture by default.
  57391. * BabylonJS clearColor by default.
  57392. */
  57393. skyboxColor: Color3;
  57394. /**
  57395. * The background rotation around the Y axis of the scene.
  57396. * This helps aligning the key lights of your scene with the background.
  57397. * 0 by default.
  57398. */
  57399. backgroundYRotation: number;
  57400. /**
  57401. * Compute automatically the size of the elements to best fit with the scene.
  57402. */
  57403. sizeAuto: boolean;
  57404. /**
  57405. * Default position of the rootMesh if autoSize is not true.
  57406. */
  57407. rootPosition: Vector3;
  57408. /**
  57409. * Sets up the image processing in the scene.
  57410. * true by default.
  57411. */
  57412. setupImageProcessing: boolean;
  57413. /**
  57414. * The texture used as your environment texture in the scene.
  57415. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57416. *
  57417. * Remarks: Can be either a texture or a url.
  57418. */
  57419. environmentTexture: string | BaseTexture;
  57420. /**
  57421. * The value of the exposure to apply to the scene.
  57422. * 0.6 by default if setupImageProcessing is true.
  57423. */
  57424. cameraExposure: number;
  57425. /**
  57426. * The value of the contrast to apply to the scene.
  57427. * 1.6 by default if setupImageProcessing is true.
  57428. */
  57429. cameraContrast: number;
  57430. /**
  57431. * Specifies whether or not tonemapping should be enabled in the scene.
  57432. * true by default if setupImageProcessing is true.
  57433. */
  57434. toneMappingEnabled: boolean;
  57435. }
  57436. /**
  57437. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57438. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57439. * It also helps with the default setup of your imageProcessing configuration.
  57440. */
  57441. export class EnvironmentHelper {
  57442. /**
  57443. * Default ground texture URL.
  57444. */
  57445. private static _groundTextureCDNUrl;
  57446. /**
  57447. * Default skybox texture URL.
  57448. */
  57449. private static _skyboxTextureCDNUrl;
  57450. /**
  57451. * Default environment texture URL.
  57452. */
  57453. private static _environmentTextureCDNUrl;
  57454. /**
  57455. * Creates the default options for the helper.
  57456. */
  57457. private static _getDefaultOptions;
  57458. private _rootMesh;
  57459. /**
  57460. * Gets the root mesh created by the helper.
  57461. */
  57462. get rootMesh(): Mesh;
  57463. private _skybox;
  57464. /**
  57465. * Gets the skybox created by the helper.
  57466. */
  57467. get skybox(): Nullable<Mesh>;
  57468. private _skyboxTexture;
  57469. /**
  57470. * Gets the skybox texture created by the helper.
  57471. */
  57472. get skyboxTexture(): Nullable<BaseTexture>;
  57473. private _skyboxMaterial;
  57474. /**
  57475. * Gets the skybox material created by the helper.
  57476. */
  57477. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57478. private _ground;
  57479. /**
  57480. * Gets the ground mesh created by the helper.
  57481. */
  57482. get ground(): Nullable<Mesh>;
  57483. private _groundTexture;
  57484. /**
  57485. * Gets the ground texture created by the helper.
  57486. */
  57487. get groundTexture(): Nullable<BaseTexture>;
  57488. private _groundMirror;
  57489. /**
  57490. * Gets the ground mirror created by the helper.
  57491. */
  57492. get groundMirror(): Nullable<MirrorTexture>;
  57493. /**
  57494. * Gets the ground mirror render list to helps pushing the meshes
  57495. * you wish in the ground reflection.
  57496. */
  57497. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57498. private _groundMaterial;
  57499. /**
  57500. * Gets the ground material created by the helper.
  57501. */
  57502. get groundMaterial(): Nullable<BackgroundMaterial>;
  57503. /**
  57504. * Stores the creation options.
  57505. */
  57506. private readonly _scene;
  57507. private _options;
  57508. /**
  57509. * This observable will be notified with any error during the creation of the environment,
  57510. * mainly texture creation errors.
  57511. */
  57512. onErrorObservable: Observable<{
  57513. message?: string;
  57514. exception?: any;
  57515. }>;
  57516. /**
  57517. * constructor
  57518. * @param options Defines the options we want to customize the helper
  57519. * @param scene The scene to add the material to
  57520. */
  57521. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57522. /**
  57523. * Updates the background according to the new options
  57524. * @param options
  57525. */
  57526. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57527. /**
  57528. * Sets the primary color of all the available elements.
  57529. * @param color the main color to affect to the ground and the background
  57530. */
  57531. setMainColor(color: Color3): void;
  57532. /**
  57533. * Setup the image processing according to the specified options.
  57534. */
  57535. private _setupImageProcessing;
  57536. /**
  57537. * Setup the environment texture according to the specified options.
  57538. */
  57539. private _setupEnvironmentTexture;
  57540. /**
  57541. * Setup the background according to the specified options.
  57542. */
  57543. private _setupBackground;
  57544. /**
  57545. * Get the scene sizes according to the setup.
  57546. */
  57547. private _getSceneSize;
  57548. /**
  57549. * Setup the ground according to the specified options.
  57550. */
  57551. private _setupGround;
  57552. /**
  57553. * Setup the ground material according to the specified options.
  57554. */
  57555. private _setupGroundMaterial;
  57556. /**
  57557. * Setup the ground diffuse texture according to the specified options.
  57558. */
  57559. private _setupGroundDiffuseTexture;
  57560. /**
  57561. * Setup the ground mirror texture according to the specified options.
  57562. */
  57563. private _setupGroundMirrorTexture;
  57564. /**
  57565. * Setup the ground to receive the mirror texture.
  57566. */
  57567. private _setupMirrorInGroundMaterial;
  57568. /**
  57569. * Setup the skybox according to the specified options.
  57570. */
  57571. private _setupSkybox;
  57572. /**
  57573. * Setup the skybox material according to the specified options.
  57574. */
  57575. private _setupSkyboxMaterial;
  57576. /**
  57577. * Setup the skybox reflection texture according to the specified options.
  57578. */
  57579. private _setupSkyboxReflectionTexture;
  57580. private _errorHandler;
  57581. /**
  57582. * Dispose all the elements created by the Helper.
  57583. */
  57584. dispose(): void;
  57585. }
  57586. }
  57587. declare module "babylonjs/Helpers/textureDome" {
  57588. import { Scene } from "babylonjs/scene";
  57589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57590. import { Mesh } from "babylonjs/Meshes/mesh";
  57591. import { Texture } from "babylonjs/Materials/Textures/texture";
  57592. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57593. import "babylonjs/Meshes/Builders/sphereBuilder";
  57594. import { Nullable } from "babylonjs/types";
  57595. import { Observable } from "babylonjs/Misc/observable";
  57596. /**
  57597. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57598. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57599. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57600. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57601. */
  57602. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57603. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57604. /**
  57605. * Define the source as a Monoscopic panoramic 360/180.
  57606. */
  57607. static readonly MODE_MONOSCOPIC: number;
  57608. /**
  57609. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57610. */
  57611. static readonly MODE_TOPBOTTOM: number;
  57612. /**
  57613. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57614. */
  57615. static readonly MODE_SIDEBYSIDE: number;
  57616. private _halfDome;
  57617. protected _useDirectMapping: boolean;
  57618. /**
  57619. * The texture being displayed on the sphere
  57620. */
  57621. protected _texture: T;
  57622. /**
  57623. * Gets the texture being displayed on the sphere
  57624. */
  57625. get texture(): T;
  57626. /**
  57627. * Sets the texture being displayed on the sphere
  57628. */
  57629. set texture(newTexture: T);
  57630. /**
  57631. * The skybox material
  57632. */
  57633. protected _material: BackgroundMaterial;
  57634. /**
  57635. * The surface used for the dome
  57636. */
  57637. protected _mesh: Mesh;
  57638. /**
  57639. * Gets the mesh used for the dome.
  57640. */
  57641. get mesh(): Mesh;
  57642. /**
  57643. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57644. */
  57645. private _halfDomeMask;
  57646. /**
  57647. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57648. * Also see the options.resolution property.
  57649. */
  57650. get fovMultiplier(): number;
  57651. set fovMultiplier(value: number);
  57652. protected _textureMode: number;
  57653. /**
  57654. * Gets or set the current texture mode for the texture. It can be:
  57655. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57656. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57657. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57658. */
  57659. get textureMode(): number;
  57660. /**
  57661. * Sets the current texture mode for the texture. It can be:
  57662. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57663. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57664. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57665. */
  57666. set textureMode(value: number);
  57667. /**
  57668. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57669. */
  57670. get halfDome(): boolean;
  57671. /**
  57672. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57673. */
  57674. set halfDome(enabled: boolean);
  57675. /**
  57676. * Oberserver used in Stereoscopic VR Mode.
  57677. */
  57678. private _onBeforeCameraRenderObserver;
  57679. /**
  57680. * Observable raised when an error occured while loading the 360 image
  57681. */
  57682. onLoadErrorObservable: Observable<string>;
  57683. /**
  57684. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57685. * @param name Element's name, child elements will append suffixes for their own names.
  57686. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57687. * @param options An object containing optional or exposed sub element properties
  57688. */
  57689. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57690. resolution?: number;
  57691. clickToPlay?: boolean;
  57692. autoPlay?: boolean;
  57693. loop?: boolean;
  57694. size?: number;
  57695. poster?: string;
  57696. faceForward?: boolean;
  57697. useDirectMapping?: boolean;
  57698. halfDomeMode?: boolean;
  57699. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57700. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57701. protected _changeTextureMode(value: number): void;
  57702. /**
  57703. * Releases resources associated with this node.
  57704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57706. */
  57707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57708. }
  57709. }
  57710. declare module "babylonjs/Helpers/photoDome" {
  57711. import { Scene } from "babylonjs/scene";
  57712. import { Texture } from "babylonjs/Materials/Textures/texture";
  57713. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57714. /**
  57715. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57716. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57717. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57718. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57719. */
  57720. export class PhotoDome extends TextureDome<Texture> {
  57721. /**
  57722. * Define the image as a Monoscopic panoramic 360 image.
  57723. */
  57724. static readonly MODE_MONOSCOPIC: number;
  57725. /**
  57726. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57727. */
  57728. static readonly MODE_TOPBOTTOM: number;
  57729. /**
  57730. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57731. */
  57732. static readonly MODE_SIDEBYSIDE: number;
  57733. /**
  57734. * Gets or sets the texture being displayed on the sphere
  57735. */
  57736. get photoTexture(): Texture;
  57737. /**
  57738. * sets the texture being displayed on the sphere
  57739. */
  57740. set photoTexture(value: Texture);
  57741. /**
  57742. * Gets the current video mode for the video. It can be:
  57743. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57744. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57745. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57746. */
  57747. get imageMode(): number;
  57748. /**
  57749. * Sets the current video mode for the video. It can be:
  57750. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57751. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57752. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57753. */
  57754. set imageMode(value: number);
  57755. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57756. }
  57757. }
  57758. declare module "babylonjs/Misc/rgbdTextureTools" {
  57759. import "babylonjs/Shaders/rgbdDecode.fragment";
  57760. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57761. import { Texture } from "babylonjs/Materials/Textures/texture";
  57762. /**
  57763. * Class used to host RGBD texture specific utilities
  57764. */
  57765. export class RGBDTextureTools {
  57766. /**
  57767. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57768. * @param texture the texture to expand.
  57769. */
  57770. static ExpandRGBDTexture(texture: Texture): void;
  57771. }
  57772. }
  57773. declare module "babylonjs/Misc/brdfTextureTools" {
  57774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57775. import { Scene } from "babylonjs/scene";
  57776. /**
  57777. * Class used to host texture specific utilities
  57778. */
  57779. export class BRDFTextureTools {
  57780. /**
  57781. * Prevents texture cache collision
  57782. */
  57783. private static _instanceNumber;
  57784. /**
  57785. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57786. * @param scene defines the hosting scene
  57787. * @returns the environment BRDF texture
  57788. */
  57789. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57790. private static _environmentBRDFBase64Texture;
  57791. }
  57792. }
  57793. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57794. import { Nullable } from "babylonjs/types";
  57795. import { Color3 } from "babylonjs/Maths/math.color";
  57796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57797. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57798. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57799. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57800. import { Engine } from "babylonjs/Engines/engine";
  57801. import { Scene } from "babylonjs/scene";
  57802. /**
  57803. * @hidden
  57804. */
  57805. export interface IMaterialClearCoatDefines {
  57806. CLEARCOAT: boolean;
  57807. CLEARCOAT_DEFAULTIOR: boolean;
  57808. CLEARCOAT_TEXTURE: boolean;
  57809. CLEARCOAT_TEXTUREDIRECTUV: number;
  57810. CLEARCOAT_BUMP: boolean;
  57811. CLEARCOAT_BUMPDIRECTUV: number;
  57812. CLEARCOAT_TINT: boolean;
  57813. CLEARCOAT_TINT_TEXTURE: boolean;
  57814. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57815. /** @hidden */
  57816. _areTexturesDirty: boolean;
  57817. }
  57818. /**
  57819. * Define the code related to the clear coat parameters of the pbr material.
  57820. */
  57821. export class PBRClearCoatConfiguration {
  57822. /**
  57823. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57824. * The default fits with a polyurethane material.
  57825. */
  57826. private static readonly _DefaultIndexOfRefraction;
  57827. private _isEnabled;
  57828. /**
  57829. * Defines if the clear coat is enabled in the material.
  57830. */
  57831. isEnabled: boolean;
  57832. /**
  57833. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57834. */
  57835. intensity: number;
  57836. /**
  57837. * Defines the clear coat layer roughness.
  57838. */
  57839. roughness: number;
  57840. private _indexOfRefraction;
  57841. /**
  57842. * Defines the index of refraction of the clear coat.
  57843. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57844. * The default fits with a polyurethane material.
  57845. * Changing the default value is more performance intensive.
  57846. */
  57847. indexOfRefraction: number;
  57848. private _texture;
  57849. /**
  57850. * Stores the clear coat values in a texture.
  57851. */
  57852. texture: Nullable<BaseTexture>;
  57853. private _bumpTexture;
  57854. /**
  57855. * Define the clear coat specific bump texture.
  57856. */
  57857. bumpTexture: Nullable<BaseTexture>;
  57858. private _isTintEnabled;
  57859. /**
  57860. * Defines if the clear coat tint is enabled in the material.
  57861. */
  57862. isTintEnabled: boolean;
  57863. /**
  57864. * Defines the clear coat tint of the material.
  57865. * This is only use if tint is enabled
  57866. */
  57867. tintColor: Color3;
  57868. /**
  57869. * Defines the distance at which the tint color should be found in the
  57870. * clear coat media.
  57871. * This is only use if tint is enabled
  57872. */
  57873. tintColorAtDistance: number;
  57874. /**
  57875. * Defines the clear coat layer thickness.
  57876. * This is only use if tint is enabled
  57877. */
  57878. tintThickness: number;
  57879. private _tintTexture;
  57880. /**
  57881. * Stores the clear tint values in a texture.
  57882. * rgb is tint
  57883. * a is a thickness factor
  57884. */
  57885. tintTexture: Nullable<BaseTexture>;
  57886. /** @hidden */
  57887. private _internalMarkAllSubMeshesAsTexturesDirty;
  57888. /** @hidden */
  57889. _markAllSubMeshesAsTexturesDirty(): void;
  57890. /**
  57891. * Instantiate a new istance of clear coat configuration.
  57892. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57893. */
  57894. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57895. /**
  57896. * Gets wehter the submesh is ready to be used or not.
  57897. * @param defines the list of "defines" to update.
  57898. * @param scene defines the scene the material belongs to.
  57899. * @param engine defines the engine the material belongs to.
  57900. * @param disableBumpMap defines wether the material disables bump or not.
  57901. * @returns - boolean indicating that the submesh is ready or not.
  57902. */
  57903. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57904. /**
  57905. * Checks to see if a texture is used in the material.
  57906. * @param defines the list of "defines" to update.
  57907. * @param scene defines the scene to the material belongs to.
  57908. */
  57909. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57910. /**
  57911. * Binds the material data.
  57912. * @param uniformBuffer defines the Uniform buffer to fill in.
  57913. * @param scene defines the scene the material belongs to.
  57914. * @param engine defines the engine the material belongs to.
  57915. * @param disableBumpMap defines wether the material disables bump or not.
  57916. * @param isFrozen defines wether the material is frozen or not.
  57917. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57918. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57919. */
  57920. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57921. /**
  57922. * Checks to see if a texture is used in the material.
  57923. * @param texture - Base texture to use.
  57924. * @returns - Boolean specifying if a texture is used in the material.
  57925. */
  57926. hasTexture(texture: BaseTexture): boolean;
  57927. /**
  57928. * Returns an array of the actively used textures.
  57929. * @param activeTextures Array of BaseTextures
  57930. */
  57931. getActiveTextures(activeTextures: BaseTexture[]): void;
  57932. /**
  57933. * Returns the animatable textures.
  57934. * @param animatables Array of animatable textures.
  57935. */
  57936. getAnimatables(animatables: IAnimatable[]): void;
  57937. /**
  57938. * Disposes the resources of the material.
  57939. * @param forceDisposeTextures - Forces the disposal of all textures.
  57940. */
  57941. dispose(forceDisposeTextures?: boolean): void;
  57942. /**
  57943. * Get the current class name of the texture useful for serialization or dynamic coding.
  57944. * @returns "PBRClearCoatConfiguration"
  57945. */
  57946. getClassName(): string;
  57947. /**
  57948. * Add fallbacks to the effect fallbacks list.
  57949. * @param defines defines the Base texture to use.
  57950. * @param fallbacks defines the current fallback list.
  57951. * @param currentRank defines the current fallback rank.
  57952. * @returns the new fallback rank.
  57953. */
  57954. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57955. /**
  57956. * Add the required uniforms to the current list.
  57957. * @param uniforms defines the current uniform list.
  57958. */
  57959. static AddUniforms(uniforms: string[]): void;
  57960. /**
  57961. * Add the required samplers to the current list.
  57962. * @param samplers defines the current sampler list.
  57963. */
  57964. static AddSamplers(samplers: string[]): void;
  57965. /**
  57966. * Add the required uniforms to the current buffer.
  57967. * @param uniformBuffer defines the current uniform buffer.
  57968. */
  57969. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57970. /**
  57971. * Makes a duplicate of the current configuration into another one.
  57972. * @param clearCoatConfiguration define the config where to copy the info
  57973. */
  57974. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57975. /**
  57976. * Serializes this clear coat configuration.
  57977. * @returns - An object with the serialized config.
  57978. */
  57979. serialize(): any;
  57980. /**
  57981. * Parses a anisotropy Configuration from a serialized object.
  57982. * @param source - Serialized object.
  57983. * @param scene Defines the scene we are parsing for
  57984. * @param rootUrl Defines the rootUrl to load from
  57985. */
  57986. parse(source: any, scene: Scene, rootUrl: string): void;
  57987. }
  57988. }
  57989. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57992. import { Vector2 } from "babylonjs/Maths/math.vector";
  57993. import { Scene } from "babylonjs/scene";
  57994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57995. import { Nullable } from "babylonjs/types";
  57996. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57997. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57998. /**
  57999. * @hidden
  58000. */
  58001. export interface IMaterialAnisotropicDefines {
  58002. ANISOTROPIC: boolean;
  58003. ANISOTROPIC_TEXTURE: boolean;
  58004. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58005. MAINUV1: boolean;
  58006. _areTexturesDirty: boolean;
  58007. _needUVs: boolean;
  58008. }
  58009. /**
  58010. * Define the code related to the anisotropic parameters of the pbr material.
  58011. */
  58012. export class PBRAnisotropicConfiguration {
  58013. private _isEnabled;
  58014. /**
  58015. * Defines if the anisotropy is enabled in the material.
  58016. */
  58017. isEnabled: boolean;
  58018. /**
  58019. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58020. */
  58021. intensity: number;
  58022. /**
  58023. * Defines if the effect is along the tangents, bitangents or in between.
  58024. * By default, the effect is "strectching" the highlights along the tangents.
  58025. */
  58026. direction: Vector2;
  58027. private _texture;
  58028. /**
  58029. * Stores the anisotropy values in a texture.
  58030. * rg is direction (like normal from -1 to 1)
  58031. * b is a intensity
  58032. */
  58033. texture: Nullable<BaseTexture>;
  58034. /** @hidden */
  58035. private _internalMarkAllSubMeshesAsTexturesDirty;
  58036. /** @hidden */
  58037. _markAllSubMeshesAsTexturesDirty(): void;
  58038. /**
  58039. * Instantiate a new istance of anisotropy configuration.
  58040. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58041. */
  58042. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58043. /**
  58044. * Specifies that the submesh is ready to be used.
  58045. * @param defines the list of "defines" to update.
  58046. * @param scene defines the scene the material belongs to.
  58047. * @returns - boolean indicating that the submesh is ready or not.
  58048. */
  58049. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58050. /**
  58051. * Checks to see if a texture is used in the material.
  58052. * @param defines the list of "defines" to update.
  58053. * @param mesh the mesh we are preparing the defines for.
  58054. * @param scene defines the scene the material belongs to.
  58055. */
  58056. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58057. /**
  58058. * Binds the material data.
  58059. * @param uniformBuffer defines the Uniform buffer to fill in.
  58060. * @param scene defines the scene the material belongs to.
  58061. * @param isFrozen defines wether the material is frozen or not.
  58062. */
  58063. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58064. /**
  58065. * Checks to see if a texture is used in the material.
  58066. * @param texture - Base texture to use.
  58067. * @returns - Boolean specifying if a texture is used in the material.
  58068. */
  58069. hasTexture(texture: BaseTexture): boolean;
  58070. /**
  58071. * Returns an array of the actively used textures.
  58072. * @param activeTextures Array of BaseTextures
  58073. */
  58074. getActiveTextures(activeTextures: BaseTexture[]): void;
  58075. /**
  58076. * Returns the animatable textures.
  58077. * @param animatables Array of animatable textures.
  58078. */
  58079. getAnimatables(animatables: IAnimatable[]): void;
  58080. /**
  58081. * Disposes the resources of the material.
  58082. * @param forceDisposeTextures - Forces the disposal of all textures.
  58083. */
  58084. dispose(forceDisposeTextures?: boolean): void;
  58085. /**
  58086. * Get the current class name of the texture useful for serialization or dynamic coding.
  58087. * @returns "PBRAnisotropicConfiguration"
  58088. */
  58089. getClassName(): string;
  58090. /**
  58091. * Add fallbacks to the effect fallbacks list.
  58092. * @param defines defines the Base texture to use.
  58093. * @param fallbacks defines the current fallback list.
  58094. * @param currentRank defines the current fallback rank.
  58095. * @returns the new fallback rank.
  58096. */
  58097. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58098. /**
  58099. * Add the required uniforms to the current list.
  58100. * @param uniforms defines the current uniform list.
  58101. */
  58102. static AddUniforms(uniforms: string[]): void;
  58103. /**
  58104. * Add the required uniforms to the current buffer.
  58105. * @param uniformBuffer defines the current uniform buffer.
  58106. */
  58107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58108. /**
  58109. * Add the required samplers to the current list.
  58110. * @param samplers defines the current sampler list.
  58111. */
  58112. static AddSamplers(samplers: string[]): void;
  58113. /**
  58114. * Makes a duplicate of the current configuration into another one.
  58115. * @param anisotropicConfiguration define the config where to copy the info
  58116. */
  58117. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58118. /**
  58119. * Serializes this anisotropy configuration.
  58120. * @returns - An object with the serialized config.
  58121. */
  58122. serialize(): any;
  58123. /**
  58124. * Parses a anisotropy Configuration from a serialized object.
  58125. * @param source - Serialized object.
  58126. * @param scene Defines the scene we are parsing for
  58127. * @param rootUrl Defines the rootUrl to load from
  58128. */
  58129. parse(source: any, scene: Scene, rootUrl: string): void;
  58130. }
  58131. }
  58132. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58133. import { Scene } from "babylonjs/scene";
  58134. /**
  58135. * @hidden
  58136. */
  58137. export interface IMaterialBRDFDefines {
  58138. BRDF_V_HEIGHT_CORRELATED: boolean;
  58139. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58140. SPHERICAL_HARMONICS: boolean;
  58141. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58142. /** @hidden */
  58143. _areMiscDirty: boolean;
  58144. }
  58145. /**
  58146. * Define the code related to the BRDF parameters of the pbr material.
  58147. */
  58148. export class PBRBRDFConfiguration {
  58149. /**
  58150. * Default value used for the energy conservation.
  58151. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58152. */
  58153. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58154. /**
  58155. * Default value used for the Smith Visibility Height Correlated mode.
  58156. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58157. */
  58158. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58159. /**
  58160. * Default value used for the IBL diffuse part.
  58161. * This can help switching back to the polynomials mode globally which is a tiny bit
  58162. * less GPU intensive at the drawback of a lower quality.
  58163. */
  58164. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58165. /**
  58166. * Default value used for activating energy conservation for the specular workflow.
  58167. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58168. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58169. */
  58170. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58171. private _useEnergyConservation;
  58172. /**
  58173. * Defines if the material uses energy conservation.
  58174. */
  58175. useEnergyConservation: boolean;
  58176. private _useSmithVisibilityHeightCorrelated;
  58177. /**
  58178. * LEGACY Mode set to false
  58179. * Defines if the material uses height smith correlated visibility term.
  58180. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58181. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58182. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58183. * Not relying on height correlated will also disable energy conservation.
  58184. */
  58185. useSmithVisibilityHeightCorrelated: boolean;
  58186. private _useSphericalHarmonics;
  58187. /**
  58188. * LEGACY Mode set to false
  58189. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58190. * diffuse part of the IBL.
  58191. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58192. * to the ground truth.
  58193. */
  58194. useSphericalHarmonics: boolean;
  58195. private _useSpecularGlossinessInputEnergyConservation;
  58196. /**
  58197. * Defines if the material uses energy conservation, when the specular workflow is active.
  58198. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58199. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58200. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58201. */
  58202. useSpecularGlossinessInputEnergyConservation: boolean;
  58203. /** @hidden */
  58204. private _internalMarkAllSubMeshesAsMiscDirty;
  58205. /** @hidden */
  58206. _markAllSubMeshesAsMiscDirty(): void;
  58207. /**
  58208. * Instantiate a new istance of clear coat configuration.
  58209. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58210. */
  58211. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58212. /**
  58213. * Checks to see if a texture is used in the material.
  58214. * @param defines the list of "defines" to update.
  58215. */
  58216. prepareDefines(defines: IMaterialBRDFDefines): void;
  58217. /**
  58218. * Get the current class name of the texture useful for serialization or dynamic coding.
  58219. * @returns "PBRClearCoatConfiguration"
  58220. */
  58221. getClassName(): string;
  58222. /**
  58223. * Makes a duplicate of the current configuration into another one.
  58224. * @param brdfConfiguration define the config where to copy the info
  58225. */
  58226. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58227. /**
  58228. * Serializes this BRDF configuration.
  58229. * @returns - An object with the serialized config.
  58230. */
  58231. serialize(): any;
  58232. /**
  58233. * Parses a anisotropy Configuration from a serialized object.
  58234. * @param source - Serialized object.
  58235. * @param scene Defines the scene we are parsing for
  58236. * @param rootUrl Defines the rootUrl to load from
  58237. */
  58238. parse(source: any, scene: Scene, rootUrl: string): void;
  58239. }
  58240. }
  58241. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58242. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58243. import { Color3 } from "babylonjs/Maths/math.color";
  58244. import { Scene } from "babylonjs/scene";
  58245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58246. import { Nullable } from "babylonjs/types";
  58247. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58248. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58249. /**
  58250. * @hidden
  58251. */
  58252. export interface IMaterialSheenDefines {
  58253. SHEEN: boolean;
  58254. SHEEN_TEXTURE: boolean;
  58255. SHEEN_TEXTUREDIRECTUV: number;
  58256. SHEEN_LINKWITHALBEDO: boolean;
  58257. SHEEN_ROUGHNESS: boolean;
  58258. SHEEN_ALBEDOSCALING: boolean;
  58259. /** @hidden */
  58260. _areTexturesDirty: boolean;
  58261. }
  58262. /**
  58263. * Define the code related to the Sheen parameters of the pbr material.
  58264. */
  58265. export class PBRSheenConfiguration {
  58266. private _isEnabled;
  58267. /**
  58268. * Defines if the material uses sheen.
  58269. */
  58270. isEnabled: boolean;
  58271. private _linkSheenWithAlbedo;
  58272. /**
  58273. * Defines if the sheen is linked to the sheen color.
  58274. */
  58275. linkSheenWithAlbedo: boolean;
  58276. /**
  58277. * Defines the sheen intensity.
  58278. */
  58279. intensity: number;
  58280. /**
  58281. * Defines the sheen color.
  58282. */
  58283. color: Color3;
  58284. private _texture;
  58285. /**
  58286. * Stores the sheen tint values in a texture.
  58287. * rgb is tint
  58288. * a is a intensity or roughness if roughness has been defined
  58289. */
  58290. texture: Nullable<BaseTexture>;
  58291. private _roughness;
  58292. /**
  58293. * Defines the sheen roughness.
  58294. * It is not taken into account if linkSheenWithAlbedo is true.
  58295. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58296. */
  58297. roughness: Nullable<number>;
  58298. private _albedoScaling;
  58299. /**
  58300. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58301. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58302. * making it easier to setup and tweak the effect
  58303. */
  58304. albedoScaling: boolean;
  58305. /** @hidden */
  58306. private _internalMarkAllSubMeshesAsTexturesDirty;
  58307. /** @hidden */
  58308. _markAllSubMeshesAsTexturesDirty(): void;
  58309. /**
  58310. * Instantiate a new istance of clear coat configuration.
  58311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58312. */
  58313. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58314. /**
  58315. * Specifies that the submesh is ready to be used.
  58316. * @param defines the list of "defines" to update.
  58317. * @param scene defines the scene the material belongs to.
  58318. * @returns - boolean indicating that the submesh is ready or not.
  58319. */
  58320. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58321. /**
  58322. * Checks to see if a texture is used in the material.
  58323. * @param defines the list of "defines" to update.
  58324. * @param scene defines the scene the material belongs to.
  58325. */
  58326. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58327. /**
  58328. * Binds the material data.
  58329. * @param uniformBuffer defines the Uniform buffer to fill in.
  58330. * @param scene defines the scene the material belongs to.
  58331. * @param isFrozen defines wether the material is frozen or not.
  58332. */
  58333. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58334. /**
  58335. * Checks to see if a texture is used in the material.
  58336. * @param texture - Base texture to use.
  58337. * @returns - Boolean specifying if a texture is used in the material.
  58338. */
  58339. hasTexture(texture: BaseTexture): boolean;
  58340. /**
  58341. * Returns an array of the actively used textures.
  58342. * @param activeTextures Array of BaseTextures
  58343. */
  58344. getActiveTextures(activeTextures: BaseTexture[]): void;
  58345. /**
  58346. * Returns the animatable textures.
  58347. * @param animatables Array of animatable textures.
  58348. */
  58349. getAnimatables(animatables: IAnimatable[]): void;
  58350. /**
  58351. * Disposes the resources of the material.
  58352. * @param forceDisposeTextures - Forces the disposal of all textures.
  58353. */
  58354. dispose(forceDisposeTextures?: boolean): void;
  58355. /**
  58356. * Get the current class name of the texture useful for serialization or dynamic coding.
  58357. * @returns "PBRSheenConfiguration"
  58358. */
  58359. getClassName(): string;
  58360. /**
  58361. * Add fallbacks to the effect fallbacks list.
  58362. * @param defines defines the Base texture to use.
  58363. * @param fallbacks defines the current fallback list.
  58364. * @param currentRank defines the current fallback rank.
  58365. * @returns the new fallback rank.
  58366. */
  58367. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58368. /**
  58369. * Add the required uniforms to the current list.
  58370. * @param uniforms defines the current uniform list.
  58371. */
  58372. static AddUniforms(uniforms: string[]): void;
  58373. /**
  58374. * Add the required uniforms to the current buffer.
  58375. * @param uniformBuffer defines the current uniform buffer.
  58376. */
  58377. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58378. /**
  58379. * Add the required samplers to the current list.
  58380. * @param samplers defines the current sampler list.
  58381. */
  58382. static AddSamplers(samplers: string[]): void;
  58383. /**
  58384. * Makes a duplicate of the current configuration into another one.
  58385. * @param sheenConfiguration define the config where to copy the info
  58386. */
  58387. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58388. /**
  58389. * Serializes this BRDF configuration.
  58390. * @returns - An object with the serialized config.
  58391. */
  58392. serialize(): any;
  58393. /**
  58394. * Parses a anisotropy Configuration from a serialized object.
  58395. * @param source - Serialized object.
  58396. * @param scene Defines the scene we are parsing for
  58397. * @param rootUrl Defines the rootUrl to load from
  58398. */
  58399. parse(source: any, scene: Scene, rootUrl: string): void;
  58400. }
  58401. }
  58402. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58403. import { Nullable } from "babylonjs/types";
  58404. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58405. import { Color3 } from "babylonjs/Maths/math.color";
  58406. import { SmartArray } from "babylonjs/Misc/smartArray";
  58407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58409. import { Effect } from "babylonjs/Materials/effect";
  58410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58411. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58412. import { Engine } from "babylonjs/Engines/engine";
  58413. import { Scene } from "babylonjs/scene";
  58414. /**
  58415. * @hidden
  58416. */
  58417. export interface IMaterialSubSurfaceDefines {
  58418. SUBSURFACE: boolean;
  58419. SS_REFRACTION: boolean;
  58420. SS_TRANSLUCENCY: boolean;
  58421. SS_SCATTERING: boolean;
  58422. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58423. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58424. SS_REFRACTIONMAP_3D: boolean;
  58425. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58426. SS_LODINREFRACTIONALPHA: boolean;
  58427. SS_GAMMAREFRACTION: boolean;
  58428. SS_RGBDREFRACTION: boolean;
  58429. SS_LINEARSPECULARREFRACTION: boolean;
  58430. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58431. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58432. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58433. /** @hidden */
  58434. _areTexturesDirty: boolean;
  58435. }
  58436. /**
  58437. * Define the code related to the sub surface parameters of the pbr material.
  58438. */
  58439. export class PBRSubSurfaceConfiguration {
  58440. private _isRefractionEnabled;
  58441. /**
  58442. * Defines if the refraction is enabled in the material.
  58443. */
  58444. isRefractionEnabled: boolean;
  58445. private _isTranslucencyEnabled;
  58446. /**
  58447. * Defines if the translucency is enabled in the material.
  58448. */
  58449. isTranslucencyEnabled: boolean;
  58450. private _isScatteringEnabled;
  58451. /**
  58452. * Defines if the sub surface scattering is enabled in the material.
  58453. */
  58454. isScatteringEnabled: boolean;
  58455. private _scatteringDiffusionProfileIndex;
  58456. /**
  58457. * Diffusion profile for subsurface scattering.
  58458. * Useful for better scattering in the skins or foliages.
  58459. */
  58460. get scatteringDiffusionProfile(): Nullable<Color3>;
  58461. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58462. /**
  58463. * Defines the refraction intensity of the material.
  58464. * The refraction when enabled replaces the Diffuse part of the material.
  58465. * The intensity helps transitionning between diffuse and refraction.
  58466. */
  58467. refractionIntensity: number;
  58468. /**
  58469. * Defines the translucency intensity of the material.
  58470. * When translucency has been enabled, this defines how much of the "translucency"
  58471. * is addded to the diffuse part of the material.
  58472. */
  58473. translucencyIntensity: number;
  58474. /**
  58475. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58476. */
  58477. useAlbedoToTintRefraction: boolean;
  58478. private _thicknessTexture;
  58479. /**
  58480. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58481. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58482. * 0 would mean minimumThickness
  58483. * 1 would mean maximumThickness
  58484. * The other channels might be use as a mask to vary the different effects intensity.
  58485. */
  58486. thicknessTexture: Nullable<BaseTexture>;
  58487. private _refractionTexture;
  58488. /**
  58489. * Defines the texture to use for refraction.
  58490. */
  58491. refractionTexture: Nullable<BaseTexture>;
  58492. private _indexOfRefraction;
  58493. /**
  58494. * Index of refraction of the material base layer.
  58495. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58496. *
  58497. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58498. *
  58499. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58500. */
  58501. indexOfRefraction: number;
  58502. private _volumeIndexOfRefraction;
  58503. /**
  58504. * Index of refraction of the material's volume.
  58505. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58506. *
  58507. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58508. * the volume will use the same IOR as the surface.
  58509. */
  58510. get volumeIndexOfRefraction(): number;
  58511. set volumeIndexOfRefraction(value: number);
  58512. private _invertRefractionY;
  58513. /**
  58514. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58515. */
  58516. invertRefractionY: boolean;
  58517. private _linkRefractionWithTransparency;
  58518. /**
  58519. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58520. * Materials half opaque for instance using refraction could benefit from this control.
  58521. */
  58522. linkRefractionWithTransparency: boolean;
  58523. /**
  58524. * Defines the minimum thickness stored in the thickness map.
  58525. * If no thickness map is defined, this value will be used to simulate thickness.
  58526. */
  58527. minimumThickness: number;
  58528. /**
  58529. * Defines the maximum thickness stored in the thickness map.
  58530. */
  58531. maximumThickness: number;
  58532. /**
  58533. * Defines the volume tint of the material.
  58534. * This is used for both translucency and scattering.
  58535. */
  58536. tintColor: Color3;
  58537. /**
  58538. * Defines the distance at which the tint color should be found in the media.
  58539. * This is used for refraction only.
  58540. */
  58541. tintColorAtDistance: number;
  58542. /**
  58543. * Defines how far each channel transmit through the media.
  58544. * It is defined as a color to simplify it selection.
  58545. */
  58546. diffusionDistance: Color3;
  58547. private _useMaskFromThicknessTexture;
  58548. /**
  58549. * Stores the intensity of the different subsurface effects in the thickness texture.
  58550. * * the green channel is the translucency intensity.
  58551. * * the blue channel is the scattering intensity.
  58552. * * the alpha channel is the refraction intensity.
  58553. */
  58554. useMaskFromThicknessTexture: boolean;
  58555. private _scene;
  58556. /** @hidden */
  58557. private _internalMarkAllSubMeshesAsTexturesDirty;
  58558. private _internalMarkScenePrePassDirty;
  58559. /** @hidden */
  58560. _markAllSubMeshesAsTexturesDirty(): void;
  58561. /** @hidden */
  58562. _markScenePrePassDirty(): void;
  58563. /**
  58564. * Instantiate a new istance of sub surface configuration.
  58565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58566. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58567. * @param scene The scene
  58568. */
  58569. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58570. /**
  58571. * Gets wehter the submesh is ready to be used or not.
  58572. * @param defines the list of "defines" to update.
  58573. * @param scene defines the scene the material belongs to.
  58574. * @returns - boolean indicating that the submesh is ready or not.
  58575. */
  58576. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58577. /**
  58578. * Checks to see if a texture is used in the material.
  58579. * @param defines the list of "defines" to update.
  58580. * @param scene defines the scene to the material belongs to.
  58581. */
  58582. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58583. /**
  58584. * Binds the material data.
  58585. * @param uniformBuffer defines the Uniform buffer to fill in.
  58586. * @param scene defines the scene the material belongs to.
  58587. * @param engine defines the engine the material belongs to.
  58588. * @param isFrozen defines whether the material is frozen or not.
  58589. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58590. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58591. */
  58592. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58593. /**
  58594. * Unbinds the material from the mesh.
  58595. * @param activeEffect defines the effect that should be unbound from.
  58596. * @returns true if unbound, otherwise false
  58597. */
  58598. unbind(activeEffect: Effect): boolean;
  58599. /**
  58600. * Returns the texture used for refraction or null if none is used.
  58601. * @param scene defines the scene the material belongs to.
  58602. * @returns - Refraction texture if present. If no refraction texture and refraction
  58603. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58604. */
  58605. private _getRefractionTexture;
  58606. /**
  58607. * Returns true if alpha blending should be disabled.
  58608. */
  58609. get disableAlphaBlending(): boolean;
  58610. /**
  58611. * Fills the list of render target textures.
  58612. * @param renderTargets the list of render targets to update
  58613. */
  58614. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58615. /**
  58616. * Checks to see if a texture is used in the material.
  58617. * @param texture - Base texture to use.
  58618. * @returns - Boolean specifying if a texture is used in the material.
  58619. */
  58620. hasTexture(texture: BaseTexture): boolean;
  58621. /**
  58622. * Gets a boolean indicating that current material needs to register RTT
  58623. * @returns true if this uses a render target otherwise false.
  58624. */
  58625. hasRenderTargetTextures(): boolean;
  58626. /**
  58627. * Returns an array of the actively used textures.
  58628. * @param activeTextures Array of BaseTextures
  58629. */
  58630. getActiveTextures(activeTextures: BaseTexture[]): void;
  58631. /**
  58632. * Returns the animatable textures.
  58633. * @param animatables Array of animatable textures.
  58634. */
  58635. getAnimatables(animatables: IAnimatable[]): void;
  58636. /**
  58637. * Disposes the resources of the material.
  58638. * @param forceDisposeTextures - Forces the disposal of all textures.
  58639. */
  58640. dispose(forceDisposeTextures?: boolean): void;
  58641. /**
  58642. * Get the current class name of the texture useful for serialization or dynamic coding.
  58643. * @returns "PBRSubSurfaceConfiguration"
  58644. */
  58645. getClassName(): string;
  58646. /**
  58647. * Add fallbacks to the effect fallbacks list.
  58648. * @param defines defines the Base texture to use.
  58649. * @param fallbacks defines the current fallback list.
  58650. * @param currentRank defines the current fallback rank.
  58651. * @returns the new fallback rank.
  58652. */
  58653. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58654. /**
  58655. * Add the required uniforms to the current list.
  58656. * @param uniforms defines the current uniform list.
  58657. */
  58658. static AddUniforms(uniforms: string[]): void;
  58659. /**
  58660. * Add the required samplers to the current list.
  58661. * @param samplers defines the current sampler list.
  58662. */
  58663. static AddSamplers(samplers: string[]): void;
  58664. /**
  58665. * Add the required uniforms to the current buffer.
  58666. * @param uniformBuffer defines the current uniform buffer.
  58667. */
  58668. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58669. /**
  58670. * Makes a duplicate of the current configuration into another one.
  58671. * @param configuration define the config where to copy the info
  58672. */
  58673. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58674. /**
  58675. * Serializes this Sub Surface configuration.
  58676. * @returns - An object with the serialized config.
  58677. */
  58678. serialize(): any;
  58679. /**
  58680. * Parses a anisotropy Configuration from a serialized object.
  58681. * @param source - Serialized object.
  58682. * @param scene Defines the scene we are parsing for
  58683. * @param rootUrl Defines the rootUrl to load from
  58684. */
  58685. parse(source: any, scene: Scene, rootUrl: string): void;
  58686. }
  58687. }
  58688. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58689. /** @hidden */
  58690. export var pbrFragmentDeclaration: {
  58691. name: string;
  58692. shader: string;
  58693. };
  58694. }
  58695. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58696. /** @hidden */
  58697. export var pbrUboDeclaration: {
  58698. name: string;
  58699. shader: string;
  58700. };
  58701. }
  58702. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58703. /** @hidden */
  58704. export var pbrFragmentExtraDeclaration: {
  58705. name: string;
  58706. shader: string;
  58707. };
  58708. }
  58709. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58710. /** @hidden */
  58711. export var pbrFragmentSamplersDeclaration: {
  58712. name: string;
  58713. shader: string;
  58714. };
  58715. }
  58716. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58717. /** @hidden */
  58718. export var subSurfaceScatteringFunctions: {
  58719. name: string;
  58720. shader: string;
  58721. };
  58722. }
  58723. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58724. /** @hidden */
  58725. export var importanceSampling: {
  58726. name: string;
  58727. shader: string;
  58728. };
  58729. }
  58730. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58731. /** @hidden */
  58732. export var pbrHelperFunctions: {
  58733. name: string;
  58734. shader: string;
  58735. };
  58736. }
  58737. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58738. /** @hidden */
  58739. export var harmonicsFunctions: {
  58740. name: string;
  58741. shader: string;
  58742. };
  58743. }
  58744. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58745. /** @hidden */
  58746. export var pbrDirectLightingSetupFunctions: {
  58747. name: string;
  58748. shader: string;
  58749. };
  58750. }
  58751. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58752. /** @hidden */
  58753. export var pbrDirectLightingFalloffFunctions: {
  58754. name: string;
  58755. shader: string;
  58756. };
  58757. }
  58758. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58759. /** @hidden */
  58760. export var pbrBRDFFunctions: {
  58761. name: string;
  58762. shader: string;
  58763. };
  58764. }
  58765. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58766. /** @hidden */
  58767. export var hdrFilteringFunctions: {
  58768. name: string;
  58769. shader: string;
  58770. };
  58771. }
  58772. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58773. /** @hidden */
  58774. export var pbrDirectLightingFunctions: {
  58775. name: string;
  58776. shader: string;
  58777. };
  58778. }
  58779. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58780. /** @hidden */
  58781. export var pbrIBLFunctions: {
  58782. name: string;
  58783. shader: string;
  58784. };
  58785. }
  58786. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58787. /** @hidden */
  58788. export var pbrBlockAlbedoOpacity: {
  58789. name: string;
  58790. shader: string;
  58791. };
  58792. }
  58793. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58794. /** @hidden */
  58795. export var pbrBlockReflectivity: {
  58796. name: string;
  58797. shader: string;
  58798. };
  58799. }
  58800. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58801. /** @hidden */
  58802. export var pbrBlockAmbientOcclusion: {
  58803. name: string;
  58804. shader: string;
  58805. };
  58806. }
  58807. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58808. /** @hidden */
  58809. export var pbrBlockAlphaFresnel: {
  58810. name: string;
  58811. shader: string;
  58812. };
  58813. }
  58814. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58815. /** @hidden */
  58816. export var pbrBlockAnisotropic: {
  58817. name: string;
  58818. shader: string;
  58819. };
  58820. }
  58821. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58822. /** @hidden */
  58823. export var pbrBlockReflection: {
  58824. name: string;
  58825. shader: string;
  58826. };
  58827. }
  58828. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58829. /** @hidden */
  58830. export var pbrBlockSheen: {
  58831. name: string;
  58832. shader: string;
  58833. };
  58834. }
  58835. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58836. /** @hidden */
  58837. export var pbrBlockClearcoat: {
  58838. name: string;
  58839. shader: string;
  58840. };
  58841. }
  58842. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58843. /** @hidden */
  58844. export var pbrBlockSubSurface: {
  58845. name: string;
  58846. shader: string;
  58847. };
  58848. }
  58849. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58850. /** @hidden */
  58851. export var pbrBlockNormalGeometric: {
  58852. name: string;
  58853. shader: string;
  58854. };
  58855. }
  58856. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58857. /** @hidden */
  58858. export var pbrBlockNormalFinal: {
  58859. name: string;
  58860. shader: string;
  58861. };
  58862. }
  58863. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58864. /** @hidden */
  58865. export var pbrBlockLightmapInit: {
  58866. name: string;
  58867. shader: string;
  58868. };
  58869. }
  58870. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58871. /** @hidden */
  58872. export var pbrBlockGeometryInfo: {
  58873. name: string;
  58874. shader: string;
  58875. };
  58876. }
  58877. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58878. /** @hidden */
  58879. export var pbrBlockReflectance0: {
  58880. name: string;
  58881. shader: string;
  58882. };
  58883. }
  58884. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58885. /** @hidden */
  58886. export var pbrBlockReflectance: {
  58887. name: string;
  58888. shader: string;
  58889. };
  58890. }
  58891. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58892. /** @hidden */
  58893. export var pbrBlockDirectLighting: {
  58894. name: string;
  58895. shader: string;
  58896. };
  58897. }
  58898. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58899. /** @hidden */
  58900. export var pbrBlockFinalLitComponents: {
  58901. name: string;
  58902. shader: string;
  58903. };
  58904. }
  58905. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58906. /** @hidden */
  58907. export var pbrBlockFinalUnlitComponents: {
  58908. name: string;
  58909. shader: string;
  58910. };
  58911. }
  58912. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58913. /** @hidden */
  58914. export var pbrBlockFinalColorComposition: {
  58915. name: string;
  58916. shader: string;
  58917. };
  58918. }
  58919. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58920. /** @hidden */
  58921. export var pbrBlockImageProcessing: {
  58922. name: string;
  58923. shader: string;
  58924. };
  58925. }
  58926. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58927. /** @hidden */
  58928. export var pbrDebug: {
  58929. name: string;
  58930. shader: string;
  58931. };
  58932. }
  58933. declare module "babylonjs/Shaders/pbr.fragment" {
  58934. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58935. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58936. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58937. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58938. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58939. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58941. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58942. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58943. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58944. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58946. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58947. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58948. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58949. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58950. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58951. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58952. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58954. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58955. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58956. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58957. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58958. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58959. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58960. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58964. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58965. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58966. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58968. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58969. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58970. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58971. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58972. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58973. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58974. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58975. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58976. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58977. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58978. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58979. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58980. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58981. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58982. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58983. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58984. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58985. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58986. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58987. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58988. /** @hidden */
  58989. export var pbrPixelShader: {
  58990. name: string;
  58991. shader: string;
  58992. };
  58993. }
  58994. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58995. /** @hidden */
  58996. export var pbrVertexDeclaration: {
  58997. name: string;
  58998. shader: string;
  58999. };
  59000. }
  59001. declare module "babylonjs/Shaders/pbr.vertex" {
  59002. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59003. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59004. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59005. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59006. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59007. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59008. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59010. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59011. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59012. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59013. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59014. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59015. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59017. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59018. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59019. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59020. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59021. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59022. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59023. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59024. /** @hidden */
  59025. export var pbrVertexShader: {
  59026. name: string;
  59027. shader: string;
  59028. };
  59029. }
  59030. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59031. import { Nullable } from "babylonjs/types";
  59032. import { Scene } from "babylonjs/scene";
  59033. import { Matrix } from "babylonjs/Maths/math.vector";
  59034. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59036. import { Mesh } from "babylonjs/Meshes/mesh";
  59037. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59038. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59039. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59040. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59041. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59042. import { Color3 } from "babylonjs/Maths/math.color";
  59043. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59044. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59046. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59048. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59049. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59050. import "babylonjs/Shaders/pbr.fragment";
  59051. import "babylonjs/Shaders/pbr.vertex";
  59052. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59053. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59054. /**
  59055. * Manages the defines for the PBR Material.
  59056. * @hidden
  59057. */
  59058. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59059. PBR: boolean;
  59060. NUM_SAMPLES: string;
  59061. REALTIME_FILTERING: boolean;
  59062. MAINUV1: boolean;
  59063. MAINUV2: boolean;
  59064. UV1: boolean;
  59065. UV2: boolean;
  59066. ALBEDO: boolean;
  59067. GAMMAALBEDO: boolean;
  59068. ALBEDODIRECTUV: number;
  59069. VERTEXCOLOR: boolean;
  59070. DETAIL: boolean;
  59071. DETAILDIRECTUV: number;
  59072. DETAIL_NORMALBLENDMETHOD: number;
  59073. AMBIENT: boolean;
  59074. AMBIENTDIRECTUV: number;
  59075. AMBIENTINGRAYSCALE: boolean;
  59076. OPACITY: boolean;
  59077. VERTEXALPHA: boolean;
  59078. OPACITYDIRECTUV: number;
  59079. OPACITYRGB: boolean;
  59080. ALPHATEST: boolean;
  59081. DEPTHPREPASS: boolean;
  59082. ALPHABLEND: boolean;
  59083. ALPHAFROMALBEDO: boolean;
  59084. ALPHATESTVALUE: string;
  59085. SPECULAROVERALPHA: boolean;
  59086. RADIANCEOVERALPHA: boolean;
  59087. ALPHAFRESNEL: boolean;
  59088. LINEARALPHAFRESNEL: boolean;
  59089. PREMULTIPLYALPHA: boolean;
  59090. EMISSIVE: boolean;
  59091. EMISSIVEDIRECTUV: number;
  59092. REFLECTIVITY: boolean;
  59093. REFLECTIVITYDIRECTUV: number;
  59094. SPECULARTERM: boolean;
  59095. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59096. MICROSURFACEAUTOMATIC: boolean;
  59097. LODBASEDMICROSFURACE: boolean;
  59098. MICROSURFACEMAP: boolean;
  59099. MICROSURFACEMAPDIRECTUV: number;
  59100. METALLICWORKFLOW: boolean;
  59101. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59102. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59103. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59104. AOSTOREINMETALMAPRED: boolean;
  59105. METALLIC_REFLECTANCE: boolean;
  59106. METALLIC_REFLECTANCEDIRECTUV: number;
  59107. ENVIRONMENTBRDF: boolean;
  59108. ENVIRONMENTBRDF_RGBD: boolean;
  59109. NORMAL: boolean;
  59110. TANGENT: boolean;
  59111. BUMP: boolean;
  59112. BUMPDIRECTUV: number;
  59113. OBJECTSPACE_NORMALMAP: boolean;
  59114. PARALLAX: boolean;
  59115. PARALLAXOCCLUSION: boolean;
  59116. NORMALXYSCALE: boolean;
  59117. LIGHTMAP: boolean;
  59118. LIGHTMAPDIRECTUV: number;
  59119. USELIGHTMAPASSHADOWMAP: boolean;
  59120. GAMMALIGHTMAP: boolean;
  59121. RGBDLIGHTMAP: boolean;
  59122. REFLECTION: boolean;
  59123. REFLECTIONMAP_3D: boolean;
  59124. REFLECTIONMAP_SPHERICAL: boolean;
  59125. REFLECTIONMAP_PLANAR: boolean;
  59126. REFLECTIONMAP_CUBIC: boolean;
  59127. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59128. REFLECTIONMAP_PROJECTION: boolean;
  59129. REFLECTIONMAP_SKYBOX: boolean;
  59130. REFLECTIONMAP_EXPLICIT: boolean;
  59131. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59132. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59133. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59134. INVERTCUBICMAP: boolean;
  59135. USESPHERICALFROMREFLECTIONMAP: boolean;
  59136. USEIRRADIANCEMAP: boolean;
  59137. SPHERICAL_HARMONICS: boolean;
  59138. USESPHERICALINVERTEX: boolean;
  59139. REFLECTIONMAP_OPPOSITEZ: boolean;
  59140. LODINREFLECTIONALPHA: boolean;
  59141. GAMMAREFLECTION: boolean;
  59142. RGBDREFLECTION: boolean;
  59143. LINEARSPECULARREFLECTION: boolean;
  59144. RADIANCEOCCLUSION: boolean;
  59145. HORIZONOCCLUSION: boolean;
  59146. INSTANCES: boolean;
  59147. THIN_INSTANCES: boolean;
  59148. PREPASS: boolean;
  59149. PREPASS_IRRADIANCE: boolean;
  59150. PREPASS_IRRADIANCE_INDEX: number;
  59151. PREPASS_ALBEDO: boolean;
  59152. PREPASS_ALBEDO_INDEX: number;
  59153. PREPASS_DEPTHNORMAL: boolean;
  59154. PREPASS_DEPTHNORMAL_INDEX: number;
  59155. SCENE_MRT_COUNT: number;
  59156. NUM_BONE_INFLUENCERS: number;
  59157. BonesPerMesh: number;
  59158. BONETEXTURE: boolean;
  59159. NONUNIFORMSCALING: boolean;
  59160. MORPHTARGETS: boolean;
  59161. MORPHTARGETS_NORMAL: boolean;
  59162. MORPHTARGETS_TANGENT: boolean;
  59163. MORPHTARGETS_UV: boolean;
  59164. NUM_MORPH_INFLUENCERS: number;
  59165. IMAGEPROCESSING: boolean;
  59166. VIGNETTE: boolean;
  59167. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59168. VIGNETTEBLENDMODEOPAQUE: boolean;
  59169. TONEMAPPING: boolean;
  59170. TONEMAPPING_ACES: boolean;
  59171. CONTRAST: boolean;
  59172. COLORCURVES: boolean;
  59173. COLORGRADING: boolean;
  59174. COLORGRADING3D: boolean;
  59175. SAMPLER3DGREENDEPTH: boolean;
  59176. SAMPLER3DBGRMAP: boolean;
  59177. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59178. EXPOSURE: boolean;
  59179. MULTIVIEW: boolean;
  59180. USEPHYSICALLIGHTFALLOFF: boolean;
  59181. USEGLTFLIGHTFALLOFF: boolean;
  59182. TWOSIDEDLIGHTING: boolean;
  59183. SHADOWFLOAT: boolean;
  59184. CLIPPLANE: boolean;
  59185. CLIPPLANE2: boolean;
  59186. CLIPPLANE3: boolean;
  59187. CLIPPLANE4: boolean;
  59188. CLIPPLANE5: boolean;
  59189. CLIPPLANE6: boolean;
  59190. POINTSIZE: boolean;
  59191. FOG: boolean;
  59192. LOGARITHMICDEPTH: boolean;
  59193. FORCENORMALFORWARD: boolean;
  59194. SPECULARAA: boolean;
  59195. CLEARCOAT: boolean;
  59196. CLEARCOAT_DEFAULTIOR: boolean;
  59197. CLEARCOAT_TEXTURE: boolean;
  59198. CLEARCOAT_TEXTUREDIRECTUV: number;
  59199. CLEARCOAT_BUMP: boolean;
  59200. CLEARCOAT_BUMPDIRECTUV: number;
  59201. CLEARCOAT_TINT: boolean;
  59202. CLEARCOAT_TINT_TEXTURE: boolean;
  59203. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59204. ANISOTROPIC: boolean;
  59205. ANISOTROPIC_TEXTURE: boolean;
  59206. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59207. BRDF_V_HEIGHT_CORRELATED: boolean;
  59208. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59209. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59210. SHEEN: boolean;
  59211. SHEEN_TEXTURE: boolean;
  59212. SHEEN_TEXTUREDIRECTUV: number;
  59213. SHEEN_LINKWITHALBEDO: boolean;
  59214. SHEEN_ROUGHNESS: boolean;
  59215. SHEEN_ALBEDOSCALING: boolean;
  59216. SUBSURFACE: boolean;
  59217. SS_REFRACTION: boolean;
  59218. SS_TRANSLUCENCY: boolean;
  59219. SS_SCATTERING: boolean;
  59220. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59221. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59222. SS_REFRACTIONMAP_3D: boolean;
  59223. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59224. SS_LODINREFRACTIONALPHA: boolean;
  59225. SS_GAMMAREFRACTION: boolean;
  59226. SS_RGBDREFRACTION: boolean;
  59227. SS_LINEARSPECULARREFRACTION: boolean;
  59228. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59229. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59230. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59231. UNLIT: boolean;
  59232. DEBUGMODE: number;
  59233. /**
  59234. * Initializes the PBR Material defines.
  59235. */
  59236. constructor();
  59237. /**
  59238. * Resets the PBR Material defines.
  59239. */
  59240. reset(): void;
  59241. }
  59242. /**
  59243. * The Physically based material base class of BJS.
  59244. *
  59245. * This offers the main features of a standard PBR material.
  59246. * For more information, please refer to the documentation :
  59247. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59248. */
  59249. export abstract class PBRBaseMaterial extends PushMaterial {
  59250. /**
  59251. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59252. */
  59253. static readonly PBRMATERIAL_OPAQUE: number;
  59254. /**
  59255. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59256. */
  59257. static readonly PBRMATERIAL_ALPHATEST: number;
  59258. /**
  59259. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59260. */
  59261. static readonly PBRMATERIAL_ALPHABLEND: number;
  59262. /**
  59263. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59264. * They are also discarded below the alpha cutoff threshold to improve performances.
  59265. */
  59266. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59267. /**
  59268. * Defines the default value of how much AO map is occluding the analytical lights
  59269. * (point spot...).
  59270. */
  59271. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59272. /**
  59273. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59274. */
  59275. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59276. /**
  59277. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59278. * to enhance interoperability with other engines.
  59279. */
  59280. static readonly LIGHTFALLOFF_GLTF: number;
  59281. /**
  59282. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59283. * to enhance interoperability with other materials.
  59284. */
  59285. static readonly LIGHTFALLOFF_STANDARD: number;
  59286. /**
  59287. * Intensity of the direct lights e.g. the four lights available in your scene.
  59288. * This impacts both the direct diffuse and specular highlights.
  59289. */
  59290. protected _directIntensity: number;
  59291. /**
  59292. * Intensity of the emissive part of the material.
  59293. * This helps controlling the emissive effect without modifying the emissive color.
  59294. */
  59295. protected _emissiveIntensity: number;
  59296. /**
  59297. * Intensity of the environment e.g. how much the environment will light the object
  59298. * either through harmonics for rough material or through the refelction for shiny ones.
  59299. */
  59300. protected _environmentIntensity: number;
  59301. /**
  59302. * This is a special control allowing the reduction of the specular highlights coming from the
  59303. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59304. */
  59305. protected _specularIntensity: number;
  59306. /**
  59307. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59308. */
  59309. private _lightingInfos;
  59310. /**
  59311. * Debug Control allowing disabling the bump map on this material.
  59312. */
  59313. protected _disableBumpMap: boolean;
  59314. /**
  59315. * AKA Diffuse Texture in standard nomenclature.
  59316. */
  59317. protected _albedoTexture: Nullable<BaseTexture>;
  59318. /**
  59319. * AKA Occlusion Texture in other nomenclature.
  59320. */
  59321. protected _ambientTexture: Nullable<BaseTexture>;
  59322. /**
  59323. * AKA Occlusion Texture Intensity in other nomenclature.
  59324. */
  59325. protected _ambientTextureStrength: number;
  59326. /**
  59327. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59328. * 1 means it completely occludes it
  59329. * 0 mean it has no impact
  59330. */
  59331. protected _ambientTextureImpactOnAnalyticalLights: number;
  59332. /**
  59333. * Stores the alpha values in a texture.
  59334. */
  59335. protected _opacityTexture: Nullable<BaseTexture>;
  59336. /**
  59337. * Stores the reflection values in a texture.
  59338. */
  59339. protected _reflectionTexture: Nullable<BaseTexture>;
  59340. /**
  59341. * Stores the emissive values in a texture.
  59342. */
  59343. protected _emissiveTexture: Nullable<BaseTexture>;
  59344. /**
  59345. * AKA Specular texture in other nomenclature.
  59346. */
  59347. protected _reflectivityTexture: Nullable<BaseTexture>;
  59348. /**
  59349. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59350. */
  59351. protected _metallicTexture: Nullable<BaseTexture>;
  59352. /**
  59353. * Specifies the metallic scalar of the metallic/roughness workflow.
  59354. * Can also be used to scale the metalness values of the metallic texture.
  59355. */
  59356. protected _metallic: Nullable<number>;
  59357. /**
  59358. * Specifies the roughness scalar of the metallic/roughness workflow.
  59359. * Can also be used to scale the roughness values of the metallic texture.
  59360. */
  59361. protected _roughness: Nullable<number>;
  59362. /**
  59363. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59364. * By default the indexOfrefraction is used to compute F0;
  59365. *
  59366. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59367. *
  59368. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59369. * F90 = metallicReflectanceColor;
  59370. */
  59371. protected _metallicF0Factor: number;
  59372. /**
  59373. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59374. * By default the F90 is always 1;
  59375. *
  59376. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59377. *
  59378. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59379. * F90 = metallicReflectanceColor;
  59380. */
  59381. protected _metallicReflectanceColor: Color3;
  59382. /**
  59383. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59384. * This is multiply against the scalar values defined in the material.
  59385. */
  59386. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59387. /**
  59388. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59389. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59390. */
  59391. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59392. /**
  59393. * Stores surface normal data used to displace a mesh in a texture.
  59394. */
  59395. protected _bumpTexture: Nullable<BaseTexture>;
  59396. /**
  59397. * Stores the pre-calculated light information of a mesh in a texture.
  59398. */
  59399. protected _lightmapTexture: Nullable<BaseTexture>;
  59400. /**
  59401. * The color of a material in ambient lighting.
  59402. */
  59403. protected _ambientColor: Color3;
  59404. /**
  59405. * AKA Diffuse Color in other nomenclature.
  59406. */
  59407. protected _albedoColor: Color3;
  59408. /**
  59409. * AKA Specular Color in other nomenclature.
  59410. */
  59411. protected _reflectivityColor: Color3;
  59412. /**
  59413. * The color applied when light is reflected from a material.
  59414. */
  59415. protected _reflectionColor: Color3;
  59416. /**
  59417. * The color applied when light is emitted from a material.
  59418. */
  59419. protected _emissiveColor: Color3;
  59420. /**
  59421. * AKA Glossiness in other nomenclature.
  59422. */
  59423. protected _microSurface: number;
  59424. /**
  59425. * Specifies that the material will use the light map as a show map.
  59426. */
  59427. protected _useLightmapAsShadowmap: boolean;
  59428. /**
  59429. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59430. * makes the reflect vector face the model (under horizon).
  59431. */
  59432. protected _useHorizonOcclusion: boolean;
  59433. /**
  59434. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59435. * too much the area relying on ambient texture to define their ambient occlusion.
  59436. */
  59437. protected _useRadianceOcclusion: boolean;
  59438. /**
  59439. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59440. */
  59441. protected _useAlphaFromAlbedoTexture: boolean;
  59442. /**
  59443. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59444. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59445. */
  59446. protected _useSpecularOverAlpha: boolean;
  59447. /**
  59448. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59449. */
  59450. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59451. /**
  59452. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59453. */
  59454. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59455. /**
  59456. * Specifies if the metallic texture contains the roughness information in its green channel.
  59457. */
  59458. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59459. /**
  59460. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59461. */
  59462. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59463. /**
  59464. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59465. */
  59466. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59467. /**
  59468. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59469. */
  59470. protected _useAmbientInGrayScale: boolean;
  59471. /**
  59472. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59473. * The material will try to infer what glossiness each pixel should be.
  59474. */
  59475. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59476. /**
  59477. * Defines the falloff type used in this material.
  59478. * It by default is Physical.
  59479. */
  59480. protected _lightFalloff: number;
  59481. /**
  59482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59484. */
  59485. protected _useRadianceOverAlpha: boolean;
  59486. /**
  59487. * Allows using an object space normal map (instead of tangent space).
  59488. */
  59489. protected _useObjectSpaceNormalMap: boolean;
  59490. /**
  59491. * Allows using the bump map in parallax mode.
  59492. */
  59493. protected _useParallax: boolean;
  59494. /**
  59495. * Allows using the bump map in parallax occlusion mode.
  59496. */
  59497. protected _useParallaxOcclusion: boolean;
  59498. /**
  59499. * Controls the scale bias of the parallax mode.
  59500. */
  59501. protected _parallaxScaleBias: number;
  59502. /**
  59503. * If sets to true, disables all the lights affecting the material.
  59504. */
  59505. protected _disableLighting: boolean;
  59506. /**
  59507. * Number of Simultaneous lights allowed on the material.
  59508. */
  59509. protected _maxSimultaneousLights: number;
  59510. /**
  59511. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59512. */
  59513. protected _invertNormalMapX: boolean;
  59514. /**
  59515. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59516. */
  59517. protected _invertNormalMapY: boolean;
  59518. /**
  59519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59520. */
  59521. protected _twoSidedLighting: boolean;
  59522. /**
  59523. * Defines the alpha limits in alpha test mode.
  59524. */
  59525. protected _alphaCutOff: number;
  59526. /**
  59527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59528. */
  59529. protected _forceAlphaTest: boolean;
  59530. /**
  59531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59532. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59533. */
  59534. protected _useAlphaFresnel: boolean;
  59535. /**
  59536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59537. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59538. */
  59539. protected _useLinearAlphaFresnel: boolean;
  59540. /**
  59541. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59542. * from cos thetav and roughness:
  59543. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59544. */
  59545. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59546. /**
  59547. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59548. */
  59549. protected _forceIrradianceInFragment: boolean;
  59550. private _realTimeFiltering;
  59551. /**
  59552. * Enables realtime filtering on the texture.
  59553. */
  59554. get realTimeFiltering(): boolean;
  59555. set realTimeFiltering(b: boolean);
  59556. private _realTimeFilteringQuality;
  59557. /**
  59558. * Quality switch for realtime filtering
  59559. */
  59560. get realTimeFilteringQuality(): number;
  59561. set realTimeFilteringQuality(n: number);
  59562. /**
  59563. * Can this material render to several textures at once
  59564. */
  59565. get canRenderToMRT(): boolean;
  59566. /**
  59567. * Force normal to face away from face.
  59568. */
  59569. protected _forceNormalForward: boolean;
  59570. /**
  59571. * Enables specular anti aliasing in the PBR shader.
  59572. * It will both interacts on the Geometry for analytical and IBL lighting.
  59573. * It also prefilter the roughness map based on the bump values.
  59574. */
  59575. protected _enableSpecularAntiAliasing: boolean;
  59576. /**
  59577. * Default configuration related to image processing available in the PBR Material.
  59578. */
  59579. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59580. /**
  59581. * Keep track of the image processing observer to allow dispose and replace.
  59582. */
  59583. private _imageProcessingObserver;
  59584. /**
  59585. * Attaches a new image processing configuration to the PBR Material.
  59586. * @param configuration
  59587. */
  59588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59589. /**
  59590. * Stores the available render targets.
  59591. */
  59592. private _renderTargets;
  59593. /**
  59594. * Sets the global ambient color for the material used in lighting calculations.
  59595. */
  59596. private _globalAmbientColor;
  59597. /**
  59598. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59599. */
  59600. private _useLogarithmicDepth;
  59601. /**
  59602. * If set to true, no lighting calculations will be applied.
  59603. */
  59604. private _unlit;
  59605. private _debugMode;
  59606. /**
  59607. * @hidden
  59608. * This is reserved for the inspector.
  59609. * Defines the material debug mode.
  59610. * It helps seeing only some components of the material while troubleshooting.
  59611. */
  59612. debugMode: number;
  59613. /**
  59614. * @hidden
  59615. * This is reserved for the inspector.
  59616. * Specify from where on screen the debug mode should start.
  59617. * The value goes from -1 (full screen) to 1 (not visible)
  59618. * It helps with side by side comparison against the final render
  59619. * This defaults to -1
  59620. */
  59621. private debugLimit;
  59622. /**
  59623. * @hidden
  59624. * This is reserved for the inspector.
  59625. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59626. * You can use the factor to better multiply the final value.
  59627. */
  59628. private debugFactor;
  59629. /**
  59630. * Defines the clear coat layer parameters for the material.
  59631. */
  59632. readonly clearCoat: PBRClearCoatConfiguration;
  59633. /**
  59634. * Defines the anisotropic parameters for the material.
  59635. */
  59636. readonly anisotropy: PBRAnisotropicConfiguration;
  59637. /**
  59638. * Defines the BRDF parameters for the material.
  59639. */
  59640. readonly brdf: PBRBRDFConfiguration;
  59641. /**
  59642. * Defines the Sheen parameters for the material.
  59643. */
  59644. readonly sheen: PBRSheenConfiguration;
  59645. /**
  59646. * Defines the SubSurface parameters for the material.
  59647. */
  59648. readonly subSurface: PBRSubSurfaceConfiguration;
  59649. /**
  59650. * Defines the detail map parameters for the material.
  59651. */
  59652. readonly detailMap: DetailMapConfiguration;
  59653. protected _rebuildInParallel: boolean;
  59654. /**
  59655. * Instantiates a new PBRMaterial instance.
  59656. *
  59657. * @param name The material name
  59658. * @param scene The scene the material will be use in.
  59659. */
  59660. constructor(name: string, scene: Scene);
  59661. /**
  59662. * Gets a boolean indicating that current material needs to register RTT
  59663. */
  59664. get hasRenderTargetTextures(): boolean;
  59665. /**
  59666. * Gets the name of the material class.
  59667. */
  59668. getClassName(): string;
  59669. /**
  59670. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59671. */
  59672. get useLogarithmicDepth(): boolean;
  59673. /**
  59674. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59675. */
  59676. set useLogarithmicDepth(value: boolean);
  59677. /**
  59678. * Returns true if alpha blending should be disabled.
  59679. */
  59680. protected get _disableAlphaBlending(): boolean;
  59681. /**
  59682. * Specifies whether or not this material should be rendered in alpha blend mode.
  59683. */
  59684. needAlphaBlending(): boolean;
  59685. /**
  59686. * Specifies whether or not this material should be rendered in alpha test mode.
  59687. */
  59688. needAlphaTesting(): boolean;
  59689. /**
  59690. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59691. */
  59692. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59693. /**
  59694. * Gets the texture used for the alpha test.
  59695. */
  59696. getAlphaTestTexture(): Nullable<BaseTexture>;
  59697. /**
  59698. * Specifies that the submesh is ready to be used.
  59699. * @param mesh - BJS mesh.
  59700. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59701. * @param useInstances - Specifies that instances should be used.
  59702. * @returns - boolean indicating that the submesh is ready or not.
  59703. */
  59704. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59705. /**
  59706. * Specifies if the material uses metallic roughness workflow.
  59707. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59708. */
  59709. isMetallicWorkflow(): boolean;
  59710. private _prepareEffect;
  59711. private _prepareDefines;
  59712. /**
  59713. * Force shader compilation
  59714. */
  59715. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59716. /**
  59717. * Initializes the uniform buffer layout for the shader.
  59718. */
  59719. buildUniformLayout(): void;
  59720. /**
  59721. * Unbinds the material from the mesh
  59722. */
  59723. unbind(): void;
  59724. /**
  59725. * Binds the submesh data.
  59726. * @param world - The world matrix.
  59727. * @param mesh - The BJS mesh.
  59728. * @param subMesh - A submesh of the BJS mesh.
  59729. */
  59730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59731. /**
  59732. * Returns the animatable textures.
  59733. * @returns - Array of animatable textures.
  59734. */
  59735. getAnimatables(): IAnimatable[];
  59736. /**
  59737. * Returns the texture used for reflections.
  59738. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59739. */
  59740. private _getReflectionTexture;
  59741. /**
  59742. * Returns an array of the actively used textures.
  59743. * @returns - Array of BaseTextures
  59744. */
  59745. getActiveTextures(): BaseTexture[];
  59746. /**
  59747. * Checks to see if a texture is used in the material.
  59748. * @param texture - Base texture to use.
  59749. * @returns - Boolean specifying if a texture is used in the material.
  59750. */
  59751. hasTexture(texture: BaseTexture): boolean;
  59752. /**
  59753. * Sets the required values to the prepass renderer.
  59754. * @param prePassRenderer defines the prepass renderer to setup
  59755. */
  59756. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59757. /**
  59758. * Disposes the resources of the material.
  59759. * @param forceDisposeEffect - Forces the disposal of effects.
  59760. * @param forceDisposeTextures - Forces the disposal of all textures.
  59761. */
  59762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59763. }
  59764. }
  59765. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59766. import { Nullable } from "babylonjs/types";
  59767. import { Scene } from "babylonjs/scene";
  59768. import { Color3 } from "babylonjs/Maths/math.color";
  59769. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59770. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59772. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59773. /**
  59774. * The Physically based material of BJS.
  59775. *
  59776. * This offers the main features of a standard PBR material.
  59777. * For more information, please refer to the documentation :
  59778. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59779. */
  59780. export class PBRMaterial extends PBRBaseMaterial {
  59781. /**
  59782. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59783. */
  59784. static readonly PBRMATERIAL_OPAQUE: number;
  59785. /**
  59786. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59787. */
  59788. static readonly PBRMATERIAL_ALPHATEST: number;
  59789. /**
  59790. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59791. */
  59792. static readonly PBRMATERIAL_ALPHABLEND: number;
  59793. /**
  59794. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59795. * They are also discarded below the alpha cutoff threshold to improve performances.
  59796. */
  59797. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59798. /**
  59799. * Defines the default value of how much AO map is occluding the analytical lights
  59800. * (point spot...).
  59801. */
  59802. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59803. /**
  59804. * Intensity of the direct lights e.g. the four lights available in your scene.
  59805. * This impacts both the direct diffuse and specular highlights.
  59806. */
  59807. directIntensity: number;
  59808. /**
  59809. * Intensity of the emissive part of the material.
  59810. * This helps controlling the emissive effect without modifying the emissive color.
  59811. */
  59812. emissiveIntensity: number;
  59813. /**
  59814. * Intensity of the environment e.g. how much the environment will light the object
  59815. * either through harmonics for rough material or through the refelction for shiny ones.
  59816. */
  59817. environmentIntensity: number;
  59818. /**
  59819. * This is a special control allowing the reduction of the specular highlights coming from the
  59820. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59821. */
  59822. specularIntensity: number;
  59823. /**
  59824. * Debug Control allowing disabling the bump map on this material.
  59825. */
  59826. disableBumpMap: boolean;
  59827. /**
  59828. * AKA Diffuse Texture in standard nomenclature.
  59829. */
  59830. albedoTexture: BaseTexture;
  59831. /**
  59832. * AKA Occlusion Texture in other nomenclature.
  59833. */
  59834. ambientTexture: BaseTexture;
  59835. /**
  59836. * AKA Occlusion Texture Intensity in other nomenclature.
  59837. */
  59838. ambientTextureStrength: number;
  59839. /**
  59840. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59841. * 1 means it completely occludes it
  59842. * 0 mean it has no impact
  59843. */
  59844. ambientTextureImpactOnAnalyticalLights: number;
  59845. /**
  59846. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59847. */
  59848. opacityTexture: BaseTexture;
  59849. /**
  59850. * Stores the reflection values in a texture.
  59851. */
  59852. reflectionTexture: Nullable<BaseTexture>;
  59853. /**
  59854. * Stores the emissive values in a texture.
  59855. */
  59856. emissiveTexture: BaseTexture;
  59857. /**
  59858. * AKA Specular texture in other nomenclature.
  59859. */
  59860. reflectivityTexture: BaseTexture;
  59861. /**
  59862. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59863. */
  59864. metallicTexture: BaseTexture;
  59865. /**
  59866. * Specifies the metallic scalar of the metallic/roughness workflow.
  59867. * Can also be used to scale the metalness values of the metallic texture.
  59868. */
  59869. metallic: Nullable<number>;
  59870. /**
  59871. * Specifies the roughness scalar of the metallic/roughness workflow.
  59872. * Can also be used to scale the roughness values of the metallic texture.
  59873. */
  59874. roughness: Nullable<number>;
  59875. /**
  59876. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59877. * By default the indexOfrefraction is used to compute F0;
  59878. *
  59879. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59880. *
  59881. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59882. * F90 = metallicReflectanceColor;
  59883. */
  59884. metallicF0Factor: number;
  59885. /**
  59886. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59887. * By default the F90 is always 1;
  59888. *
  59889. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59890. *
  59891. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59892. * F90 = metallicReflectanceColor;
  59893. */
  59894. metallicReflectanceColor: Color3;
  59895. /**
  59896. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59897. * This is multiply against the scalar values defined in the material.
  59898. */
  59899. metallicReflectanceTexture: Nullable<BaseTexture>;
  59900. /**
  59901. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59902. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59903. */
  59904. microSurfaceTexture: BaseTexture;
  59905. /**
  59906. * Stores surface normal data used to displace a mesh in a texture.
  59907. */
  59908. bumpTexture: BaseTexture;
  59909. /**
  59910. * Stores the pre-calculated light information of a mesh in a texture.
  59911. */
  59912. lightmapTexture: BaseTexture;
  59913. /**
  59914. * Stores the refracted light information in a texture.
  59915. */
  59916. get refractionTexture(): Nullable<BaseTexture>;
  59917. set refractionTexture(value: Nullable<BaseTexture>);
  59918. /**
  59919. * The color of a material in ambient lighting.
  59920. */
  59921. ambientColor: Color3;
  59922. /**
  59923. * AKA Diffuse Color in other nomenclature.
  59924. */
  59925. albedoColor: Color3;
  59926. /**
  59927. * AKA Specular Color in other nomenclature.
  59928. */
  59929. reflectivityColor: Color3;
  59930. /**
  59931. * The color reflected from the material.
  59932. */
  59933. reflectionColor: Color3;
  59934. /**
  59935. * The color emitted from the material.
  59936. */
  59937. emissiveColor: Color3;
  59938. /**
  59939. * AKA Glossiness in other nomenclature.
  59940. */
  59941. microSurface: number;
  59942. /**
  59943. * Index of refraction of the material base layer.
  59944. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59945. *
  59946. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59947. *
  59948. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59949. */
  59950. get indexOfRefraction(): number;
  59951. set indexOfRefraction(value: number);
  59952. /**
  59953. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59954. */
  59955. get invertRefractionY(): boolean;
  59956. set invertRefractionY(value: boolean);
  59957. /**
  59958. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59959. * Materials half opaque for instance using refraction could benefit from this control.
  59960. */
  59961. get linkRefractionWithTransparency(): boolean;
  59962. set linkRefractionWithTransparency(value: boolean);
  59963. /**
  59964. * If true, the light map contains occlusion information instead of lighting info.
  59965. */
  59966. useLightmapAsShadowmap: boolean;
  59967. /**
  59968. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59969. */
  59970. useAlphaFromAlbedoTexture: boolean;
  59971. /**
  59972. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59973. */
  59974. forceAlphaTest: boolean;
  59975. /**
  59976. * Defines the alpha limits in alpha test mode.
  59977. */
  59978. alphaCutOff: number;
  59979. /**
  59980. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59981. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59982. */
  59983. useSpecularOverAlpha: boolean;
  59984. /**
  59985. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59986. */
  59987. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59988. /**
  59989. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59990. */
  59991. useRoughnessFromMetallicTextureAlpha: boolean;
  59992. /**
  59993. * Specifies if the metallic texture contains the roughness information in its green channel.
  59994. */
  59995. useRoughnessFromMetallicTextureGreen: boolean;
  59996. /**
  59997. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59998. */
  59999. useMetallnessFromMetallicTextureBlue: boolean;
  60000. /**
  60001. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60002. */
  60003. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60004. /**
  60005. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60006. */
  60007. useAmbientInGrayScale: boolean;
  60008. /**
  60009. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60010. * The material will try to infer what glossiness each pixel should be.
  60011. */
  60012. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60013. /**
  60014. * BJS is using an harcoded light falloff based on a manually sets up range.
  60015. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60016. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60017. */
  60018. get usePhysicalLightFalloff(): boolean;
  60019. /**
  60020. * BJS is using an harcoded light falloff based on a manually sets up range.
  60021. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60022. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60023. */
  60024. set usePhysicalLightFalloff(value: boolean);
  60025. /**
  60026. * In order to support the falloff compatibility with gltf, a special mode has been added
  60027. * to reproduce the gltf light falloff.
  60028. */
  60029. get useGLTFLightFalloff(): boolean;
  60030. /**
  60031. * In order to support the falloff compatibility with gltf, a special mode has been added
  60032. * to reproduce the gltf light falloff.
  60033. */
  60034. set useGLTFLightFalloff(value: boolean);
  60035. /**
  60036. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60037. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60038. */
  60039. useRadianceOverAlpha: boolean;
  60040. /**
  60041. * Allows using an object space normal map (instead of tangent space).
  60042. */
  60043. useObjectSpaceNormalMap: boolean;
  60044. /**
  60045. * Allows using the bump map in parallax mode.
  60046. */
  60047. useParallax: boolean;
  60048. /**
  60049. * Allows using the bump map in parallax occlusion mode.
  60050. */
  60051. useParallaxOcclusion: boolean;
  60052. /**
  60053. * Controls the scale bias of the parallax mode.
  60054. */
  60055. parallaxScaleBias: number;
  60056. /**
  60057. * If sets to true, disables all the lights affecting the material.
  60058. */
  60059. disableLighting: boolean;
  60060. /**
  60061. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60062. */
  60063. forceIrradianceInFragment: boolean;
  60064. /**
  60065. * Number of Simultaneous lights allowed on the material.
  60066. */
  60067. maxSimultaneousLights: number;
  60068. /**
  60069. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60070. */
  60071. invertNormalMapX: boolean;
  60072. /**
  60073. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60074. */
  60075. invertNormalMapY: boolean;
  60076. /**
  60077. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60078. */
  60079. twoSidedLighting: boolean;
  60080. /**
  60081. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60082. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60083. */
  60084. useAlphaFresnel: boolean;
  60085. /**
  60086. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60087. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60088. */
  60089. useLinearAlphaFresnel: boolean;
  60090. /**
  60091. * Let user defines the brdf lookup texture used for IBL.
  60092. * A default 8bit version is embedded but you could point at :
  60093. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60094. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60095. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60096. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60097. */
  60098. environmentBRDFTexture: Nullable<BaseTexture>;
  60099. /**
  60100. * Force normal to face away from face.
  60101. */
  60102. forceNormalForward: boolean;
  60103. /**
  60104. * Enables specular anti aliasing in the PBR shader.
  60105. * It will both interacts on the Geometry for analytical and IBL lighting.
  60106. * It also prefilter the roughness map based on the bump values.
  60107. */
  60108. enableSpecularAntiAliasing: boolean;
  60109. /**
  60110. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60111. * makes the reflect vector face the model (under horizon).
  60112. */
  60113. useHorizonOcclusion: boolean;
  60114. /**
  60115. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60116. * too much the area relying on ambient texture to define their ambient occlusion.
  60117. */
  60118. useRadianceOcclusion: boolean;
  60119. /**
  60120. * If set to true, no lighting calculations will be applied.
  60121. */
  60122. unlit: boolean;
  60123. /**
  60124. * Gets the image processing configuration used either in this material.
  60125. */
  60126. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60127. /**
  60128. * Sets the Default image processing configuration used either in the this material.
  60129. *
  60130. * If sets to null, the scene one is in use.
  60131. */
  60132. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60133. /**
  60134. * Gets wether the color curves effect is enabled.
  60135. */
  60136. get cameraColorCurvesEnabled(): boolean;
  60137. /**
  60138. * Sets wether the color curves effect is enabled.
  60139. */
  60140. set cameraColorCurvesEnabled(value: boolean);
  60141. /**
  60142. * Gets wether the color grading effect is enabled.
  60143. */
  60144. get cameraColorGradingEnabled(): boolean;
  60145. /**
  60146. * Gets wether the color grading effect is enabled.
  60147. */
  60148. set cameraColorGradingEnabled(value: boolean);
  60149. /**
  60150. * Gets wether tonemapping is enabled or not.
  60151. */
  60152. get cameraToneMappingEnabled(): boolean;
  60153. /**
  60154. * Sets wether tonemapping is enabled or not
  60155. */
  60156. set cameraToneMappingEnabled(value: boolean);
  60157. /**
  60158. * The camera exposure used on this material.
  60159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60160. * This corresponds to a photographic exposure.
  60161. */
  60162. get cameraExposure(): number;
  60163. /**
  60164. * The camera exposure used on this material.
  60165. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60166. * This corresponds to a photographic exposure.
  60167. */
  60168. set cameraExposure(value: number);
  60169. /**
  60170. * Gets The camera contrast used on this material.
  60171. */
  60172. get cameraContrast(): number;
  60173. /**
  60174. * Sets The camera contrast used on this material.
  60175. */
  60176. set cameraContrast(value: number);
  60177. /**
  60178. * Gets the Color Grading 2D Lookup Texture.
  60179. */
  60180. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60181. /**
  60182. * Sets the Color Grading 2D Lookup Texture.
  60183. */
  60184. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60185. /**
  60186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60188. * 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;
  60189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60190. */
  60191. get cameraColorCurves(): Nullable<ColorCurves>;
  60192. /**
  60193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60195. * 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;
  60196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60197. */
  60198. set cameraColorCurves(value: Nullable<ColorCurves>);
  60199. /**
  60200. * Instantiates a new PBRMaterial instance.
  60201. *
  60202. * @param name The material name
  60203. * @param scene The scene the material will be use in.
  60204. */
  60205. constructor(name: string, scene: Scene);
  60206. /**
  60207. * Returns the name of this material class.
  60208. */
  60209. getClassName(): string;
  60210. /**
  60211. * Makes a duplicate of the current material.
  60212. * @param name - name to use for the new material.
  60213. */
  60214. clone(name: string): PBRMaterial;
  60215. /**
  60216. * Serializes this PBR Material.
  60217. * @returns - An object with the serialized material.
  60218. */
  60219. serialize(): any;
  60220. /**
  60221. * Parses a PBR Material from a serialized object.
  60222. * @param source - Serialized object.
  60223. * @param scene - BJS scene instance.
  60224. * @param rootUrl - url for the scene object
  60225. * @returns - PBRMaterial
  60226. */
  60227. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60228. }
  60229. }
  60230. declare module "babylonjs/Misc/dds" {
  60231. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60233. import { Nullable } from "babylonjs/types";
  60234. import { Scene } from "babylonjs/scene";
  60235. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60236. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60237. /**
  60238. * Direct draw surface info
  60239. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60240. */
  60241. export interface DDSInfo {
  60242. /**
  60243. * Width of the texture
  60244. */
  60245. width: number;
  60246. /**
  60247. * Width of the texture
  60248. */
  60249. height: number;
  60250. /**
  60251. * Number of Mipmaps for the texture
  60252. * @see https://en.wikipedia.org/wiki/Mipmap
  60253. */
  60254. mipmapCount: number;
  60255. /**
  60256. * If the textures format is a known fourCC format
  60257. * @see https://www.fourcc.org/
  60258. */
  60259. isFourCC: boolean;
  60260. /**
  60261. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60262. */
  60263. isRGB: boolean;
  60264. /**
  60265. * If the texture is a lumincance format
  60266. */
  60267. isLuminance: boolean;
  60268. /**
  60269. * If this is a cube texture
  60270. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60271. */
  60272. isCube: boolean;
  60273. /**
  60274. * If the texture is a compressed format eg. FOURCC_DXT1
  60275. */
  60276. isCompressed: boolean;
  60277. /**
  60278. * The dxgiFormat of the texture
  60279. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60280. */
  60281. dxgiFormat: number;
  60282. /**
  60283. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60284. */
  60285. textureType: number;
  60286. /**
  60287. * Sphericle polynomial created for the dds texture
  60288. */
  60289. sphericalPolynomial?: SphericalPolynomial;
  60290. }
  60291. /**
  60292. * Class used to provide DDS decompression tools
  60293. */
  60294. export class DDSTools {
  60295. /**
  60296. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60297. */
  60298. static StoreLODInAlphaChannel: boolean;
  60299. /**
  60300. * Gets DDS information from an array buffer
  60301. * @param data defines the array buffer view to read data from
  60302. * @returns the DDS information
  60303. */
  60304. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60305. private static _FloatView;
  60306. private static _Int32View;
  60307. private static _ToHalfFloat;
  60308. private static _FromHalfFloat;
  60309. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60310. private static _GetHalfFloatRGBAArrayBuffer;
  60311. private static _GetFloatRGBAArrayBuffer;
  60312. private static _GetFloatAsUIntRGBAArrayBuffer;
  60313. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60314. private static _GetRGBAArrayBuffer;
  60315. private static _ExtractLongWordOrder;
  60316. private static _GetRGBArrayBuffer;
  60317. private static _GetLuminanceArrayBuffer;
  60318. /**
  60319. * Uploads DDS Levels to a Babylon Texture
  60320. * @hidden
  60321. */
  60322. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60323. }
  60324. module "babylonjs/Engines/thinEngine" {
  60325. interface ThinEngine {
  60326. /**
  60327. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60328. * @param rootUrl defines the url where the file to load is located
  60329. * @param scene defines the current scene
  60330. * @param lodScale defines scale to apply to the mip map selection
  60331. * @param lodOffset defines offset to apply to the mip map selection
  60332. * @param onLoad defines an optional callback raised when the texture is loaded
  60333. * @param onError defines an optional callback raised if there is an issue to load the texture
  60334. * @param format defines the format of the data
  60335. * @param forcedExtension defines the extension to use to pick the right loader
  60336. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60337. * @returns the cube texture as an InternalTexture
  60338. */
  60339. 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;
  60340. }
  60341. }
  60342. }
  60343. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60344. import { Nullable } from "babylonjs/types";
  60345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60346. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60347. /**
  60348. * Implementation of the DDS Texture Loader.
  60349. * @hidden
  60350. */
  60351. export class _DDSTextureLoader implements IInternalTextureLoader {
  60352. /**
  60353. * Defines wether the loader supports cascade loading the different faces.
  60354. */
  60355. readonly supportCascades: boolean;
  60356. /**
  60357. * This returns if the loader support the current file information.
  60358. * @param extension defines the file extension of the file being loaded
  60359. * @returns true if the loader can load the specified file
  60360. */
  60361. canLoad(extension: string): boolean;
  60362. /**
  60363. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60364. * @param data contains the texture data
  60365. * @param texture defines the BabylonJS internal texture
  60366. * @param createPolynomials will be true if polynomials have been requested
  60367. * @param onLoad defines the callback to trigger once the texture is ready
  60368. * @param onError defines the callback to trigger in case of error
  60369. */
  60370. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60371. /**
  60372. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60373. * @param data contains the texture data
  60374. * @param texture defines the BabylonJS internal texture
  60375. * @param callback defines the method to call once ready to upload
  60376. */
  60377. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60378. }
  60379. }
  60380. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60381. import { Nullable } from "babylonjs/types";
  60382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60383. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60384. /**
  60385. * Implementation of the ENV Texture Loader.
  60386. * @hidden
  60387. */
  60388. export class _ENVTextureLoader implements IInternalTextureLoader {
  60389. /**
  60390. * Defines wether the loader supports cascade loading the different faces.
  60391. */
  60392. readonly supportCascades: boolean;
  60393. /**
  60394. * This returns if the loader support the current file information.
  60395. * @param extension defines the file extension of the file being loaded
  60396. * @returns true if the loader can load the specified file
  60397. */
  60398. canLoad(extension: string): boolean;
  60399. /**
  60400. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60401. * @param data contains the texture data
  60402. * @param texture defines the BabylonJS internal texture
  60403. * @param createPolynomials will be true if polynomials have been requested
  60404. * @param onLoad defines the callback to trigger once the texture is ready
  60405. * @param onError defines the callback to trigger in case of error
  60406. */
  60407. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60408. /**
  60409. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60410. * @param data contains the texture data
  60411. * @param texture defines the BabylonJS internal texture
  60412. * @param callback defines the method to call once ready to upload
  60413. */
  60414. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60415. }
  60416. }
  60417. declare module "babylonjs/Misc/khronosTextureContainer" {
  60418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60419. /**
  60420. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60421. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60422. */
  60423. export class KhronosTextureContainer {
  60424. /** contents of the KTX container file */
  60425. data: ArrayBufferView;
  60426. private static HEADER_LEN;
  60427. private static COMPRESSED_2D;
  60428. private static COMPRESSED_3D;
  60429. private static TEX_2D;
  60430. private static TEX_3D;
  60431. /**
  60432. * Gets the openGL type
  60433. */
  60434. glType: number;
  60435. /**
  60436. * Gets the openGL type size
  60437. */
  60438. glTypeSize: number;
  60439. /**
  60440. * Gets the openGL format
  60441. */
  60442. glFormat: number;
  60443. /**
  60444. * Gets the openGL internal format
  60445. */
  60446. glInternalFormat: number;
  60447. /**
  60448. * Gets the base internal format
  60449. */
  60450. glBaseInternalFormat: number;
  60451. /**
  60452. * Gets image width in pixel
  60453. */
  60454. pixelWidth: number;
  60455. /**
  60456. * Gets image height in pixel
  60457. */
  60458. pixelHeight: number;
  60459. /**
  60460. * Gets image depth in pixels
  60461. */
  60462. pixelDepth: number;
  60463. /**
  60464. * Gets the number of array elements
  60465. */
  60466. numberOfArrayElements: number;
  60467. /**
  60468. * Gets the number of faces
  60469. */
  60470. numberOfFaces: number;
  60471. /**
  60472. * Gets the number of mipmap levels
  60473. */
  60474. numberOfMipmapLevels: number;
  60475. /**
  60476. * Gets the bytes of key value data
  60477. */
  60478. bytesOfKeyValueData: number;
  60479. /**
  60480. * Gets the load type
  60481. */
  60482. loadType: number;
  60483. /**
  60484. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60485. */
  60486. isInvalid: boolean;
  60487. /**
  60488. * Creates a new KhronosTextureContainer
  60489. * @param data contents of the KTX container file
  60490. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60491. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60492. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60493. */
  60494. constructor(
  60495. /** contents of the KTX container file */
  60496. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60497. /**
  60498. * Uploads KTX content to a Babylon Texture.
  60499. * It is assumed that the texture has already been created & is currently bound
  60500. * @hidden
  60501. */
  60502. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60503. private _upload2DCompressedLevels;
  60504. /**
  60505. * Checks if the given data starts with a KTX file identifier.
  60506. * @param data the data to check
  60507. * @returns true if the data is a KTX file or false otherwise
  60508. */
  60509. static IsValid(data: ArrayBufferView): boolean;
  60510. }
  60511. }
  60512. declare module "babylonjs/Misc/workerPool" {
  60513. import { IDisposable } from "babylonjs/scene";
  60514. /**
  60515. * Helper class to push actions to a pool of workers.
  60516. */
  60517. export class WorkerPool implements IDisposable {
  60518. private _workerInfos;
  60519. private _pendingActions;
  60520. /**
  60521. * Constructor
  60522. * @param workers Array of workers to use for actions
  60523. */
  60524. constructor(workers: Array<Worker>);
  60525. /**
  60526. * Terminates all workers and clears any pending actions.
  60527. */
  60528. dispose(): void;
  60529. /**
  60530. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60531. * pended until a worker has completed its action.
  60532. * @param action The action to perform. Call onComplete when the action is complete.
  60533. */
  60534. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60535. private _execute;
  60536. }
  60537. }
  60538. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60540. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60541. /**
  60542. * Class for loading KTX2 files
  60543. * @hidden
  60544. */
  60545. export class KhronosTextureContainer2 {
  60546. private static _WorkerPoolPromise?;
  60547. private static _Initialized;
  60548. private static _Ktx2Decoder;
  60549. /**
  60550. * URL to use when loading the KTX2 decoder module
  60551. */
  60552. static JSModuleURL: string;
  60553. /**
  60554. * Default number of workers used to handle data decoding
  60555. */
  60556. static DefaultNumWorkers: number;
  60557. private static GetDefaultNumWorkers;
  60558. private _engine;
  60559. private static _CreateWorkerPool;
  60560. /**
  60561. * Constructor
  60562. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60563. */
  60564. constructor(engine: ThinEngine, numWorkers?: number);
  60565. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60566. /**
  60567. * Stop all async operations and release resources.
  60568. */
  60569. dispose(): void;
  60570. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60571. /**
  60572. * Checks if the given data starts with a KTX2 file identifier.
  60573. * @param data the data to check
  60574. * @returns true if the data is a KTX2 file or false otherwise
  60575. */
  60576. static IsValid(data: ArrayBufferView): boolean;
  60577. }
  60578. export function workerFunc(): void;
  60579. }
  60580. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60581. import { Nullable } from "babylonjs/types";
  60582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60583. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60584. /**
  60585. * Implementation of the KTX Texture Loader.
  60586. * @hidden
  60587. */
  60588. export class _KTXTextureLoader implements IInternalTextureLoader {
  60589. /**
  60590. * Defines wether the loader supports cascade loading the different faces.
  60591. */
  60592. readonly supportCascades: boolean;
  60593. /**
  60594. * This returns if the loader support the current file information.
  60595. * @param extension defines the file extension of the file being loaded
  60596. * @param mimeType defines the optional mime type of the file being loaded
  60597. * @returns true if the loader can load the specified file
  60598. */
  60599. canLoad(extension: string, mimeType?: string): boolean;
  60600. /**
  60601. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60602. * @param data contains the texture data
  60603. * @param texture defines the BabylonJS internal texture
  60604. * @param createPolynomials will be true if polynomials have been requested
  60605. * @param onLoad defines the callback to trigger once the texture is ready
  60606. * @param onError defines the callback to trigger in case of error
  60607. */
  60608. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60609. /**
  60610. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60611. * @param data contains the texture data
  60612. * @param texture defines the BabylonJS internal texture
  60613. * @param callback defines the method to call once ready to upload
  60614. */
  60615. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60616. }
  60617. }
  60618. declare module "babylonjs/Helpers/sceneHelpers" {
  60619. import { Nullable } from "babylonjs/types";
  60620. import { Mesh } from "babylonjs/Meshes/mesh";
  60621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60622. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60623. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60624. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60625. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60626. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60627. import "babylonjs/Meshes/Builders/boxBuilder";
  60628. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60629. /** @hidden */
  60630. export var _forceSceneHelpersToBundle: boolean;
  60631. module "babylonjs/scene" {
  60632. interface Scene {
  60633. /**
  60634. * Creates a default light for the scene.
  60635. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60636. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60637. */
  60638. createDefaultLight(replace?: boolean): void;
  60639. /**
  60640. * Creates a default camera for the scene.
  60641. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60642. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60643. * @param replace has default false, when true replaces the active camera in the scene
  60644. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60645. */
  60646. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60647. /**
  60648. * Creates a default camera and a default light.
  60649. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60650. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60651. * @param replace has the default false, when true replaces the active camera/light in the scene
  60652. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60653. */
  60654. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60655. /**
  60656. * Creates a new sky box
  60657. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60658. * @param environmentTexture defines the texture to use as environment texture
  60659. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60660. * @param scale defines the overall scale of the skybox
  60661. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60662. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60663. * @returns a new mesh holding the sky box
  60664. */
  60665. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60666. /**
  60667. * Creates a new environment
  60668. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60669. * @param options defines the options you can use to configure the environment
  60670. * @returns the new EnvironmentHelper
  60671. */
  60672. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60673. /**
  60674. * Creates a new VREXperienceHelper
  60675. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60676. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60677. * @returns a new VREXperienceHelper
  60678. */
  60679. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60680. /**
  60681. * Creates a new WebXRDefaultExperience
  60682. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60683. * @param options experience options
  60684. * @returns a promise for a new WebXRDefaultExperience
  60685. */
  60686. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60687. }
  60688. }
  60689. }
  60690. declare module "babylonjs/Helpers/videoDome" {
  60691. import { Scene } from "babylonjs/scene";
  60692. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60693. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60694. /**
  60695. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60696. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60697. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60698. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60699. */
  60700. export class VideoDome extends TextureDome<VideoTexture> {
  60701. /**
  60702. * Define the video source as a Monoscopic panoramic 360 video.
  60703. */
  60704. static readonly MODE_MONOSCOPIC: number;
  60705. /**
  60706. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60707. */
  60708. static readonly MODE_TOPBOTTOM: number;
  60709. /**
  60710. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60711. */
  60712. static readonly MODE_SIDEBYSIDE: number;
  60713. /**
  60714. * Get the video texture associated with this video dome
  60715. */
  60716. get videoTexture(): VideoTexture;
  60717. /**
  60718. * Get the video mode of this dome
  60719. */
  60720. get videoMode(): number;
  60721. /**
  60722. * Set the video mode of this dome.
  60723. * @see textureMode
  60724. */
  60725. set videoMode(value: number);
  60726. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60727. }
  60728. }
  60729. declare module "babylonjs/Helpers/index" {
  60730. export * from "babylonjs/Helpers/environmentHelper";
  60731. export * from "babylonjs/Helpers/photoDome";
  60732. export * from "babylonjs/Helpers/sceneHelpers";
  60733. export * from "babylonjs/Helpers/videoDome";
  60734. }
  60735. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60736. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60737. import { IDisposable } from "babylonjs/scene";
  60738. import { Engine } from "babylonjs/Engines/engine";
  60739. /**
  60740. * This class can be used to get instrumentation data from a Babylon engine
  60741. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60742. */
  60743. export class EngineInstrumentation implements IDisposable {
  60744. /**
  60745. * Define the instrumented engine.
  60746. */
  60747. engine: Engine;
  60748. private _captureGPUFrameTime;
  60749. private _gpuFrameTimeToken;
  60750. private _gpuFrameTime;
  60751. private _captureShaderCompilationTime;
  60752. private _shaderCompilationTime;
  60753. private _onBeginFrameObserver;
  60754. private _onEndFrameObserver;
  60755. private _onBeforeShaderCompilationObserver;
  60756. private _onAfterShaderCompilationObserver;
  60757. /**
  60758. * Gets the perf counter used for GPU frame time
  60759. */
  60760. get gpuFrameTimeCounter(): PerfCounter;
  60761. /**
  60762. * Gets the GPU frame time capture status
  60763. */
  60764. get captureGPUFrameTime(): boolean;
  60765. /**
  60766. * Enable or disable the GPU frame time capture
  60767. */
  60768. set captureGPUFrameTime(value: boolean);
  60769. /**
  60770. * Gets the perf counter used for shader compilation time
  60771. */
  60772. get shaderCompilationTimeCounter(): PerfCounter;
  60773. /**
  60774. * Gets the shader compilation time capture status
  60775. */
  60776. get captureShaderCompilationTime(): boolean;
  60777. /**
  60778. * Enable or disable the shader compilation time capture
  60779. */
  60780. set captureShaderCompilationTime(value: boolean);
  60781. /**
  60782. * Instantiates a new engine instrumentation.
  60783. * This class can be used to get instrumentation data from a Babylon engine
  60784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60785. * @param engine Defines the engine to instrument
  60786. */
  60787. constructor(
  60788. /**
  60789. * Define the instrumented engine.
  60790. */
  60791. engine: Engine);
  60792. /**
  60793. * Dispose and release associated resources.
  60794. */
  60795. dispose(): void;
  60796. }
  60797. }
  60798. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60799. import { Scene, IDisposable } from "babylonjs/scene";
  60800. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60801. /**
  60802. * This class can be used to get instrumentation data from a Babylon engine
  60803. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60804. */
  60805. export class SceneInstrumentation implements IDisposable {
  60806. /**
  60807. * Defines the scene to instrument
  60808. */
  60809. scene: Scene;
  60810. private _captureActiveMeshesEvaluationTime;
  60811. private _activeMeshesEvaluationTime;
  60812. private _captureRenderTargetsRenderTime;
  60813. private _renderTargetsRenderTime;
  60814. private _captureFrameTime;
  60815. private _frameTime;
  60816. private _captureRenderTime;
  60817. private _renderTime;
  60818. private _captureInterFrameTime;
  60819. private _interFrameTime;
  60820. private _captureParticlesRenderTime;
  60821. private _particlesRenderTime;
  60822. private _captureSpritesRenderTime;
  60823. private _spritesRenderTime;
  60824. private _capturePhysicsTime;
  60825. private _physicsTime;
  60826. private _captureAnimationsTime;
  60827. private _animationsTime;
  60828. private _captureCameraRenderTime;
  60829. private _cameraRenderTime;
  60830. private _onBeforeActiveMeshesEvaluationObserver;
  60831. private _onAfterActiveMeshesEvaluationObserver;
  60832. private _onBeforeRenderTargetsRenderObserver;
  60833. private _onAfterRenderTargetsRenderObserver;
  60834. private _onAfterRenderObserver;
  60835. private _onBeforeDrawPhaseObserver;
  60836. private _onAfterDrawPhaseObserver;
  60837. private _onBeforeAnimationsObserver;
  60838. private _onBeforeParticlesRenderingObserver;
  60839. private _onAfterParticlesRenderingObserver;
  60840. private _onBeforeSpritesRenderingObserver;
  60841. private _onAfterSpritesRenderingObserver;
  60842. private _onBeforePhysicsObserver;
  60843. private _onAfterPhysicsObserver;
  60844. private _onAfterAnimationsObserver;
  60845. private _onBeforeCameraRenderObserver;
  60846. private _onAfterCameraRenderObserver;
  60847. /**
  60848. * Gets the perf counter used for active meshes evaluation time
  60849. */
  60850. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60851. /**
  60852. * Gets the active meshes evaluation time capture status
  60853. */
  60854. get captureActiveMeshesEvaluationTime(): boolean;
  60855. /**
  60856. * Enable or disable the active meshes evaluation time capture
  60857. */
  60858. set captureActiveMeshesEvaluationTime(value: boolean);
  60859. /**
  60860. * Gets the perf counter used for render targets render time
  60861. */
  60862. get renderTargetsRenderTimeCounter(): PerfCounter;
  60863. /**
  60864. * Gets the render targets render time capture status
  60865. */
  60866. get captureRenderTargetsRenderTime(): boolean;
  60867. /**
  60868. * Enable or disable the render targets render time capture
  60869. */
  60870. set captureRenderTargetsRenderTime(value: boolean);
  60871. /**
  60872. * Gets the perf counter used for particles render time
  60873. */
  60874. get particlesRenderTimeCounter(): PerfCounter;
  60875. /**
  60876. * Gets the particles render time capture status
  60877. */
  60878. get captureParticlesRenderTime(): boolean;
  60879. /**
  60880. * Enable or disable the particles render time capture
  60881. */
  60882. set captureParticlesRenderTime(value: boolean);
  60883. /**
  60884. * Gets the perf counter used for sprites render time
  60885. */
  60886. get spritesRenderTimeCounter(): PerfCounter;
  60887. /**
  60888. * Gets the sprites render time capture status
  60889. */
  60890. get captureSpritesRenderTime(): boolean;
  60891. /**
  60892. * Enable or disable the sprites render time capture
  60893. */
  60894. set captureSpritesRenderTime(value: boolean);
  60895. /**
  60896. * Gets the perf counter used for physics time
  60897. */
  60898. get physicsTimeCounter(): PerfCounter;
  60899. /**
  60900. * Gets the physics time capture status
  60901. */
  60902. get capturePhysicsTime(): boolean;
  60903. /**
  60904. * Enable or disable the physics time capture
  60905. */
  60906. set capturePhysicsTime(value: boolean);
  60907. /**
  60908. * Gets the perf counter used for animations time
  60909. */
  60910. get animationsTimeCounter(): PerfCounter;
  60911. /**
  60912. * Gets the animations time capture status
  60913. */
  60914. get captureAnimationsTime(): boolean;
  60915. /**
  60916. * Enable or disable the animations time capture
  60917. */
  60918. set captureAnimationsTime(value: boolean);
  60919. /**
  60920. * Gets the perf counter used for frame time capture
  60921. */
  60922. get frameTimeCounter(): PerfCounter;
  60923. /**
  60924. * Gets the frame time capture status
  60925. */
  60926. get captureFrameTime(): boolean;
  60927. /**
  60928. * Enable or disable the frame time capture
  60929. */
  60930. set captureFrameTime(value: boolean);
  60931. /**
  60932. * Gets the perf counter used for inter-frames time capture
  60933. */
  60934. get interFrameTimeCounter(): PerfCounter;
  60935. /**
  60936. * Gets the inter-frames time capture status
  60937. */
  60938. get captureInterFrameTime(): boolean;
  60939. /**
  60940. * Enable or disable the inter-frames time capture
  60941. */
  60942. set captureInterFrameTime(value: boolean);
  60943. /**
  60944. * Gets the perf counter used for render time capture
  60945. */
  60946. get renderTimeCounter(): PerfCounter;
  60947. /**
  60948. * Gets the render time capture status
  60949. */
  60950. get captureRenderTime(): boolean;
  60951. /**
  60952. * Enable or disable the render time capture
  60953. */
  60954. set captureRenderTime(value: boolean);
  60955. /**
  60956. * Gets the perf counter used for camera render time capture
  60957. */
  60958. get cameraRenderTimeCounter(): PerfCounter;
  60959. /**
  60960. * Gets the camera render time capture status
  60961. */
  60962. get captureCameraRenderTime(): boolean;
  60963. /**
  60964. * Enable or disable the camera render time capture
  60965. */
  60966. set captureCameraRenderTime(value: boolean);
  60967. /**
  60968. * Gets the perf counter used for draw calls
  60969. */
  60970. get drawCallsCounter(): PerfCounter;
  60971. /**
  60972. * Instantiates a new scene instrumentation.
  60973. * This class can be used to get instrumentation data from a Babylon engine
  60974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60975. * @param scene Defines the scene to instrument
  60976. */
  60977. constructor(
  60978. /**
  60979. * Defines the scene to instrument
  60980. */
  60981. scene: Scene);
  60982. /**
  60983. * Dispose and release associated resources.
  60984. */
  60985. dispose(): void;
  60986. }
  60987. }
  60988. declare module "babylonjs/Instrumentation/index" {
  60989. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60990. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60991. export * from "babylonjs/Instrumentation/timeToken";
  60992. }
  60993. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60994. /** @hidden */
  60995. export var glowMapGenerationPixelShader: {
  60996. name: string;
  60997. shader: string;
  60998. };
  60999. }
  61000. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61001. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61006. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61007. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61008. /** @hidden */
  61009. export var glowMapGenerationVertexShader: {
  61010. name: string;
  61011. shader: string;
  61012. };
  61013. }
  61014. declare module "babylonjs/Layers/effectLayer" {
  61015. import { Observable } from "babylonjs/Misc/observable";
  61016. import { Nullable } from "babylonjs/types";
  61017. import { Camera } from "babylonjs/Cameras/camera";
  61018. import { Scene } from "babylonjs/scene";
  61019. import { ISize } from "babylonjs/Maths/math.size";
  61020. import { Color4 } from "babylonjs/Maths/math.color";
  61021. import { Engine } from "babylonjs/Engines/engine";
  61022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61024. import { Mesh } from "babylonjs/Meshes/mesh";
  61025. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61028. import { Effect } from "babylonjs/Materials/effect";
  61029. import { Material } from "babylonjs/Materials/material";
  61030. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61031. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61032. /**
  61033. * Effect layer options. This helps customizing the behaviour
  61034. * of the effect layer.
  61035. */
  61036. export interface IEffectLayerOptions {
  61037. /**
  61038. * Multiplication factor apply to the canvas size to compute the render target size
  61039. * used to generated the objects (the smaller the faster).
  61040. */
  61041. mainTextureRatio: number;
  61042. /**
  61043. * Enforces a fixed size texture to ensure effect stability across devices.
  61044. */
  61045. mainTextureFixedSize?: number;
  61046. /**
  61047. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61048. */
  61049. alphaBlendingMode: number;
  61050. /**
  61051. * The camera attached to the layer.
  61052. */
  61053. camera: Nullable<Camera>;
  61054. /**
  61055. * The rendering group to draw the layer in.
  61056. */
  61057. renderingGroupId: number;
  61058. }
  61059. /**
  61060. * The effect layer Helps adding post process effect blended with the main pass.
  61061. *
  61062. * This can be for instance use to generate glow or higlight effects on the scene.
  61063. *
  61064. * The effect layer class can not be used directly and is intented to inherited from to be
  61065. * customized per effects.
  61066. */
  61067. export abstract class EffectLayer {
  61068. private _vertexBuffers;
  61069. private _indexBuffer;
  61070. private _cachedDefines;
  61071. private _effectLayerMapGenerationEffect;
  61072. private _effectLayerOptions;
  61073. private _mergeEffect;
  61074. protected _scene: Scene;
  61075. protected _engine: Engine;
  61076. protected _maxSize: number;
  61077. protected _mainTextureDesiredSize: ISize;
  61078. protected _mainTexture: RenderTargetTexture;
  61079. protected _shouldRender: boolean;
  61080. protected _postProcesses: PostProcess[];
  61081. protected _textures: BaseTexture[];
  61082. protected _emissiveTextureAndColor: {
  61083. texture: Nullable<BaseTexture>;
  61084. color: Color4;
  61085. };
  61086. /**
  61087. * The name of the layer
  61088. */
  61089. name: string;
  61090. /**
  61091. * The clear color of the texture used to generate the glow map.
  61092. */
  61093. neutralColor: Color4;
  61094. /**
  61095. * Specifies whether the highlight layer is enabled or not.
  61096. */
  61097. isEnabled: boolean;
  61098. /**
  61099. * Gets the camera attached to the layer.
  61100. */
  61101. get camera(): Nullable<Camera>;
  61102. /**
  61103. * Gets the rendering group id the layer should render in.
  61104. */
  61105. get renderingGroupId(): number;
  61106. set renderingGroupId(renderingGroupId: number);
  61107. /**
  61108. * An event triggered when the effect layer has been disposed.
  61109. */
  61110. onDisposeObservable: Observable<EffectLayer>;
  61111. /**
  61112. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61113. */
  61114. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61115. /**
  61116. * An event triggered when the generated texture is being merged in the scene.
  61117. */
  61118. onBeforeComposeObservable: Observable<EffectLayer>;
  61119. /**
  61120. * An event triggered when the mesh is rendered into the effect render target.
  61121. */
  61122. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61123. /**
  61124. * An event triggered after the mesh has been rendered into the effect render target.
  61125. */
  61126. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61127. /**
  61128. * An event triggered when the generated texture has been merged in the scene.
  61129. */
  61130. onAfterComposeObservable: Observable<EffectLayer>;
  61131. /**
  61132. * An event triggered when the efffect layer changes its size.
  61133. */
  61134. onSizeChangedObservable: Observable<EffectLayer>;
  61135. /** @hidden */
  61136. static _SceneComponentInitialization: (scene: Scene) => void;
  61137. /**
  61138. * Instantiates a new effect Layer and references it in the scene.
  61139. * @param name The name of the layer
  61140. * @param scene The scene to use the layer in
  61141. */
  61142. constructor(
  61143. /** The Friendly of the effect in the scene */
  61144. name: string, scene: Scene);
  61145. /**
  61146. * Get the effect name of the layer.
  61147. * @return The effect name
  61148. */
  61149. abstract getEffectName(): string;
  61150. /**
  61151. * Checks for the readiness of the element composing the layer.
  61152. * @param subMesh the mesh to check for
  61153. * @param useInstances specify whether or not to use instances to render the mesh
  61154. * @return true if ready otherwise, false
  61155. */
  61156. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61157. /**
  61158. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61159. * @returns true if the effect requires stencil during the main canvas render pass.
  61160. */
  61161. abstract needStencil(): boolean;
  61162. /**
  61163. * Create the merge effect. This is the shader use to blit the information back
  61164. * to the main canvas at the end of the scene rendering.
  61165. * @returns The effect containing the shader used to merge the effect on the main canvas
  61166. */
  61167. protected abstract _createMergeEffect(): Effect;
  61168. /**
  61169. * Creates the render target textures and post processes used in the effect layer.
  61170. */
  61171. protected abstract _createTextureAndPostProcesses(): void;
  61172. /**
  61173. * Implementation specific of rendering the generating effect on the main canvas.
  61174. * @param effect The effect used to render through
  61175. */
  61176. protected abstract _internalRender(effect: Effect): void;
  61177. /**
  61178. * Sets the required values for both the emissive texture and and the main color.
  61179. */
  61180. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61181. /**
  61182. * Free any resources and references associated to a mesh.
  61183. * Internal use
  61184. * @param mesh The mesh to free.
  61185. */
  61186. abstract _disposeMesh(mesh: Mesh): void;
  61187. /**
  61188. * Serializes this layer (Glow or Highlight for example)
  61189. * @returns a serialized layer object
  61190. */
  61191. abstract serialize?(): any;
  61192. /**
  61193. * Initializes the effect layer with the required options.
  61194. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61195. */
  61196. protected _init(options: Partial<IEffectLayerOptions>): void;
  61197. /**
  61198. * Generates the index buffer of the full screen quad blending to the main canvas.
  61199. */
  61200. private _generateIndexBuffer;
  61201. /**
  61202. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61203. */
  61204. private _generateVertexBuffer;
  61205. /**
  61206. * Sets the main texture desired size which is the closest power of two
  61207. * of the engine canvas size.
  61208. */
  61209. private _setMainTextureSize;
  61210. /**
  61211. * Creates the main texture for the effect layer.
  61212. */
  61213. protected _createMainTexture(): void;
  61214. /**
  61215. * Adds specific effects defines.
  61216. * @param defines The defines to add specifics to.
  61217. */
  61218. protected _addCustomEffectDefines(defines: string[]): void;
  61219. /**
  61220. * Checks for the readiness of the element composing the layer.
  61221. * @param subMesh the mesh to check for
  61222. * @param useInstances specify whether or not to use instances to render the mesh
  61223. * @param emissiveTexture the associated emissive texture used to generate the glow
  61224. * @return true if ready otherwise, false
  61225. */
  61226. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61227. /**
  61228. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61229. */
  61230. render(): void;
  61231. /**
  61232. * Determine if a given mesh will be used in the current effect.
  61233. * @param mesh mesh to test
  61234. * @returns true if the mesh will be used
  61235. */
  61236. hasMesh(mesh: AbstractMesh): boolean;
  61237. /**
  61238. * Returns true if the layer contains information to display, otherwise false.
  61239. * @returns true if the glow layer should be rendered
  61240. */
  61241. shouldRender(): boolean;
  61242. /**
  61243. * Returns true if the mesh should render, otherwise false.
  61244. * @param mesh The mesh to render
  61245. * @returns true if it should render otherwise false
  61246. */
  61247. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61248. /**
  61249. * Returns true if the mesh can be rendered, otherwise false.
  61250. * @param mesh The mesh to render
  61251. * @param material The material used on the mesh
  61252. * @returns true if it can be rendered otherwise false
  61253. */
  61254. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61255. /**
  61256. * Returns true if the mesh should render, otherwise false.
  61257. * @param mesh The mesh to render
  61258. * @returns true if it should render otherwise false
  61259. */
  61260. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61261. /**
  61262. * Renders the submesh passed in parameter to the generation map.
  61263. */
  61264. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61265. /**
  61266. * Defines whether the current material of the mesh should be use to render the effect.
  61267. * @param mesh defines the current mesh to render
  61268. */
  61269. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61270. /**
  61271. * Rebuild the required buffers.
  61272. * @hidden Internal use only.
  61273. */
  61274. _rebuild(): void;
  61275. /**
  61276. * Dispose only the render target textures and post process.
  61277. */
  61278. private _disposeTextureAndPostProcesses;
  61279. /**
  61280. * Dispose the highlight layer and free resources.
  61281. */
  61282. dispose(): void;
  61283. /**
  61284. * Gets the class name of the effect layer
  61285. * @returns the string with the class name of the effect layer
  61286. */
  61287. getClassName(): string;
  61288. /**
  61289. * Creates an effect layer from parsed effect layer data
  61290. * @param parsedEffectLayer defines effect layer data
  61291. * @param scene defines the current scene
  61292. * @param rootUrl defines the root URL containing the effect layer information
  61293. * @returns a parsed effect Layer
  61294. */
  61295. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61296. }
  61297. }
  61298. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61299. import { Scene } from "babylonjs/scene";
  61300. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61301. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61302. import { AbstractScene } from "babylonjs/abstractScene";
  61303. module "babylonjs/abstractScene" {
  61304. interface AbstractScene {
  61305. /**
  61306. * The list of effect layers (highlights/glow) added to the scene
  61307. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61308. * @see https://doc.babylonjs.com/how_to/glow_layer
  61309. */
  61310. effectLayers: Array<EffectLayer>;
  61311. /**
  61312. * Removes the given effect layer from this scene.
  61313. * @param toRemove defines the effect layer to remove
  61314. * @returns the index of the removed effect layer
  61315. */
  61316. removeEffectLayer(toRemove: EffectLayer): number;
  61317. /**
  61318. * Adds the given effect layer to this scene
  61319. * @param newEffectLayer defines the effect layer to add
  61320. */
  61321. addEffectLayer(newEffectLayer: EffectLayer): void;
  61322. }
  61323. }
  61324. /**
  61325. * Defines the layer scene component responsible to manage any effect layers
  61326. * in a given scene.
  61327. */
  61328. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61329. /**
  61330. * The component name helpfull to identify the component in the list of scene components.
  61331. */
  61332. readonly name: string;
  61333. /**
  61334. * The scene the component belongs to.
  61335. */
  61336. scene: Scene;
  61337. private _engine;
  61338. private _renderEffects;
  61339. private _needStencil;
  61340. private _previousStencilState;
  61341. /**
  61342. * Creates a new instance of the component for the given scene
  61343. * @param scene Defines the scene to register the component in
  61344. */
  61345. constructor(scene: Scene);
  61346. /**
  61347. * Registers the component in a given scene
  61348. */
  61349. register(): void;
  61350. /**
  61351. * Rebuilds the elements related to this component in case of
  61352. * context lost for instance.
  61353. */
  61354. rebuild(): void;
  61355. /**
  61356. * Serializes the component data to the specified json object
  61357. * @param serializationObject The object to serialize to
  61358. */
  61359. serialize(serializationObject: any): void;
  61360. /**
  61361. * Adds all the elements from the container to the scene
  61362. * @param container the container holding the elements
  61363. */
  61364. addFromContainer(container: AbstractScene): void;
  61365. /**
  61366. * Removes all the elements in the container from the scene
  61367. * @param container contains the elements to remove
  61368. * @param dispose if the removed element should be disposed (default: false)
  61369. */
  61370. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61371. /**
  61372. * Disposes the component and the associated ressources.
  61373. */
  61374. dispose(): void;
  61375. private _isReadyForMesh;
  61376. private _renderMainTexture;
  61377. private _setStencil;
  61378. private _setStencilBack;
  61379. private _draw;
  61380. private _drawCamera;
  61381. private _drawRenderingGroup;
  61382. }
  61383. }
  61384. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61385. /** @hidden */
  61386. export var glowMapMergePixelShader: {
  61387. name: string;
  61388. shader: string;
  61389. };
  61390. }
  61391. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61392. /** @hidden */
  61393. export var glowMapMergeVertexShader: {
  61394. name: string;
  61395. shader: string;
  61396. };
  61397. }
  61398. declare module "babylonjs/Layers/glowLayer" {
  61399. import { Nullable } from "babylonjs/types";
  61400. import { Camera } from "babylonjs/Cameras/camera";
  61401. import { Scene } from "babylonjs/scene";
  61402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61404. import { Mesh } from "babylonjs/Meshes/mesh";
  61405. import { Texture } from "babylonjs/Materials/Textures/texture";
  61406. import { Effect } from "babylonjs/Materials/effect";
  61407. import { Material } from "babylonjs/Materials/material";
  61408. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61409. import { Color4 } from "babylonjs/Maths/math.color";
  61410. import "babylonjs/Shaders/glowMapMerge.fragment";
  61411. import "babylonjs/Shaders/glowMapMerge.vertex";
  61412. import "babylonjs/Layers/effectLayerSceneComponent";
  61413. module "babylonjs/abstractScene" {
  61414. interface AbstractScene {
  61415. /**
  61416. * Return a the first highlight layer of the scene with a given name.
  61417. * @param name The name of the highlight layer to look for.
  61418. * @return The highlight layer if found otherwise null.
  61419. */
  61420. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61421. }
  61422. }
  61423. /**
  61424. * Glow layer options. This helps customizing the behaviour
  61425. * of the glow layer.
  61426. */
  61427. export interface IGlowLayerOptions {
  61428. /**
  61429. * Multiplication factor apply to the canvas size to compute the render target size
  61430. * used to generated the glowing objects (the smaller the faster).
  61431. */
  61432. mainTextureRatio: number;
  61433. /**
  61434. * Enforces a fixed size texture to ensure resize independant blur.
  61435. */
  61436. mainTextureFixedSize?: number;
  61437. /**
  61438. * How big is the kernel of the blur texture.
  61439. */
  61440. blurKernelSize: number;
  61441. /**
  61442. * The camera attached to the layer.
  61443. */
  61444. camera: Nullable<Camera>;
  61445. /**
  61446. * Enable MSAA by chosing the number of samples.
  61447. */
  61448. mainTextureSamples?: number;
  61449. /**
  61450. * The rendering group to draw the layer in.
  61451. */
  61452. renderingGroupId: number;
  61453. }
  61454. /**
  61455. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61456. *
  61457. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61458. *
  61459. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61460. */
  61461. export class GlowLayer extends EffectLayer {
  61462. /**
  61463. * Effect Name of the layer.
  61464. */
  61465. static readonly EffectName: string;
  61466. /**
  61467. * The default blur kernel size used for the glow.
  61468. */
  61469. static DefaultBlurKernelSize: number;
  61470. /**
  61471. * The default texture size ratio used for the glow.
  61472. */
  61473. static DefaultTextureRatio: number;
  61474. /**
  61475. * Sets the kernel size of the blur.
  61476. */
  61477. set blurKernelSize(value: number);
  61478. /**
  61479. * Gets the kernel size of the blur.
  61480. */
  61481. get blurKernelSize(): number;
  61482. /**
  61483. * Sets the glow intensity.
  61484. */
  61485. set intensity(value: number);
  61486. /**
  61487. * Gets the glow intensity.
  61488. */
  61489. get intensity(): number;
  61490. private _options;
  61491. private _intensity;
  61492. private _horizontalBlurPostprocess1;
  61493. private _verticalBlurPostprocess1;
  61494. private _horizontalBlurPostprocess2;
  61495. private _verticalBlurPostprocess2;
  61496. private _blurTexture1;
  61497. private _blurTexture2;
  61498. private _postProcesses1;
  61499. private _postProcesses2;
  61500. private _includedOnlyMeshes;
  61501. private _excludedMeshes;
  61502. private _meshesUsingTheirOwnMaterials;
  61503. /**
  61504. * Callback used to let the user override the color selection on a per mesh basis
  61505. */
  61506. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61507. /**
  61508. * Callback used to let the user override the texture selection on a per mesh basis
  61509. */
  61510. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61511. /**
  61512. * Instantiates a new glow Layer and references it to the scene.
  61513. * @param name The name of the layer
  61514. * @param scene The scene to use the layer in
  61515. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61516. */
  61517. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61518. /**
  61519. * Get the effect name of the layer.
  61520. * @return The effect name
  61521. */
  61522. getEffectName(): string;
  61523. /**
  61524. * Create the merge effect. This is the shader use to blit the information back
  61525. * to the main canvas at the end of the scene rendering.
  61526. */
  61527. protected _createMergeEffect(): Effect;
  61528. /**
  61529. * Creates the render target textures and post processes used in the glow layer.
  61530. */
  61531. protected _createTextureAndPostProcesses(): void;
  61532. /**
  61533. * Checks for the readiness of the element composing the layer.
  61534. * @param subMesh the mesh to check for
  61535. * @param useInstances specify wether or not to use instances to render the mesh
  61536. * @param emissiveTexture the associated emissive texture used to generate the glow
  61537. * @return true if ready otherwise, false
  61538. */
  61539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61540. /**
  61541. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61542. */
  61543. needStencil(): boolean;
  61544. /**
  61545. * Returns true if the mesh can be rendered, otherwise false.
  61546. * @param mesh The mesh to render
  61547. * @param material The material used on the mesh
  61548. * @returns true if it can be rendered otherwise false
  61549. */
  61550. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61551. /**
  61552. * Implementation specific of rendering the generating effect on the main canvas.
  61553. * @param effect The effect used to render through
  61554. */
  61555. protected _internalRender(effect: Effect): void;
  61556. /**
  61557. * Sets the required values for both the emissive texture and and the main color.
  61558. */
  61559. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61560. /**
  61561. * Returns true if the mesh should render, otherwise false.
  61562. * @param mesh The mesh to render
  61563. * @returns true if it should render otherwise false
  61564. */
  61565. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61566. /**
  61567. * Adds specific effects defines.
  61568. * @param defines The defines to add specifics to.
  61569. */
  61570. protected _addCustomEffectDefines(defines: string[]): void;
  61571. /**
  61572. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61573. * @param mesh The mesh to exclude from the glow layer
  61574. */
  61575. addExcludedMesh(mesh: Mesh): void;
  61576. /**
  61577. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61578. * @param mesh The mesh to remove
  61579. */
  61580. removeExcludedMesh(mesh: Mesh): void;
  61581. /**
  61582. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61583. * @param mesh The mesh to include in the glow layer
  61584. */
  61585. addIncludedOnlyMesh(mesh: Mesh): void;
  61586. /**
  61587. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61588. * @param mesh The mesh to remove
  61589. */
  61590. removeIncludedOnlyMesh(mesh: Mesh): void;
  61591. /**
  61592. * Determine if a given mesh will be used in the glow layer
  61593. * @param mesh The mesh to test
  61594. * @returns true if the mesh will be highlighted by the current glow layer
  61595. */
  61596. hasMesh(mesh: AbstractMesh): boolean;
  61597. /**
  61598. * Defines whether the current material of the mesh should be use to render the effect.
  61599. * @param mesh defines the current mesh to render
  61600. */
  61601. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61602. /**
  61603. * Add a mesh to be rendered through its own material and not with emissive only.
  61604. * @param mesh The mesh for which we need to use its material
  61605. */
  61606. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61607. /**
  61608. * Remove a mesh from being rendered through its own material and not with emissive only.
  61609. * @param mesh The mesh for which we need to not use its material
  61610. */
  61611. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61612. /**
  61613. * Free any resources and references associated to a mesh.
  61614. * Internal use
  61615. * @param mesh The mesh to free.
  61616. * @hidden
  61617. */
  61618. _disposeMesh(mesh: Mesh): void;
  61619. /**
  61620. * Gets the class name of the effect layer
  61621. * @returns the string with the class name of the effect layer
  61622. */
  61623. getClassName(): string;
  61624. /**
  61625. * Serializes this glow layer
  61626. * @returns a serialized glow layer object
  61627. */
  61628. serialize(): any;
  61629. /**
  61630. * Creates a Glow Layer from parsed glow layer data
  61631. * @param parsedGlowLayer defines glow layer data
  61632. * @param scene defines the current scene
  61633. * @param rootUrl defines the root URL containing the glow layer information
  61634. * @returns a parsed Glow Layer
  61635. */
  61636. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61637. }
  61638. }
  61639. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61640. /** @hidden */
  61641. export var glowBlurPostProcessPixelShader: {
  61642. name: string;
  61643. shader: string;
  61644. };
  61645. }
  61646. declare module "babylonjs/Layers/highlightLayer" {
  61647. import { Observable } from "babylonjs/Misc/observable";
  61648. import { Nullable } from "babylonjs/types";
  61649. import { Camera } from "babylonjs/Cameras/camera";
  61650. import { Scene } from "babylonjs/scene";
  61651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61653. import { Mesh } from "babylonjs/Meshes/mesh";
  61654. import { Effect } from "babylonjs/Materials/effect";
  61655. import { Material } from "babylonjs/Materials/material";
  61656. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61657. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61658. import "babylonjs/Shaders/glowMapMerge.fragment";
  61659. import "babylonjs/Shaders/glowMapMerge.vertex";
  61660. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61661. module "babylonjs/abstractScene" {
  61662. interface AbstractScene {
  61663. /**
  61664. * Return a the first highlight layer of the scene with a given name.
  61665. * @param name The name of the highlight layer to look for.
  61666. * @return The highlight layer if found otherwise null.
  61667. */
  61668. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61669. }
  61670. }
  61671. /**
  61672. * Highlight layer options. This helps customizing the behaviour
  61673. * of the highlight layer.
  61674. */
  61675. export interface IHighlightLayerOptions {
  61676. /**
  61677. * Multiplication factor apply to the canvas size to compute the render target size
  61678. * used to generated the glowing objects (the smaller the faster).
  61679. */
  61680. mainTextureRatio: number;
  61681. /**
  61682. * Enforces a fixed size texture to ensure resize independant blur.
  61683. */
  61684. mainTextureFixedSize?: number;
  61685. /**
  61686. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61687. * of the picture to blur (the smaller the faster).
  61688. */
  61689. blurTextureSizeRatio: number;
  61690. /**
  61691. * How big in texel of the blur texture is the vertical blur.
  61692. */
  61693. blurVerticalSize: number;
  61694. /**
  61695. * How big in texel of the blur texture is the horizontal blur.
  61696. */
  61697. blurHorizontalSize: number;
  61698. /**
  61699. * Alpha blending mode used to apply the blur. Default is combine.
  61700. */
  61701. alphaBlendingMode: number;
  61702. /**
  61703. * The camera attached to the layer.
  61704. */
  61705. camera: Nullable<Camera>;
  61706. /**
  61707. * Should we display highlight as a solid stroke?
  61708. */
  61709. isStroke?: boolean;
  61710. /**
  61711. * The rendering group to draw the layer in.
  61712. */
  61713. renderingGroupId: number;
  61714. }
  61715. /**
  61716. * The highlight layer Helps adding a glow effect around a mesh.
  61717. *
  61718. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61719. * glowy meshes to your scene.
  61720. *
  61721. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61722. */
  61723. export class HighlightLayer extends EffectLayer {
  61724. name: string;
  61725. /**
  61726. * Effect Name of the highlight layer.
  61727. */
  61728. static readonly EffectName: string;
  61729. /**
  61730. * The neutral color used during the preparation of the glow effect.
  61731. * This is black by default as the blend operation is a blend operation.
  61732. */
  61733. static NeutralColor: Color4;
  61734. /**
  61735. * Stencil value used for glowing meshes.
  61736. */
  61737. static GlowingMeshStencilReference: number;
  61738. /**
  61739. * Stencil value used for the other meshes in the scene.
  61740. */
  61741. static NormalMeshStencilReference: number;
  61742. /**
  61743. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61744. */
  61745. innerGlow: boolean;
  61746. /**
  61747. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61748. */
  61749. outerGlow: boolean;
  61750. /**
  61751. * Specifies the horizontal size of the blur.
  61752. */
  61753. set blurHorizontalSize(value: number);
  61754. /**
  61755. * Specifies the vertical size of the blur.
  61756. */
  61757. set blurVerticalSize(value: number);
  61758. /**
  61759. * Gets the horizontal size of the blur.
  61760. */
  61761. get blurHorizontalSize(): number;
  61762. /**
  61763. * Gets the vertical size of the blur.
  61764. */
  61765. get blurVerticalSize(): number;
  61766. /**
  61767. * An event triggered when the highlight layer is being blurred.
  61768. */
  61769. onBeforeBlurObservable: Observable<HighlightLayer>;
  61770. /**
  61771. * An event triggered when the highlight layer has been blurred.
  61772. */
  61773. onAfterBlurObservable: Observable<HighlightLayer>;
  61774. private _instanceGlowingMeshStencilReference;
  61775. private _options;
  61776. private _downSamplePostprocess;
  61777. private _horizontalBlurPostprocess;
  61778. private _verticalBlurPostprocess;
  61779. private _blurTexture;
  61780. private _meshes;
  61781. private _excludedMeshes;
  61782. /**
  61783. * Instantiates a new highlight Layer and references it to the scene..
  61784. * @param name The name of the layer
  61785. * @param scene The scene to use the layer in
  61786. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61787. */
  61788. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61789. /**
  61790. * Get the effect name of the layer.
  61791. * @return The effect name
  61792. */
  61793. getEffectName(): string;
  61794. /**
  61795. * Create the merge effect. This is the shader use to blit the information back
  61796. * to the main canvas at the end of the scene rendering.
  61797. */
  61798. protected _createMergeEffect(): Effect;
  61799. /**
  61800. * Creates the render target textures and post processes used in the highlight layer.
  61801. */
  61802. protected _createTextureAndPostProcesses(): void;
  61803. /**
  61804. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61805. */
  61806. needStencil(): boolean;
  61807. /**
  61808. * Checks for the readiness of the element composing the layer.
  61809. * @param subMesh the mesh to check for
  61810. * @param useInstances specify wether or not to use instances to render the mesh
  61811. * @param emissiveTexture the associated emissive texture used to generate the glow
  61812. * @return true if ready otherwise, false
  61813. */
  61814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61815. /**
  61816. * Implementation specific of rendering the generating effect on the main canvas.
  61817. * @param effect The effect used to render through
  61818. */
  61819. protected _internalRender(effect: Effect): void;
  61820. /**
  61821. * Returns true if the layer contains information to display, otherwise false.
  61822. */
  61823. shouldRender(): boolean;
  61824. /**
  61825. * Returns true if the mesh should render, otherwise false.
  61826. * @param mesh The mesh to render
  61827. * @returns true if it should render otherwise false
  61828. */
  61829. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61830. /**
  61831. * Returns true if the mesh can be rendered, otherwise false.
  61832. * @param mesh The mesh to render
  61833. * @param material The material used on the mesh
  61834. * @returns true if it can be rendered otherwise false
  61835. */
  61836. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61837. /**
  61838. * Adds specific effects defines.
  61839. * @param defines The defines to add specifics to.
  61840. */
  61841. protected _addCustomEffectDefines(defines: string[]): void;
  61842. /**
  61843. * Sets the required values for both the emissive texture and and the main color.
  61844. */
  61845. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61846. /**
  61847. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61848. * @param mesh The mesh to exclude from the highlight layer
  61849. */
  61850. addExcludedMesh(mesh: Mesh): void;
  61851. /**
  61852. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61853. * @param mesh The mesh to highlight
  61854. */
  61855. removeExcludedMesh(mesh: Mesh): void;
  61856. /**
  61857. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61858. * @param mesh mesh to test
  61859. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61860. */
  61861. hasMesh(mesh: AbstractMesh): boolean;
  61862. /**
  61863. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61864. * @param mesh The mesh to highlight
  61865. * @param color The color of the highlight
  61866. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61867. */
  61868. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61869. /**
  61870. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61871. * @param mesh The mesh to highlight
  61872. */
  61873. removeMesh(mesh: Mesh): void;
  61874. /**
  61875. * Remove all the meshes currently referenced in the highlight layer
  61876. */
  61877. removeAllMeshes(): void;
  61878. /**
  61879. * Force the stencil to the normal expected value for none glowing parts
  61880. */
  61881. private _defaultStencilReference;
  61882. /**
  61883. * Free any resources and references associated to a mesh.
  61884. * Internal use
  61885. * @param mesh The mesh to free.
  61886. * @hidden
  61887. */
  61888. _disposeMesh(mesh: Mesh): void;
  61889. /**
  61890. * Dispose the highlight layer and free resources.
  61891. */
  61892. dispose(): void;
  61893. /**
  61894. * Gets the class name of the effect layer
  61895. * @returns the string with the class name of the effect layer
  61896. */
  61897. getClassName(): string;
  61898. /**
  61899. * Serializes this Highlight layer
  61900. * @returns a serialized Highlight layer object
  61901. */
  61902. serialize(): any;
  61903. /**
  61904. * Creates a Highlight layer from parsed Highlight layer data
  61905. * @param parsedHightlightLayer defines the Highlight layer data
  61906. * @param scene defines the current scene
  61907. * @param rootUrl defines the root URL containing the Highlight layer information
  61908. * @returns a parsed Highlight layer
  61909. */
  61910. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61911. }
  61912. }
  61913. declare module "babylonjs/Layers/layerSceneComponent" {
  61914. import { Scene } from "babylonjs/scene";
  61915. import { ISceneComponent } from "babylonjs/sceneComponent";
  61916. import { Layer } from "babylonjs/Layers/layer";
  61917. import { AbstractScene } from "babylonjs/abstractScene";
  61918. module "babylonjs/abstractScene" {
  61919. interface AbstractScene {
  61920. /**
  61921. * The list of layers (background and foreground) of the scene
  61922. */
  61923. layers: Array<Layer>;
  61924. }
  61925. }
  61926. /**
  61927. * Defines the layer scene component responsible to manage any layers
  61928. * in a given scene.
  61929. */
  61930. export class LayerSceneComponent implements ISceneComponent {
  61931. /**
  61932. * The component name helpfull to identify the component in the list of scene components.
  61933. */
  61934. readonly name: string;
  61935. /**
  61936. * The scene the component belongs to.
  61937. */
  61938. scene: Scene;
  61939. private _engine;
  61940. /**
  61941. * Creates a new instance of the component for the given scene
  61942. * @param scene Defines the scene to register the component in
  61943. */
  61944. constructor(scene: Scene);
  61945. /**
  61946. * Registers the component in a given scene
  61947. */
  61948. register(): void;
  61949. /**
  61950. * Rebuilds the elements related to this component in case of
  61951. * context lost for instance.
  61952. */
  61953. rebuild(): void;
  61954. /**
  61955. * Disposes the component and the associated ressources.
  61956. */
  61957. dispose(): void;
  61958. private _draw;
  61959. private _drawCameraPredicate;
  61960. private _drawCameraBackground;
  61961. private _drawCameraForeground;
  61962. private _drawRenderTargetPredicate;
  61963. private _drawRenderTargetBackground;
  61964. private _drawRenderTargetForeground;
  61965. /**
  61966. * Adds all the elements from the container to the scene
  61967. * @param container the container holding the elements
  61968. */
  61969. addFromContainer(container: AbstractScene): void;
  61970. /**
  61971. * Removes all the elements in the container from the scene
  61972. * @param container contains the elements to remove
  61973. * @param dispose if the removed element should be disposed (default: false)
  61974. */
  61975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61976. }
  61977. }
  61978. declare module "babylonjs/Shaders/layer.fragment" {
  61979. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61980. /** @hidden */
  61981. export var layerPixelShader: {
  61982. name: string;
  61983. shader: string;
  61984. };
  61985. }
  61986. declare module "babylonjs/Shaders/layer.vertex" {
  61987. /** @hidden */
  61988. export var layerVertexShader: {
  61989. name: string;
  61990. shader: string;
  61991. };
  61992. }
  61993. declare module "babylonjs/Layers/layer" {
  61994. import { Observable } from "babylonjs/Misc/observable";
  61995. import { Nullable } from "babylonjs/types";
  61996. import { Scene } from "babylonjs/scene";
  61997. import { Vector2 } from "babylonjs/Maths/math.vector";
  61998. import { Color4 } from "babylonjs/Maths/math.color";
  61999. import { Texture } from "babylonjs/Materials/Textures/texture";
  62000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62001. import "babylonjs/Shaders/layer.fragment";
  62002. import "babylonjs/Shaders/layer.vertex";
  62003. /**
  62004. * This represents a full screen 2d layer.
  62005. * This can be useful to display a picture in the background of your scene for instance.
  62006. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62007. */
  62008. export class Layer {
  62009. /**
  62010. * Define the name of the layer.
  62011. */
  62012. name: string;
  62013. /**
  62014. * Define the texture the layer should display.
  62015. */
  62016. texture: Nullable<Texture>;
  62017. /**
  62018. * Is the layer in background or foreground.
  62019. */
  62020. isBackground: boolean;
  62021. /**
  62022. * Define the color of the layer (instead of texture).
  62023. */
  62024. color: Color4;
  62025. /**
  62026. * Define the scale of the layer in order to zoom in out of the texture.
  62027. */
  62028. scale: Vector2;
  62029. /**
  62030. * Define an offset for the layer in order to shift the texture.
  62031. */
  62032. offset: Vector2;
  62033. /**
  62034. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62035. */
  62036. alphaBlendingMode: number;
  62037. /**
  62038. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62039. * Alpha test will not mix with the background color in case of transparency.
  62040. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62041. */
  62042. alphaTest: boolean;
  62043. /**
  62044. * Define a mask to restrict the layer to only some of the scene cameras.
  62045. */
  62046. layerMask: number;
  62047. /**
  62048. * Define the list of render target the layer is visible into.
  62049. */
  62050. renderTargetTextures: RenderTargetTexture[];
  62051. /**
  62052. * Define if the layer is only used in renderTarget or if it also
  62053. * renders in the main frame buffer of the canvas.
  62054. */
  62055. renderOnlyInRenderTargetTextures: boolean;
  62056. private _scene;
  62057. private _vertexBuffers;
  62058. private _indexBuffer;
  62059. private _effect;
  62060. private _previousDefines;
  62061. /**
  62062. * An event triggered when the layer is disposed.
  62063. */
  62064. onDisposeObservable: Observable<Layer>;
  62065. private _onDisposeObserver;
  62066. /**
  62067. * Back compatibility with callback before the onDisposeObservable existed.
  62068. * The set callback will be triggered when the layer has been disposed.
  62069. */
  62070. set onDispose(callback: () => void);
  62071. /**
  62072. * An event triggered before rendering the scene
  62073. */
  62074. onBeforeRenderObservable: Observable<Layer>;
  62075. private _onBeforeRenderObserver;
  62076. /**
  62077. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62078. * The set callback will be triggered just before rendering the layer.
  62079. */
  62080. set onBeforeRender(callback: () => void);
  62081. /**
  62082. * An event triggered after rendering the scene
  62083. */
  62084. onAfterRenderObservable: Observable<Layer>;
  62085. private _onAfterRenderObserver;
  62086. /**
  62087. * Back compatibility with callback before the onAfterRenderObservable existed.
  62088. * The set callback will be triggered just after rendering the layer.
  62089. */
  62090. set onAfterRender(callback: () => void);
  62091. /**
  62092. * Instantiates a new layer.
  62093. * This represents a full screen 2d layer.
  62094. * This can be useful to display a picture in the background of your scene for instance.
  62095. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62096. * @param name Define the name of the layer in the scene
  62097. * @param imgUrl Define the url of the texture to display in the layer
  62098. * @param scene Define the scene the layer belongs to
  62099. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62100. * @param color Defines a color for the layer
  62101. */
  62102. constructor(
  62103. /**
  62104. * Define the name of the layer.
  62105. */
  62106. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62107. private _createIndexBuffer;
  62108. /** @hidden */
  62109. _rebuild(): void;
  62110. /**
  62111. * Renders the layer in the scene.
  62112. */
  62113. render(): void;
  62114. /**
  62115. * Disposes and releases the associated ressources.
  62116. */
  62117. dispose(): void;
  62118. }
  62119. }
  62120. declare module "babylonjs/Layers/index" {
  62121. export * from "babylonjs/Layers/effectLayer";
  62122. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62123. export * from "babylonjs/Layers/glowLayer";
  62124. export * from "babylonjs/Layers/highlightLayer";
  62125. export * from "babylonjs/Layers/layer";
  62126. export * from "babylonjs/Layers/layerSceneComponent";
  62127. }
  62128. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62129. /** @hidden */
  62130. export var lensFlarePixelShader: {
  62131. name: string;
  62132. shader: string;
  62133. };
  62134. }
  62135. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62136. /** @hidden */
  62137. export var lensFlareVertexShader: {
  62138. name: string;
  62139. shader: string;
  62140. };
  62141. }
  62142. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62143. import { Scene } from "babylonjs/scene";
  62144. import { Vector3 } from "babylonjs/Maths/math.vector";
  62145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62146. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62147. import "babylonjs/Shaders/lensFlare.fragment";
  62148. import "babylonjs/Shaders/lensFlare.vertex";
  62149. import { Viewport } from "babylonjs/Maths/math.viewport";
  62150. /**
  62151. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62152. * It is usually composed of several `lensFlare`.
  62153. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62154. */
  62155. export class LensFlareSystem {
  62156. /**
  62157. * Define the name of the lens flare system
  62158. */
  62159. name: string;
  62160. /**
  62161. * List of lens flares used in this system.
  62162. */
  62163. lensFlares: LensFlare[];
  62164. /**
  62165. * Define a limit from the border the lens flare can be visible.
  62166. */
  62167. borderLimit: number;
  62168. /**
  62169. * Define a viewport border we do not want to see the lens flare in.
  62170. */
  62171. viewportBorder: number;
  62172. /**
  62173. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62174. */
  62175. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62176. /**
  62177. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62178. */
  62179. layerMask: number;
  62180. /**
  62181. * Define the id of the lens flare system in the scene.
  62182. * (equal to name by default)
  62183. */
  62184. id: string;
  62185. private _scene;
  62186. private _emitter;
  62187. private _vertexBuffers;
  62188. private _indexBuffer;
  62189. private _effect;
  62190. private _positionX;
  62191. private _positionY;
  62192. private _isEnabled;
  62193. /** @hidden */
  62194. static _SceneComponentInitialization: (scene: Scene) => void;
  62195. /**
  62196. * Instantiates a lens flare system.
  62197. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62198. * It is usually composed of several `lensFlare`.
  62199. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62200. * @param name Define the name of the lens flare system in the scene
  62201. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62202. * @param scene Define the scene the lens flare system belongs to
  62203. */
  62204. constructor(
  62205. /**
  62206. * Define the name of the lens flare system
  62207. */
  62208. name: string, emitter: any, scene: Scene);
  62209. /**
  62210. * Define if the lens flare system is enabled.
  62211. */
  62212. get isEnabled(): boolean;
  62213. set isEnabled(value: boolean);
  62214. /**
  62215. * Get the scene the effects belongs to.
  62216. * @returns the scene holding the lens flare system
  62217. */
  62218. getScene(): Scene;
  62219. /**
  62220. * Get the emitter of the lens flare system.
  62221. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62222. * @returns the emitter of the lens flare system
  62223. */
  62224. getEmitter(): any;
  62225. /**
  62226. * Set the emitter of the lens flare system.
  62227. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62228. * @param newEmitter Define the new emitter of the system
  62229. */
  62230. setEmitter(newEmitter: any): void;
  62231. /**
  62232. * Get the lens flare system emitter position.
  62233. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62234. * @returns the position
  62235. */
  62236. getEmitterPosition(): Vector3;
  62237. /**
  62238. * @hidden
  62239. */
  62240. computeEffectivePosition(globalViewport: Viewport): boolean;
  62241. /** @hidden */
  62242. _isVisible(): boolean;
  62243. /**
  62244. * @hidden
  62245. */
  62246. render(): boolean;
  62247. /**
  62248. * Dispose and release the lens flare with its associated resources.
  62249. */
  62250. dispose(): void;
  62251. /**
  62252. * Parse a lens flare system from a JSON repressentation
  62253. * @param parsedLensFlareSystem Define the JSON to parse
  62254. * @param scene Define the scene the parsed system should be instantiated in
  62255. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62256. * @returns the parsed system
  62257. */
  62258. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62259. /**
  62260. * Serialize the current Lens Flare System into a JSON representation.
  62261. * @returns the serialized JSON
  62262. */
  62263. serialize(): any;
  62264. }
  62265. }
  62266. declare module "babylonjs/LensFlares/lensFlare" {
  62267. import { Nullable } from "babylonjs/types";
  62268. import { Color3 } from "babylonjs/Maths/math.color";
  62269. import { Texture } from "babylonjs/Materials/Textures/texture";
  62270. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62271. /**
  62272. * This represents one of the lens effect in a `lensFlareSystem`.
  62273. * It controls one of the indiviual texture used in the effect.
  62274. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62275. */
  62276. export class LensFlare {
  62277. /**
  62278. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62279. */
  62280. size: number;
  62281. /**
  62282. * 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.
  62283. */
  62284. position: number;
  62285. /**
  62286. * Define the lens color.
  62287. */
  62288. color: Color3;
  62289. /**
  62290. * Define the lens texture.
  62291. */
  62292. texture: Nullable<Texture>;
  62293. /**
  62294. * Define the alpha mode to render this particular lens.
  62295. */
  62296. alphaMode: number;
  62297. private _system;
  62298. /**
  62299. * Creates a new Lens Flare.
  62300. * This represents one of the lens effect in a `lensFlareSystem`.
  62301. * It controls one of the indiviual texture used in the effect.
  62302. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62303. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62304. * @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.
  62305. * @param color Define the lens color
  62306. * @param imgUrl Define the lens texture url
  62307. * @param system Define the `lensFlareSystem` this flare is part of
  62308. * @returns The newly created Lens Flare
  62309. */
  62310. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62311. /**
  62312. * Instantiates a new Lens Flare.
  62313. * This represents one of the lens effect in a `lensFlareSystem`.
  62314. * It controls one of the indiviual texture used in the effect.
  62315. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62316. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62317. * @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.
  62318. * @param color Define the lens color
  62319. * @param imgUrl Define the lens texture url
  62320. * @param system Define the `lensFlareSystem` this flare is part of
  62321. */
  62322. constructor(
  62323. /**
  62324. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62325. */
  62326. size: number,
  62327. /**
  62328. * 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.
  62329. */
  62330. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62331. /**
  62332. * Dispose and release the lens flare with its associated resources.
  62333. */
  62334. dispose(): void;
  62335. }
  62336. }
  62337. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62338. import { Nullable } from "babylonjs/types";
  62339. import { Scene } from "babylonjs/scene";
  62340. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62341. import { AbstractScene } from "babylonjs/abstractScene";
  62342. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62343. module "babylonjs/abstractScene" {
  62344. interface AbstractScene {
  62345. /**
  62346. * The list of lens flare system added to the scene
  62347. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62348. */
  62349. lensFlareSystems: Array<LensFlareSystem>;
  62350. /**
  62351. * Removes the given lens flare system from this scene.
  62352. * @param toRemove The lens flare system to remove
  62353. * @returns The index of the removed lens flare system
  62354. */
  62355. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62356. /**
  62357. * Adds the given lens flare system to this scene
  62358. * @param newLensFlareSystem The lens flare system to add
  62359. */
  62360. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62361. /**
  62362. * Gets a lens flare system using its name
  62363. * @param name defines the name to look for
  62364. * @returns the lens flare system or null if not found
  62365. */
  62366. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62367. /**
  62368. * Gets a lens flare system using its id
  62369. * @param id defines the id to look for
  62370. * @returns the lens flare system or null if not found
  62371. */
  62372. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62373. }
  62374. }
  62375. /**
  62376. * Defines the lens flare scene component responsible to manage any lens flares
  62377. * in a given scene.
  62378. */
  62379. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62380. /**
  62381. * The component name helpfull to identify the component in the list of scene components.
  62382. */
  62383. readonly name: string;
  62384. /**
  62385. * The scene the component belongs to.
  62386. */
  62387. scene: Scene;
  62388. /**
  62389. * Creates a new instance of the component for the given scene
  62390. * @param scene Defines the scene to register the component in
  62391. */
  62392. constructor(scene: Scene);
  62393. /**
  62394. * Registers the component in a given scene
  62395. */
  62396. register(): void;
  62397. /**
  62398. * Rebuilds the elements related to this component in case of
  62399. * context lost for instance.
  62400. */
  62401. rebuild(): void;
  62402. /**
  62403. * Adds all the elements from the container to the scene
  62404. * @param container the container holding the elements
  62405. */
  62406. addFromContainer(container: AbstractScene): void;
  62407. /**
  62408. * Removes all the elements in the container from the scene
  62409. * @param container contains the elements to remove
  62410. * @param dispose if the removed element should be disposed (default: false)
  62411. */
  62412. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62413. /**
  62414. * Serializes the component data to the specified json object
  62415. * @param serializationObject The object to serialize to
  62416. */
  62417. serialize(serializationObject: any): void;
  62418. /**
  62419. * Disposes the component and the associated ressources.
  62420. */
  62421. dispose(): void;
  62422. private _draw;
  62423. }
  62424. }
  62425. declare module "babylonjs/LensFlares/index" {
  62426. export * from "babylonjs/LensFlares/lensFlare";
  62427. export * from "babylonjs/LensFlares/lensFlareSystem";
  62428. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62429. }
  62430. declare module "babylonjs/Shaders/depth.fragment" {
  62431. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62432. /** @hidden */
  62433. export var depthPixelShader: {
  62434. name: string;
  62435. shader: string;
  62436. };
  62437. }
  62438. declare module "babylonjs/Shaders/depth.vertex" {
  62439. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62441. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62442. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62444. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62445. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62446. /** @hidden */
  62447. export var depthVertexShader: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. declare module "babylonjs/Rendering/depthRenderer" {
  62453. import { Nullable } from "babylonjs/types";
  62454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62455. import { Scene } from "babylonjs/scene";
  62456. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62457. import { Camera } from "babylonjs/Cameras/camera";
  62458. import "babylonjs/Shaders/depth.fragment";
  62459. import "babylonjs/Shaders/depth.vertex";
  62460. /**
  62461. * This represents a depth renderer in Babylon.
  62462. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62463. */
  62464. export class DepthRenderer {
  62465. private _scene;
  62466. private _depthMap;
  62467. private _effect;
  62468. private readonly _storeNonLinearDepth;
  62469. private readonly _clearColor;
  62470. /** Get if the depth renderer is using packed depth or not */
  62471. readonly isPacked: boolean;
  62472. private _cachedDefines;
  62473. private _camera;
  62474. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62475. enabled: boolean;
  62476. /**
  62477. * Specifiess that the depth renderer will only be used within
  62478. * the camera it is created for.
  62479. * This can help forcing its rendering during the camera processing.
  62480. */
  62481. useOnlyInActiveCamera: boolean;
  62482. /** @hidden */
  62483. static _SceneComponentInitialization: (scene: Scene) => void;
  62484. /**
  62485. * Instantiates a depth renderer
  62486. * @param scene The scene the renderer belongs to
  62487. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62488. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62489. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62490. */
  62491. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62492. /**
  62493. * Creates the depth rendering effect and checks if the effect is ready.
  62494. * @param subMesh The submesh to be used to render the depth map of
  62495. * @param useInstances If multiple world instances should be used
  62496. * @returns if the depth renderer is ready to render the depth map
  62497. */
  62498. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62499. /**
  62500. * Gets the texture which the depth map will be written to.
  62501. * @returns The depth map texture
  62502. */
  62503. getDepthMap(): RenderTargetTexture;
  62504. /**
  62505. * Disposes of the depth renderer.
  62506. */
  62507. dispose(): void;
  62508. }
  62509. }
  62510. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62511. /** @hidden */
  62512. export var minmaxReduxPixelShader: {
  62513. name: string;
  62514. shader: string;
  62515. };
  62516. }
  62517. declare module "babylonjs/Misc/minMaxReducer" {
  62518. import { Nullable } from "babylonjs/types";
  62519. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62520. import { Camera } from "babylonjs/Cameras/camera";
  62521. import { Observer } from "babylonjs/Misc/observable";
  62522. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62523. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62524. import { Observable } from "babylonjs/Misc/observable";
  62525. import "babylonjs/Shaders/minmaxRedux.fragment";
  62526. /**
  62527. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62528. * and maximum values from all values of the texture.
  62529. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62530. * The source values are read from the red channel of the texture.
  62531. */
  62532. export class MinMaxReducer {
  62533. /**
  62534. * Observable triggered when the computation has been performed
  62535. */
  62536. onAfterReductionPerformed: Observable<{
  62537. min: number;
  62538. max: number;
  62539. }>;
  62540. protected _camera: Camera;
  62541. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62542. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62543. protected _postProcessManager: PostProcessManager;
  62544. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62545. protected _forceFullscreenViewport: boolean;
  62546. /**
  62547. * Creates a min/max reducer
  62548. * @param camera The camera to use for the post processes
  62549. */
  62550. constructor(camera: Camera);
  62551. /**
  62552. * Gets the texture used to read the values from.
  62553. */
  62554. get sourceTexture(): Nullable<RenderTargetTexture>;
  62555. /**
  62556. * Sets the source texture to read the values from.
  62557. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62558. * because in such textures '1' value must not be taken into account to compute the maximum
  62559. * as this value is used to clear the texture.
  62560. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62561. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62562. * @param depthRedux Indicates if the texture is a depth texture or not
  62563. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62564. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62565. */
  62566. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62567. /**
  62568. * Defines the refresh rate of the computation.
  62569. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62570. */
  62571. get refreshRate(): number;
  62572. set refreshRate(value: number);
  62573. protected _activated: boolean;
  62574. /**
  62575. * Gets the activation status of the reducer
  62576. */
  62577. get activated(): boolean;
  62578. /**
  62579. * Activates the reduction computation.
  62580. * When activated, the observers registered in onAfterReductionPerformed are
  62581. * called after the compuation is performed
  62582. */
  62583. activate(): void;
  62584. /**
  62585. * Deactivates the reduction computation.
  62586. */
  62587. deactivate(): void;
  62588. /**
  62589. * Disposes the min/max reducer
  62590. * @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.
  62591. */
  62592. dispose(disposeAll?: boolean): void;
  62593. }
  62594. }
  62595. declare module "babylonjs/Misc/depthReducer" {
  62596. import { Nullable } from "babylonjs/types";
  62597. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62598. import { Camera } from "babylonjs/Cameras/camera";
  62599. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62600. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62601. /**
  62602. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62603. */
  62604. export class DepthReducer extends MinMaxReducer {
  62605. private _depthRenderer;
  62606. private _depthRendererId;
  62607. /**
  62608. * Gets the depth renderer used for the computation.
  62609. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62610. */
  62611. get depthRenderer(): Nullable<DepthRenderer>;
  62612. /**
  62613. * Creates a depth reducer
  62614. * @param camera The camera used to render the depth texture
  62615. */
  62616. constructor(camera: Camera);
  62617. /**
  62618. * Sets the depth renderer to use to generate the depth map
  62619. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62620. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62621. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62622. */
  62623. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62624. /** @hidden */
  62625. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62626. /**
  62627. * Activates the reduction computation.
  62628. * When activated, the observers registered in onAfterReductionPerformed are
  62629. * called after the compuation is performed
  62630. */
  62631. activate(): void;
  62632. /**
  62633. * Deactivates the reduction computation.
  62634. */
  62635. deactivate(): void;
  62636. /**
  62637. * Disposes the depth reducer
  62638. * @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.
  62639. */
  62640. dispose(disposeAll?: boolean): void;
  62641. }
  62642. }
  62643. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62644. import { Nullable } from "babylonjs/types";
  62645. import { Scene } from "babylonjs/scene";
  62646. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62647. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62649. import { Effect } from "babylonjs/Materials/effect";
  62650. import "babylonjs/Shaders/shadowMap.fragment";
  62651. import "babylonjs/Shaders/shadowMap.vertex";
  62652. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62653. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62654. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62655. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62656. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62657. /**
  62658. * A CSM implementation allowing casting shadows on large scenes.
  62659. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62660. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62661. */
  62662. export class CascadedShadowGenerator extends ShadowGenerator {
  62663. private static readonly frustumCornersNDCSpace;
  62664. /**
  62665. * Name of the CSM class
  62666. */
  62667. static CLASSNAME: string;
  62668. /**
  62669. * Defines the default number of cascades used by the CSM.
  62670. */
  62671. static readonly DEFAULT_CASCADES_COUNT: number;
  62672. /**
  62673. * Defines the minimum number of cascades used by the CSM.
  62674. */
  62675. static readonly MIN_CASCADES_COUNT: number;
  62676. /**
  62677. * Defines the maximum number of cascades used by the CSM.
  62678. */
  62679. static readonly MAX_CASCADES_COUNT: number;
  62680. protected _validateFilter(filter: number): number;
  62681. /**
  62682. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62683. */
  62684. penumbraDarkness: number;
  62685. private _numCascades;
  62686. /**
  62687. * Gets or set the number of cascades used by the CSM.
  62688. */
  62689. get numCascades(): number;
  62690. set numCascades(value: number);
  62691. /**
  62692. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62693. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62694. */
  62695. stabilizeCascades: boolean;
  62696. private _freezeShadowCastersBoundingInfo;
  62697. private _freezeShadowCastersBoundingInfoObservable;
  62698. /**
  62699. * Enables or disables the shadow casters bounding info computation.
  62700. * If your shadow casters don't move, you can disable this feature.
  62701. * If it is enabled, the bounding box computation is done every frame.
  62702. */
  62703. get freezeShadowCastersBoundingInfo(): boolean;
  62704. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62705. private _scbiMin;
  62706. private _scbiMax;
  62707. protected _computeShadowCastersBoundingInfo(): void;
  62708. protected _shadowCastersBoundingInfo: BoundingInfo;
  62709. /**
  62710. * Gets or sets the shadow casters bounding info.
  62711. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62712. * so that the system won't overwrite the bounds you provide
  62713. */
  62714. get shadowCastersBoundingInfo(): BoundingInfo;
  62715. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62716. protected _breaksAreDirty: boolean;
  62717. protected _minDistance: number;
  62718. protected _maxDistance: number;
  62719. /**
  62720. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62721. *
  62722. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62723. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62724. * @param min minimal distance for the breaks (default to 0.)
  62725. * @param max maximal distance for the breaks (default to 1.)
  62726. */
  62727. setMinMaxDistance(min: number, max: number): void;
  62728. /** Gets the minimal distance used in the cascade break computation */
  62729. get minDistance(): number;
  62730. /** Gets the maximal distance used in the cascade break computation */
  62731. get maxDistance(): number;
  62732. /**
  62733. * Gets the class name of that object
  62734. * @returns "CascadedShadowGenerator"
  62735. */
  62736. getClassName(): string;
  62737. private _cascadeMinExtents;
  62738. private _cascadeMaxExtents;
  62739. /**
  62740. * Gets a cascade minimum extents
  62741. * @param cascadeIndex index of the cascade
  62742. * @returns the minimum cascade extents
  62743. */
  62744. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62745. /**
  62746. * Gets a cascade maximum extents
  62747. * @param cascadeIndex index of the cascade
  62748. * @returns the maximum cascade extents
  62749. */
  62750. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62751. private _cascades;
  62752. private _currentLayer;
  62753. private _viewSpaceFrustumsZ;
  62754. private _viewMatrices;
  62755. private _projectionMatrices;
  62756. private _transformMatrices;
  62757. private _transformMatricesAsArray;
  62758. private _frustumLengths;
  62759. private _lightSizeUVCorrection;
  62760. private _depthCorrection;
  62761. private _frustumCornersWorldSpace;
  62762. private _frustumCenter;
  62763. private _shadowCameraPos;
  62764. private _shadowMaxZ;
  62765. /**
  62766. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62767. * It defaults to camera.maxZ
  62768. */
  62769. get shadowMaxZ(): number;
  62770. /**
  62771. * Sets the shadow max z distance.
  62772. */
  62773. set shadowMaxZ(value: number);
  62774. protected _debug: boolean;
  62775. /**
  62776. * Gets or sets the debug flag.
  62777. * When enabled, the cascades are materialized by different colors on the screen.
  62778. */
  62779. get debug(): boolean;
  62780. set debug(dbg: boolean);
  62781. private _depthClamp;
  62782. /**
  62783. * Gets or sets the depth clamping value.
  62784. *
  62785. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62786. * to account for the shadow casters far away.
  62787. *
  62788. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62789. */
  62790. get depthClamp(): boolean;
  62791. set depthClamp(value: boolean);
  62792. private _cascadeBlendPercentage;
  62793. /**
  62794. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62795. * It defaults to 0.1 (10% blending).
  62796. */
  62797. get cascadeBlendPercentage(): number;
  62798. set cascadeBlendPercentage(value: number);
  62799. private _lambda;
  62800. /**
  62801. * Gets or set the lambda parameter.
  62802. * This parameter is used to split the camera frustum and create the cascades.
  62803. * 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.
  62804. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62805. */
  62806. get lambda(): number;
  62807. set lambda(value: number);
  62808. /**
  62809. * Gets the view matrix corresponding to a given cascade
  62810. * @param cascadeNum cascade to retrieve the view matrix from
  62811. * @returns the cascade view matrix
  62812. */
  62813. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62814. /**
  62815. * Gets the projection matrix corresponding to a given cascade
  62816. * @param cascadeNum cascade to retrieve the projection matrix from
  62817. * @returns the cascade projection matrix
  62818. */
  62819. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62820. /**
  62821. * Gets the transformation matrix corresponding to a given cascade
  62822. * @param cascadeNum cascade to retrieve the transformation matrix from
  62823. * @returns the cascade transformation matrix
  62824. */
  62825. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62826. private _depthRenderer;
  62827. /**
  62828. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62829. *
  62830. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62831. *
  62832. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62833. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62834. * @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
  62835. */
  62836. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62837. private _depthReducer;
  62838. private _autoCalcDepthBounds;
  62839. /**
  62840. * Gets or sets the autoCalcDepthBounds property.
  62841. *
  62842. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62843. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62844. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62845. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62846. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62847. */
  62848. get autoCalcDepthBounds(): boolean;
  62849. set autoCalcDepthBounds(value: boolean);
  62850. /**
  62851. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62852. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62853. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62854. * for setting the refresh rate on the renderer yourself!
  62855. */
  62856. get autoCalcDepthBoundsRefreshRate(): number;
  62857. set autoCalcDepthBoundsRefreshRate(value: number);
  62858. /**
  62859. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62860. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62861. * you change the camera near/far planes!
  62862. */
  62863. splitFrustum(): void;
  62864. private _splitFrustum;
  62865. private _computeMatrices;
  62866. private _computeFrustumInWorldSpace;
  62867. private _computeCascadeFrustum;
  62868. /**
  62869. * Support test.
  62870. */
  62871. static get IsSupported(): boolean;
  62872. /** @hidden */
  62873. static _SceneComponentInitialization: (scene: Scene) => void;
  62874. /**
  62875. * Creates a Cascaded Shadow Generator object.
  62876. * A ShadowGenerator is the required tool to use the shadows.
  62877. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62878. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62879. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62880. * @param light The directional light object generating the shadows.
  62881. * @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.
  62882. */
  62883. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62884. protected _initializeGenerator(): void;
  62885. protected _createTargetRenderTexture(): void;
  62886. protected _initializeShadowMap(): void;
  62887. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62888. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62889. /**
  62890. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62891. * @param defines Defines of the material we want to update
  62892. * @param lightIndex Index of the light in the enabled light list of the material
  62893. */
  62894. prepareDefines(defines: any, lightIndex: number): void;
  62895. /**
  62896. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62897. * defined in the generator but impacting the effect).
  62898. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62899. * @param effect The effect we are binfing the information for
  62900. */
  62901. bindShadowLight(lightIndex: string, effect: Effect): void;
  62902. /**
  62903. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62904. * (eq to view projection * shadow projection matrices)
  62905. * @returns The transform matrix used to create the shadow map
  62906. */
  62907. getTransformMatrix(): Matrix;
  62908. /**
  62909. * Disposes the ShadowGenerator.
  62910. * Returns nothing.
  62911. */
  62912. dispose(): void;
  62913. /**
  62914. * Serializes the shadow generator setup to a json object.
  62915. * @returns The serialized JSON object
  62916. */
  62917. serialize(): any;
  62918. /**
  62919. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62920. * @param parsedShadowGenerator The JSON object to parse
  62921. * @param scene The scene to create the shadow map for
  62922. * @returns The parsed shadow generator
  62923. */
  62924. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62925. }
  62926. }
  62927. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62928. import { Scene } from "babylonjs/scene";
  62929. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62930. import { AbstractScene } from "babylonjs/abstractScene";
  62931. /**
  62932. * Defines the shadow generator component responsible to manage any shadow generators
  62933. * in a given scene.
  62934. */
  62935. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62936. /**
  62937. * The component name helpfull to identify the component in the list of scene components.
  62938. */
  62939. readonly name: string;
  62940. /**
  62941. * The scene the component belongs to.
  62942. */
  62943. scene: Scene;
  62944. /**
  62945. * Creates a new instance of the component for the given scene
  62946. * @param scene Defines the scene to register the component in
  62947. */
  62948. constructor(scene: Scene);
  62949. /**
  62950. * Registers the component in a given scene
  62951. */
  62952. register(): void;
  62953. /**
  62954. * Rebuilds the elements related to this component in case of
  62955. * context lost for instance.
  62956. */
  62957. rebuild(): void;
  62958. /**
  62959. * Serializes the component data to the specified json object
  62960. * @param serializationObject The object to serialize to
  62961. */
  62962. serialize(serializationObject: any): void;
  62963. /**
  62964. * Adds all the elements from the container to the scene
  62965. * @param container the container holding the elements
  62966. */
  62967. addFromContainer(container: AbstractScene): void;
  62968. /**
  62969. * Removes all the elements in the container from the scene
  62970. * @param container contains the elements to remove
  62971. * @param dispose if the removed element should be disposed (default: false)
  62972. */
  62973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62974. /**
  62975. * Rebuilds the elements related to this component in case of
  62976. * context lost for instance.
  62977. */
  62978. dispose(): void;
  62979. private _gatherRenderTargets;
  62980. }
  62981. }
  62982. declare module "babylonjs/Lights/Shadows/index" {
  62983. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62984. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62985. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62986. }
  62987. declare module "babylonjs/Lights/pointLight" {
  62988. import { Scene } from "babylonjs/scene";
  62989. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62991. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62992. import { Effect } from "babylonjs/Materials/effect";
  62993. /**
  62994. * A point light is a light defined by an unique point in world space.
  62995. * The light is emitted in every direction from this point.
  62996. * A good example of a point light is a standard light bulb.
  62997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62998. */
  62999. export class PointLight extends ShadowLight {
  63000. private _shadowAngle;
  63001. /**
  63002. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63003. * This specifies what angle the shadow will use to be created.
  63004. *
  63005. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63006. */
  63007. get shadowAngle(): number;
  63008. /**
  63009. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63010. * This specifies what angle the shadow will use to be created.
  63011. *
  63012. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63013. */
  63014. set shadowAngle(value: number);
  63015. /**
  63016. * Gets the direction if it has been set.
  63017. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63018. */
  63019. get direction(): Vector3;
  63020. /**
  63021. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63022. */
  63023. set direction(value: Vector3);
  63024. /**
  63025. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63026. * A PointLight emits the light in every direction.
  63027. * It can cast shadows.
  63028. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63029. * ```javascript
  63030. * var pointLight = new PointLight("pl", camera.position, scene);
  63031. * ```
  63032. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63033. * @param name The light friendly name
  63034. * @param position The position of the point light in the scene
  63035. * @param scene The scene the lights belongs to
  63036. */
  63037. constructor(name: string, position: Vector3, scene: Scene);
  63038. /**
  63039. * Returns the string "PointLight"
  63040. * @returns the class name
  63041. */
  63042. getClassName(): string;
  63043. /**
  63044. * Returns the integer 0.
  63045. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63046. */
  63047. getTypeID(): number;
  63048. /**
  63049. * Specifies wether or not the shadowmap should be a cube texture.
  63050. * @returns true if the shadowmap needs to be a cube texture.
  63051. */
  63052. needCube(): boolean;
  63053. /**
  63054. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63055. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63056. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63057. */
  63058. getShadowDirection(faceIndex?: number): Vector3;
  63059. /**
  63060. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63061. * - fov = PI / 2
  63062. * - aspect ratio : 1.0
  63063. * - z-near and far equal to the active camera minZ and maxZ.
  63064. * Returns the PointLight.
  63065. */
  63066. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63067. protected _buildUniformLayout(): void;
  63068. /**
  63069. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63070. * @param effect The effect to update
  63071. * @param lightIndex The index of the light in the effect to update
  63072. * @returns The point light
  63073. */
  63074. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63075. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63076. /**
  63077. * Prepares the list of defines specific to the light type.
  63078. * @param defines the list of defines
  63079. * @param lightIndex defines the index of the light for the effect
  63080. */
  63081. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63082. }
  63083. }
  63084. declare module "babylonjs/Lights/index" {
  63085. export * from "babylonjs/Lights/light";
  63086. export * from "babylonjs/Lights/shadowLight";
  63087. export * from "babylonjs/Lights/Shadows/index";
  63088. export * from "babylonjs/Lights/directionalLight";
  63089. export * from "babylonjs/Lights/hemisphericLight";
  63090. export * from "babylonjs/Lights/pointLight";
  63091. export * from "babylonjs/Lights/spotLight";
  63092. }
  63093. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63094. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63095. /**
  63096. * Header information of HDR texture files.
  63097. */
  63098. export interface HDRInfo {
  63099. /**
  63100. * The height of the texture in pixels.
  63101. */
  63102. height: number;
  63103. /**
  63104. * The width of the texture in pixels.
  63105. */
  63106. width: number;
  63107. /**
  63108. * The index of the beginning of the data in the binary file.
  63109. */
  63110. dataPosition: number;
  63111. }
  63112. /**
  63113. * This groups tools to convert HDR texture to native colors array.
  63114. */
  63115. export class HDRTools {
  63116. private static Ldexp;
  63117. private static Rgbe2float;
  63118. private static readStringLine;
  63119. /**
  63120. * Reads header information from an RGBE texture stored in a native array.
  63121. * More information on this format are available here:
  63122. * https://en.wikipedia.org/wiki/RGBE_image_format
  63123. *
  63124. * @param uint8array The binary file stored in native array.
  63125. * @return The header information.
  63126. */
  63127. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63128. /**
  63129. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63130. * This RGBE texture needs to store the information as a panorama.
  63131. *
  63132. * More information on this format are available here:
  63133. * https://en.wikipedia.org/wiki/RGBE_image_format
  63134. *
  63135. * @param buffer The binary file stored in an array buffer.
  63136. * @param size The expected size of the extracted cubemap.
  63137. * @return The Cube Map information.
  63138. */
  63139. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63140. /**
  63141. * Returns the pixels data extracted from an RGBE texture.
  63142. * This pixels will be stored left to right up to down in the R G B order in one array.
  63143. *
  63144. * More information on this format are available here:
  63145. * https://en.wikipedia.org/wiki/RGBE_image_format
  63146. *
  63147. * @param uint8array The binary file stored in an array buffer.
  63148. * @param hdrInfo The header information of the file.
  63149. * @return The pixels data in RGB right to left up to down order.
  63150. */
  63151. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63152. private static RGBE_ReadPixels_RLE;
  63153. private static RGBE_ReadPixels_NOT_RLE;
  63154. }
  63155. }
  63156. declare module "babylonjs/Materials/effectRenderer" {
  63157. import { Nullable } from "babylonjs/types";
  63158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63159. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63160. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63161. import { Viewport } from "babylonjs/Maths/math.viewport";
  63162. import { Observable } from "babylonjs/Misc/observable";
  63163. import { Effect } from "babylonjs/Materials/effect";
  63164. import "babylonjs/Shaders/postprocess.vertex";
  63165. /**
  63166. * Effect Render Options
  63167. */
  63168. export interface IEffectRendererOptions {
  63169. /**
  63170. * Defines the vertices positions.
  63171. */
  63172. positions?: number[];
  63173. /**
  63174. * Defines the indices.
  63175. */
  63176. indices?: number[];
  63177. }
  63178. /**
  63179. * Helper class to render one or more effects.
  63180. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63181. */
  63182. export class EffectRenderer {
  63183. private engine;
  63184. private static _DefaultOptions;
  63185. private _vertexBuffers;
  63186. private _indexBuffer;
  63187. private _fullscreenViewport;
  63188. /**
  63189. * Creates an effect renderer
  63190. * @param engine the engine to use for rendering
  63191. * @param options defines the options of the effect renderer
  63192. */
  63193. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63194. /**
  63195. * Sets the current viewport in normalized coordinates 0-1
  63196. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63197. */
  63198. setViewport(viewport?: Viewport): void;
  63199. /**
  63200. * Binds the embedded attributes buffer to the effect.
  63201. * @param effect Defines the effect to bind the attributes for
  63202. */
  63203. bindBuffers(effect: Effect): void;
  63204. /**
  63205. * Sets the current effect wrapper to use during draw.
  63206. * The effect needs to be ready before calling this api.
  63207. * This also sets the default full screen position attribute.
  63208. * @param effectWrapper Defines the effect to draw with
  63209. */
  63210. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63211. /**
  63212. * Restores engine states
  63213. */
  63214. restoreStates(): void;
  63215. /**
  63216. * Draws a full screen quad.
  63217. */
  63218. draw(): void;
  63219. private isRenderTargetTexture;
  63220. /**
  63221. * renders one or more effects to a specified texture
  63222. * @param effectWrapper the effect to renderer
  63223. * @param outputTexture texture to draw to, if null it will render to the screen.
  63224. */
  63225. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63226. /**
  63227. * Disposes of the effect renderer
  63228. */
  63229. dispose(): void;
  63230. }
  63231. /**
  63232. * Options to create an EffectWrapper
  63233. */
  63234. interface EffectWrapperCreationOptions {
  63235. /**
  63236. * Engine to use to create the effect
  63237. */
  63238. engine: ThinEngine;
  63239. /**
  63240. * Fragment shader for the effect
  63241. */
  63242. fragmentShader: string;
  63243. /**
  63244. * Use the shader store instead of direct source code
  63245. */
  63246. useShaderStore?: boolean;
  63247. /**
  63248. * Vertex shader for the effect
  63249. */
  63250. vertexShader?: string;
  63251. /**
  63252. * Attributes to use in the shader
  63253. */
  63254. attributeNames?: Array<string>;
  63255. /**
  63256. * Uniforms to use in the shader
  63257. */
  63258. uniformNames?: Array<string>;
  63259. /**
  63260. * Texture sampler names to use in the shader
  63261. */
  63262. samplerNames?: Array<string>;
  63263. /**
  63264. * Defines to use in the shader
  63265. */
  63266. defines?: Array<string>;
  63267. /**
  63268. * Callback when effect is compiled
  63269. */
  63270. onCompiled?: Nullable<(effect: Effect) => void>;
  63271. /**
  63272. * The friendly name of the effect displayed in Spector.
  63273. */
  63274. name?: string;
  63275. }
  63276. /**
  63277. * Wraps an effect to be used for rendering
  63278. */
  63279. export class EffectWrapper {
  63280. /**
  63281. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63282. */
  63283. onApplyObservable: Observable<{}>;
  63284. /**
  63285. * The underlying effect
  63286. */
  63287. effect: Effect;
  63288. /**
  63289. * Creates an effect to be renderer
  63290. * @param creationOptions options to create the effect
  63291. */
  63292. constructor(creationOptions: EffectWrapperCreationOptions);
  63293. /**
  63294. * Disposes of the effect wrapper
  63295. */
  63296. dispose(): void;
  63297. }
  63298. }
  63299. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63300. /** @hidden */
  63301. export var hdrFilteringVertexShader: {
  63302. name: string;
  63303. shader: string;
  63304. };
  63305. }
  63306. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63308. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63309. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63310. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63311. /** @hidden */
  63312. export var hdrFilteringPixelShader: {
  63313. name: string;
  63314. shader: string;
  63315. };
  63316. }
  63317. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63319. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63320. import { Nullable } from "babylonjs/types";
  63321. import "babylonjs/Shaders/hdrFiltering.vertex";
  63322. import "babylonjs/Shaders/hdrFiltering.fragment";
  63323. /**
  63324. * Options for texture filtering
  63325. */
  63326. interface IHDRFilteringOptions {
  63327. /**
  63328. * Scales pixel intensity for the input HDR map.
  63329. */
  63330. hdrScale?: number;
  63331. /**
  63332. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63333. */
  63334. quality?: number;
  63335. }
  63336. /**
  63337. * Filters HDR maps to get correct renderings of PBR reflections
  63338. */
  63339. export class HDRFiltering {
  63340. private _engine;
  63341. private _effectRenderer;
  63342. private _effectWrapper;
  63343. private _lodGenerationOffset;
  63344. private _lodGenerationScale;
  63345. /**
  63346. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63347. * you care about baking speed.
  63348. */
  63349. quality: number;
  63350. /**
  63351. * Scales pixel intensity for the input HDR map.
  63352. */
  63353. hdrScale: number;
  63354. /**
  63355. * Instantiates HDR filter for reflection maps
  63356. *
  63357. * @param engine Thin engine
  63358. * @param options Options
  63359. */
  63360. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63361. private _createRenderTarget;
  63362. private _prefilterInternal;
  63363. private _createEffect;
  63364. /**
  63365. * Get a value indicating if the filter is ready to be used
  63366. * @param texture Texture to filter
  63367. * @returns true if the filter is ready
  63368. */
  63369. isReady(texture: BaseTexture): boolean;
  63370. /**
  63371. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63372. * Prefiltering will be invoked at the end of next rendering pass.
  63373. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63374. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63375. * @param texture Texture to filter
  63376. * @param onFinished Callback when filtering is done
  63377. * @return Promise called when prefiltering is done
  63378. */
  63379. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63380. }
  63381. }
  63382. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63383. import { Nullable } from "babylonjs/types";
  63384. import { Scene } from "babylonjs/scene";
  63385. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63388. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63389. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63390. /**
  63391. * This represents a texture coming from an HDR input.
  63392. *
  63393. * The only supported format is currently panorama picture stored in RGBE format.
  63394. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63395. */
  63396. export class HDRCubeTexture extends BaseTexture {
  63397. private static _facesMapping;
  63398. private _generateHarmonics;
  63399. private _noMipmap;
  63400. private _prefilterOnLoad;
  63401. private _textureMatrix;
  63402. private _size;
  63403. private _onLoad;
  63404. private _onError;
  63405. /**
  63406. * The texture URL.
  63407. */
  63408. url: string;
  63409. protected _isBlocking: boolean;
  63410. /**
  63411. * Sets wether or not the texture is blocking during loading.
  63412. */
  63413. set isBlocking(value: boolean);
  63414. /**
  63415. * Gets wether or not the texture is blocking during loading.
  63416. */
  63417. get isBlocking(): boolean;
  63418. protected _rotationY: number;
  63419. /**
  63420. * Sets texture matrix rotation angle around Y axis in radians.
  63421. */
  63422. set rotationY(value: number);
  63423. /**
  63424. * Gets texture matrix rotation angle around Y axis radians.
  63425. */
  63426. get rotationY(): number;
  63427. /**
  63428. * Gets or sets the center of the bounding box associated with the cube texture
  63429. * It must define where the camera used to render the texture was set
  63430. */
  63431. boundingBoxPosition: Vector3;
  63432. private _boundingBoxSize;
  63433. /**
  63434. * Gets or sets the size of the bounding box associated with the cube texture
  63435. * When defined, the cubemap will switch to local mode
  63436. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63437. * @example https://www.babylonjs-playground.com/#RNASML
  63438. */
  63439. set boundingBoxSize(value: Vector3);
  63440. get boundingBoxSize(): Vector3;
  63441. /**
  63442. * Instantiates an HDRTexture from the following parameters.
  63443. *
  63444. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63445. * @param sceneOrEngine The scene or engine the texture will be used in
  63446. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63447. * @param noMipmap Forces to not generate the mipmap if true
  63448. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63449. * @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)
  63450. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63451. */
  63452. 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>);
  63453. /**
  63454. * Get the current class name of the texture useful for serialization or dynamic coding.
  63455. * @returns "HDRCubeTexture"
  63456. */
  63457. getClassName(): string;
  63458. /**
  63459. * Occurs when the file is raw .hdr file.
  63460. */
  63461. private loadTexture;
  63462. clone(): HDRCubeTexture;
  63463. delayLoad(): void;
  63464. /**
  63465. * Get the texture reflection matrix used to rotate/transform the reflection.
  63466. * @returns the reflection matrix
  63467. */
  63468. getReflectionTextureMatrix(): Matrix;
  63469. /**
  63470. * Set the texture reflection matrix used to rotate/transform the reflection.
  63471. * @param value Define the reflection matrix to set
  63472. */
  63473. setReflectionTextureMatrix(value: Matrix): void;
  63474. /**
  63475. * Parses a JSON representation of an HDR Texture in order to create the texture
  63476. * @param parsedTexture Define the JSON representation
  63477. * @param scene Define the scene the texture should be created in
  63478. * @param rootUrl Define the root url in case we need to load relative dependencies
  63479. * @returns the newly created texture after parsing
  63480. */
  63481. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63482. serialize(): any;
  63483. }
  63484. }
  63485. declare module "babylonjs/Physics/physicsEngine" {
  63486. import { Nullable } from "babylonjs/types";
  63487. import { Vector3 } from "babylonjs/Maths/math.vector";
  63488. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63489. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63490. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63491. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63492. /**
  63493. * Class used to control physics engine
  63494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63495. */
  63496. export class PhysicsEngine implements IPhysicsEngine {
  63497. private _physicsPlugin;
  63498. /**
  63499. * Global value used to control the smallest number supported by the simulation
  63500. */
  63501. static Epsilon: number;
  63502. private _impostors;
  63503. private _joints;
  63504. private _subTimeStep;
  63505. /**
  63506. * Gets the gravity vector used by the simulation
  63507. */
  63508. gravity: Vector3;
  63509. /**
  63510. * Factory used to create the default physics plugin.
  63511. * @returns The default physics plugin
  63512. */
  63513. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63514. /**
  63515. * Creates a new Physics Engine
  63516. * @param gravity defines the gravity vector used by the simulation
  63517. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63518. */
  63519. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63520. /**
  63521. * Sets the gravity vector used by the simulation
  63522. * @param gravity defines the gravity vector to use
  63523. */
  63524. setGravity(gravity: Vector3): void;
  63525. /**
  63526. * Set the time step of the physics engine.
  63527. * Default is 1/60.
  63528. * To slow it down, enter 1/600 for example.
  63529. * To speed it up, 1/30
  63530. * @param newTimeStep defines the new timestep to apply to this world.
  63531. */
  63532. setTimeStep(newTimeStep?: number): void;
  63533. /**
  63534. * Get the time step of the physics engine.
  63535. * @returns the current time step
  63536. */
  63537. getTimeStep(): number;
  63538. /**
  63539. * Set the sub time step of the physics engine.
  63540. * Default is 0 meaning there is no sub steps
  63541. * To increase physics resolution precision, set a small value (like 1 ms)
  63542. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63543. */
  63544. setSubTimeStep(subTimeStep?: number): void;
  63545. /**
  63546. * Get the sub time step of the physics engine.
  63547. * @returns the current sub time step
  63548. */
  63549. getSubTimeStep(): number;
  63550. /**
  63551. * Release all resources
  63552. */
  63553. dispose(): void;
  63554. /**
  63555. * Gets the name of the current physics plugin
  63556. * @returns the name of the plugin
  63557. */
  63558. getPhysicsPluginName(): string;
  63559. /**
  63560. * Adding a new impostor for the impostor tracking.
  63561. * This will be done by the impostor itself.
  63562. * @param impostor the impostor to add
  63563. */
  63564. addImpostor(impostor: PhysicsImpostor): void;
  63565. /**
  63566. * Remove an impostor from the engine.
  63567. * This impostor and its mesh will not longer be updated by the physics engine.
  63568. * @param impostor the impostor to remove
  63569. */
  63570. removeImpostor(impostor: PhysicsImpostor): void;
  63571. /**
  63572. * Add a joint to the physics engine
  63573. * @param mainImpostor defines the main impostor to which the joint is added.
  63574. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63575. * @param joint defines the joint that will connect both impostors.
  63576. */
  63577. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63578. /**
  63579. * Removes a joint from the simulation
  63580. * @param mainImpostor defines the impostor used with the joint
  63581. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63582. * @param joint defines the joint to remove
  63583. */
  63584. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63585. /**
  63586. * Called by the scene. No need to call it.
  63587. * @param delta defines the timespam between frames
  63588. */
  63589. _step(delta: number): void;
  63590. /**
  63591. * Gets the current plugin used to run the simulation
  63592. * @returns current plugin
  63593. */
  63594. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63595. /**
  63596. * Gets the list of physic impostors
  63597. * @returns an array of PhysicsImpostor
  63598. */
  63599. getImpostors(): Array<PhysicsImpostor>;
  63600. /**
  63601. * Gets the impostor for a physics enabled object
  63602. * @param object defines the object impersonated by the impostor
  63603. * @returns the PhysicsImpostor or null if not found
  63604. */
  63605. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63606. /**
  63607. * Gets the impostor for a physics body object
  63608. * @param body defines physics body used by the impostor
  63609. * @returns the PhysicsImpostor or null if not found
  63610. */
  63611. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63612. /**
  63613. * Does a raycast in the physics world
  63614. * @param from when should the ray start?
  63615. * @param to when should the ray end?
  63616. * @returns PhysicsRaycastResult
  63617. */
  63618. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63619. }
  63620. }
  63621. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63622. import { Nullable } from "babylonjs/types";
  63623. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63625. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63626. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63627. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63628. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63629. /** @hidden */
  63630. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63631. private _useDeltaForWorldStep;
  63632. world: any;
  63633. name: string;
  63634. private _physicsMaterials;
  63635. private _fixedTimeStep;
  63636. private _cannonRaycastResult;
  63637. private _raycastResult;
  63638. private _physicsBodysToRemoveAfterStep;
  63639. private _firstFrame;
  63640. BJSCANNON: any;
  63641. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63642. setGravity(gravity: Vector3): void;
  63643. setTimeStep(timeStep: number): void;
  63644. getTimeStep(): number;
  63645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63646. private _removeMarkedPhysicsBodiesFromWorld;
  63647. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63648. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63649. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63650. private _processChildMeshes;
  63651. removePhysicsBody(impostor: PhysicsImpostor): void;
  63652. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63653. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63654. private _addMaterial;
  63655. private _checkWithEpsilon;
  63656. private _createShape;
  63657. private _createHeightmap;
  63658. private _minus90X;
  63659. private _plus90X;
  63660. private _tmpPosition;
  63661. private _tmpDeltaPosition;
  63662. private _tmpUnityRotation;
  63663. private _updatePhysicsBodyTransformation;
  63664. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63665. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63666. isSupported(): boolean;
  63667. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63668. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63669. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63670. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63671. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63672. getBodyMass(impostor: PhysicsImpostor): number;
  63673. getBodyFriction(impostor: PhysicsImpostor): number;
  63674. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63675. getBodyRestitution(impostor: PhysicsImpostor): number;
  63676. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63677. sleepBody(impostor: PhysicsImpostor): void;
  63678. wakeUpBody(impostor: PhysicsImpostor): void;
  63679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63680. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63681. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63682. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63683. getRadius(impostor: PhysicsImpostor): number;
  63684. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63685. dispose(): void;
  63686. private _extendNamespace;
  63687. /**
  63688. * Does a raycast in the physics world
  63689. * @param from when should the ray start?
  63690. * @param to when should the ray end?
  63691. * @returns PhysicsRaycastResult
  63692. */
  63693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63694. }
  63695. }
  63696. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63697. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63698. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63699. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63701. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63702. import { Nullable } from "babylonjs/types";
  63703. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63704. /** @hidden */
  63705. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63706. private _useDeltaForWorldStep;
  63707. world: any;
  63708. name: string;
  63709. BJSOIMO: any;
  63710. private _raycastResult;
  63711. private _fixedTimeStep;
  63712. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63713. setGravity(gravity: Vector3): void;
  63714. setTimeStep(timeStep: number): void;
  63715. getTimeStep(): number;
  63716. private _tmpImpostorsArray;
  63717. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63719. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63720. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63721. private _tmpPositionVector;
  63722. removePhysicsBody(impostor: PhysicsImpostor): void;
  63723. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63725. isSupported(): boolean;
  63726. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63727. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63728. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63729. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63730. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63731. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63732. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63733. getBodyMass(impostor: PhysicsImpostor): number;
  63734. getBodyFriction(impostor: PhysicsImpostor): number;
  63735. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63736. getBodyRestitution(impostor: PhysicsImpostor): number;
  63737. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63738. sleepBody(impostor: PhysicsImpostor): void;
  63739. wakeUpBody(impostor: PhysicsImpostor): void;
  63740. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63741. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63742. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63743. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63744. getRadius(impostor: PhysicsImpostor): number;
  63745. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63746. dispose(): void;
  63747. /**
  63748. * Does a raycast in the physics world
  63749. * @param from when should the ray start?
  63750. * @param to when should the ray end?
  63751. * @returns PhysicsRaycastResult
  63752. */
  63753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63754. }
  63755. }
  63756. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63757. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63758. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63759. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63760. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63761. import { Nullable } from "babylonjs/types";
  63762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63764. /**
  63765. * AmmoJS Physics plugin
  63766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63767. * @see https://github.com/kripken/ammo.js/
  63768. */
  63769. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63770. private _useDeltaForWorldStep;
  63771. /**
  63772. * Reference to the Ammo library
  63773. */
  63774. bjsAMMO: any;
  63775. /**
  63776. * Created ammoJS world which physics bodies are added to
  63777. */
  63778. world: any;
  63779. /**
  63780. * Name of the plugin
  63781. */
  63782. name: string;
  63783. private _timeStep;
  63784. private _fixedTimeStep;
  63785. private _maxSteps;
  63786. private _tmpQuaternion;
  63787. private _tmpAmmoTransform;
  63788. private _tmpAmmoQuaternion;
  63789. private _tmpAmmoConcreteContactResultCallback;
  63790. private _collisionConfiguration;
  63791. private _dispatcher;
  63792. private _overlappingPairCache;
  63793. private _solver;
  63794. private _softBodySolver;
  63795. private _tmpAmmoVectorA;
  63796. private _tmpAmmoVectorB;
  63797. private _tmpAmmoVectorC;
  63798. private _tmpAmmoVectorD;
  63799. private _tmpContactCallbackResult;
  63800. private _tmpAmmoVectorRCA;
  63801. private _tmpAmmoVectorRCB;
  63802. private _raycastResult;
  63803. private static readonly DISABLE_COLLISION_FLAG;
  63804. private static readonly KINEMATIC_FLAG;
  63805. private static readonly DISABLE_DEACTIVATION_FLAG;
  63806. /**
  63807. * Initializes the ammoJS plugin
  63808. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63809. * @param ammoInjection can be used to inject your own ammo reference
  63810. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63811. */
  63812. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63813. /**
  63814. * Sets the gravity of the physics world (m/(s^2))
  63815. * @param gravity Gravity to set
  63816. */
  63817. setGravity(gravity: Vector3): void;
  63818. /**
  63819. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63820. * @param timeStep timestep to use in seconds
  63821. */
  63822. setTimeStep(timeStep: number): void;
  63823. /**
  63824. * 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)
  63825. * @param fixedTimeStep fixedTimeStep to use in seconds
  63826. */
  63827. setFixedTimeStep(fixedTimeStep: number): void;
  63828. /**
  63829. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63830. * @param maxSteps the maximum number of steps by the physics engine per frame
  63831. */
  63832. setMaxSteps(maxSteps: number): void;
  63833. /**
  63834. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63835. * @returns the current timestep in seconds
  63836. */
  63837. getTimeStep(): number;
  63838. /**
  63839. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63840. */
  63841. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63842. private _isImpostorInContact;
  63843. private _isImpostorPairInContact;
  63844. private _stepSimulation;
  63845. /**
  63846. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63847. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63848. * After the step the babylon meshes are set to the position of the physics imposters
  63849. * @param delta amount of time to step forward
  63850. * @param impostors array of imposters to update before/after the step
  63851. */
  63852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63853. /**
  63854. * Update babylon mesh to match physics world object
  63855. * @param impostor imposter to match
  63856. */
  63857. private _afterSoftStep;
  63858. /**
  63859. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63860. * @param impostor imposter to match
  63861. */
  63862. private _ropeStep;
  63863. /**
  63864. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63865. * @param impostor imposter to match
  63866. */
  63867. private _softbodyOrClothStep;
  63868. private _tmpMatrix;
  63869. /**
  63870. * Applies an impulse on the imposter
  63871. * @param impostor imposter to apply impulse to
  63872. * @param force amount of force to be applied to the imposter
  63873. * @param contactPoint the location to apply the impulse on the imposter
  63874. */
  63875. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63876. /**
  63877. * Applies a force on the imposter
  63878. * @param impostor imposter to apply force
  63879. * @param force amount of force to be applied to the imposter
  63880. * @param contactPoint the location to apply the force on the imposter
  63881. */
  63882. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63883. /**
  63884. * Creates a physics body using the plugin
  63885. * @param impostor the imposter to create the physics body on
  63886. */
  63887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63888. /**
  63889. * Removes the physics body from the imposter and disposes of the body's memory
  63890. * @param impostor imposter to remove the physics body from
  63891. */
  63892. removePhysicsBody(impostor: PhysicsImpostor): void;
  63893. /**
  63894. * Generates a joint
  63895. * @param impostorJoint the imposter joint to create the joint with
  63896. */
  63897. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63898. /**
  63899. * Removes a joint
  63900. * @param impostorJoint the imposter joint to remove the joint from
  63901. */
  63902. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63903. private _addMeshVerts;
  63904. /**
  63905. * Initialise the soft body vertices to match its object's (mesh) vertices
  63906. * Softbody vertices (nodes) are in world space and to match this
  63907. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63908. * @param impostor to create the softbody for
  63909. */
  63910. private _softVertexData;
  63911. /**
  63912. * Create an impostor's soft body
  63913. * @param impostor to create the softbody for
  63914. */
  63915. private _createSoftbody;
  63916. /**
  63917. * Create cloth for an impostor
  63918. * @param impostor to create the softbody for
  63919. */
  63920. private _createCloth;
  63921. /**
  63922. * Create rope for an impostor
  63923. * @param impostor to create the softbody for
  63924. */
  63925. private _createRope;
  63926. /**
  63927. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63928. * @param impostor to create the custom physics shape for
  63929. */
  63930. private _createCustom;
  63931. private _addHullVerts;
  63932. private _createShape;
  63933. /**
  63934. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63935. * @param impostor imposter containing the physics body and babylon object
  63936. */
  63937. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63938. /**
  63939. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63940. * @param impostor imposter containing the physics body and babylon object
  63941. * @param newPosition new position
  63942. * @param newRotation new rotation
  63943. */
  63944. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63945. /**
  63946. * If this plugin is supported
  63947. * @returns true if its supported
  63948. */
  63949. isSupported(): boolean;
  63950. /**
  63951. * Sets the linear velocity of the physics body
  63952. * @param impostor imposter to set the velocity on
  63953. * @param velocity velocity to set
  63954. */
  63955. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63956. /**
  63957. * Sets the angular velocity of the physics body
  63958. * @param impostor imposter to set the velocity on
  63959. * @param velocity velocity to set
  63960. */
  63961. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63962. /**
  63963. * gets the linear velocity
  63964. * @param impostor imposter to get linear velocity from
  63965. * @returns linear velocity
  63966. */
  63967. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63968. /**
  63969. * gets the angular velocity
  63970. * @param impostor imposter to get angular velocity from
  63971. * @returns angular velocity
  63972. */
  63973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63974. /**
  63975. * Sets the mass of physics body
  63976. * @param impostor imposter to set the mass on
  63977. * @param mass mass to set
  63978. */
  63979. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63980. /**
  63981. * Gets the mass of the physics body
  63982. * @param impostor imposter to get the mass from
  63983. * @returns mass
  63984. */
  63985. getBodyMass(impostor: PhysicsImpostor): number;
  63986. /**
  63987. * Gets friction of the impostor
  63988. * @param impostor impostor to get friction from
  63989. * @returns friction value
  63990. */
  63991. getBodyFriction(impostor: PhysicsImpostor): number;
  63992. /**
  63993. * Sets friction of the impostor
  63994. * @param impostor impostor to set friction on
  63995. * @param friction friction value
  63996. */
  63997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63998. /**
  63999. * Gets restitution of the impostor
  64000. * @param impostor impostor to get restitution from
  64001. * @returns restitution value
  64002. */
  64003. getBodyRestitution(impostor: PhysicsImpostor): number;
  64004. /**
  64005. * Sets resitution of the impostor
  64006. * @param impostor impostor to set resitution on
  64007. * @param restitution resitution value
  64008. */
  64009. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64010. /**
  64011. * Gets pressure inside the impostor
  64012. * @param impostor impostor to get pressure from
  64013. * @returns pressure value
  64014. */
  64015. getBodyPressure(impostor: PhysicsImpostor): number;
  64016. /**
  64017. * Sets pressure inside a soft body impostor
  64018. * Cloth and rope must remain 0 pressure
  64019. * @param impostor impostor to set pressure on
  64020. * @param pressure pressure value
  64021. */
  64022. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64023. /**
  64024. * Gets stiffness of the impostor
  64025. * @param impostor impostor to get stiffness from
  64026. * @returns pressure value
  64027. */
  64028. getBodyStiffness(impostor: PhysicsImpostor): number;
  64029. /**
  64030. * Sets stiffness of the impostor
  64031. * @param impostor impostor to set stiffness on
  64032. * @param stiffness stiffness value from 0 to 1
  64033. */
  64034. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64035. /**
  64036. * Gets velocityIterations of the impostor
  64037. * @param impostor impostor to get velocity iterations from
  64038. * @returns velocityIterations value
  64039. */
  64040. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64041. /**
  64042. * Sets velocityIterations of the impostor
  64043. * @param impostor impostor to set velocity iterations on
  64044. * @param velocityIterations velocityIterations value
  64045. */
  64046. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64047. /**
  64048. * Gets positionIterations of the impostor
  64049. * @param impostor impostor to get position iterations from
  64050. * @returns positionIterations value
  64051. */
  64052. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64053. /**
  64054. * Sets positionIterations of the impostor
  64055. * @param impostor impostor to set position on
  64056. * @param positionIterations positionIterations value
  64057. */
  64058. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64059. /**
  64060. * Append an anchor to a cloth object
  64061. * @param impostor is the cloth impostor to add anchor to
  64062. * @param otherImpostor is the rigid impostor to anchor to
  64063. * @param width ratio across width from 0 to 1
  64064. * @param height ratio up height from 0 to 1
  64065. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64066. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64067. */
  64068. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64069. /**
  64070. * Append an hook to a rope object
  64071. * @param impostor is the rope impostor to add hook to
  64072. * @param otherImpostor is the rigid impostor to hook to
  64073. * @param length ratio along the rope from 0 to 1
  64074. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64075. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64076. */
  64077. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64078. /**
  64079. * Sleeps the physics body and stops it from being active
  64080. * @param impostor impostor to sleep
  64081. */
  64082. sleepBody(impostor: PhysicsImpostor): void;
  64083. /**
  64084. * Activates the physics body
  64085. * @param impostor impostor to activate
  64086. */
  64087. wakeUpBody(impostor: PhysicsImpostor): void;
  64088. /**
  64089. * Updates the distance parameters of the joint
  64090. * @param joint joint to update
  64091. * @param maxDistance maximum distance of the joint
  64092. * @param minDistance minimum distance of the joint
  64093. */
  64094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64095. /**
  64096. * Sets a motor on the joint
  64097. * @param joint joint to set motor on
  64098. * @param speed speed of the motor
  64099. * @param maxForce maximum force of the motor
  64100. * @param motorIndex index of the motor
  64101. */
  64102. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64103. /**
  64104. * Sets the motors limit
  64105. * @param joint joint to set limit on
  64106. * @param upperLimit upper limit
  64107. * @param lowerLimit lower limit
  64108. */
  64109. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64110. /**
  64111. * Syncs the position and rotation of a mesh with the impostor
  64112. * @param mesh mesh to sync
  64113. * @param impostor impostor to update the mesh with
  64114. */
  64115. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64116. /**
  64117. * Gets the radius of the impostor
  64118. * @param impostor impostor to get radius from
  64119. * @returns the radius
  64120. */
  64121. getRadius(impostor: PhysicsImpostor): number;
  64122. /**
  64123. * Gets the box size of the impostor
  64124. * @param impostor impostor to get box size from
  64125. * @param result the resulting box size
  64126. */
  64127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64128. /**
  64129. * Disposes of the impostor
  64130. */
  64131. dispose(): void;
  64132. /**
  64133. * Does a raycast in the physics world
  64134. * @param from when should the ray start?
  64135. * @param to when should the ray end?
  64136. * @returns PhysicsRaycastResult
  64137. */
  64138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64139. }
  64140. }
  64141. declare module "babylonjs/Probes/reflectionProbe" {
  64142. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64143. import { Vector3 } from "babylonjs/Maths/math.vector";
  64144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64145. import { Nullable } from "babylonjs/types";
  64146. import { Scene } from "babylonjs/scene";
  64147. module "babylonjs/abstractScene" {
  64148. interface AbstractScene {
  64149. /**
  64150. * The list of reflection probes added to the scene
  64151. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64152. */
  64153. reflectionProbes: Array<ReflectionProbe>;
  64154. /**
  64155. * Removes the given reflection probe from this scene.
  64156. * @param toRemove The reflection probe to remove
  64157. * @returns The index of the removed reflection probe
  64158. */
  64159. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64160. /**
  64161. * Adds the given reflection probe to this scene.
  64162. * @param newReflectionProbe The reflection probe to add
  64163. */
  64164. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64165. }
  64166. }
  64167. /**
  64168. * Class used to generate realtime reflection / refraction cube textures
  64169. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64170. */
  64171. export class ReflectionProbe {
  64172. /** defines the name of the probe */
  64173. name: string;
  64174. private _scene;
  64175. private _renderTargetTexture;
  64176. private _projectionMatrix;
  64177. private _viewMatrix;
  64178. private _target;
  64179. private _add;
  64180. private _attachedMesh;
  64181. private _invertYAxis;
  64182. /** Gets or sets probe position (center of the cube map) */
  64183. position: Vector3;
  64184. /**
  64185. * Creates a new reflection probe
  64186. * @param name defines the name of the probe
  64187. * @param size defines the texture resolution (for each face)
  64188. * @param scene defines the hosting scene
  64189. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64190. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64191. */
  64192. constructor(
  64193. /** defines the name of the probe */
  64194. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64195. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64196. get samples(): number;
  64197. set samples(value: number);
  64198. /** Gets or sets the refresh rate to use (on every frame by default) */
  64199. get refreshRate(): number;
  64200. set refreshRate(value: number);
  64201. /**
  64202. * Gets the hosting scene
  64203. * @returns a Scene
  64204. */
  64205. getScene(): Scene;
  64206. /** Gets the internal CubeTexture used to render to */
  64207. get cubeTexture(): RenderTargetTexture;
  64208. /** Gets the list of meshes to render */
  64209. get renderList(): Nullable<AbstractMesh[]>;
  64210. /**
  64211. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64212. * @param mesh defines the mesh to attach to
  64213. */
  64214. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64215. /**
  64216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64217. * @param renderingGroupId The rendering group id corresponding to its index
  64218. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64219. */
  64220. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64221. /**
  64222. * Clean all associated resources
  64223. */
  64224. dispose(): void;
  64225. /**
  64226. * Converts the reflection probe information to a readable string for debug purpose.
  64227. * @param fullDetails Supports for multiple levels of logging within scene loading
  64228. * @returns the human readable reflection probe info
  64229. */
  64230. toString(fullDetails?: boolean): string;
  64231. /**
  64232. * Get the class name of the relfection probe.
  64233. * @returns "ReflectionProbe"
  64234. */
  64235. getClassName(): string;
  64236. /**
  64237. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64238. * @returns The JSON representation of the texture
  64239. */
  64240. serialize(): any;
  64241. /**
  64242. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64243. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64244. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64245. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64246. * @returns The parsed reflection probe if successful
  64247. */
  64248. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64249. }
  64250. }
  64251. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64252. /** @hidden */
  64253. export var _BabylonLoaderRegistered: boolean;
  64254. /**
  64255. * Helps setting up some configuration for the babylon file loader.
  64256. */
  64257. export class BabylonFileLoaderConfiguration {
  64258. /**
  64259. * The loader does not allow injecting custom physix engine into the plugins.
  64260. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64261. * So you could set this variable to your engine import to make it work.
  64262. */
  64263. static LoaderInjectedPhysicsEngine: any;
  64264. }
  64265. }
  64266. declare module "babylonjs/Loading/Plugins/index" {
  64267. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64268. }
  64269. declare module "babylonjs/Loading/index" {
  64270. export * from "babylonjs/Loading/loadingScreen";
  64271. export * from "babylonjs/Loading/Plugins/index";
  64272. export * from "babylonjs/Loading/sceneLoader";
  64273. export * from "babylonjs/Loading/sceneLoaderFlags";
  64274. }
  64275. declare module "babylonjs/Materials/Background/index" {
  64276. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64277. }
  64278. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64279. import { Scene } from "babylonjs/scene";
  64280. import { Color3 } from "babylonjs/Maths/math.color";
  64281. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64283. /**
  64284. * The Physically based simple base material of BJS.
  64285. *
  64286. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64287. * It is used as the base class for both the specGloss and metalRough conventions.
  64288. */
  64289. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64290. /**
  64291. * Number of Simultaneous lights allowed on the material.
  64292. */
  64293. maxSimultaneousLights: number;
  64294. /**
  64295. * If sets to true, disables all the lights affecting the material.
  64296. */
  64297. disableLighting: boolean;
  64298. /**
  64299. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64300. */
  64301. environmentTexture: BaseTexture;
  64302. /**
  64303. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64304. */
  64305. invertNormalMapX: boolean;
  64306. /**
  64307. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64308. */
  64309. invertNormalMapY: boolean;
  64310. /**
  64311. * Normal map used in the model.
  64312. */
  64313. normalTexture: BaseTexture;
  64314. /**
  64315. * Emissivie color used to self-illuminate the model.
  64316. */
  64317. emissiveColor: Color3;
  64318. /**
  64319. * Emissivie texture used to self-illuminate the model.
  64320. */
  64321. emissiveTexture: BaseTexture;
  64322. /**
  64323. * Occlusion Channel Strenght.
  64324. */
  64325. occlusionStrength: number;
  64326. /**
  64327. * Occlusion Texture of the material (adding extra occlusion effects).
  64328. */
  64329. occlusionTexture: BaseTexture;
  64330. /**
  64331. * Defines the alpha limits in alpha test mode.
  64332. */
  64333. alphaCutOff: number;
  64334. /**
  64335. * Gets the current double sided mode.
  64336. */
  64337. get doubleSided(): boolean;
  64338. /**
  64339. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64340. */
  64341. set doubleSided(value: boolean);
  64342. /**
  64343. * Stores the pre-calculated light information of a mesh in a texture.
  64344. */
  64345. lightmapTexture: BaseTexture;
  64346. /**
  64347. * If true, the light map contains occlusion information instead of lighting info.
  64348. */
  64349. useLightmapAsShadowmap: boolean;
  64350. /**
  64351. * Instantiates a new PBRMaterial instance.
  64352. *
  64353. * @param name The material name
  64354. * @param scene The scene the material will be use in.
  64355. */
  64356. constructor(name: string, scene: Scene);
  64357. getClassName(): string;
  64358. }
  64359. }
  64360. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64361. import { Scene } from "babylonjs/scene";
  64362. import { Color3 } from "babylonjs/Maths/math.color";
  64363. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64364. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64365. /**
  64366. * The PBR material of BJS following the metal roughness convention.
  64367. *
  64368. * This fits to the PBR convention in the GLTF definition:
  64369. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64370. */
  64371. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64372. /**
  64373. * The base color has two different interpretations depending on the value of metalness.
  64374. * When the material is a metal, the base color is the specific measured reflectance value
  64375. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64376. * of the material.
  64377. */
  64378. baseColor: Color3;
  64379. /**
  64380. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64381. * well as opacity information in the alpha channel.
  64382. */
  64383. baseTexture: BaseTexture;
  64384. /**
  64385. * Specifies the metallic scalar value of the material.
  64386. * Can also be used to scale the metalness values of the metallic texture.
  64387. */
  64388. metallic: number;
  64389. /**
  64390. * Specifies the roughness scalar value of the material.
  64391. * Can also be used to scale the roughness values of the metallic texture.
  64392. */
  64393. roughness: number;
  64394. /**
  64395. * Texture containing both the metallic value in the B channel and the
  64396. * roughness value in the G channel to keep better precision.
  64397. */
  64398. metallicRoughnessTexture: BaseTexture;
  64399. /**
  64400. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64401. *
  64402. * @param name The material name
  64403. * @param scene The scene the material will be use in.
  64404. */
  64405. constructor(name: string, scene: Scene);
  64406. /**
  64407. * Return the currrent class name of the material.
  64408. */
  64409. getClassName(): string;
  64410. /**
  64411. * Makes a duplicate of the current material.
  64412. * @param name - name to use for the new material.
  64413. */
  64414. clone(name: string): PBRMetallicRoughnessMaterial;
  64415. /**
  64416. * Serialize the material to a parsable JSON object.
  64417. */
  64418. serialize(): any;
  64419. /**
  64420. * Parses a JSON object correponding to the serialize function.
  64421. */
  64422. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64423. }
  64424. }
  64425. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64426. import { Scene } from "babylonjs/scene";
  64427. import { Color3 } from "babylonjs/Maths/math.color";
  64428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64429. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64430. /**
  64431. * The PBR material of BJS following the specular glossiness convention.
  64432. *
  64433. * This fits to the PBR convention in the GLTF definition:
  64434. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64435. */
  64436. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64437. /**
  64438. * Specifies the diffuse color of the material.
  64439. */
  64440. diffuseColor: Color3;
  64441. /**
  64442. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64443. * channel.
  64444. */
  64445. diffuseTexture: BaseTexture;
  64446. /**
  64447. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64448. */
  64449. specularColor: Color3;
  64450. /**
  64451. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64452. */
  64453. glossiness: number;
  64454. /**
  64455. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64456. */
  64457. specularGlossinessTexture: BaseTexture;
  64458. /**
  64459. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64460. *
  64461. * @param name The material name
  64462. * @param scene The scene the material will be use in.
  64463. */
  64464. constructor(name: string, scene: Scene);
  64465. /**
  64466. * Return the currrent class name of the material.
  64467. */
  64468. getClassName(): string;
  64469. /**
  64470. * Makes a duplicate of the current material.
  64471. * @param name - name to use for the new material.
  64472. */
  64473. clone(name: string): PBRSpecularGlossinessMaterial;
  64474. /**
  64475. * Serialize the material to a parsable JSON object.
  64476. */
  64477. serialize(): any;
  64478. /**
  64479. * Parses a JSON object correponding to the serialize function.
  64480. */
  64481. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64482. }
  64483. }
  64484. declare module "babylonjs/Materials/PBR/index" {
  64485. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64486. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64487. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64488. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64489. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64490. }
  64491. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64492. import { Nullable } from "babylonjs/types";
  64493. import { Scene } from "babylonjs/scene";
  64494. import { Matrix } from "babylonjs/Maths/math.vector";
  64495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64496. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64497. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64498. /**
  64499. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64500. * It can help converting any input color in a desired output one. This can then be used to create effects
  64501. * from sepia, black and white to sixties or futuristic rendering...
  64502. *
  64503. * The only supported format is currently 3dl.
  64504. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64505. */
  64506. export class ColorGradingTexture extends BaseTexture {
  64507. /**
  64508. * The texture URL.
  64509. */
  64510. url: string;
  64511. /**
  64512. * Empty line regex stored for GC.
  64513. */
  64514. private static _noneEmptyLineRegex;
  64515. private _textureMatrix;
  64516. private _onLoad;
  64517. /**
  64518. * Instantiates a ColorGradingTexture from the following parameters.
  64519. *
  64520. * @param url The location of the color gradind data (currently only supporting 3dl)
  64521. * @param sceneOrEngine The scene or engine the texture will be used in
  64522. * @param onLoad defines a callback triggered when the texture has been loaded
  64523. */
  64524. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64525. /**
  64526. * Fires the onload event from the constructor if requested.
  64527. */
  64528. private _triggerOnLoad;
  64529. /**
  64530. * Returns the texture matrix used in most of the material.
  64531. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64532. */
  64533. getTextureMatrix(): Matrix;
  64534. /**
  64535. * Occurs when the file being loaded is a .3dl LUT file.
  64536. */
  64537. private load3dlTexture;
  64538. /**
  64539. * Starts the loading process of the texture.
  64540. */
  64541. private loadTexture;
  64542. /**
  64543. * Clones the color gradind texture.
  64544. */
  64545. clone(): ColorGradingTexture;
  64546. /**
  64547. * Called during delayed load for textures.
  64548. */
  64549. delayLoad(): void;
  64550. /**
  64551. * Parses a color grading texture serialized by Babylon.
  64552. * @param parsedTexture The texture information being parsedTexture
  64553. * @param scene The scene to load the texture in
  64554. * @param rootUrl The root url of the data assets to load
  64555. * @return A color gradind texture
  64556. */
  64557. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64558. /**
  64559. * Serializes the LUT texture to json format.
  64560. */
  64561. serialize(): any;
  64562. }
  64563. }
  64564. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64566. import { Scene } from "babylonjs/scene";
  64567. import { Nullable } from "babylonjs/types";
  64568. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64569. /**
  64570. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64571. */
  64572. export class EquiRectangularCubeTexture extends BaseTexture {
  64573. /** The six faces of the cube. */
  64574. private static _FacesMapping;
  64575. private _noMipmap;
  64576. private _onLoad;
  64577. private _onError;
  64578. /** The size of the cubemap. */
  64579. private _size;
  64580. /** The buffer of the image. */
  64581. private _buffer;
  64582. /** The width of the input image. */
  64583. private _width;
  64584. /** The height of the input image. */
  64585. private _height;
  64586. /** The URL to the image. */
  64587. url: string;
  64588. /**
  64589. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64590. * @param url The location of the image
  64591. * @param scene The scene the texture will be used in
  64592. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64593. * @param noMipmap Forces to not generate the mipmap if true
  64594. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64595. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64596. * @param onLoad — defines a callback called when texture is loaded
  64597. * @param onError — defines a callback called if there is an error
  64598. */
  64599. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64600. /**
  64601. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64602. */
  64603. private loadImage;
  64604. /**
  64605. * Convert the image buffer into a cubemap and create a CubeTexture.
  64606. */
  64607. private loadTexture;
  64608. /**
  64609. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64610. * @param buffer The ArrayBuffer that should be converted.
  64611. * @returns The buffer as Float32Array.
  64612. */
  64613. private getFloat32ArrayFromArrayBuffer;
  64614. /**
  64615. * Get the current class name of the texture useful for serialization or dynamic coding.
  64616. * @returns "EquiRectangularCubeTexture"
  64617. */
  64618. getClassName(): string;
  64619. /**
  64620. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64621. * @returns A clone of the current EquiRectangularCubeTexture.
  64622. */
  64623. clone(): EquiRectangularCubeTexture;
  64624. }
  64625. }
  64626. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64627. import { Nullable } from "babylonjs/types";
  64628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64629. import { Matrix } from "babylonjs/Maths/math.vector";
  64630. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64631. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64632. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64633. import { Scene } from "babylonjs/scene";
  64634. /**
  64635. * Defines the options related to the creation of an HtmlElementTexture
  64636. */
  64637. export interface IHtmlElementTextureOptions {
  64638. /**
  64639. * Defines wether mip maps should be created or not.
  64640. */
  64641. generateMipMaps?: boolean;
  64642. /**
  64643. * Defines the sampling mode of the texture.
  64644. */
  64645. samplingMode?: number;
  64646. /**
  64647. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64648. */
  64649. engine: Nullable<ThinEngine>;
  64650. /**
  64651. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64652. */
  64653. scene: Nullable<Scene>;
  64654. }
  64655. /**
  64656. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64657. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64658. * is automatically managed.
  64659. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64660. * in your application.
  64661. *
  64662. * As the update is not automatic, you need to call them manually.
  64663. */
  64664. export class HtmlElementTexture extends BaseTexture {
  64665. /**
  64666. * The texture URL.
  64667. */
  64668. element: HTMLVideoElement | HTMLCanvasElement;
  64669. private static readonly DefaultOptions;
  64670. private _textureMatrix;
  64671. private _isVideo;
  64672. private _generateMipMaps;
  64673. private _samplingMode;
  64674. /**
  64675. * Instantiates a HtmlElementTexture from the following parameters.
  64676. *
  64677. * @param name Defines the name of the texture
  64678. * @param element Defines the video or canvas the texture is filled with
  64679. * @param options Defines the other none mandatory texture creation options
  64680. */
  64681. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64682. private _createInternalTexture;
  64683. /**
  64684. * Returns the texture matrix used in most of the material.
  64685. */
  64686. getTextureMatrix(): Matrix;
  64687. /**
  64688. * Updates the content of the texture.
  64689. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64690. */
  64691. update(invertY?: Nullable<boolean>): void;
  64692. }
  64693. }
  64694. declare module "babylonjs/Misc/tga" {
  64695. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64696. /**
  64697. * Based on jsTGALoader - Javascript loader for TGA file
  64698. * By Vincent Thibault
  64699. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64700. */
  64701. export class TGATools {
  64702. private static _TYPE_INDEXED;
  64703. private static _TYPE_RGB;
  64704. private static _TYPE_GREY;
  64705. private static _TYPE_RLE_INDEXED;
  64706. private static _TYPE_RLE_RGB;
  64707. private static _TYPE_RLE_GREY;
  64708. private static _ORIGIN_MASK;
  64709. private static _ORIGIN_SHIFT;
  64710. private static _ORIGIN_BL;
  64711. private static _ORIGIN_BR;
  64712. private static _ORIGIN_UL;
  64713. private static _ORIGIN_UR;
  64714. /**
  64715. * Gets the header of a TGA file
  64716. * @param data defines the TGA data
  64717. * @returns the header
  64718. */
  64719. static GetTGAHeader(data: Uint8Array): any;
  64720. /**
  64721. * Uploads TGA content to a Babylon Texture
  64722. * @hidden
  64723. */
  64724. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64725. /** @hidden */
  64726. 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;
  64727. /** @hidden */
  64728. 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;
  64729. /** @hidden */
  64730. 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;
  64731. /** @hidden */
  64732. 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;
  64733. /** @hidden */
  64734. 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;
  64735. /** @hidden */
  64736. 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;
  64737. }
  64738. }
  64739. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64740. import { Nullable } from "babylonjs/types";
  64741. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64742. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64743. /**
  64744. * Implementation of the TGA Texture Loader.
  64745. * @hidden
  64746. */
  64747. export class _TGATextureLoader implements IInternalTextureLoader {
  64748. /**
  64749. * Defines wether the loader supports cascade loading the different faces.
  64750. */
  64751. readonly supportCascades: boolean;
  64752. /**
  64753. * This returns if the loader support the current file information.
  64754. * @param extension defines the file extension of the file being loaded
  64755. * @returns true if the loader can load the specified file
  64756. */
  64757. canLoad(extension: string): boolean;
  64758. /**
  64759. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64760. * @param data contains the texture data
  64761. * @param texture defines the BabylonJS internal texture
  64762. * @param createPolynomials will be true if polynomials have been requested
  64763. * @param onLoad defines the callback to trigger once the texture is ready
  64764. * @param onError defines the callback to trigger in case of error
  64765. */
  64766. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64767. /**
  64768. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64769. * @param data contains the texture data
  64770. * @param texture defines the BabylonJS internal texture
  64771. * @param callback defines the method to call once ready to upload
  64772. */
  64773. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64774. }
  64775. }
  64776. declare module "babylonjs/Misc/basis" {
  64777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64778. /**
  64779. * Info about the .basis files
  64780. */
  64781. class BasisFileInfo {
  64782. /**
  64783. * If the file has alpha
  64784. */
  64785. hasAlpha: boolean;
  64786. /**
  64787. * Info about each image of the basis file
  64788. */
  64789. images: Array<{
  64790. levels: Array<{
  64791. width: number;
  64792. height: number;
  64793. transcodedPixels: ArrayBufferView;
  64794. }>;
  64795. }>;
  64796. }
  64797. /**
  64798. * Result of transcoding a basis file
  64799. */
  64800. class TranscodeResult {
  64801. /**
  64802. * Info about the .basis file
  64803. */
  64804. fileInfo: BasisFileInfo;
  64805. /**
  64806. * Format to use when loading the file
  64807. */
  64808. format: number;
  64809. }
  64810. /**
  64811. * Configuration options for the Basis transcoder
  64812. */
  64813. export class BasisTranscodeConfiguration {
  64814. /**
  64815. * Supported compression formats used to determine the supported output format of the transcoder
  64816. */
  64817. supportedCompressionFormats?: {
  64818. /**
  64819. * etc1 compression format
  64820. */
  64821. etc1?: boolean;
  64822. /**
  64823. * s3tc compression format
  64824. */
  64825. s3tc?: boolean;
  64826. /**
  64827. * pvrtc compression format
  64828. */
  64829. pvrtc?: boolean;
  64830. /**
  64831. * etc2 compression format
  64832. */
  64833. etc2?: boolean;
  64834. };
  64835. /**
  64836. * If mipmap levels should be loaded for transcoded images (Default: true)
  64837. */
  64838. loadMipmapLevels?: boolean;
  64839. /**
  64840. * Index of a single image to load (Default: all images)
  64841. */
  64842. loadSingleImage?: number;
  64843. }
  64844. /**
  64845. * Used to load .Basis files
  64846. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64847. */
  64848. export class BasisTools {
  64849. private static _IgnoreSupportedFormats;
  64850. /**
  64851. * URL to use when loading the basis transcoder
  64852. */
  64853. static JSModuleURL: string;
  64854. /**
  64855. * URL to use when loading the wasm module for the transcoder
  64856. */
  64857. static WasmModuleURL: string;
  64858. /**
  64859. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64860. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64861. * @returns internal format corresponding to the Basis format
  64862. */
  64863. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64864. private static _WorkerPromise;
  64865. private static _Worker;
  64866. private static _actionId;
  64867. private static _CreateWorkerAsync;
  64868. /**
  64869. * Transcodes a loaded image file to compressed pixel data
  64870. * @param data image data to transcode
  64871. * @param config configuration options for the transcoding
  64872. * @returns a promise resulting in the transcoded image
  64873. */
  64874. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64875. /**
  64876. * Loads a texture from the transcode result
  64877. * @param texture texture load to
  64878. * @param transcodeResult the result of transcoding the basis file to load from
  64879. */
  64880. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64881. }
  64882. }
  64883. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64884. import { Nullable } from "babylonjs/types";
  64885. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64886. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64887. /**
  64888. * Loader for .basis file format
  64889. */
  64890. export class _BasisTextureLoader implements IInternalTextureLoader {
  64891. /**
  64892. * Defines whether the loader supports cascade loading the different faces.
  64893. */
  64894. readonly supportCascades: boolean;
  64895. /**
  64896. * This returns if the loader support the current file information.
  64897. * @param extension defines the file extension of the file being loaded
  64898. * @returns true if the loader can load the specified file
  64899. */
  64900. canLoad(extension: string): boolean;
  64901. /**
  64902. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64903. * @param data contains the texture data
  64904. * @param texture defines the BabylonJS internal texture
  64905. * @param createPolynomials will be true if polynomials have been requested
  64906. * @param onLoad defines the callback to trigger once the texture is ready
  64907. * @param onError defines the callback to trigger in case of error
  64908. */
  64909. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64910. /**
  64911. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64912. * @param data contains the texture data
  64913. * @param texture defines the BabylonJS internal texture
  64914. * @param callback defines the method to call once ready to upload
  64915. */
  64916. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64917. }
  64918. }
  64919. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64920. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64921. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64922. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64923. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64924. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64925. }
  64926. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64927. import { Vector2 } from "babylonjs/Maths/math.vector";
  64928. /**
  64929. * Defines the basic options interface of a TexturePacker Frame
  64930. */
  64931. export interface ITexturePackerFrame {
  64932. /**
  64933. * The frame ID
  64934. */
  64935. id: number;
  64936. /**
  64937. * The frames Scale
  64938. */
  64939. scale: Vector2;
  64940. /**
  64941. * The Frames offset
  64942. */
  64943. offset: Vector2;
  64944. }
  64945. /**
  64946. * This is a support class for frame Data on texture packer sets.
  64947. */
  64948. export class TexturePackerFrame implements ITexturePackerFrame {
  64949. /**
  64950. * The frame ID
  64951. */
  64952. id: number;
  64953. /**
  64954. * The frames Scale
  64955. */
  64956. scale: Vector2;
  64957. /**
  64958. * The Frames offset
  64959. */
  64960. offset: Vector2;
  64961. /**
  64962. * Initializes a texture package frame.
  64963. * @param id The numerical frame identifier
  64964. * @param scale Scalar Vector2 for UV frame
  64965. * @param offset Vector2 for the frame position in UV units.
  64966. * @returns TexturePackerFrame
  64967. */
  64968. constructor(id: number, scale: Vector2, offset: Vector2);
  64969. }
  64970. }
  64971. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64973. import { Scene } from "babylonjs/scene";
  64974. import { Nullable } from "babylonjs/types";
  64975. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64976. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64977. /**
  64978. * Defines the basic options interface of a TexturePacker
  64979. */
  64980. export interface ITexturePackerOptions {
  64981. /**
  64982. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64983. */
  64984. map?: string[];
  64985. /**
  64986. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64987. */
  64988. uvsIn?: string;
  64989. /**
  64990. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64991. */
  64992. uvsOut?: string;
  64993. /**
  64994. * number representing the layout style. Defaults to LAYOUT_STRIP
  64995. */
  64996. layout?: number;
  64997. /**
  64998. * number of columns if using custom column count layout(2). This defaults to 4.
  64999. */
  65000. colnum?: number;
  65001. /**
  65002. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65003. */
  65004. updateInputMeshes?: boolean;
  65005. /**
  65006. * boolean flag to dispose all the source textures. Defaults to true.
  65007. */
  65008. disposeSources?: boolean;
  65009. /**
  65010. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65011. */
  65012. fillBlanks?: boolean;
  65013. /**
  65014. * string value representing the context fill style color. Defaults to 'black'.
  65015. */
  65016. customFillColor?: string;
  65017. /**
  65018. * Width and Height Value of each Frame in the TexturePacker Sets
  65019. */
  65020. frameSize?: number;
  65021. /**
  65022. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65023. */
  65024. paddingRatio?: number;
  65025. /**
  65026. * Number that declares the fill method for the padding gutter.
  65027. */
  65028. paddingMode?: number;
  65029. /**
  65030. * If in SUBUV_COLOR padding mode what color to use.
  65031. */
  65032. paddingColor?: Color3 | Color4;
  65033. }
  65034. /**
  65035. * Defines the basic interface of a TexturePacker JSON File
  65036. */
  65037. export interface ITexturePackerJSON {
  65038. /**
  65039. * The frame ID
  65040. */
  65041. name: string;
  65042. /**
  65043. * The base64 channel data
  65044. */
  65045. sets: any;
  65046. /**
  65047. * The options of the Packer
  65048. */
  65049. options: ITexturePackerOptions;
  65050. /**
  65051. * The frame data of the Packer
  65052. */
  65053. frames: Array<number>;
  65054. }
  65055. /**
  65056. * This is a support class that generates a series of packed texture sets.
  65057. * @see https://doc.babylonjs.com/babylon101/materials
  65058. */
  65059. export class TexturePacker {
  65060. /** Packer Layout Constant 0 */
  65061. static readonly LAYOUT_STRIP: number;
  65062. /** Packer Layout Constant 1 */
  65063. static readonly LAYOUT_POWER2: number;
  65064. /** Packer Layout Constant 2 */
  65065. static readonly LAYOUT_COLNUM: number;
  65066. /** Packer Layout Constant 0 */
  65067. static readonly SUBUV_WRAP: number;
  65068. /** Packer Layout Constant 1 */
  65069. static readonly SUBUV_EXTEND: number;
  65070. /** Packer Layout Constant 2 */
  65071. static readonly SUBUV_COLOR: number;
  65072. /** The Name of the Texture Package */
  65073. name: string;
  65074. /** The scene scope of the TexturePacker */
  65075. scene: Scene;
  65076. /** The Meshes to target */
  65077. meshes: AbstractMesh[];
  65078. /** Arguments passed with the Constructor */
  65079. options: ITexturePackerOptions;
  65080. /** The promise that is started upon initialization */
  65081. promise: Nullable<Promise<TexturePacker | string>>;
  65082. /** The Container object for the channel sets that are generated */
  65083. sets: object;
  65084. /** The Container array for the frames that are generated */
  65085. frames: TexturePackerFrame[];
  65086. /** The expected number of textures the system is parsing. */
  65087. private _expecting;
  65088. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65089. private _paddingValue;
  65090. /**
  65091. * Initializes a texture package series from an array of meshes or a single mesh.
  65092. * @param name The name of the package
  65093. * @param meshes The target meshes to compose the package from
  65094. * @param options The arguments that texture packer should follow while building.
  65095. * @param scene The scene which the textures are scoped to.
  65096. * @returns TexturePacker
  65097. */
  65098. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65099. /**
  65100. * Starts the package process
  65101. * @param resolve The promises resolution function
  65102. * @returns TexturePacker
  65103. */
  65104. private _createFrames;
  65105. /**
  65106. * Calculates the Size of the Channel Sets
  65107. * @returns Vector2
  65108. */
  65109. private _calculateSize;
  65110. /**
  65111. * Calculates the UV data for the frames.
  65112. * @param baseSize the base frameSize
  65113. * @param padding the base frame padding
  65114. * @param dtSize size of the Dynamic Texture for that channel
  65115. * @param dtUnits is 1/dtSize
  65116. * @param update flag to update the input meshes
  65117. */
  65118. private _calculateMeshUVFrames;
  65119. /**
  65120. * Calculates the frames Offset.
  65121. * @param index of the frame
  65122. * @returns Vector2
  65123. */
  65124. private _getFrameOffset;
  65125. /**
  65126. * Updates a Mesh to the frame data
  65127. * @param mesh that is the target
  65128. * @param frameID or the frame index
  65129. */
  65130. private _updateMeshUV;
  65131. /**
  65132. * Updates a Meshes materials to use the texture packer channels
  65133. * @param m is the mesh to target
  65134. * @param force all channels on the packer to be set.
  65135. */
  65136. private _updateTextureReferences;
  65137. /**
  65138. * Public method to set a Mesh to a frame
  65139. * @param m that is the target
  65140. * @param frameID or the frame index
  65141. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65142. */
  65143. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65144. /**
  65145. * Starts the async promise to compile the texture packer.
  65146. * @returns Promise<void>
  65147. */
  65148. processAsync(): Promise<void>;
  65149. /**
  65150. * Disposes all textures associated with this packer
  65151. */
  65152. dispose(): void;
  65153. /**
  65154. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65155. * @param imageType is the image type to use.
  65156. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65157. */
  65158. download(imageType?: string, quality?: number): void;
  65159. /**
  65160. * Public method to load a texturePacker JSON file.
  65161. * @param data of the JSON file in string format.
  65162. */
  65163. updateFromJSON(data: string): void;
  65164. }
  65165. }
  65166. declare module "babylonjs/Materials/Textures/Packer/index" {
  65167. export * from "babylonjs/Materials/Textures/Packer/packer";
  65168. export * from "babylonjs/Materials/Textures/Packer/frame";
  65169. }
  65170. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65171. import { Scene } from "babylonjs/scene";
  65172. import { Texture } from "babylonjs/Materials/Textures/texture";
  65173. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65174. /**
  65175. * 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.
  65176. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65177. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65178. */
  65179. export class CustomProceduralTexture extends ProceduralTexture {
  65180. private _animate;
  65181. private _time;
  65182. private _config;
  65183. private _texturePath;
  65184. /**
  65185. * Instantiates a new Custom Procedural Texture.
  65186. * 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.
  65187. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65188. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65189. * @param name Define the name of the texture
  65190. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65191. * @param size Define the size of the texture to create
  65192. * @param scene Define the scene the texture belongs to
  65193. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65194. * @param generateMipMaps Define if the texture should creates mip maps or not
  65195. */
  65196. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65197. private _loadJson;
  65198. /**
  65199. * Is the texture ready to be used ? (rendered at least once)
  65200. * @returns true if ready, otherwise, false.
  65201. */
  65202. isReady(): boolean;
  65203. /**
  65204. * Render the texture to its associated render target.
  65205. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65206. */
  65207. render(useCameraPostProcess?: boolean): void;
  65208. /**
  65209. * Update the list of dependant textures samplers in the shader.
  65210. */
  65211. updateTextures(): void;
  65212. /**
  65213. * Update the uniform values of the procedural texture in the shader.
  65214. */
  65215. updateShaderUniforms(): void;
  65216. /**
  65217. * Define if the texture animates or not.
  65218. */
  65219. get animate(): boolean;
  65220. set animate(value: boolean);
  65221. }
  65222. }
  65223. declare module "babylonjs/Shaders/noise.fragment" {
  65224. /** @hidden */
  65225. export var noisePixelShader: {
  65226. name: string;
  65227. shader: string;
  65228. };
  65229. }
  65230. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65231. import { Nullable } from "babylonjs/types";
  65232. import { Scene } from "babylonjs/scene";
  65233. import { Texture } from "babylonjs/Materials/Textures/texture";
  65234. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65235. import "babylonjs/Shaders/noise.fragment";
  65236. /**
  65237. * Class used to generate noise procedural textures
  65238. */
  65239. export class NoiseProceduralTexture extends ProceduralTexture {
  65240. /** Gets or sets the start time (default is 0) */
  65241. time: number;
  65242. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65243. brightness: number;
  65244. /** Defines the number of octaves to process */
  65245. octaves: number;
  65246. /** Defines the level of persistence (0.8 by default) */
  65247. persistence: number;
  65248. /** Gets or sets animation speed factor (default is 1) */
  65249. animationSpeedFactor: number;
  65250. /**
  65251. * Creates a new NoiseProceduralTexture
  65252. * @param name defines the name fo the texture
  65253. * @param size defines the size of the texture (default is 256)
  65254. * @param scene defines the hosting scene
  65255. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65256. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65257. */
  65258. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65259. private _updateShaderUniforms;
  65260. protected _getDefines(): string;
  65261. /** Generate the current state of the procedural texture */
  65262. render(useCameraPostProcess?: boolean): void;
  65263. /**
  65264. * Serializes this noise procedural texture
  65265. * @returns a serialized noise procedural texture object
  65266. */
  65267. serialize(): any;
  65268. /**
  65269. * Clone the texture.
  65270. * @returns the cloned texture
  65271. */
  65272. clone(): NoiseProceduralTexture;
  65273. /**
  65274. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65275. * @param parsedTexture defines parsed texture data
  65276. * @param scene defines the current scene
  65277. * @param rootUrl defines the root URL containing noise procedural texture information
  65278. * @returns a parsed NoiseProceduralTexture
  65279. */
  65280. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65281. }
  65282. }
  65283. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65284. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65285. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65286. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65287. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65288. }
  65289. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65290. import { Nullable } from "babylonjs/types";
  65291. import { Scene } from "babylonjs/scene";
  65292. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65293. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65294. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65295. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65296. /**
  65297. * Raw cube texture where the raw buffers are passed in
  65298. */
  65299. export class RawCubeTexture extends CubeTexture {
  65300. /**
  65301. * Creates a cube texture where the raw buffers are passed in.
  65302. * @param scene defines the scene the texture is attached to
  65303. * @param data defines the array of data to use to create each face
  65304. * @param size defines the size of the textures
  65305. * @param format defines the format of the data
  65306. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65307. * @param generateMipMaps defines if the engine should generate the mip levels
  65308. * @param invertY defines if data must be stored with Y axis inverted
  65309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65310. * @param compression defines the compression used (null by default)
  65311. */
  65312. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65313. /**
  65314. * Updates the raw cube texture.
  65315. * @param data defines the data to store
  65316. * @param format defines the data format
  65317. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65318. * @param invertY defines if data must be stored with Y axis inverted
  65319. * @param compression defines the compression used (null by default)
  65320. * @param level defines which level of the texture to update
  65321. */
  65322. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65323. /**
  65324. * Updates a raw cube texture with RGBD encoded data.
  65325. * @param data defines the array of data [mipmap][face] to use to create each face
  65326. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65327. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65328. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65329. * @returns a promsie that resolves when the operation is complete
  65330. */
  65331. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65332. /**
  65333. * Clones the raw cube texture.
  65334. * @return a new cube texture
  65335. */
  65336. clone(): CubeTexture;
  65337. /** @hidden */
  65338. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65339. }
  65340. }
  65341. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65342. import { Scene } from "babylonjs/scene";
  65343. import { Texture } from "babylonjs/Materials/Textures/texture";
  65344. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65345. /**
  65346. * Class used to store 2D array textures containing user data
  65347. */
  65348. export class RawTexture2DArray extends Texture {
  65349. /** Gets or sets the texture format to use */
  65350. format: number;
  65351. /**
  65352. * Create a new RawTexture2DArray
  65353. * @param data defines the data of the texture
  65354. * @param width defines the width of the texture
  65355. * @param height defines the height of the texture
  65356. * @param depth defines the number of layers of the texture
  65357. * @param format defines the texture format to use
  65358. * @param scene defines the hosting scene
  65359. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65360. * @param invertY defines if texture must be stored with Y axis inverted
  65361. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65362. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65363. */
  65364. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65365. /** Gets or sets the texture format to use */
  65366. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65367. /**
  65368. * Update the texture with new data
  65369. * @param data defines the data to store in the texture
  65370. */
  65371. update(data: ArrayBufferView): void;
  65372. }
  65373. }
  65374. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65375. import { Scene } from "babylonjs/scene";
  65376. import { Texture } from "babylonjs/Materials/Textures/texture";
  65377. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65378. /**
  65379. * Class used to store 3D textures containing user data
  65380. */
  65381. export class RawTexture3D extends Texture {
  65382. /** Gets or sets the texture format to use */
  65383. format: number;
  65384. /**
  65385. * Create a new RawTexture3D
  65386. * @param data defines the data of the texture
  65387. * @param width defines the width of the texture
  65388. * @param height defines the height of the texture
  65389. * @param depth defines the depth of the texture
  65390. * @param format defines the texture format to use
  65391. * @param scene defines the hosting scene
  65392. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65393. * @param invertY defines if texture must be stored with Y axis inverted
  65394. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65395. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65396. */
  65397. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65398. /** Gets or sets the texture format to use */
  65399. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65400. /**
  65401. * Update the texture with new data
  65402. * @param data defines the data to store in the texture
  65403. */
  65404. update(data: ArrayBufferView): void;
  65405. }
  65406. }
  65407. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65408. import { Scene } from "babylonjs/scene";
  65409. import { Plane } from "babylonjs/Maths/math.plane";
  65410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65411. /**
  65412. * Creates a refraction texture used by refraction channel of the standard material.
  65413. * It is like a mirror but to see through a material.
  65414. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65415. */
  65416. export class RefractionTexture extends RenderTargetTexture {
  65417. /**
  65418. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65419. * 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.
  65420. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65421. */
  65422. refractionPlane: Plane;
  65423. /**
  65424. * Define how deep under the surface we should see.
  65425. */
  65426. depth: number;
  65427. /**
  65428. * Creates a refraction texture used by refraction channel of the standard material.
  65429. * It is like a mirror but to see through a material.
  65430. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65431. * @param name Define the texture name
  65432. * @param size Define the size of the underlying texture
  65433. * @param scene Define the scene the refraction belongs to
  65434. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65435. */
  65436. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65437. /**
  65438. * Clone the refraction texture.
  65439. * @returns the cloned texture
  65440. */
  65441. clone(): RefractionTexture;
  65442. /**
  65443. * Serialize the texture to a JSON representation you could use in Parse later on
  65444. * @returns the serialized JSON representation
  65445. */
  65446. serialize(): any;
  65447. }
  65448. }
  65449. declare module "babylonjs/Materials/Textures/index" {
  65450. export * from "babylonjs/Materials/Textures/baseTexture";
  65451. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65452. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65453. export * from "babylonjs/Materials/Textures/cubeTexture";
  65454. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65455. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65456. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65457. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65458. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65459. export * from "babylonjs/Materials/Textures/internalTexture";
  65460. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65461. export * from "babylonjs/Materials/Textures/Loaders/index";
  65462. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65463. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65464. export * from "babylonjs/Materials/Textures/Packer/index";
  65465. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65466. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65467. export * from "babylonjs/Materials/Textures/rawTexture";
  65468. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65469. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65470. export * from "babylonjs/Materials/Textures/refractionTexture";
  65471. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65472. export * from "babylonjs/Materials/Textures/texture";
  65473. export * from "babylonjs/Materials/Textures/videoTexture";
  65474. }
  65475. declare module "babylonjs/Materials/Node/Enums/index" {
  65476. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65477. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65478. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65479. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65480. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65481. }
  65482. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65486. import { Mesh } from "babylonjs/Meshes/mesh";
  65487. import { Effect } from "babylonjs/Materials/effect";
  65488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65489. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65490. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65491. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65492. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65493. /**
  65494. * Block used to add support for vertex skinning (bones)
  65495. */
  65496. export class BonesBlock extends NodeMaterialBlock {
  65497. /**
  65498. * Creates a new BonesBlock
  65499. * @param name defines the block name
  65500. */
  65501. constructor(name: string);
  65502. /**
  65503. * Initialize the block and prepare the context for build
  65504. * @param state defines the state that will be used for the build
  65505. */
  65506. initialize(state: NodeMaterialBuildState): void;
  65507. /**
  65508. * Gets the current class name
  65509. * @returns the class name
  65510. */
  65511. getClassName(): string;
  65512. /**
  65513. * Gets the matrix indices input component
  65514. */
  65515. get matricesIndices(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the matrix weights input component
  65518. */
  65519. get matricesWeights(): NodeMaterialConnectionPoint;
  65520. /**
  65521. * Gets the extra matrix indices input component
  65522. */
  65523. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65524. /**
  65525. * Gets the extra matrix weights input component
  65526. */
  65527. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the world input component
  65530. */
  65531. get world(): NodeMaterialConnectionPoint;
  65532. /**
  65533. * Gets the output component
  65534. */
  65535. get output(): NodeMaterialConnectionPoint;
  65536. autoConfigure(material: NodeMaterial): void;
  65537. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65540. protected _buildBlock(state: NodeMaterialBuildState): this;
  65541. }
  65542. }
  65543. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65549. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65550. /**
  65551. * Block used to add support for instances
  65552. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65553. */
  65554. export class InstancesBlock extends NodeMaterialBlock {
  65555. /**
  65556. * Creates a new InstancesBlock
  65557. * @param name defines the block name
  65558. */
  65559. constructor(name: string);
  65560. /**
  65561. * Gets the current class name
  65562. * @returns the class name
  65563. */
  65564. getClassName(): string;
  65565. /**
  65566. * Gets the first world row input component
  65567. */
  65568. get world0(): NodeMaterialConnectionPoint;
  65569. /**
  65570. * Gets the second world row input component
  65571. */
  65572. get world1(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the third world row input component
  65575. */
  65576. get world2(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the forth world row input component
  65579. */
  65580. get world3(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the world input component
  65583. */
  65584. get world(): NodeMaterialConnectionPoint;
  65585. /**
  65586. * Gets the output component
  65587. */
  65588. get output(): NodeMaterialConnectionPoint;
  65589. /**
  65590. * Gets the isntanceID component
  65591. */
  65592. get instanceID(): NodeMaterialConnectionPoint;
  65593. autoConfigure(material: NodeMaterial): void;
  65594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65595. protected _buildBlock(state: NodeMaterialBuildState): this;
  65596. }
  65597. }
  65598. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65603. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65604. import { Effect } from "babylonjs/Materials/effect";
  65605. import { Mesh } from "babylonjs/Meshes/mesh";
  65606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65608. /**
  65609. * Block used to add morph targets support to vertex shader
  65610. */
  65611. export class MorphTargetsBlock extends NodeMaterialBlock {
  65612. private _repeatableContentAnchor;
  65613. /**
  65614. * Create a new MorphTargetsBlock
  65615. * @param name defines the block name
  65616. */
  65617. constructor(name: string);
  65618. /**
  65619. * Gets the current class name
  65620. * @returns the class name
  65621. */
  65622. getClassName(): string;
  65623. /**
  65624. * Gets the position input component
  65625. */
  65626. get position(): NodeMaterialConnectionPoint;
  65627. /**
  65628. * Gets the normal input component
  65629. */
  65630. get normal(): NodeMaterialConnectionPoint;
  65631. /**
  65632. * Gets the tangent input component
  65633. */
  65634. get tangent(): NodeMaterialConnectionPoint;
  65635. /**
  65636. * Gets the tangent input component
  65637. */
  65638. get uv(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the position output component
  65641. */
  65642. get positionOutput(): NodeMaterialConnectionPoint;
  65643. /**
  65644. * Gets the normal output component
  65645. */
  65646. get normalOutput(): NodeMaterialConnectionPoint;
  65647. /**
  65648. * Gets the tangent output component
  65649. */
  65650. get tangentOutput(): NodeMaterialConnectionPoint;
  65651. /**
  65652. * Gets the tangent output component
  65653. */
  65654. get uvOutput(): NodeMaterialConnectionPoint;
  65655. initialize(state: NodeMaterialBuildState): void;
  65656. autoConfigure(material: NodeMaterial): void;
  65657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65658. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65659. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65660. protected _buildBlock(state: NodeMaterialBuildState): this;
  65661. }
  65662. }
  65663. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65667. import { Nullable } from "babylonjs/types";
  65668. import { Scene } from "babylonjs/scene";
  65669. import { Effect } from "babylonjs/Materials/effect";
  65670. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65671. import { Mesh } from "babylonjs/Meshes/mesh";
  65672. import { Light } from "babylonjs/Lights/light";
  65673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65674. /**
  65675. * Block used to get data information from a light
  65676. */
  65677. export class LightInformationBlock extends NodeMaterialBlock {
  65678. private _lightDataUniformName;
  65679. private _lightColorUniformName;
  65680. private _lightTypeDefineName;
  65681. /**
  65682. * Gets or sets the light associated with this block
  65683. */
  65684. light: Nullable<Light>;
  65685. /**
  65686. * Creates a new LightInformationBlock
  65687. * @param name defines the block name
  65688. */
  65689. constructor(name: string);
  65690. /**
  65691. * Gets the current class name
  65692. * @returns the class name
  65693. */
  65694. getClassName(): string;
  65695. /**
  65696. * Gets the world position input component
  65697. */
  65698. get worldPosition(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the direction output component
  65701. */
  65702. get direction(): NodeMaterialConnectionPoint;
  65703. /**
  65704. * Gets the direction output component
  65705. */
  65706. get color(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the direction output component
  65709. */
  65710. get intensity(): NodeMaterialConnectionPoint;
  65711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65713. protected _buildBlock(state: NodeMaterialBuildState): this;
  65714. serialize(): any;
  65715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65716. }
  65717. }
  65718. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65719. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65720. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65721. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65722. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65723. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65724. }
  65725. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65730. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65731. import { Effect } from "babylonjs/Materials/effect";
  65732. import { Mesh } from "babylonjs/Meshes/mesh";
  65733. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65734. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65735. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65736. /**
  65737. * Block used to add image processing support to fragment shader
  65738. */
  65739. export class ImageProcessingBlock extends NodeMaterialBlock {
  65740. /**
  65741. * Create a new ImageProcessingBlock
  65742. * @param name defines the block name
  65743. */
  65744. constructor(name: string);
  65745. /**
  65746. * Gets the current class name
  65747. * @returns the class name
  65748. */
  65749. getClassName(): string;
  65750. /**
  65751. * Gets the color input component
  65752. */
  65753. get color(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the output component
  65756. */
  65757. get output(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Initialize the block and prepare the context for build
  65760. * @param state defines the state that will be used for the build
  65761. */
  65762. initialize(state: NodeMaterialBuildState): void;
  65763. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65766. protected _buildBlock(state: NodeMaterialBuildState): this;
  65767. }
  65768. }
  65769. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65773. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65775. import { Effect } from "babylonjs/Materials/effect";
  65776. import { Mesh } from "babylonjs/Meshes/mesh";
  65777. import { Scene } from "babylonjs/scene";
  65778. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65779. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65780. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65781. /**
  65782. * Block used to pertub normals based on a normal map
  65783. */
  65784. export class PerturbNormalBlock extends NodeMaterialBlock {
  65785. private _tangentSpaceParameterName;
  65786. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65787. invertX: boolean;
  65788. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65789. invertY: boolean;
  65790. /**
  65791. * Create a new PerturbNormalBlock
  65792. * @param name defines the block name
  65793. */
  65794. constructor(name: string);
  65795. /**
  65796. * Gets the current class name
  65797. * @returns the class name
  65798. */
  65799. getClassName(): string;
  65800. /**
  65801. * Gets the world position input component
  65802. */
  65803. get worldPosition(): NodeMaterialConnectionPoint;
  65804. /**
  65805. * Gets the world normal input component
  65806. */
  65807. get worldNormal(): NodeMaterialConnectionPoint;
  65808. /**
  65809. * Gets the world tangent input component
  65810. */
  65811. get worldTangent(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the uv input component
  65814. */
  65815. get uv(): NodeMaterialConnectionPoint;
  65816. /**
  65817. * Gets the normal map color input component
  65818. */
  65819. get normalMapColor(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the strength input component
  65822. */
  65823. get strength(): NodeMaterialConnectionPoint;
  65824. /**
  65825. * Gets the output component
  65826. */
  65827. get output(): NodeMaterialConnectionPoint;
  65828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65830. autoConfigure(material: NodeMaterial): void;
  65831. protected _buildBlock(state: NodeMaterialBuildState): this;
  65832. protected _dumpPropertiesCode(): string;
  65833. serialize(): any;
  65834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65835. }
  65836. }
  65837. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65841. /**
  65842. * Block used to discard a pixel if a value is smaller than a cutoff
  65843. */
  65844. export class DiscardBlock extends NodeMaterialBlock {
  65845. /**
  65846. * Create a new DiscardBlock
  65847. * @param name defines the block name
  65848. */
  65849. constructor(name: string);
  65850. /**
  65851. * Gets the current class name
  65852. * @returns the class name
  65853. */
  65854. getClassName(): string;
  65855. /**
  65856. * Gets the color input component
  65857. */
  65858. get value(): NodeMaterialConnectionPoint;
  65859. /**
  65860. * Gets the cutoff input component
  65861. */
  65862. get cutoff(): NodeMaterialConnectionPoint;
  65863. protected _buildBlock(state: NodeMaterialBuildState): this;
  65864. }
  65865. }
  65866. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65870. /**
  65871. * Block used to test if the fragment shader is front facing
  65872. */
  65873. export class FrontFacingBlock extends NodeMaterialBlock {
  65874. /**
  65875. * Creates a new FrontFacingBlock
  65876. * @param name defines the block name
  65877. */
  65878. constructor(name: string);
  65879. /**
  65880. * Gets the current class name
  65881. * @returns the class name
  65882. */
  65883. getClassName(): string;
  65884. /**
  65885. * Gets the output component
  65886. */
  65887. get output(): NodeMaterialConnectionPoint;
  65888. protected _buildBlock(state: NodeMaterialBuildState): this;
  65889. }
  65890. }
  65891. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65895. /**
  65896. * Block used to get the derivative value on x and y of a given input
  65897. */
  65898. export class DerivativeBlock extends NodeMaterialBlock {
  65899. /**
  65900. * Create a new DerivativeBlock
  65901. * @param name defines the block name
  65902. */
  65903. constructor(name: string);
  65904. /**
  65905. * Gets the current class name
  65906. * @returns the class name
  65907. */
  65908. getClassName(): string;
  65909. /**
  65910. * Gets the input component
  65911. */
  65912. get input(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the derivative output on x
  65915. */
  65916. get dx(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the derivative output on y
  65919. */
  65920. get dy(): NodeMaterialConnectionPoint;
  65921. protected _buildBlock(state: NodeMaterialBuildState): this;
  65922. }
  65923. }
  65924. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65928. /**
  65929. * Block used to make gl_FragCoord available
  65930. */
  65931. export class FragCoordBlock extends NodeMaterialBlock {
  65932. /**
  65933. * Creates a new FragCoordBlock
  65934. * @param name defines the block name
  65935. */
  65936. constructor(name: string);
  65937. /**
  65938. * Gets the current class name
  65939. * @returns the class name
  65940. */
  65941. getClassName(): string;
  65942. /**
  65943. * Gets the xy component
  65944. */
  65945. get xy(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Gets the xyz component
  65948. */
  65949. get xyz(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the xyzw component
  65952. */
  65953. get xyzw(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the x component
  65956. */
  65957. get x(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the y component
  65960. */
  65961. get y(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the z component
  65964. */
  65965. get z(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the w component
  65968. */
  65969. get output(): NodeMaterialConnectionPoint;
  65970. protected writeOutputs(state: NodeMaterialBuildState): string;
  65971. protected _buildBlock(state: NodeMaterialBuildState): this;
  65972. }
  65973. }
  65974. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65978. import { Effect } from "babylonjs/Materials/effect";
  65979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65980. import { Mesh } from "babylonjs/Meshes/mesh";
  65981. /**
  65982. * Block used to get the screen sizes
  65983. */
  65984. export class ScreenSizeBlock extends NodeMaterialBlock {
  65985. private _varName;
  65986. private _scene;
  65987. /**
  65988. * Creates a new ScreenSizeBlock
  65989. * @param name defines the block name
  65990. */
  65991. constructor(name: string);
  65992. /**
  65993. * Gets the current class name
  65994. * @returns the class name
  65995. */
  65996. getClassName(): string;
  65997. /**
  65998. * Gets the xy component
  65999. */
  66000. get xy(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the x component
  66003. */
  66004. get x(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the y component
  66007. */
  66008. get y(): NodeMaterialConnectionPoint;
  66009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66010. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66011. protected _buildBlock(state: NodeMaterialBuildState): this;
  66012. }
  66013. }
  66014. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66015. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66016. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66017. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66018. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66019. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66020. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66021. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66022. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66023. }
  66024. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66027. import { Mesh } from "babylonjs/Meshes/mesh";
  66028. import { Effect } from "babylonjs/Materials/effect";
  66029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66031. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66032. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66033. /**
  66034. * Block used to add support for scene fog
  66035. */
  66036. export class FogBlock extends NodeMaterialBlock {
  66037. private _fogDistanceName;
  66038. private _fogParameters;
  66039. /**
  66040. * Create a new FogBlock
  66041. * @param name defines the block name
  66042. */
  66043. constructor(name: string);
  66044. /**
  66045. * Gets the current class name
  66046. * @returns the class name
  66047. */
  66048. getClassName(): string;
  66049. /**
  66050. * Gets the world position input component
  66051. */
  66052. get worldPosition(): NodeMaterialConnectionPoint;
  66053. /**
  66054. * Gets the view input component
  66055. */
  66056. get view(): NodeMaterialConnectionPoint;
  66057. /**
  66058. * Gets the color input component
  66059. */
  66060. get input(): NodeMaterialConnectionPoint;
  66061. /**
  66062. * Gets the fog color input component
  66063. */
  66064. get fogColor(): NodeMaterialConnectionPoint;
  66065. /**
  66066. * Gets the output component
  66067. */
  66068. get output(): NodeMaterialConnectionPoint;
  66069. autoConfigure(material: NodeMaterial): void;
  66070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66072. protected _buildBlock(state: NodeMaterialBuildState): this;
  66073. }
  66074. }
  66075. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66081. import { Effect } from "babylonjs/Materials/effect";
  66082. import { Mesh } from "babylonjs/Meshes/mesh";
  66083. import { Light } from "babylonjs/Lights/light";
  66084. import { Nullable } from "babylonjs/types";
  66085. import { Scene } from "babylonjs/scene";
  66086. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66087. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66088. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66089. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66090. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66091. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66092. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66093. /**
  66094. * Block used to add light in the fragment shader
  66095. */
  66096. export class LightBlock extends NodeMaterialBlock {
  66097. private _lightId;
  66098. /**
  66099. * Gets or sets the light associated with this block
  66100. */
  66101. light: Nullable<Light>;
  66102. /**
  66103. * Create a new LightBlock
  66104. * @param name defines the block name
  66105. */
  66106. constructor(name: string);
  66107. /**
  66108. * Gets the current class name
  66109. * @returns the class name
  66110. */
  66111. getClassName(): string;
  66112. /**
  66113. * Gets the world position input component
  66114. */
  66115. get worldPosition(): NodeMaterialConnectionPoint;
  66116. /**
  66117. * Gets the world normal input component
  66118. */
  66119. get worldNormal(): NodeMaterialConnectionPoint;
  66120. /**
  66121. * Gets the camera (or eye) position component
  66122. */
  66123. get cameraPosition(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the glossiness component
  66126. */
  66127. get glossiness(): NodeMaterialConnectionPoint;
  66128. /**
  66129. * Gets the glossinness power component
  66130. */
  66131. get glossPower(): NodeMaterialConnectionPoint;
  66132. /**
  66133. * Gets the diffuse color component
  66134. */
  66135. get diffuseColor(): NodeMaterialConnectionPoint;
  66136. /**
  66137. * Gets the specular color component
  66138. */
  66139. get specularColor(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the diffuse output component
  66142. */
  66143. get diffuseOutput(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the specular output component
  66146. */
  66147. get specularOutput(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the shadow output component
  66150. */
  66151. get shadow(): NodeMaterialConnectionPoint;
  66152. autoConfigure(material: NodeMaterial): void;
  66153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66154. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66156. private _injectVertexCode;
  66157. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66158. serialize(): any;
  66159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66160. }
  66161. }
  66162. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66165. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66166. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66167. /**
  66168. * Block used to read a reflection texture from a sampler
  66169. */
  66170. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66171. /**
  66172. * Create a new ReflectionTextureBlock
  66173. * @param name defines the block name
  66174. */
  66175. constructor(name: string);
  66176. /**
  66177. * Gets the current class name
  66178. * @returns the class name
  66179. */
  66180. getClassName(): string;
  66181. /**
  66182. * Gets the world position input component
  66183. */
  66184. get position(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the world position input component
  66187. */
  66188. get worldPosition(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the world normal input component
  66191. */
  66192. get worldNormal(): NodeMaterialConnectionPoint;
  66193. /**
  66194. * Gets the world input component
  66195. */
  66196. get world(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the camera (or eye) position component
  66199. */
  66200. get cameraPosition(): NodeMaterialConnectionPoint;
  66201. /**
  66202. * Gets the view input component
  66203. */
  66204. get view(): NodeMaterialConnectionPoint;
  66205. /**
  66206. * Gets the rgb output component
  66207. */
  66208. get rgb(): NodeMaterialConnectionPoint;
  66209. /**
  66210. * Gets the rgba output component
  66211. */
  66212. get rgba(): NodeMaterialConnectionPoint;
  66213. /**
  66214. * Gets the r output component
  66215. */
  66216. get r(): NodeMaterialConnectionPoint;
  66217. /**
  66218. * Gets the g output component
  66219. */
  66220. get g(): NodeMaterialConnectionPoint;
  66221. /**
  66222. * Gets the b output component
  66223. */
  66224. get b(): NodeMaterialConnectionPoint;
  66225. /**
  66226. * Gets the a output component
  66227. */
  66228. get a(): NodeMaterialConnectionPoint;
  66229. autoConfigure(material: NodeMaterial): void;
  66230. protected _buildBlock(state: NodeMaterialBuildState): this;
  66231. }
  66232. }
  66233. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66234. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66235. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66236. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66237. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66238. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66239. }
  66240. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66241. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66242. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66243. }
  66244. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66248. /**
  66249. * Block used to add 2 vectors
  66250. */
  66251. export class AddBlock extends NodeMaterialBlock {
  66252. /**
  66253. * Creates a new AddBlock
  66254. * @param name defines the block name
  66255. */
  66256. constructor(name: string);
  66257. /**
  66258. * Gets the current class name
  66259. * @returns the class name
  66260. */
  66261. getClassName(): string;
  66262. /**
  66263. * Gets the left operand input component
  66264. */
  66265. get left(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the right operand input component
  66268. */
  66269. get right(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the output component
  66272. */
  66273. get output(): NodeMaterialConnectionPoint;
  66274. protected _buildBlock(state: NodeMaterialBuildState): this;
  66275. }
  66276. }
  66277. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66281. /**
  66282. * Block used to scale a vector by a float
  66283. */
  66284. export class ScaleBlock extends NodeMaterialBlock {
  66285. /**
  66286. * Creates a new ScaleBlock
  66287. * @param name defines the block name
  66288. */
  66289. constructor(name: string);
  66290. /**
  66291. * Gets the current class name
  66292. * @returns the class name
  66293. */
  66294. getClassName(): string;
  66295. /**
  66296. * Gets the input component
  66297. */
  66298. get input(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the factor input component
  66301. */
  66302. get factor(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the output component
  66305. */
  66306. get output(): NodeMaterialConnectionPoint;
  66307. protected _buildBlock(state: NodeMaterialBuildState): this;
  66308. }
  66309. }
  66310. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66314. import { Scene } from "babylonjs/scene";
  66315. /**
  66316. * Block used to clamp a float
  66317. */
  66318. export class ClampBlock extends NodeMaterialBlock {
  66319. /** Gets or sets the minimum range */
  66320. minimum: number;
  66321. /** Gets or sets the maximum range */
  66322. maximum: number;
  66323. /**
  66324. * Creates a new ClampBlock
  66325. * @param name defines the block name
  66326. */
  66327. constructor(name: string);
  66328. /**
  66329. * Gets the current class name
  66330. * @returns the class name
  66331. */
  66332. getClassName(): string;
  66333. /**
  66334. * Gets the value input component
  66335. */
  66336. get value(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the output component
  66339. */
  66340. get output(): NodeMaterialConnectionPoint;
  66341. protected _buildBlock(state: NodeMaterialBuildState): this;
  66342. protected _dumpPropertiesCode(): string;
  66343. serialize(): any;
  66344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66345. }
  66346. }
  66347. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66351. /**
  66352. * Block used to apply a cross product between 2 vectors
  66353. */
  66354. export class CrossBlock extends NodeMaterialBlock {
  66355. /**
  66356. * Creates a new CrossBlock
  66357. * @param name defines the block name
  66358. */
  66359. constructor(name: string);
  66360. /**
  66361. * Gets the current class name
  66362. * @returns the class name
  66363. */
  66364. getClassName(): string;
  66365. /**
  66366. * Gets the left operand input component
  66367. */
  66368. get left(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the right operand input component
  66371. */
  66372. get right(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the output component
  66375. */
  66376. get output(): NodeMaterialConnectionPoint;
  66377. protected _buildBlock(state: NodeMaterialBuildState): this;
  66378. }
  66379. }
  66380. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66384. /**
  66385. * Block used to apply a dot product between 2 vectors
  66386. */
  66387. export class DotBlock extends NodeMaterialBlock {
  66388. /**
  66389. * Creates a new DotBlock
  66390. * @param name defines the block name
  66391. */
  66392. constructor(name: string);
  66393. /**
  66394. * Gets the current class name
  66395. * @returns the class name
  66396. */
  66397. getClassName(): string;
  66398. /**
  66399. * Gets the left operand input component
  66400. */
  66401. get left(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the right operand input component
  66404. */
  66405. get right(): NodeMaterialConnectionPoint;
  66406. /**
  66407. * Gets the output component
  66408. */
  66409. get output(): NodeMaterialConnectionPoint;
  66410. protected _buildBlock(state: NodeMaterialBuildState): this;
  66411. }
  66412. }
  66413. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66417. /**
  66418. * Block used to normalize a vector
  66419. */
  66420. export class NormalizeBlock extends NodeMaterialBlock {
  66421. /**
  66422. * Creates a new NormalizeBlock
  66423. * @param name defines the block name
  66424. */
  66425. constructor(name: string);
  66426. /**
  66427. * Gets the current class name
  66428. * @returns the class name
  66429. */
  66430. getClassName(): string;
  66431. /**
  66432. * Gets the input component
  66433. */
  66434. get input(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the output component
  66437. */
  66438. get output(): NodeMaterialConnectionPoint;
  66439. protected _buildBlock(state: NodeMaterialBuildState): this;
  66440. }
  66441. }
  66442. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66446. /**
  66447. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66448. */
  66449. export class ColorMergerBlock extends NodeMaterialBlock {
  66450. /**
  66451. * Create a new ColorMergerBlock
  66452. * @param name defines the block name
  66453. */
  66454. constructor(name: string);
  66455. /**
  66456. * Gets the current class name
  66457. * @returns the class name
  66458. */
  66459. getClassName(): string;
  66460. /**
  66461. * Gets the rgb component (input)
  66462. */
  66463. get rgbIn(): NodeMaterialConnectionPoint;
  66464. /**
  66465. * Gets the r component (input)
  66466. */
  66467. get r(): NodeMaterialConnectionPoint;
  66468. /**
  66469. * Gets the g component (input)
  66470. */
  66471. get g(): NodeMaterialConnectionPoint;
  66472. /**
  66473. * Gets the b component (input)
  66474. */
  66475. get b(): NodeMaterialConnectionPoint;
  66476. /**
  66477. * Gets the a component (input)
  66478. */
  66479. get a(): NodeMaterialConnectionPoint;
  66480. /**
  66481. * Gets the rgba component (output)
  66482. */
  66483. get rgba(): NodeMaterialConnectionPoint;
  66484. /**
  66485. * Gets the rgb component (output)
  66486. */
  66487. get rgbOut(): NodeMaterialConnectionPoint;
  66488. /**
  66489. * Gets the rgb component (output)
  66490. * @deprecated Please use rgbOut instead.
  66491. */
  66492. get rgb(): NodeMaterialConnectionPoint;
  66493. protected _buildBlock(state: NodeMaterialBuildState): this;
  66494. }
  66495. }
  66496. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66500. /**
  66501. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66502. */
  66503. export class VectorSplitterBlock extends NodeMaterialBlock {
  66504. /**
  66505. * Create a new VectorSplitterBlock
  66506. * @param name defines the block name
  66507. */
  66508. constructor(name: string);
  66509. /**
  66510. * Gets the current class name
  66511. * @returns the class name
  66512. */
  66513. getClassName(): string;
  66514. /**
  66515. * Gets the xyzw component (input)
  66516. */
  66517. get xyzw(): NodeMaterialConnectionPoint;
  66518. /**
  66519. * Gets the xyz component (input)
  66520. */
  66521. get xyzIn(): NodeMaterialConnectionPoint;
  66522. /**
  66523. * Gets the xy component (input)
  66524. */
  66525. get xyIn(): NodeMaterialConnectionPoint;
  66526. /**
  66527. * Gets the xyz component (output)
  66528. */
  66529. get xyzOut(): NodeMaterialConnectionPoint;
  66530. /**
  66531. * Gets the xy component (output)
  66532. */
  66533. get xyOut(): NodeMaterialConnectionPoint;
  66534. /**
  66535. * Gets the x component (output)
  66536. */
  66537. get x(): NodeMaterialConnectionPoint;
  66538. /**
  66539. * Gets the y component (output)
  66540. */
  66541. get y(): NodeMaterialConnectionPoint;
  66542. /**
  66543. * Gets the z component (output)
  66544. */
  66545. get z(): NodeMaterialConnectionPoint;
  66546. /**
  66547. * Gets the w component (output)
  66548. */
  66549. get w(): NodeMaterialConnectionPoint;
  66550. protected _inputRename(name: string): string;
  66551. protected _outputRename(name: string): string;
  66552. protected _buildBlock(state: NodeMaterialBuildState): this;
  66553. }
  66554. }
  66555. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66559. /**
  66560. * Block used to lerp between 2 values
  66561. */
  66562. export class LerpBlock extends NodeMaterialBlock {
  66563. /**
  66564. * Creates a new LerpBlock
  66565. * @param name defines the block name
  66566. */
  66567. constructor(name: string);
  66568. /**
  66569. * Gets the current class name
  66570. * @returns the class name
  66571. */
  66572. getClassName(): string;
  66573. /**
  66574. * Gets the left operand input component
  66575. */
  66576. get left(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the right operand input component
  66579. */
  66580. get right(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the gradient operand input component
  66583. */
  66584. get gradient(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the output component
  66587. */
  66588. get output(): NodeMaterialConnectionPoint;
  66589. protected _buildBlock(state: NodeMaterialBuildState): this;
  66590. }
  66591. }
  66592. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66596. /**
  66597. * Block used to divide 2 vectors
  66598. */
  66599. export class DivideBlock extends NodeMaterialBlock {
  66600. /**
  66601. * Creates a new DivideBlock
  66602. * @param name defines the block name
  66603. */
  66604. constructor(name: string);
  66605. /**
  66606. * Gets the current class name
  66607. * @returns the class name
  66608. */
  66609. getClassName(): string;
  66610. /**
  66611. * Gets the left operand input component
  66612. */
  66613. get left(): NodeMaterialConnectionPoint;
  66614. /**
  66615. * Gets the right operand input component
  66616. */
  66617. get right(): NodeMaterialConnectionPoint;
  66618. /**
  66619. * Gets the output component
  66620. */
  66621. get output(): NodeMaterialConnectionPoint;
  66622. protected _buildBlock(state: NodeMaterialBuildState): this;
  66623. }
  66624. }
  66625. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66629. /**
  66630. * Block used to subtract 2 vectors
  66631. */
  66632. export class SubtractBlock extends NodeMaterialBlock {
  66633. /**
  66634. * Creates a new SubtractBlock
  66635. * @param name defines the block name
  66636. */
  66637. constructor(name: string);
  66638. /**
  66639. * Gets the current class name
  66640. * @returns the class name
  66641. */
  66642. getClassName(): string;
  66643. /**
  66644. * Gets the left operand input component
  66645. */
  66646. get left(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the right operand input component
  66649. */
  66650. get right(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the output component
  66653. */
  66654. get output(): NodeMaterialConnectionPoint;
  66655. protected _buildBlock(state: NodeMaterialBuildState): this;
  66656. }
  66657. }
  66658. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66662. /**
  66663. * Block used to step a value
  66664. */
  66665. export class StepBlock extends NodeMaterialBlock {
  66666. /**
  66667. * Creates a new StepBlock
  66668. * @param name defines the block name
  66669. */
  66670. constructor(name: string);
  66671. /**
  66672. * Gets the current class name
  66673. * @returns the class name
  66674. */
  66675. getClassName(): string;
  66676. /**
  66677. * Gets the value operand input component
  66678. */
  66679. get value(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the edge operand input component
  66682. */
  66683. get edge(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the output component
  66686. */
  66687. get output(): NodeMaterialConnectionPoint;
  66688. protected _buildBlock(state: NodeMaterialBuildState): this;
  66689. }
  66690. }
  66691. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66695. /**
  66696. * Block used to get the opposite (1 - x) of a value
  66697. */
  66698. export class OneMinusBlock extends NodeMaterialBlock {
  66699. /**
  66700. * Creates a new OneMinusBlock
  66701. * @param name defines the block name
  66702. */
  66703. constructor(name: string);
  66704. /**
  66705. * Gets the current class name
  66706. * @returns the class name
  66707. */
  66708. getClassName(): string;
  66709. /**
  66710. * Gets the input component
  66711. */
  66712. get input(): NodeMaterialConnectionPoint;
  66713. /**
  66714. * Gets the output component
  66715. */
  66716. get output(): NodeMaterialConnectionPoint;
  66717. protected _buildBlock(state: NodeMaterialBuildState): this;
  66718. }
  66719. }
  66720. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66724. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66725. /**
  66726. * Block used to get the view direction
  66727. */
  66728. export class ViewDirectionBlock extends NodeMaterialBlock {
  66729. /**
  66730. * Creates a new ViewDirectionBlock
  66731. * @param name defines the block name
  66732. */
  66733. constructor(name: string);
  66734. /**
  66735. * Gets the current class name
  66736. * @returns the class name
  66737. */
  66738. getClassName(): string;
  66739. /**
  66740. * Gets the world position component
  66741. */
  66742. get worldPosition(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the camera position component
  66745. */
  66746. get cameraPosition(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the output component
  66749. */
  66750. get output(): NodeMaterialConnectionPoint;
  66751. autoConfigure(material: NodeMaterial): void;
  66752. protected _buildBlock(state: NodeMaterialBuildState): this;
  66753. }
  66754. }
  66755. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66759. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66760. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66761. /**
  66762. * Block used to compute fresnel value
  66763. */
  66764. export class FresnelBlock extends NodeMaterialBlock {
  66765. /**
  66766. * Create a new FresnelBlock
  66767. * @param name defines the block name
  66768. */
  66769. constructor(name: string);
  66770. /**
  66771. * Gets the current class name
  66772. * @returns the class name
  66773. */
  66774. getClassName(): string;
  66775. /**
  66776. * Gets the world normal input component
  66777. */
  66778. get worldNormal(): NodeMaterialConnectionPoint;
  66779. /**
  66780. * Gets the view direction input component
  66781. */
  66782. get viewDirection(): NodeMaterialConnectionPoint;
  66783. /**
  66784. * Gets the bias input component
  66785. */
  66786. get bias(): NodeMaterialConnectionPoint;
  66787. /**
  66788. * Gets the camera (or eye) position component
  66789. */
  66790. get power(): NodeMaterialConnectionPoint;
  66791. /**
  66792. * Gets the fresnel output component
  66793. */
  66794. get fresnel(): NodeMaterialConnectionPoint;
  66795. autoConfigure(material: NodeMaterial): void;
  66796. protected _buildBlock(state: NodeMaterialBuildState): this;
  66797. }
  66798. }
  66799. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66803. /**
  66804. * Block used to get the max of 2 values
  66805. */
  66806. export class MaxBlock extends NodeMaterialBlock {
  66807. /**
  66808. * Creates a new MaxBlock
  66809. * @param name defines the block name
  66810. */
  66811. constructor(name: string);
  66812. /**
  66813. * Gets the current class name
  66814. * @returns the class name
  66815. */
  66816. getClassName(): string;
  66817. /**
  66818. * Gets the left operand input component
  66819. */
  66820. get left(): NodeMaterialConnectionPoint;
  66821. /**
  66822. * Gets the right operand input component
  66823. */
  66824. get right(): NodeMaterialConnectionPoint;
  66825. /**
  66826. * Gets the output component
  66827. */
  66828. get output(): NodeMaterialConnectionPoint;
  66829. protected _buildBlock(state: NodeMaterialBuildState): this;
  66830. }
  66831. }
  66832. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66836. /**
  66837. * Block used to get the min of 2 values
  66838. */
  66839. export class MinBlock extends NodeMaterialBlock {
  66840. /**
  66841. * Creates a new MinBlock
  66842. * @param name defines the block name
  66843. */
  66844. constructor(name: string);
  66845. /**
  66846. * Gets the current class name
  66847. * @returns the class name
  66848. */
  66849. getClassName(): string;
  66850. /**
  66851. * Gets the left operand input component
  66852. */
  66853. get left(): NodeMaterialConnectionPoint;
  66854. /**
  66855. * Gets the right operand input component
  66856. */
  66857. get right(): NodeMaterialConnectionPoint;
  66858. /**
  66859. * Gets the output component
  66860. */
  66861. get output(): NodeMaterialConnectionPoint;
  66862. protected _buildBlock(state: NodeMaterialBuildState): this;
  66863. }
  66864. }
  66865. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66869. /**
  66870. * Block used to get the distance between 2 values
  66871. */
  66872. export class DistanceBlock extends NodeMaterialBlock {
  66873. /**
  66874. * Creates a new DistanceBlock
  66875. * @param name defines the block name
  66876. */
  66877. constructor(name: string);
  66878. /**
  66879. * Gets the current class name
  66880. * @returns the class name
  66881. */
  66882. getClassName(): string;
  66883. /**
  66884. * Gets the left operand input component
  66885. */
  66886. get left(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the right operand input component
  66889. */
  66890. get right(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the output component
  66893. */
  66894. get output(): NodeMaterialConnectionPoint;
  66895. protected _buildBlock(state: NodeMaterialBuildState): this;
  66896. }
  66897. }
  66898. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66902. /**
  66903. * Block used to get the length of a vector
  66904. */
  66905. export class LengthBlock extends NodeMaterialBlock {
  66906. /**
  66907. * Creates a new LengthBlock
  66908. * @param name defines the block name
  66909. */
  66910. constructor(name: string);
  66911. /**
  66912. * Gets the current class name
  66913. * @returns the class name
  66914. */
  66915. getClassName(): string;
  66916. /**
  66917. * Gets the value input component
  66918. */
  66919. get value(): NodeMaterialConnectionPoint;
  66920. /**
  66921. * Gets the output component
  66922. */
  66923. get output(): NodeMaterialConnectionPoint;
  66924. protected _buildBlock(state: NodeMaterialBuildState): this;
  66925. }
  66926. }
  66927. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66931. /**
  66932. * Block used to get negative version of a value (i.e. x * -1)
  66933. */
  66934. export class NegateBlock extends NodeMaterialBlock {
  66935. /**
  66936. * Creates a new NegateBlock
  66937. * @param name defines the block name
  66938. */
  66939. constructor(name: string);
  66940. /**
  66941. * Gets the current class name
  66942. * @returns the class name
  66943. */
  66944. getClassName(): string;
  66945. /**
  66946. * Gets the value input component
  66947. */
  66948. get value(): NodeMaterialConnectionPoint;
  66949. /**
  66950. * Gets the output component
  66951. */
  66952. get output(): NodeMaterialConnectionPoint;
  66953. protected _buildBlock(state: NodeMaterialBuildState): this;
  66954. }
  66955. }
  66956. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66960. /**
  66961. * Block used to get the value of the first parameter raised to the power of the second
  66962. */
  66963. export class PowBlock extends NodeMaterialBlock {
  66964. /**
  66965. * Creates a new PowBlock
  66966. * @param name defines the block name
  66967. */
  66968. constructor(name: string);
  66969. /**
  66970. * Gets the current class name
  66971. * @returns the class name
  66972. */
  66973. getClassName(): string;
  66974. /**
  66975. * Gets the value operand input component
  66976. */
  66977. get value(): NodeMaterialConnectionPoint;
  66978. /**
  66979. * Gets the power operand input component
  66980. */
  66981. get power(): NodeMaterialConnectionPoint;
  66982. /**
  66983. * Gets the output component
  66984. */
  66985. get output(): NodeMaterialConnectionPoint;
  66986. protected _buildBlock(state: NodeMaterialBuildState): this;
  66987. }
  66988. }
  66989. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66993. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66994. /**
  66995. * Block used to get a random number
  66996. */
  66997. export class RandomNumberBlock extends NodeMaterialBlock {
  66998. /**
  66999. * Creates a new RandomNumberBlock
  67000. * @param name defines the block name
  67001. */
  67002. constructor(name: string);
  67003. /**
  67004. * Gets the current class name
  67005. * @returns the class name
  67006. */
  67007. getClassName(): string;
  67008. /**
  67009. * Gets the seed input component
  67010. */
  67011. get seed(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the output component
  67014. */
  67015. get output(): NodeMaterialConnectionPoint;
  67016. protected _buildBlock(state: NodeMaterialBuildState): this;
  67017. }
  67018. }
  67019. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67023. /**
  67024. * Block used to compute arc tangent of 2 values
  67025. */
  67026. export class ArcTan2Block extends NodeMaterialBlock {
  67027. /**
  67028. * Creates a new ArcTan2Block
  67029. * @param name defines the block name
  67030. */
  67031. constructor(name: string);
  67032. /**
  67033. * Gets the current class name
  67034. * @returns the class name
  67035. */
  67036. getClassName(): string;
  67037. /**
  67038. * Gets the x operand input component
  67039. */
  67040. get x(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the y operand input component
  67043. */
  67044. get y(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the output component
  67047. */
  67048. get output(): NodeMaterialConnectionPoint;
  67049. protected _buildBlock(state: NodeMaterialBuildState): this;
  67050. }
  67051. }
  67052. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67056. /**
  67057. * Block used to smooth step a value
  67058. */
  67059. export class SmoothStepBlock extends NodeMaterialBlock {
  67060. /**
  67061. * Creates a new SmoothStepBlock
  67062. * @param name defines the block name
  67063. */
  67064. constructor(name: string);
  67065. /**
  67066. * Gets the current class name
  67067. * @returns the class name
  67068. */
  67069. getClassName(): string;
  67070. /**
  67071. * Gets the value operand input component
  67072. */
  67073. get value(): NodeMaterialConnectionPoint;
  67074. /**
  67075. * Gets the first edge operand input component
  67076. */
  67077. get edge0(): NodeMaterialConnectionPoint;
  67078. /**
  67079. * Gets the second edge operand input component
  67080. */
  67081. get edge1(): NodeMaterialConnectionPoint;
  67082. /**
  67083. * Gets the output component
  67084. */
  67085. get output(): NodeMaterialConnectionPoint;
  67086. protected _buildBlock(state: NodeMaterialBuildState): this;
  67087. }
  67088. }
  67089. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67093. /**
  67094. * Block used to get the reciprocal (1 / x) of a value
  67095. */
  67096. export class ReciprocalBlock extends NodeMaterialBlock {
  67097. /**
  67098. * Creates a new ReciprocalBlock
  67099. * @param name defines the block name
  67100. */
  67101. constructor(name: string);
  67102. /**
  67103. * Gets the current class name
  67104. * @returns the class name
  67105. */
  67106. getClassName(): string;
  67107. /**
  67108. * Gets the input component
  67109. */
  67110. get input(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the output component
  67113. */
  67114. get output(): NodeMaterialConnectionPoint;
  67115. protected _buildBlock(state: NodeMaterialBuildState): this;
  67116. }
  67117. }
  67118. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67122. /**
  67123. * Block used to replace a color by another one
  67124. */
  67125. export class ReplaceColorBlock extends NodeMaterialBlock {
  67126. /**
  67127. * Creates a new ReplaceColorBlock
  67128. * @param name defines the block name
  67129. */
  67130. constructor(name: string);
  67131. /**
  67132. * Gets the current class name
  67133. * @returns the class name
  67134. */
  67135. getClassName(): string;
  67136. /**
  67137. * Gets the value input component
  67138. */
  67139. get value(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the reference input component
  67142. */
  67143. get reference(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the distance input component
  67146. */
  67147. get distance(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the replacement input component
  67150. */
  67151. get replacement(): NodeMaterialConnectionPoint;
  67152. /**
  67153. * Gets the output component
  67154. */
  67155. get output(): NodeMaterialConnectionPoint;
  67156. protected _buildBlock(state: NodeMaterialBuildState): this;
  67157. }
  67158. }
  67159. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67163. /**
  67164. * Block used to posterize a value
  67165. * @see https://en.wikipedia.org/wiki/Posterization
  67166. */
  67167. export class PosterizeBlock extends NodeMaterialBlock {
  67168. /**
  67169. * Creates a new PosterizeBlock
  67170. * @param name defines the block name
  67171. */
  67172. constructor(name: string);
  67173. /**
  67174. * Gets the current class name
  67175. * @returns the class name
  67176. */
  67177. getClassName(): string;
  67178. /**
  67179. * Gets the value input component
  67180. */
  67181. get value(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the steps input component
  67184. */
  67185. get steps(): NodeMaterialConnectionPoint;
  67186. /**
  67187. * Gets the output component
  67188. */
  67189. get output(): NodeMaterialConnectionPoint;
  67190. protected _buildBlock(state: NodeMaterialBuildState): this;
  67191. }
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67197. import { Scene } from "babylonjs/scene";
  67198. /**
  67199. * Operations supported by the Wave block
  67200. */
  67201. export enum WaveBlockKind {
  67202. /** SawTooth */
  67203. SawTooth = 0,
  67204. /** Square */
  67205. Square = 1,
  67206. /** Triangle */
  67207. Triangle = 2
  67208. }
  67209. /**
  67210. * Block used to apply wave operation to floats
  67211. */
  67212. export class WaveBlock extends NodeMaterialBlock {
  67213. /**
  67214. * Gets or sets the kibnd of wave to be applied by the block
  67215. */
  67216. kind: WaveBlockKind;
  67217. /**
  67218. * Creates a new WaveBlock
  67219. * @param name defines the block name
  67220. */
  67221. constructor(name: string);
  67222. /**
  67223. * Gets the current class name
  67224. * @returns the class name
  67225. */
  67226. getClassName(): string;
  67227. /**
  67228. * Gets the input component
  67229. */
  67230. get input(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the output component
  67233. */
  67234. get output(): NodeMaterialConnectionPoint;
  67235. protected _buildBlock(state: NodeMaterialBuildState): this;
  67236. serialize(): any;
  67237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67238. }
  67239. }
  67240. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67244. import { Color3 } from "babylonjs/Maths/math.color";
  67245. import { Scene } from "babylonjs/scene";
  67246. import { Observable } from "babylonjs/Misc/observable";
  67247. /**
  67248. * Class used to store a color step for the GradientBlock
  67249. */
  67250. export class GradientBlockColorStep {
  67251. private _step;
  67252. /**
  67253. * Gets value indicating which step this color is associated with (between 0 and 1)
  67254. */
  67255. get step(): number;
  67256. /**
  67257. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67258. */
  67259. set step(val: number);
  67260. private _color;
  67261. /**
  67262. * Gets the color associated with this step
  67263. */
  67264. get color(): Color3;
  67265. /**
  67266. * Sets the color associated with this step
  67267. */
  67268. set color(val: Color3);
  67269. /**
  67270. * Creates a new GradientBlockColorStep
  67271. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67272. * @param color defines the color associated with this step
  67273. */
  67274. constructor(step: number, color: Color3);
  67275. }
  67276. /**
  67277. * Block used to return a color from a gradient based on an input value between 0 and 1
  67278. */
  67279. export class GradientBlock extends NodeMaterialBlock {
  67280. /**
  67281. * Gets or sets the list of color steps
  67282. */
  67283. colorSteps: GradientBlockColorStep[];
  67284. /** Gets an observable raised when the value is changed */
  67285. onValueChangedObservable: Observable<GradientBlock>;
  67286. /** calls observable when the value is changed*/
  67287. colorStepsUpdated(): void;
  67288. /**
  67289. * Creates a new GradientBlock
  67290. * @param name defines the block name
  67291. */
  67292. constructor(name: string);
  67293. /**
  67294. * Gets the current class name
  67295. * @returns the class name
  67296. */
  67297. getClassName(): string;
  67298. /**
  67299. * Gets the gradient input component
  67300. */
  67301. get gradient(): NodeMaterialConnectionPoint;
  67302. /**
  67303. * Gets the output component
  67304. */
  67305. get output(): NodeMaterialConnectionPoint;
  67306. private _writeColorConstant;
  67307. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67308. serialize(): any;
  67309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67310. protected _dumpPropertiesCode(): string;
  67311. }
  67312. }
  67313. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67317. /**
  67318. * Block used to normalize lerp between 2 values
  67319. */
  67320. export class NLerpBlock extends NodeMaterialBlock {
  67321. /**
  67322. * Creates a new NLerpBlock
  67323. * @param name defines the block name
  67324. */
  67325. constructor(name: string);
  67326. /**
  67327. * Gets the current class name
  67328. * @returns the class name
  67329. */
  67330. getClassName(): string;
  67331. /**
  67332. * Gets the left operand input component
  67333. */
  67334. get left(): NodeMaterialConnectionPoint;
  67335. /**
  67336. * Gets the right operand input component
  67337. */
  67338. get right(): NodeMaterialConnectionPoint;
  67339. /**
  67340. * Gets the gradient operand input component
  67341. */
  67342. get gradient(): NodeMaterialConnectionPoint;
  67343. /**
  67344. * Gets the output component
  67345. */
  67346. get output(): NodeMaterialConnectionPoint;
  67347. protected _buildBlock(state: NodeMaterialBuildState): this;
  67348. }
  67349. }
  67350. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  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. import { Scene } from "babylonjs/scene";
  67355. /**
  67356. * block used to Generate a Worley Noise 3D Noise Pattern
  67357. */
  67358. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67359. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67360. manhattanDistance: boolean;
  67361. /**
  67362. * Creates a new WorleyNoise3DBlock
  67363. * @param name defines the block name
  67364. */
  67365. constructor(name: string);
  67366. /**
  67367. * Gets the current class name
  67368. * @returns the class name
  67369. */
  67370. getClassName(): string;
  67371. /**
  67372. * Gets the seed input component
  67373. */
  67374. get seed(): NodeMaterialConnectionPoint;
  67375. /**
  67376. * Gets the jitter input component
  67377. */
  67378. get jitter(): NodeMaterialConnectionPoint;
  67379. /**
  67380. * Gets the output component
  67381. */
  67382. get output(): NodeMaterialConnectionPoint;
  67383. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67384. /**
  67385. * Exposes the properties to the UI?
  67386. */
  67387. protected _dumpPropertiesCode(): string;
  67388. /**
  67389. * Exposes the properties to the Seralize?
  67390. */
  67391. serialize(): any;
  67392. /**
  67393. * Exposes the properties to the deseralize?
  67394. */
  67395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67396. }
  67397. }
  67398. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67402. /**
  67403. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67404. */
  67405. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67406. /**
  67407. * Creates a new SimplexPerlin3DBlock
  67408. * @param name defines the block name
  67409. */
  67410. constructor(name: string);
  67411. /**
  67412. * Gets the current class name
  67413. * @returns the class name
  67414. */
  67415. getClassName(): string;
  67416. /**
  67417. * Gets the seed operand input component
  67418. */
  67419. get seed(): NodeMaterialConnectionPoint;
  67420. /**
  67421. * Gets the output component
  67422. */
  67423. get output(): NodeMaterialConnectionPoint;
  67424. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67425. }
  67426. }
  67427. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67431. /**
  67432. * Block used to blend normals
  67433. */
  67434. export class NormalBlendBlock extends NodeMaterialBlock {
  67435. /**
  67436. * Creates a new NormalBlendBlock
  67437. * @param name defines the block name
  67438. */
  67439. constructor(name: string);
  67440. /**
  67441. * Gets the current class name
  67442. * @returns the class name
  67443. */
  67444. getClassName(): string;
  67445. /**
  67446. * Gets the first input component
  67447. */
  67448. get normalMap0(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the second input component
  67451. */
  67452. get normalMap1(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the output component
  67455. */
  67456. get output(): NodeMaterialConnectionPoint;
  67457. protected _buildBlock(state: NodeMaterialBuildState): this;
  67458. }
  67459. }
  67460. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67464. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67465. /**
  67466. * Block used to rotate a 2d vector by a given angle
  67467. */
  67468. export class Rotate2dBlock extends NodeMaterialBlock {
  67469. /**
  67470. * Creates a new Rotate2dBlock
  67471. * @param name defines the block name
  67472. */
  67473. constructor(name: string);
  67474. /**
  67475. * Gets the current class name
  67476. * @returns the class name
  67477. */
  67478. getClassName(): string;
  67479. /**
  67480. * Gets the input vector
  67481. */
  67482. get input(): NodeMaterialConnectionPoint;
  67483. /**
  67484. * Gets the input angle
  67485. */
  67486. get angle(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the output component
  67489. */
  67490. get output(): NodeMaterialConnectionPoint;
  67491. autoConfigure(material: NodeMaterial): void;
  67492. protected _buildBlock(state: NodeMaterialBuildState): this;
  67493. }
  67494. }
  67495. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67499. /**
  67500. * Block used to get the reflected vector from a direction and a normal
  67501. */
  67502. export class ReflectBlock extends NodeMaterialBlock {
  67503. /**
  67504. * Creates a new ReflectBlock
  67505. * @param name defines the block name
  67506. */
  67507. constructor(name: string);
  67508. /**
  67509. * Gets the current class name
  67510. * @returns the class name
  67511. */
  67512. getClassName(): string;
  67513. /**
  67514. * Gets the incident component
  67515. */
  67516. get incident(): NodeMaterialConnectionPoint;
  67517. /**
  67518. * Gets the normal component
  67519. */
  67520. get normal(): NodeMaterialConnectionPoint;
  67521. /**
  67522. * Gets the output component
  67523. */
  67524. get output(): NodeMaterialConnectionPoint;
  67525. protected _buildBlock(state: NodeMaterialBuildState): this;
  67526. }
  67527. }
  67528. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67532. /**
  67533. * Block used to get the refracted vector from a direction and a normal
  67534. */
  67535. export class RefractBlock extends NodeMaterialBlock {
  67536. /**
  67537. * Creates a new RefractBlock
  67538. * @param name defines the block name
  67539. */
  67540. constructor(name: string);
  67541. /**
  67542. * Gets the current class name
  67543. * @returns the class name
  67544. */
  67545. getClassName(): string;
  67546. /**
  67547. * Gets the incident component
  67548. */
  67549. get incident(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the normal component
  67552. */
  67553. get normal(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the index of refraction component
  67556. */
  67557. get ior(): NodeMaterialConnectionPoint;
  67558. /**
  67559. * Gets the output component
  67560. */
  67561. get output(): NodeMaterialConnectionPoint;
  67562. protected _buildBlock(state: NodeMaterialBuildState): this;
  67563. }
  67564. }
  67565. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67569. /**
  67570. * Block used to desaturate a color
  67571. */
  67572. export class DesaturateBlock extends NodeMaterialBlock {
  67573. /**
  67574. * Creates a new DesaturateBlock
  67575. * @param name defines the block name
  67576. */
  67577. constructor(name: string);
  67578. /**
  67579. * Gets the current class name
  67580. * @returns the class name
  67581. */
  67582. getClassName(): string;
  67583. /**
  67584. * Gets the color operand input component
  67585. */
  67586. get color(): NodeMaterialConnectionPoint;
  67587. /**
  67588. * Gets the level operand input component
  67589. */
  67590. get level(): NodeMaterialConnectionPoint;
  67591. /**
  67592. * Gets the output component
  67593. */
  67594. get output(): NodeMaterialConnectionPoint;
  67595. protected _buildBlock(state: NodeMaterialBuildState): this;
  67596. }
  67597. }
  67598. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67602. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67603. import { Nullable } from "babylonjs/types";
  67604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67605. import { Scene } from "babylonjs/scene";
  67606. /**
  67607. * Block used to implement the ambient occlusion module of the PBR material
  67608. */
  67609. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67610. /**
  67611. * Create a new AmbientOcclusionBlock
  67612. * @param name defines the block name
  67613. */
  67614. constructor(name: string);
  67615. /**
  67616. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67617. */
  67618. useAmbientInGrayScale: boolean;
  67619. /**
  67620. * Initialize the block and prepare the context for build
  67621. * @param state defines the state that will be used for the build
  67622. */
  67623. initialize(state: NodeMaterialBuildState): void;
  67624. /**
  67625. * Gets the current class name
  67626. * @returns the class name
  67627. */
  67628. getClassName(): string;
  67629. /**
  67630. * Gets the texture input component
  67631. */
  67632. get texture(): NodeMaterialConnectionPoint;
  67633. /**
  67634. * Gets the texture intensity component
  67635. */
  67636. get intensity(): NodeMaterialConnectionPoint;
  67637. /**
  67638. * Gets the direct light intensity input component
  67639. */
  67640. get directLightIntensity(): NodeMaterialConnectionPoint;
  67641. /**
  67642. * Gets the ambient occlusion object output component
  67643. */
  67644. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67645. /**
  67646. * Gets the main code of the block (fragment side)
  67647. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67648. * @returns the shader code
  67649. */
  67650. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67652. protected _buildBlock(state: NodeMaterialBuildState): this;
  67653. protected _dumpPropertiesCode(): string;
  67654. serialize(): any;
  67655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67656. }
  67657. }
  67658. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67661. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67662. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67664. import { Nullable } from "babylonjs/types";
  67665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67666. import { Mesh } from "babylonjs/Meshes/mesh";
  67667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67668. import { Effect } from "babylonjs/Materials/effect";
  67669. import { Scene } from "babylonjs/scene";
  67670. /**
  67671. * Block used to implement the reflection module of the PBR material
  67672. */
  67673. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67674. /** @hidden */
  67675. _defineLODReflectionAlpha: string;
  67676. /** @hidden */
  67677. _defineLinearSpecularReflection: string;
  67678. private _vEnvironmentIrradianceName;
  67679. /** @hidden */
  67680. _vReflectionMicrosurfaceInfosName: string;
  67681. /** @hidden */
  67682. _vReflectionInfosName: string;
  67683. /** @hidden */
  67684. _vReflectionFilteringInfoName: string;
  67685. private _scene;
  67686. /**
  67687. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67688. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67689. * It's less burden on the user side in the editor part.
  67690. */
  67691. /** @hidden */
  67692. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67693. /** @hidden */
  67694. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67695. /** @hidden */
  67696. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67697. /**
  67698. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67699. * diffuse part of the IBL.
  67700. */
  67701. useSphericalHarmonics: boolean;
  67702. /**
  67703. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67704. */
  67705. forceIrradianceInFragment: boolean;
  67706. /**
  67707. * Create a new ReflectionBlock
  67708. * @param name defines the block name
  67709. */
  67710. constructor(name: string);
  67711. /**
  67712. * Gets the current class name
  67713. * @returns the class name
  67714. */
  67715. getClassName(): string;
  67716. /**
  67717. * Gets the position input component
  67718. */
  67719. get position(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the world position input component
  67722. */
  67723. get worldPosition(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the world normal input component
  67726. */
  67727. get worldNormal(): NodeMaterialConnectionPoint;
  67728. /**
  67729. * Gets the world input component
  67730. */
  67731. get world(): NodeMaterialConnectionPoint;
  67732. /**
  67733. * Gets the camera (or eye) position component
  67734. */
  67735. get cameraPosition(): NodeMaterialConnectionPoint;
  67736. /**
  67737. * Gets the view input component
  67738. */
  67739. get view(): NodeMaterialConnectionPoint;
  67740. /**
  67741. * Gets the color input component
  67742. */
  67743. get color(): NodeMaterialConnectionPoint;
  67744. /**
  67745. * Gets the reflection object output component
  67746. */
  67747. get reflection(): NodeMaterialConnectionPoint;
  67748. /**
  67749. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67750. */
  67751. get hasTexture(): boolean;
  67752. /**
  67753. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67754. */
  67755. get reflectionColor(): string;
  67756. protected _getTexture(): Nullable<BaseTexture>;
  67757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67759. /**
  67760. * Gets the code to inject in the vertex shader
  67761. * @param state current state of the node material building
  67762. * @returns the shader code
  67763. */
  67764. handleVertexSide(state: NodeMaterialBuildState): string;
  67765. /**
  67766. * Gets the main code of the block (fragment side)
  67767. * @param state current state of the node material building
  67768. * @param normalVarName name of the existing variable corresponding to the normal
  67769. * @returns the shader code
  67770. */
  67771. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67772. protected _buildBlock(state: NodeMaterialBuildState): this;
  67773. protected _dumpPropertiesCode(): string;
  67774. serialize(): any;
  67775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67776. }
  67777. }
  67778. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67782. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67784. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67785. import { Scene } from "babylonjs/scene";
  67786. import { Nullable } from "babylonjs/types";
  67787. /**
  67788. * Block used to implement the sheen module of the PBR material
  67789. */
  67790. export class SheenBlock extends NodeMaterialBlock {
  67791. /**
  67792. * Create a new SheenBlock
  67793. * @param name defines the block name
  67794. */
  67795. constructor(name: string);
  67796. /**
  67797. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67798. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67799. * making it easier to setup and tweak the effect
  67800. */
  67801. albedoScaling: boolean;
  67802. /**
  67803. * Defines if the sheen is linked to the sheen color.
  67804. */
  67805. linkSheenWithAlbedo: boolean;
  67806. /**
  67807. * Initialize the block and prepare the context for build
  67808. * @param state defines the state that will be used for the build
  67809. */
  67810. initialize(state: NodeMaterialBuildState): void;
  67811. /**
  67812. * Gets the current class name
  67813. * @returns the class name
  67814. */
  67815. getClassName(): string;
  67816. /**
  67817. * Gets the intensity input component
  67818. */
  67819. get intensity(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the color input component
  67822. */
  67823. get color(): NodeMaterialConnectionPoint;
  67824. /**
  67825. * Gets the roughness input component
  67826. */
  67827. get roughness(): NodeMaterialConnectionPoint;
  67828. /**
  67829. * Gets the sheen object output component
  67830. */
  67831. get sheen(): NodeMaterialConnectionPoint;
  67832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67833. /**
  67834. * Gets the main code of the block (fragment side)
  67835. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67836. * @returns the shader code
  67837. */
  67838. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67839. protected _buildBlock(state: NodeMaterialBuildState): this;
  67840. protected _dumpPropertiesCode(): string;
  67841. serialize(): any;
  67842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67843. }
  67844. }
  67845. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67846. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67851. import { Scene } from "babylonjs/scene";
  67852. import { Nullable } from "babylonjs/types";
  67853. import { Mesh } from "babylonjs/Meshes/mesh";
  67854. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67855. import { Effect } from "babylonjs/Materials/effect";
  67856. /**
  67857. * Block used to implement the reflectivity module of the PBR material
  67858. */
  67859. export class ReflectivityBlock extends NodeMaterialBlock {
  67860. private _metallicReflectanceColor;
  67861. private _metallicF0Factor;
  67862. /** @hidden */
  67863. _vMetallicReflectanceFactorsName: string;
  67864. /**
  67865. * The property below is set by the main PBR block prior to calling methods of this class.
  67866. */
  67867. /** @hidden */
  67868. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67869. /**
  67870. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67871. */
  67872. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67873. /**
  67874. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67875. */
  67876. useMetallnessFromMetallicTextureBlue: boolean;
  67877. /**
  67878. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67879. */
  67880. useRoughnessFromMetallicTextureAlpha: boolean;
  67881. /**
  67882. * Specifies if the metallic texture contains the roughness information in its green channel.
  67883. */
  67884. useRoughnessFromMetallicTextureGreen: boolean;
  67885. /**
  67886. * Create a new ReflectivityBlock
  67887. * @param name defines the block name
  67888. */
  67889. constructor(name: string);
  67890. /**
  67891. * Initialize the block and prepare the context for build
  67892. * @param state defines the state that will be used for the build
  67893. */
  67894. initialize(state: NodeMaterialBuildState): void;
  67895. /**
  67896. * Gets the current class name
  67897. * @returns the class name
  67898. */
  67899. getClassName(): string;
  67900. /**
  67901. * Gets the metallic input component
  67902. */
  67903. get metallic(): NodeMaterialConnectionPoint;
  67904. /**
  67905. * Gets the roughness input component
  67906. */
  67907. get roughness(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the texture input component
  67910. */
  67911. get texture(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the reflectivity object output component
  67914. */
  67915. get reflectivity(): NodeMaterialConnectionPoint;
  67916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67917. /**
  67918. * Gets the main code of the block (fragment side)
  67919. * @param state current state of the node material building
  67920. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67921. * @returns the shader code
  67922. */
  67923. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67925. protected _buildBlock(state: NodeMaterialBuildState): this;
  67926. protected _dumpPropertiesCode(): string;
  67927. serialize(): any;
  67928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67929. }
  67930. }
  67931. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67932. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67937. /**
  67938. * Block used to implement the anisotropy module of the PBR material
  67939. */
  67940. export class AnisotropyBlock extends NodeMaterialBlock {
  67941. /**
  67942. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67943. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67944. * It's less burden on the user side in the editor part.
  67945. */
  67946. /** @hidden */
  67947. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67948. /** @hidden */
  67949. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67950. /**
  67951. * Create a new AnisotropyBlock
  67952. * @param name defines the block name
  67953. */
  67954. constructor(name: string);
  67955. /**
  67956. * Initialize the block and prepare the context for build
  67957. * @param state defines the state that will be used for the build
  67958. */
  67959. initialize(state: NodeMaterialBuildState): void;
  67960. /**
  67961. * Gets the current class name
  67962. * @returns the class name
  67963. */
  67964. getClassName(): string;
  67965. /**
  67966. * Gets the intensity input component
  67967. */
  67968. get intensity(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the direction input component
  67971. */
  67972. get direction(): NodeMaterialConnectionPoint;
  67973. /**
  67974. * Gets the texture input component
  67975. */
  67976. get texture(): NodeMaterialConnectionPoint;
  67977. /**
  67978. * Gets the uv input component
  67979. */
  67980. get uv(): NodeMaterialConnectionPoint;
  67981. /**
  67982. * Gets the worldTangent input component
  67983. */
  67984. get worldTangent(): NodeMaterialConnectionPoint;
  67985. /**
  67986. * Gets the anisotropy object output component
  67987. */
  67988. get anisotropy(): NodeMaterialConnectionPoint;
  67989. private _generateTBNSpace;
  67990. /**
  67991. * Gets the main code of the block (fragment side)
  67992. * @param state current state of the node material building
  67993. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67994. * @returns the shader code
  67995. */
  67996. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67998. protected _buildBlock(state: NodeMaterialBuildState): this;
  67999. }
  68000. }
  68001. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68005. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68007. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68008. import { Nullable } from "babylonjs/types";
  68009. import { Mesh } from "babylonjs/Meshes/mesh";
  68010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68011. import { Effect } from "babylonjs/Materials/effect";
  68012. /**
  68013. * Block used to implement the clear coat module of the PBR material
  68014. */
  68015. export class ClearCoatBlock extends NodeMaterialBlock {
  68016. private _scene;
  68017. /**
  68018. * Create a new ClearCoatBlock
  68019. * @param name defines the block name
  68020. */
  68021. constructor(name: string);
  68022. /**
  68023. * Initialize the block and prepare the context for build
  68024. * @param state defines the state that will be used for the build
  68025. */
  68026. initialize(state: NodeMaterialBuildState): void;
  68027. /**
  68028. * Gets the current class name
  68029. * @returns the class name
  68030. */
  68031. getClassName(): string;
  68032. /**
  68033. * Gets the intensity input component
  68034. */
  68035. get intensity(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the roughness input component
  68038. */
  68039. get roughness(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the ior input component
  68042. */
  68043. get ior(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the texture input component
  68046. */
  68047. get texture(): NodeMaterialConnectionPoint;
  68048. /**
  68049. * Gets the bump texture input component
  68050. */
  68051. get bumpTexture(): NodeMaterialConnectionPoint;
  68052. /**
  68053. * Gets the uv input component
  68054. */
  68055. get uv(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the tint color input component
  68058. */
  68059. get tintColor(): NodeMaterialConnectionPoint;
  68060. /**
  68061. * Gets the tint "at distance" input component
  68062. */
  68063. get tintAtDistance(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the tint thickness input component
  68066. */
  68067. get tintThickness(): NodeMaterialConnectionPoint;
  68068. /**
  68069. * Gets the world tangent input component
  68070. */
  68071. get worldTangent(): NodeMaterialConnectionPoint;
  68072. /**
  68073. * Gets the clear coat object output component
  68074. */
  68075. get clearcoat(): NodeMaterialConnectionPoint;
  68076. autoConfigure(material: NodeMaterial): void;
  68077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68079. private _generateTBNSpace;
  68080. /**
  68081. * Gets the main code of the block (fragment side)
  68082. * @param state current state of the node material building
  68083. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68084. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68085. * @param worldPosVarName name of the variable holding the world position
  68086. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68087. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68088. * @param worldNormalVarName name of the variable holding the world normal
  68089. * @returns the shader code
  68090. */
  68091. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68092. protected _buildBlock(state: NodeMaterialBuildState): this;
  68093. }
  68094. }
  68095. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68101. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68102. import { Nullable } from "babylonjs/types";
  68103. /**
  68104. * Block used to implement the sub surface module of the PBR material
  68105. */
  68106. export class SubSurfaceBlock extends NodeMaterialBlock {
  68107. /**
  68108. * Create a new SubSurfaceBlock
  68109. * @param name defines the block name
  68110. */
  68111. constructor(name: string);
  68112. /**
  68113. * Stores the intensity of the different subsurface effects in the thickness texture.
  68114. * * the green channel is the translucency intensity.
  68115. * * the blue channel is the scattering intensity.
  68116. * * the alpha channel is the refraction intensity.
  68117. */
  68118. useMaskFromThicknessTexture: boolean;
  68119. /**
  68120. * Initialize the block and prepare the context for build
  68121. * @param state defines the state that will be used for the build
  68122. */
  68123. initialize(state: NodeMaterialBuildState): void;
  68124. /**
  68125. * Gets the current class name
  68126. * @returns the class name
  68127. */
  68128. getClassName(): string;
  68129. /**
  68130. * Gets the min thickness input component
  68131. */
  68132. get minThickness(): NodeMaterialConnectionPoint;
  68133. /**
  68134. * Gets the max thickness input component
  68135. */
  68136. get maxThickness(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the thickness texture component
  68139. */
  68140. get thicknessTexture(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the tint color input component
  68143. */
  68144. get tintColor(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the translucency intensity input component
  68147. */
  68148. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the translucency diffusion distance input component
  68151. */
  68152. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68153. /**
  68154. * Gets the refraction object parameters
  68155. */
  68156. get refraction(): NodeMaterialConnectionPoint;
  68157. /**
  68158. * Gets the sub surface object output component
  68159. */
  68160. get subsurface(): NodeMaterialConnectionPoint;
  68161. autoConfigure(material: NodeMaterial): void;
  68162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68163. /**
  68164. * Gets the main code of the block (fragment side)
  68165. * @param state current state of the node material building
  68166. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68167. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68168. * @param worldPosVarName name of the variable holding the world position
  68169. * @returns the shader code
  68170. */
  68171. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68172. protected _buildBlock(state: NodeMaterialBuildState): this;
  68173. }
  68174. }
  68175. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68180. import { Light } from "babylonjs/Lights/light";
  68181. import { Nullable } from "babylonjs/types";
  68182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68183. import { Effect } from "babylonjs/Materials/effect";
  68184. import { Mesh } from "babylonjs/Meshes/mesh";
  68185. import { Scene } from "babylonjs/scene";
  68186. /**
  68187. * Block used to implement the PBR metallic/roughness model
  68188. */
  68189. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68190. /**
  68191. * Gets or sets the light associated with this block
  68192. */
  68193. light: Nullable<Light>;
  68194. private _lightId;
  68195. private _scene;
  68196. private _environmentBRDFTexture;
  68197. private _environmentBrdfSamplerName;
  68198. private _vNormalWName;
  68199. private _invertNormalName;
  68200. /**
  68201. * Create a new ReflectionBlock
  68202. * @param name defines the block name
  68203. */
  68204. constructor(name: string);
  68205. /**
  68206. * Intensity of the direct lights e.g. the four lights available in your scene.
  68207. * This impacts both the direct diffuse and specular highlights.
  68208. */
  68209. directIntensity: number;
  68210. /**
  68211. * Intensity of the environment e.g. how much the environment will light the object
  68212. * either through harmonics for rough material or through the refelction for shiny ones.
  68213. */
  68214. environmentIntensity: number;
  68215. /**
  68216. * This is a special control allowing the reduction of the specular highlights coming from the
  68217. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68218. */
  68219. specularIntensity: number;
  68220. /**
  68221. * Defines the falloff type used in this material.
  68222. * It by default is Physical.
  68223. */
  68224. lightFalloff: number;
  68225. /**
  68226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68227. */
  68228. useAlphaFromAlbedoTexture: boolean;
  68229. /**
  68230. * Specifies that alpha test should be used
  68231. */
  68232. useAlphaTest: boolean;
  68233. /**
  68234. * Defines the alpha limits in alpha test mode.
  68235. */
  68236. alphaTestCutoff: number;
  68237. /**
  68238. * Specifies that alpha blending should be used
  68239. */
  68240. useAlphaBlending: boolean;
  68241. /**
  68242. * Defines if the alpha value should be determined via the rgb values.
  68243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68244. */
  68245. opacityRGB: boolean;
  68246. /**
  68247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68249. */
  68250. useRadianceOverAlpha: boolean;
  68251. /**
  68252. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68253. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68254. */
  68255. useSpecularOverAlpha: boolean;
  68256. /**
  68257. * Enables specular anti aliasing in the PBR shader.
  68258. * It will both interacts on the Geometry for analytical and IBL lighting.
  68259. * It also prefilter the roughness map based on the bump values.
  68260. */
  68261. enableSpecularAntiAliasing: boolean;
  68262. /**
  68263. * Enables realtime filtering on the texture.
  68264. */
  68265. realTimeFiltering: boolean;
  68266. /**
  68267. * Quality switch for realtime filtering
  68268. */
  68269. realTimeFilteringQuality: number;
  68270. /**
  68271. * Defines if the material uses energy conservation.
  68272. */
  68273. useEnergyConservation: boolean;
  68274. /**
  68275. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68276. * too much the area relying on ambient texture to define their ambient occlusion.
  68277. */
  68278. useRadianceOcclusion: boolean;
  68279. /**
  68280. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68281. * makes the reflect vector face the model (under horizon).
  68282. */
  68283. useHorizonOcclusion: boolean;
  68284. /**
  68285. * If set to true, no lighting calculations will be applied.
  68286. */
  68287. unlit: boolean;
  68288. /**
  68289. * Force normal to face away from face.
  68290. */
  68291. forceNormalForward: boolean;
  68292. /**
  68293. * Defines the material debug mode.
  68294. * It helps seeing only some components of the material while troubleshooting.
  68295. */
  68296. debugMode: number;
  68297. /**
  68298. * Specify from where on screen the debug mode should start.
  68299. * The value goes from -1 (full screen) to 1 (not visible)
  68300. * It helps with side by side comparison against the final render
  68301. * This defaults to 0
  68302. */
  68303. debugLimit: number;
  68304. /**
  68305. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68306. * You can use the factor to better multiply the final value.
  68307. */
  68308. debugFactor: number;
  68309. /**
  68310. * Initialize the block and prepare the context for build
  68311. * @param state defines the state that will be used for the build
  68312. */
  68313. initialize(state: NodeMaterialBuildState): void;
  68314. /**
  68315. * Gets the current class name
  68316. * @returns the class name
  68317. */
  68318. getClassName(): string;
  68319. /**
  68320. * Gets the world position input component
  68321. */
  68322. get worldPosition(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the world normal input component
  68325. */
  68326. get worldNormal(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the perturbed normal input component
  68329. */
  68330. get perturbedNormal(): NodeMaterialConnectionPoint;
  68331. /**
  68332. * Gets the camera position input component
  68333. */
  68334. get cameraPosition(): NodeMaterialConnectionPoint;
  68335. /**
  68336. * Gets the base color input component
  68337. */
  68338. get baseColor(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the opacity texture input component
  68341. */
  68342. get opacityTexture(): NodeMaterialConnectionPoint;
  68343. /**
  68344. * Gets the ambient color input component
  68345. */
  68346. get ambientColor(): NodeMaterialConnectionPoint;
  68347. /**
  68348. * Gets the reflectivity object parameters
  68349. */
  68350. get reflectivity(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the ambient occlusion object parameters
  68353. */
  68354. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68355. /**
  68356. * Gets the reflection object parameters
  68357. */
  68358. get reflection(): NodeMaterialConnectionPoint;
  68359. /**
  68360. * Gets the sheen object parameters
  68361. */
  68362. get sheen(): NodeMaterialConnectionPoint;
  68363. /**
  68364. * Gets the clear coat object parameters
  68365. */
  68366. get clearcoat(): NodeMaterialConnectionPoint;
  68367. /**
  68368. * Gets the sub surface object parameters
  68369. */
  68370. get subsurface(): NodeMaterialConnectionPoint;
  68371. /**
  68372. * Gets the anisotropy object parameters
  68373. */
  68374. get anisotropy(): NodeMaterialConnectionPoint;
  68375. /**
  68376. * Gets the ambient output component
  68377. */
  68378. get ambient(): NodeMaterialConnectionPoint;
  68379. /**
  68380. * Gets the diffuse output component
  68381. */
  68382. get diffuse(): NodeMaterialConnectionPoint;
  68383. /**
  68384. * Gets the specular output component
  68385. */
  68386. get specular(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the sheen output component
  68389. */
  68390. get sheenDir(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Gets the clear coat output component
  68393. */
  68394. get clearcoatDir(): NodeMaterialConnectionPoint;
  68395. /**
  68396. * Gets the indirect diffuse output component
  68397. */
  68398. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the indirect specular output component
  68401. */
  68402. get specularIndirect(): NodeMaterialConnectionPoint;
  68403. /**
  68404. * Gets the indirect sheen output component
  68405. */
  68406. get sheenIndirect(): NodeMaterialConnectionPoint;
  68407. /**
  68408. * Gets the indirect clear coat output component
  68409. */
  68410. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68411. /**
  68412. * Gets the refraction output component
  68413. */
  68414. get refraction(): NodeMaterialConnectionPoint;
  68415. /**
  68416. * Gets the global lighting output component
  68417. */
  68418. get lighting(): NodeMaterialConnectionPoint;
  68419. /**
  68420. * Gets the shadow output component
  68421. */
  68422. get shadow(): NodeMaterialConnectionPoint;
  68423. /**
  68424. * Gets the alpha output component
  68425. */
  68426. get alpha(): NodeMaterialConnectionPoint;
  68427. autoConfigure(material: NodeMaterial): void;
  68428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68429. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68431. private _injectVertexCode;
  68432. /**
  68433. * Gets the code corresponding to the albedo/opacity module
  68434. * @returns the shader code
  68435. */
  68436. getAlbedoOpacityCode(): string;
  68437. protected _buildBlock(state: NodeMaterialBuildState): this;
  68438. protected _dumpPropertiesCode(): string;
  68439. serialize(): any;
  68440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68441. }
  68442. }
  68443. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68444. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68445. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68446. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68447. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68448. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68449. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68450. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68451. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68452. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68453. }
  68454. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68455. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68456. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68457. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68458. }
  68459. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68463. /**
  68464. * Block used to compute value of one parameter modulo another
  68465. */
  68466. export class ModBlock extends NodeMaterialBlock {
  68467. /**
  68468. * Creates a new ModBlock
  68469. * @param name defines the block name
  68470. */
  68471. constructor(name: string);
  68472. /**
  68473. * Gets the current class name
  68474. * @returns the class name
  68475. */
  68476. getClassName(): string;
  68477. /**
  68478. * Gets the left operand input component
  68479. */
  68480. get left(): NodeMaterialConnectionPoint;
  68481. /**
  68482. * Gets the right operand input component
  68483. */
  68484. get right(): NodeMaterialConnectionPoint;
  68485. /**
  68486. * Gets the output component
  68487. */
  68488. get output(): NodeMaterialConnectionPoint;
  68489. protected _buildBlock(state: NodeMaterialBuildState): this;
  68490. }
  68491. }
  68492. declare module "babylonjs/Materials/Node/Blocks/index" {
  68493. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68494. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68495. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68496. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68497. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68512. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68519. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68520. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68521. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68522. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68523. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68524. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68525. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68526. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68527. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68528. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68529. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68530. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68531. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68532. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68533. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68534. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68535. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68536. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68537. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68538. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68539. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68540. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68541. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68542. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68543. }
  68544. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68545. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68546. }
  68547. declare module "babylonjs/Materials/Node/index" {
  68548. export * from "babylonjs/Materials/Node/Enums/index";
  68549. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68550. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68551. export * from "babylonjs/Materials/Node/nodeMaterial";
  68552. export * from "babylonjs/Materials/Node/Blocks/index";
  68553. export * from "babylonjs/Materials/Node/Optimizers/index";
  68554. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68555. }
  68556. declare module "babylonjs/Materials/index" {
  68557. export * from "babylonjs/Materials/Background/index";
  68558. export * from "babylonjs/Materials/colorCurves";
  68559. export * from "babylonjs/Materials/iEffectFallbacks";
  68560. export * from "babylonjs/Materials/effectFallbacks";
  68561. export * from "babylonjs/Materials/effect";
  68562. export * from "babylonjs/Materials/fresnelParameters";
  68563. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68564. export * from "babylonjs/Materials/material";
  68565. export * from "babylonjs/Materials/materialDefines";
  68566. export * from "babylonjs/Materials/thinMaterialHelper";
  68567. export * from "babylonjs/Materials/materialHelper";
  68568. export * from "babylonjs/Materials/multiMaterial";
  68569. export * from "babylonjs/Materials/PBR/index";
  68570. export * from "babylonjs/Materials/pushMaterial";
  68571. export * from "babylonjs/Materials/shaderMaterial";
  68572. export * from "babylonjs/Materials/standardMaterial";
  68573. export * from "babylonjs/Materials/Textures/index";
  68574. export * from "babylonjs/Materials/uniformBuffer";
  68575. export * from "babylonjs/Materials/materialFlags";
  68576. export * from "babylonjs/Materials/Node/index";
  68577. export * from "babylonjs/Materials/effectRenderer";
  68578. export * from "babylonjs/Materials/shadowDepthWrapper";
  68579. }
  68580. declare module "babylonjs/Maths/index" {
  68581. export * from "babylonjs/Maths/math.scalar";
  68582. export * from "babylonjs/Maths/math";
  68583. export * from "babylonjs/Maths/sphericalPolynomial";
  68584. }
  68585. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68586. import { IDisposable } from "babylonjs/scene";
  68587. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68588. /**
  68589. * Configuration for Draco compression
  68590. */
  68591. export interface IDracoCompressionConfiguration {
  68592. /**
  68593. * Configuration for the decoder.
  68594. */
  68595. decoder: {
  68596. /**
  68597. * The url to the WebAssembly module.
  68598. */
  68599. wasmUrl?: string;
  68600. /**
  68601. * The url to the WebAssembly binary.
  68602. */
  68603. wasmBinaryUrl?: string;
  68604. /**
  68605. * The url to the fallback JavaScript module.
  68606. */
  68607. fallbackUrl?: string;
  68608. };
  68609. }
  68610. /**
  68611. * Draco compression (https://google.github.io/draco/)
  68612. *
  68613. * This class wraps the Draco module.
  68614. *
  68615. * **Encoder**
  68616. *
  68617. * The encoder is not currently implemented.
  68618. *
  68619. * **Decoder**
  68620. *
  68621. * 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.
  68622. *
  68623. * To update the configuration, use the following code:
  68624. * ```javascript
  68625. * DracoCompression.Configuration = {
  68626. * decoder: {
  68627. * wasmUrl: "<url to the WebAssembly library>",
  68628. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68629. * fallbackUrl: "<url to the fallback JavaScript library>",
  68630. * }
  68631. * };
  68632. * ```
  68633. *
  68634. * 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.
  68635. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68636. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68637. *
  68638. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68639. * ```javascript
  68640. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68641. * ```
  68642. *
  68643. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68644. */
  68645. export class DracoCompression implements IDisposable {
  68646. private _workerPoolPromise?;
  68647. private _decoderModulePromise?;
  68648. /**
  68649. * The configuration. Defaults to the following urls:
  68650. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68651. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68652. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68653. */
  68654. static Configuration: IDracoCompressionConfiguration;
  68655. /**
  68656. * Returns true if the decoder configuration is available.
  68657. */
  68658. static get DecoderAvailable(): boolean;
  68659. /**
  68660. * Default number of workers to create when creating the draco compression object.
  68661. */
  68662. static DefaultNumWorkers: number;
  68663. private static GetDefaultNumWorkers;
  68664. private static _Default;
  68665. /**
  68666. * Default instance for the draco compression object.
  68667. */
  68668. static get Default(): DracoCompression;
  68669. /**
  68670. * Constructor
  68671. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68672. */
  68673. constructor(numWorkers?: number);
  68674. /**
  68675. * Stop all async operations and release resources.
  68676. */
  68677. dispose(): void;
  68678. /**
  68679. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68680. * @returns a promise that resolves when ready
  68681. */
  68682. whenReadyAsync(): Promise<void>;
  68683. /**
  68684. * Decode Draco compressed mesh data to vertex data.
  68685. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68686. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68687. * @returns A promise that resolves with the decoded vertex data
  68688. */
  68689. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68690. [kind: string]: number;
  68691. }): Promise<VertexData>;
  68692. }
  68693. }
  68694. declare module "babylonjs/Meshes/Compression/index" {
  68695. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68696. }
  68697. declare module "babylonjs/Meshes/csg" {
  68698. import { Nullable } from "babylonjs/types";
  68699. import { Scene } from "babylonjs/scene";
  68700. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68701. import { Mesh } from "babylonjs/Meshes/mesh";
  68702. import { Material } from "babylonjs/Materials/material";
  68703. /**
  68704. * Class for building Constructive Solid Geometry
  68705. */
  68706. export class CSG {
  68707. private polygons;
  68708. /**
  68709. * The world matrix
  68710. */
  68711. matrix: Matrix;
  68712. /**
  68713. * Stores the position
  68714. */
  68715. position: Vector3;
  68716. /**
  68717. * Stores the rotation
  68718. */
  68719. rotation: Vector3;
  68720. /**
  68721. * Stores the rotation quaternion
  68722. */
  68723. rotationQuaternion: Nullable<Quaternion>;
  68724. /**
  68725. * Stores the scaling vector
  68726. */
  68727. scaling: Vector3;
  68728. /**
  68729. * Convert the Mesh to CSG
  68730. * @param mesh The Mesh to convert to CSG
  68731. * @returns A new CSG from the Mesh
  68732. */
  68733. static FromMesh(mesh: Mesh): CSG;
  68734. /**
  68735. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68736. * @param polygons Polygons used to construct a CSG solid
  68737. */
  68738. private static FromPolygons;
  68739. /**
  68740. * Clones, or makes a deep copy, of the CSG
  68741. * @returns A new CSG
  68742. */
  68743. clone(): CSG;
  68744. /**
  68745. * Unions this CSG with another CSG
  68746. * @param csg The CSG to union against this CSG
  68747. * @returns The unioned CSG
  68748. */
  68749. union(csg: CSG): CSG;
  68750. /**
  68751. * Unions this CSG with another CSG in place
  68752. * @param csg The CSG to union against this CSG
  68753. */
  68754. unionInPlace(csg: CSG): void;
  68755. /**
  68756. * Subtracts this CSG with another CSG
  68757. * @param csg The CSG to subtract against this CSG
  68758. * @returns A new CSG
  68759. */
  68760. subtract(csg: CSG): CSG;
  68761. /**
  68762. * Subtracts this CSG with another CSG in place
  68763. * @param csg The CSG to subtact against this CSG
  68764. */
  68765. subtractInPlace(csg: CSG): void;
  68766. /**
  68767. * Intersect this CSG with another CSG
  68768. * @param csg The CSG to intersect against this CSG
  68769. * @returns A new CSG
  68770. */
  68771. intersect(csg: CSG): CSG;
  68772. /**
  68773. * Intersects this CSG with another CSG in place
  68774. * @param csg The CSG to intersect against this CSG
  68775. */
  68776. intersectInPlace(csg: CSG): void;
  68777. /**
  68778. * Return a new CSG solid with solid and empty space switched. This solid is
  68779. * not modified.
  68780. * @returns A new CSG solid with solid and empty space switched
  68781. */
  68782. inverse(): CSG;
  68783. /**
  68784. * Inverses the CSG in place
  68785. */
  68786. inverseInPlace(): void;
  68787. /**
  68788. * This is used to keep meshes transformations so they can be restored
  68789. * when we build back a Babylon Mesh
  68790. * NB : All CSG operations are performed in world coordinates
  68791. * @param csg The CSG to copy the transform attributes from
  68792. * @returns This CSG
  68793. */
  68794. copyTransformAttributes(csg: CSG): CSG;
  68795. /**
  68796. * Build Raw mesh from CSG
  68797. * Coordinates here are in world space
  68798. * @param name The name of the mesh geometry
  68799. * @param scene The Scene
  68800. * @param keepSubMeshes Specifies if the submeshes should be kept
  68801. * @returns A new Mesh
  68802. */
  68803. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68804. /**
  68805. * Build Mesh from CSG taking material and transforms into account
  68806. * @param name The name of the Mesh
  68807. * @param material The material of the Mesh
  68808. * @param scene The Scene
  68809. * @param keepSubMeshes Specifies if submeshes should be kept
  68810. * @returns The new Mesh
  68811. */
  68812. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68813. }
  68814. }
  68815. declare module "babylonjs/Meshes/trailMesh" {
  68816. import { Mesh } from "babylonjs/Meshes/mesh";
  68817. import { Scene } from "babylonjs/scene";
  68818. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68819. /**
  68820. * Class used to create a trail following a mesh
  68821. */
  68822. export class TrailMesh extends Mesh {
  68823. private _generator;
  68824. private _autoStart;
  68825. private _running;
  68826. private _diameter;
  68827. private _length;
  68828. private _sectionPolygonPointsCount;
  68829. private _sectionVectors;
  68830. private _sectionNormalVectors;
  68831. private _beforeRenderObserver;
  68832. /**
  68833. * @constructor
  68834. * @param name The value used by scene.getMeshByName() to do a lookup.
  68835. * @param generator The mesh or transform node to generate a trail.
  68836. * @param scene The scene to add this mesh to.
  68837. * @param diameter Diameter of trailing mesh. Default is 1.
  68838. * @param length Length of trailing mesh. Default is 60.
  68839. * @param autoStart Automatically start trailing mesh. Default true.
  68840. */
  68841. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68842. /**
  68843. * "TrailMesh"
  68844. * @returns "TrailMesh"
  68845. */
  68846. getClassName(): string;
  68847. private _createMesh;
  68848. /**
  68849. * Start trailing mesh.
  68850. */
  68851. start(): void;
  68852. /**
  68853. * Stop trailing mesh.
  68854. */
  68855. stop(): void;
  68856. /**
  68857. * Update trailing mesh geometry.
  68858. */
  68859. update(): void;
  68860. /**
  68861. * Returns a new TrailMesh object.
  68862. * @param name is a string, the name given to the new mesh
  68863. * @param newGenerator use new generator object for cloned trail mesh
  68864. * @returns a new mesh
  68865. */
  68866. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68867. /**
  68868. * Serializes this trail mesh
  68869. * @param serializationObject object to write serialization to
  68870. */
  68871. serialize(serializationObject: any): void;
  68872. /**
  68873. * Parses a serialized trail mesh
  68874. * @param parsedMesh the serialized mesh
  68875. * @param scene the scene to create the trail mesh in
  68876. * @returns the created trail mesh
  68877. */
  68878. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68879. }
  68880. }
  68881. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68882. import { Nullable } from "babylonjs/types";
  68883. import { Scene } from "babylonjs/scene";
  68884. import { Vector4 } from "babylonjs/Maths/math.vector";
  68885. import { Color4 } from "babylonjs/Maths/math.color";
  68886. import { Mesh } from "babylonjs/Meshes/mesh";
  68887. /**
  68888. * Class containing static functions to help procedurally build meshes
  68889. */
  68890. export class TiledBoxBuilder {
  68891. /**
  68892. * Creates a box mesh
  68893. * 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)
  68894. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68898. * @param name defines the name of the mesh
  68899. * @param options defines the options used to create the mesh
  68900. * @param scene defines the hosting scene
  68901. * @returns the box mesh
  68902. */
  68903. static CreateTiledBox(name: string, options: {
  68904. pattern?: number;
  68905. width?: number;
  68906. height?: number;
  68907. depth?: number;
  68908. tileSize?: number;
  68909. tileWidth?: number;
  68910. tileHeight?: number;
  68911. alignHorizontal?: number;
  68912. alignVertical?: number;
  68913. faceUV?: Vector4[];
  68914. faceColors?: Color4[];
  68915. sideOrientation?: number;
  68916. updatable?: boolean;
  68917. }, scene?: Nullable<Scene>): Mesh;
  68918. }
  68919. }
  68920. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68921. import { Vector4 } from "babylonjs/Maths/math.vector";
  68922. import { Mesh } from "babylonjs/Meshes/mesh";
  68923. /**
  68924. * Class containing static functions to help procedurally build meshes
  68925. */
  68926. export class TorusKnotBuilder {
  68927. /**
  68928. * Creates a torus knot mesh
  68929. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68930. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68931. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68932. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68936. * @param name defines the name of the mesh
  68937. * @param options defines the options used to create the mesh
  68938. * @param scene defines the hosting scene
  68939. * @returns the torus knot mesh
  68940. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68941. */
  68942. static CreateTorusKnot(name: string, options: {
  68943. radius?: number;
  68944. tube?: number;
  68945. radialSegments?: number;
  68946. tubularSegments?: number;
  68947. p?: number;
  68948. q?: number;
  68949. updatable?: boolean;
  68950. sideOrientation?: number;
  68951. frontUVs?: Vector4;
  68952. backUVs?: Vector4;
  68953. }, scene: any): Mesh;
  68954. }
  68955. }
  68956. declare module "babylonjs/Meshes/polygonMesh" {
  68957. import { Scene } from "babylonjs/scene";
  68958. import { Vector2 } from "babylonjs/Maths/math.vector";
  68959. import { Mesh } from "babylonjs/Meshes/mesh";
  68960. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68961. import { Path2 } from "babylonjs/Maths/math.path";
  68962. /**
  68963. * Polygon
  68964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68965. */
  68966. export class Polygon {
  68967. /**
  68968. * Creates a rectangle
  68969. * @param xmin bottom X coord
  68970. * @param ymin bottom Y coord
  68971. * @param xmax top X coord
  68972. * @param ymax top Y coord
  68973. * @returns points that make the resulting rectation
  68974. */
  68975. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68976. /**
  68977. * Creates a circle
  68978. * @param radius radius of circle
  68979. * @param cx scale in x
  68980. * @param cy scale in y
  68981. * @param numberOfSides number of sides that make up the circle
  68982. * @returns points that make the resulting circle
  68983. */
  68984. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68985. /**
  68986. * Creates a polygon from input string
  68987. * @param input Input polygon data
  68988. * @returns the parsed points
  68989. */
  68990. static Parse(input: string): Vector2[];
  68991. /**
  68992. * Starts building a polygon from x and y coordinates
  68993. * @param x x coordinate
  68994. * @param y y coordinate
  68995. * @returns the started path2
  68996. */
  68997. static StartingAt(x: number, y: number): Path2;
  68998. }
  68999. /**
  69000. * Builds a polygon
  69001. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69002. */
  69003. export class PolygonMeshBuilder {
  69004. private _points;
  69005. private _outlinepoints;
  69006. private _holes;
  69007. private _name;
  69008. private _scene;
  69009. private _epoints;
  69010. private _eholes;
  69011. private _addToepoint;
  69012. /**
  69013. * Babylon reference to the earcut plugin.
  69014. */
  69015. bjsEarcut: any;
  69016. /**
  69017. * Creates a PolygonMeshBuilder
  69018. * @param name name of the builder
  69019. * @param contours Path of the polygon
  69020. * @param scene scene to add to when creating the mesh
  69021. * @param earcutInjection can be used to inject your own earcut reference
  69022. */
  69023. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69024. /**
  69025. * Adds a whole within the polygon
  69026. * @param hole Array of points defining the hole
  69027. * @returns this
  69028. */
  69029. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69030. /**
  69031. * Creates the polygon
  69032. * @param updatable If the mesh should be updatable
  69033. * @param depth The depth of the mesh created
  69034. * @returns the created mesh
  69035. */
  69036. build(updatable?: boolean, depth?: number): Mesh;
  69037. /**
  69038. * Creates the polygon
  69039. * @param depth The depth of the mesh created
  69040. * @returns the created VertexData
  69041. */
  69042. buildVertexData(depth?: number): VertexData;
  69043. /**
  69044. * Adds a side to the polygon
  69045. * @param positions points that make the polygon
  69046. * @param normals normals of the polygon
  69047. * @param uvs uvs of the polygon
  69048. * @param indices indices of the polygon
  69049. * @param bounds bounds of the polygon
  69050. * @param points points of the polygon
  69051. * @param depth depth of the polygon
  69052. * @param flip flip of the polygon
  69053. */
  69054. private addSide;
  69055. }
  69056. }
  69057. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69058. import { Scene } from "babylonjs/scene";
  69059. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69060. import { Color4 } from "babylonjs/Maths/math.color";
  69061. import { Mesh } from "babylonjs/Meshes/mesh";
  69062. import { Nullable } from "babylonjs/types";
  69063. /**
  69064. * Class containing static functions to help procedurally build meshes
  69065. */
  69066. export class PolygonBuilder {
  69067. /**
  69068. * Creates a polygon mesh
  69069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69070. * * 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
  69071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69074. * * Remember you can only change the shape positions, not their number when updating a polygon
  69075. * @param name defines the name of the mesh
  69076. * @param options defines the options used to create the mesh
  69077. * @param scene defines the hosting scene
  69078. * @param earcutInjection can be used to inject your own earcut reference
  69079. * @returns the polygon mesh
  69080. */
  69081. static CreatePolygon(name: string, options: {
  69082. shape: Vector3[];
  69083. holes?: Vector3[][];
  69084. depth?: number;
  69085. faceUV?: Vector4[];
  69086. faceColors?: Color4[];
  69087. updatable?: boolean;
  69088. sideOrientation?: number;
  69089. frontUVs?: Vector4;
  69090. backUVs?: Vector4;
  69091. wrap?: boolean;
  69092. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69093. /**
  69094. * Creates an extruded polygon mesh, with depth in the Y direction.
  69095. * * 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)
  69096. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69097. * @param name defines the name of the mesh
  69098. * @param options defines the options used to create the mesh
  69099. * @param scene defines the hosting scene
  69100. * @param earcutInjection can be used to inject your own earcut reference
  69101. * @returns the polygon mesh
  69102. */
  69103. static ExtrudePolygon(name: string, options: {
  69104. shape: Vector3[];
  69105. holes?: Vector3[][];
  69106. depth?: number;
  69107. faceUV?: Vector4[];
  69108. faceColors?: Color4[];
  69109. updatable?: boolean;
  69110. sideOrientation?: number;
  69111. frontUVs?: Vector4;
  69112. backUVs?: Vector4;
  69113. wrap?: boolean;
  69114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69115. }
  69116. }
  69117. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69118. import { Scene } from "babylonjs/scene";
  69119. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69120. import { Mesh } from "babylonjs/Meshes/mesh";
  69121. import { Nullable } from "babylonjs/types";
  69122. /**
  69123. * Class containing static functions to help procedurally build meshes
  69124. */
  69125. export class LatheBuilder {
  69126. /**
  69127. * Creates lathe mesh.
  69128. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69129. * * 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
  69130. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69131. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69132. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69133. * * 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
  69134. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69135. * * 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
  69136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69140. * @param name defines the name of the mesh
  69141. * @param options defines the options used to create the mesh
  69142. * @param scene defines the hosting scene
  69143. * @returns the lathe mesh
  69144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69145. */
  69146. static CreateLathe(name: string, options: {
  69147. shape: Vector3[];
  69148. radius?: number;
  69149. tessellation?: number;
  69150. clip?: number;
  69151. arc?: number;
  69152. closed?: boolean;
  69153. updatable?: boolean;
  69154. sideOrientation?: number;
  69155. frontUVs?: Vector4;
  69156. backUVs?: Vector4;
  69157. cap?: number;
  69158. invertUV?: boolean;
  69159. }, scene?: Nullable<Scene>): Mesh;
  69160. }
  69161. }
  69162. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69163. import { Nullable } from "babylonjs/types";
  69164. import { Scene } from "babylonjs/scene";
  69165. import { Vector4 } from "babylonjs/Maths/math.vector";
  69166. import { Mesh } from "babylonjs/Meshes/mesh";
  69167. /**
  69168. * Class containing static functions to help procedurally build meshes
  69169. */
  69170. export class TiledPlaneBuilder {
  69171. /**
  69172. * Creates a tiled plane mesh
  69173. * * The parameter `pattern` will, depending on value, do nothing or
  69174. * * * flip (reflect about central vertical) alternate tiles across and up
  69175. * * * flip every tile on alternate rows
  69176. * * * rotate (180 degs) alternate tiles across and up
  69177. * * * rotate every tile on alternate rows
  69178. * * * flip and rotate alternate tiles across and up
  69179. * * * flip and rotate every tile on alternate rows
  69180. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69181. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  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. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69184. * * 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)
  69185. * * 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)
  69186. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69187. * @param name defines the name of the mesh
  69188. * @param options defines the options used to create the mesh
  69189. * @param scene defines the hosting scene
  69190. * @returns the box mesh
  69191. */
  69192. static CreateTiledPlane(name: string, options: {
  69193. pattern?: number;
  69194. tileSize?: number;
  69195. tileWidth?: number;
  69196. tileHeight?: number;
  69197. size?: number;
  69198. width?: number;
  69199. height?: number;
  69200. alignHorizontal?: number;
  69201. alignVertical?: number;
  69202. sideOrientation?: number;
  69203. frontUVs?: Vector4;
  69204. backUVs?: Vector4;
  69205. updatable?: boolean;
  69206. }, scene?: Nullable<Scene>): Mesh;
  69207. }
  69208. }
  69209. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69210. import { Nullable } from "babylonjs/types";
  69211. import { Scene } from "babylonjs/scene";
  69212. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69213. import { Mesh } from "babylonjs/Meshes/mesh";
  69214. /**
  69215. * Class containing static functions to help procedurally build meshes
  69216. */
  69217. export class TubeBuilder {
  69218. /**
  69219. * Creates a tube mesh.
  69220. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69221. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69222. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69223. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69224. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69225. * * 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)
  69226. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69227. * * 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
  69228. * * 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
  69229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69233. * @param name defines the name of the mesh
  69234. * @param options defines the options used to create the mesh
  69235. * @param scene defines the hosting scene
  69236. * @returns the tube mesh
  69237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69238. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69239. */
  69240. static CreateTube(name: string, options: {
  69241. path: Vector3[];
  69242. radius?: number;
  69243. tessellation?: number;
  69244. radiusFunction?: {
  69245. (i: number, distance: number): number;
  69246. };
  69247. cap?: number;
  69248. arc?: number;
  69249. updatable?: boolean;
  69250. sideOrientation?: number;
  69251. frontUVs?: Vector4;
  69252. backUVs?: Vector4;
  69253. instance?: Mesh;
  69254. invertUV?: boolean;
  69255. }, scene?: Nullable<Scene>): Mesh;
  69256. }
  69257. }
  69258. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69259. import { Scene } from "babylonjs/scene";
  69260. import { Vector4 } from "babylonjs/Maths/math.vector";
  69261. import { Mesh } from "babylonjs/Meshes/mesh";
  69262. import { Nullable } from "babylonjs/types";
  69263. /**
  69264. * Class containing static functions to help procedurally build meshes
  69265. */
  69266. export class IcoSphereBuilder {
  69267. /**
  69268. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69269. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69270. * * 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`)
  69271. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69272. * * 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
  69273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69276. * @param name defines the name of the mesh
  69277. * @param options defines the options used to create the mesh
  69278. * @param scene defines the hosting scene
  69279. * @returns the icosahedron mesh
  69280. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69281. */
  69282. static CreateIcoSphere(name: string, options: {
  69283. radius?: number;
  69284. radiusX?: number;
  69285. radiusY?: number;
  69286. radiusZ?: number;
  69287. flat?: boolean;
  69288. subdivisions?: number;
  69289. sideOrientation?: number;
  69290. frontUVs?: Vector4;
  69291. backUVs?: Vector4;
  69292. updatable?: boolean;
  69293. }, scene?: Nullable<Scene>): Mesh;
  69294. }
  69295. }
  69296. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69297. import { Vector3 } from "babylonjs/Maths/math.vector";
  69298. import { Mesh } from "babylonjs/Meshes/mesh";
  69299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69300. /**
  69301. * Class containing static functions to help procedurally build meshes
  69302. */
  69303. export class DecalBuilder {
  69304. /**
  69305. * Creates a decal mesh.
  69306. * 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
  69307. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69308. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69309. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69310. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69311. * @param name defines the name of the mesh
  69312. * @param sourceMesh defines the mesh where the decal must be applied
  69313. * @param options defines the options used to create the mesh
  69314. * @param scene defines the hosting scene
  69315. * @returns the decal mesh
  69316. * @see https://doc.babylonjs.com/how_to/decals
  69317. */
  69318. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69319. position?: Vector3;
  69320. normal?: Vector3;
  69321. size?: Vector3;
  69322. angle?: number;
  69323. }): Mesh;
  69324. }
  69325. }
  69326. declare module "babylonjs/Meshes/meshBuilder" {
  69327. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69328. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69329. import { Nullable } from "babylonjs/types";
  69330. import { Scene } from "babylonjs/scene";
  69331. import { Mesh } from "babylonjs/Meshes/mesh";
  69332. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69333. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69335. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69336. import { Plane } from "babylonjs/Maths/math.plane";
  69337. /**
  69338. * Class containing static functions to help procedurally build meshes
  69339. */
  69340. export class MeshBuilder {
  69341. /**
  69342. * Creates a box mesh
  69343. * * The parameter `size` sets the size (float) of each box side (default 1)
  69344. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69345. * * 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)
  69346. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69350. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69351. * @param name defines the name of the mesh
  69352. * @param options defines the options used to create the mesh
  69353. * @param scene defines the hosting scene
  69354. * @returns the box mesh
  69355. */
  69356. static CreateBox(name: string, options: {
  69357. size?: number;
  69358. width?: number;
  69359. height?: number;
  69360. depth?: number;
  69361. faceUV?: Vector4[];
  69362. faceColors?: Color4[];
  69363. sideOrientation?: number;
  69364. frontUVs?: Vector4;
  69365. backUVs?: Vector4;
  69366. wrap?: boolean;
  69367. topBaseAt?: number;
  69368. bottomBaseAt?: number;
  69369. updatable?: boolean;
  69370. }, scene?: Nullable<Scene>): Mesh;
  69371. /**
  69372. * Creates a tiled box mesh
  69373. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69375. * @param name defines the name of the mesh
  69376. * @param options defines the options used to create the mesh
  69377. * @param scene defines the hosting scene
  69378. * @returns the tiled box mesh
  69379. */
  69380. static CreateTiledBox(name: string, options: {
  69381. pattern?: number;
  69382. size?: number;
  69383. width?: number;
  69384. height?: number;
  69385. depth: number;
  69386. tileSize?: number;
  69387. tileWidth?: number;
  69388. tileHeight?: number;
  69389. faceUV?: Vector4[];
  69390. faceColors?: Color4[];
  69391. alignHorizontal?: number;
  69392. alignVertical?: number;
  69393. sideOrientation?: number;
  69394. updatable?: boolean;
  69395. }, scene?: Nullable<Scene>): Mesh;
  69396. /**
  69397. * Creates a sphere mesh
  69398. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69399. * * 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`)
  69400. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69401. * * 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
  69402. * * 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)
  69403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69406. * @param name defines the name of the mesh
  69407. * @param options defines the options used to create the mesh
  69408. * @param scene defines the hosting scene
  69409. * @returns the sphere mesh
  69410. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69411. */
  69412. static CreateSphere(name: string, options: {
  69413. segments?: number;
  69414. diameter?: number;
  69415. diameterX?: number;
  69416. diameterY?: number;
  69417. diameterZ?: number;
  69418. arc?: number;
  69419. slice?: number;
  69420. sideOrientation?: number;
  69421. frontUVs?: Vector4;
  69422. backUVs?: Vector4;
  69423. updatable?: boolean;
  69424. }, scene?: Nullable<Scene>): Mesh;
  69425. /**
  69426. * Creates a plane polygonal mesh. By default, this is a disc
  69427. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69428. * * 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
  69429. * * 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
  69430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69433. * @param name defines the name of the mesh
  69434. * @param options defines the options used to create the mesh
  69435. * @param scene defines the hosting scene
  69436. * @returns the plane polygonal mesh
  69437. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69438. */
  69439. static CreateDisc(name: string, options: {
  69440. radius?: number;
  69441. tessellation?: number;
  69442. arc?: number;
  69443. updatable?: boolean;
  69444. sideOrientation?: number;
  69445. frontUVs?: Vector4;
  69446. backUVs?: Vector4;
  69447. }, scene?: Nullable<Scene>): Mesh;
  69448. /**
  69449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69451. * * 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`)
  69452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69453. * * 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
  69454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69457. * @param name defines the name of the mesh
  69458. * @param options defines the options used to create the mesh
  69459. * @param scene defines the hosting scene
  69460. * @returns the icosahedron mesh
  69461. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69462. */
  69463. static CreateIcoSphere(name: string, options: {
  69464. radius?: number;
  69465. radiusX?: number;
  69466. radiusY?: number;
  69467. radiusZ?: number;
  69468. flat?: boolean;
  69469. subdivisions?: number;
  69470. sideOrientation?: number;
  69471. frontUVs?: Vector4;
  69472. backUVs?: Vector4;
  69473. updatable?: boolean;
  69474. }, scene?: Nullable<Scene>): Mesh;
  69475. /**
  69476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69480. * * 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
  69481. * * 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
  69482. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69486. * * 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
  69487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69488. * * 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
  69489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69491. * @param name defines the name of the mesh
  69492. * @param options defines the options used to create the mesh
  69493. * @param scene defines the hosting scene
  69494. * @returns the ribbon mesh
  69495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69497. */
  69498. static CreateRibbon(name: string, options: {
  69499. pathArray: Vector3[][];
  69500. closeArray?: boolean;
  69501. closePath?: boolean;
  69502. offset?: number;
  69503. updatable?: boolean;
  69504. sideOrientation?: number;
  69505. frontUVs?: Vector4;
  69506. backUVs?: Vector4;
  69507. instance?: Mesh;
  69508. invertUV?: boolean;
  69509. uvs?: Vector2[];
  69510. colors?: Color4[];
  69511. }, scene?: Nullable<Scene>): Mesh;
  69512. /**
  69513. * Creates a cylinder or a cone mesh
  69514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69516. * * 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.
  69517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69521. * * 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).
  69522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69523. * * 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).
  69524. * * 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
  69525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69526. * * 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
  69527. * * 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.
  69528. * * If `enclose` is false, a ring surface is one element.
  69529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69530. * * 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
  69531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69534. * @param name defines the name of the mesh
  69535. * @param options defines the options used to create the mesh
  69536. * @param scene defines the hosting scene
  69537. * @returns the cylinder mesh
  69538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69539. */
  69540. static CreateCylinder(name: string, options: {
  69541. height?: number;
  69542. diameterTop?: number;
  69543. diameterBottom?: number;
  69544. diameter?: number;
  69545. tessellation?: number;
  69546. subdivisions?: number;
  69547. arc?: number;
  69548. faceColors?: Color4[];
  69549. faceUV?: Vector4[];
  69550. updatable?: boolean;
  69551. hasRings?: boolean;
  69552. enclose?: boolean;
  69553. cap?: number;
  69554. sideOrientation?: number;
  69555. frontUVs?: Vector4;
  69556. backUVs?: Vector4;
  69557. }, scene?: Nullable<Scene>): Mesh;
  69558. /**
  69559. * Creates a torus mesh
  69560. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69561. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69562. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69566. * @param name defines the name of the mesh
  69567. * @param options defines the options used to create the mesh
  69568. * @param scene defines the hosting scene
  69569. * @returns the torus mesh
  69570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69571. */
  69572. static CreateTorus(name: string, options: {
  69573. diameter?: number;
  69574. thickness?: number;
  69575. tessellation?: number;
  69576. updatable?: boolean;
  69577. sideOrientation?: number;
  69578. frontUVs?: Vector4;
  69579. backUVs?: Vector4;
  69580. }, scene?: Nullable<Scene>): Mesh;
  69581. /**
  69582. * Creates a torus knot mesh
  69583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69590. * @param name defines the name of the mesh
  69591. * @param options defines the options used to create the mesh
  69592. * @param scene defines the hosting scene
  69593. * @returns the torus knot mesh
  69594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69595. */
  69596. static CreateTorusKnot(name: string, options: {
  69597. radius?: number;
  69598. tube?: number;
  69599. radialSegments?: number;
  69600. tubularSegments?: number;
  69601. p?: number;
  69602. q?: number;
  69603. updatable?: boolean;
  69604. sideOrientation?: number;
  69605. frontUVs?: Vector4;
  69606. backUVs?: Vector4;
  69607. }, scene?: Nullable<Scene>): Mesh;
  69608. /**
  69609. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69610. * * 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
  69611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69612. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69613. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69614. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69616. * * 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
  69617. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69620. * @param name defines the name of the new line system
  69621. * @param options defines the options used to create the line system
  69622. * @param scene defines the hosting scene
  69623. * @returns a new line system mesh
  69624. */
  69625. static CreateLineSystem(name: string, options: {
  69626. lines: Vector3[][];
  69627. updatable?: boolean;
  69628. instance?: Nullable<LinesMesh>;
  69629. colors?: Nullable<Color4[][]>;
  69630. useVertexAlpha?: boolean;
  69631. }, scene: Nullable<Scene>): LinesMesh;
  69632. /**
  69633. * Creates a line mesh
  69634. * 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
  69635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69636. * * The parameter `points` is an array successive Vector3
  69637. * * 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
  69638. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69639. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69640. * * When updating an instance, remember that only point positions can change, not the number of points
  69641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69643. * @param name defines the name of the new line system
  69644. * @param options defines the options used to create the line system
  69645. * @param scene defines the hosting scene
  69646. * @returns a new line mesh
  69647. */
  69648. static CreateLines(name: string, options: {
  69649. points: Vector3[];
  69650. updatable?: boolean;
  69651. instance?: Nullable<LinesMesh>;
  69652. colors?: Color4[];
  69653. useVertexAlpha?: boolean;
  69654. }, scene?: Nullable<Scene>): LinesMesh;
  69655. /**
  69656. * Creates a dashed line mesh
  69657. * * 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
  69658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69659. * * The parameter `points` is an array successive Vector3
  69660. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69661. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69662. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69663. * * 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
  69664. * * When updating an instance, remember that only point positions can change, not the number of points
  69665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69666. * @param name defines the name of the mesh
  69667. * @param options defines the options used to create the mesh
  69668. * @param scene defines the hosting scene
  69669. * @returns the dashed line mesh
  69670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69671. */
  69672. static CreateDashedLines(name: string, options: {
  69673. points: Vector3[];
  69674. dashSize?: number;
  69675. gapSize?: number;
  69676. dashNb?: number;
  69677. updatable?: boolean;
  69678. instance?: LinesMesh;
  69679. }, scene?: Nullable<Scene>): LinesMesh;
  69680. /**
  69681. * 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.
  69682. * * 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.
  69683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69684. * * 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.
  69685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69686. * * 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
  69687. * * 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
  69688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69693. * @param name defines the name of the mesh
  69694. * @param options defines the options used to create the mesh
  69695. * @param scene defines the hosting scene
  69696. * @returns the extruded shape mesh
  69697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69699. */
  69700. static ExtrudeShape(name: string, options: {
  69701. shape: Vector3[];
  69702. path: Vector3[];
  69703. scale?: number;
  69704. rotation?: number;
  69705. cap?: number;
  69706. updatable?: boolean;
  69707. sideOrientation?: number;
  69708. frontUVs?: Vector4;
  69709. backUVs?: Vector4;
  69710. instance?: Mesh;
  69711. invertUV?: boolean;
  69712. }, scene?: Nullable<Scene>): Mesh;
  69713. /**
  69714. * Creates an custom extruded shape mesh.
  69715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69716. * * 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.
  69717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69718. * * 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
  69719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69720. * * 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
  69721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69724. * * 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
  69725. * * 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
  69726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69731. * @param name defines the name of the mesh
  69732. * @param options defines the options used to create the mesh
  69733. * @param scene defines the hosting scene
  69734. * @returns the custom extruded shape mesh
  69735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69738. */
  69739. static ExtrudeShapeCustom(name: string, options: {
  69740. shape: Vector3[];
  69741. path: Vector3[];
  69742. scaleFunction?: any;
  69743. rotationFunction?: any;
  69744. ribbonCloseArray?: boolean;
  69745. ribbonClosePath?: boolean;
  69746. cap?: number;
  69747. updatable?: boolean;
  69748. sideOrientation?: number;
  69749. frontUVs?: Vector4;
  69750. backUVs?: Vector4;
  69751. instance?: Mesh;
  69752. invertUV?: boolean;
  69753. }, scene?: Nullable<Scene>): Mesh;
  69754. /**
  69755. * Creates lathe mesh.
  69756. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69757. * * 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
  69758. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69759. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69760. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69761. * * 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
  69762. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69763. * * 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
  69764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69768. * @param name defines the name of the mesh
  69769. * @param options defines the options used to create the mesh
  69770. * @param scene defines the hosting scene
  69771. * @returns the lathe mesh
  69772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69773. */
  69774. static CreateLathe(name: string, options: {
  69775. shape: Vector3[];
  69776. radius?: number;
  69777. tessellation?: number;
  69778. clip?: number;
  69779. arc?: number;
  69780. closed?: boolean;
  69781. updatable?: boolean;
  69782. sideOrientation?: number;
  69783. frontUVs?: Vector4;
  69784. backUVs?: Vector4;
  69785. cap?: number;
  69786. invertUV?: boolean;
  69787. }, scene?: Nullable<Scene>): Mesh;
  69788. /**
  69789. * Creates a tiled plane mesh
  69790. * * You can set a limited pattern arrangement with the tiles
  69791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69794. * @param name defines the name of the mesh
  69795. * @param options defines the options used to create the mesh
  69796. * @param scene defines the hosting scene
  69797. * @returns the plane mesh
  69798. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69799. */
  69800. static CreateTiledPlane(name: string, options: {
  69801. pattern?: number;
  69802. tileSize?: number;
  69803. tileWidth?: number;
  69804. tileHeight?: number;
  69805. size?: number;
  69806. width?: number;
  69807. height?: number;
  69808. alignHorizontal?: number;
  69809. alignVertical?: number;
  69810. sideOrientation?: number;
  69811. frontUVs?: Vector4;
  69812. backUVs?: Vector4;
  69813. updatable?: boolean;
  69814. }, scene?: Nullable<Scene>): Mesh;
  69815. /**
  69816. * Creates a plane mesh
  69817. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69818. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69819. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69823. * @param name defines the name of the mesh
  69824. * @param options defines the options used to create the mesh
  69825. * @param scene defines the hosting scene
  69826. * @returns the plane mesh
  69827. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69828. */
  69829. static CreatePlane(name: string, options: {
  69830. size?: number;
  69831. width?: number;
  69832. height?: number;
  69833. sideOrientation?: number;
  69834. frontUVs?: Vector4;
  69835. backUVs?: Vector4;
  69836. updatable?: boolean;
  69837. sourcePlane?: Plane;
  69838. }, scene?: Nullable<Scene>): Mesh;
  69839. /**
  69840. * Creates a ground mesh
  69841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69844. * @param name defines the name of the mesh
  69845. * @param options defines the options used to create the mesh
  69846. * @param scene defines the hosting scene
  69847. * @returns the ground mesh
  69848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69849. */
  69850. static CreateGround(name: string, options: {
  69851. width?: number;
  69852. height?: number;
  69853. subdivisions?: number;
  69854. subdivisionsX?: number;
  69855. subdivisionsY?: number;
  69856. updatable?: boolean;
  69857. }, scene?: Nullable<Scene>): Mesh;
  69858. /**
  69859. * Creates a tiled ground mesh
  69860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69862. * * 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
  69863. * * 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
  69864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69865. * @param name defines the name of the mesh
  69866. * @param options defines the options used to create the mesh
  69867. * @param scene defines the hosting scene
  69868. * @returns the tiled ground mesh
  69869. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69870. */
  69871. static CreateTiledGround(name: string, options: {
  69872. xmin: number;
  69873. zmin: number;
  69874. xmax: number;
  69875. zmax: number;
  69876. subdivisions?: {
  69877. w: number;
  69878. h: number;
  69879. };
  69880. precision?: {
  69881. w: number;
  69882. h: number;
  69883. };
  69884. updatable?: boolean;
  69885. }, scene?: Nullable<Scene>): Mesh;
  69886. /**
  69887. * Creates a ground mesh from a height map
  69888. * * The parameter `url` sets the URL of the height map image resource.
  69889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69893. * * 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.
  69894. * * 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).
  69895. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69897. * @param name defines the name of the mesh
  69898. * @param url defines the url to the height map
  69899. * @param options defines the options used to create the mesh
  69900. * @param scene defines the hosting scene
  69901. * @returns the ground mesh
  69902. * @see https://doc.babylonjs.com/babylon101/height_map
  69903. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69904. */
  69905. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69906. width?: number;
  69907. height?: number;
  69908. subdivisions?: number;
  69909. minHeight?: number;
  69910. maxHeight?: number;
  69911. colorFilter?: Color3;
  69912. alphaFilter?: number;
  69913. updatable?: boolean;
  69914. onReady?: (mesh: GroundMesh) => void;
  69915. }, scene?: Nullable<Scene>): GroundMesh;
  69916. /**
  69917. * Creates a polygon mesh
  69918. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69919. * * 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
  69920. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69923. * * Remember you can only change the shape positions, not their number when updating a polygon
  69924. * @param name defines the name of the mesh
  69925. * @param options defines the options used to create the mesh
  69926. * @param scene defines the hosting scene
  69927. * @param earcutInjection can be used to inject your own earcut reference
  69928. * @returns the polygon mesh
  69929. */
  69930. static CreatePolygon(name: string, options: {
  69931. shape: Vector3[];
  69932. holes?: Vector3[][];
  69933. depth?: number;
  69934. faceUV?: Vector4[];
  69935. faceColors?: Color4[];
  69936. updatable?: boolean;
  69937. sideOrientation?: number;
  69938. frontUVs?: Vector4;
  69939. backUVs?: Vector4;
  69940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69941. /**
  69942. * Creates an extruded polygon mesh, with depth in the Y direction.
  69943. * * 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)
  69944. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69945. * @param name defines the name of the mesh
  69946. * @param options defines the options used to create the mesh
  69947. * @param scene defines the hosting scene
  69948. * @param earcutInjection can be used to inject your own earcut reference
  69949. * @returns the polygon mesh
  69950. */
  69951. static ExtrudePolygon(name: string, options: {
  69952. shape: Vector3[];
  69953. holes?: Vector3[][];
  69954. depth?: number;
  69955. faceUV?: Vector4[];
  69956. faceColors?: Color4[];
  69957. updatable?: boolean;
  69958. sideOrientation?: number;
  69959. frontUVs?: Vector4;
  69960. backUVs?: Vector4;
  69961. wrap?: boolean;
  69962. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69963. /**
  69964. * Creates a tube mesh.
  69965. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69966. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69967. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69968. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69969. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69970. * * 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)
  69971. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69972. * * 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
  69973. * * 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
  69974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69976. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69978. * @param name defines the name of the mesh
  69979. * @param options defines the options used to create the mesh
  69980. * @param scene defines the hosting scene
  69981. * @returns the tube mesh
  69982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69983. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69984. */
  69985. static CreateTube(name: string, options: {
  69986. path: Vector3[];
  69987. radius?: number;
  69988. tessellation?: number;
  69989. radiusFunction?: {
  69990. (i: number, distance: number): number;
  69991. };
  69992. cap?: number;
  69993. arc?: number;
  69994. updatable?: boolean;
  69995. sideOrientation?: number;
  69996. frontUVs?: Vector4;
  69997. backUVs?: Vector4;
  69998. instance?: Mesh;
  69999. invertUV?: boolean;
  70000. }, scene?: Nullable<Scene>): Mesh;
  70001. /**
  70002. * Creates a polyhedron mesh
  70003. * * 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
  70004. * * The parameter `size` (positive float, default 1) sets the polygon size
  70005. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70006. * * 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`
  70007. * * 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
  70008. * * 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)`)
  70009. * * 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
  70010. * * 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
  70011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70014. * @param name defines the name of the mesh
  70015. * @param options defines the options used to create the mesh
  70016. * @param scene defines the hosting scene
  70017. * @returns the polyhedron mesh
  70018. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70019. */
  70020. static CreatePolyhedron(name: string, options: {
  70021. type?: number;
  70022. size?: number;
  70023. sizeX?: number;
  70024. sizeY?: number;
  70025. sizeZ?: number;
  70026. custom?: any;
  70027. faceUV?: Vector4[];
  70028. faceColors?: Color4[];
  70029. flat?: boolean;
  70030. updatable?: boolean;
  70031. sideOrientation?: number;
  70032. frontUVs?: Vector4;
  70033. backUVs?: Vector4;
  70034. }, scene?: Nullable<Scene>): Mesh;
  70035. /**
  70036. * Creates a decal mesh.
  70037. * 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
  70038. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70039. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70040. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70041. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70042. * @param name defines the name of the mesh
  70043. * @param sourceMesh defines the mesh where the decal must be applied
  70044. * @param options defines the options used to create the mesh
  70045. * @param scene defines the hosting scene
  70046. * @returns the decal mesh
  70047. * @see https://doc.babylonjs.com/how_to/decals
  70048. */
  70049. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70050. position?: Vector3;
  70051. normal?: Vector3;
  70052. size?: Vector3;
  70053. angle?: number;
  70054. }): Mesh;
  70055. /**
  70056. * Creates a Capsule Mesh
  70057. * @param name defines the name of the mesh.
  70058. * @param options the constructors options used to shape the mesh.
  70059. * @param scene defines the scene the mesh is scoped to.
  70060. * @returns the capsule mesh
  70061. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70062. */
  70063. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70064. }
  70065. }
  70066. declare module "babylonjs/Meshes/meshSimplification" {
  70067. import { Mesh } from "babylonjs/Meshes/mesh";
  70068. /**
  70069. * A simplifier interface for future simplification implementations
  70070. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70071. */
  70072. export interface ISimplifier {
  70073. /**
  70074. * Simplification of a given mesh according to the given settings.
  70075. * Since this requires computation, it is assumed that the function runs async.
  70076. * @param settings The settings of the simplification, including quality and distance
  70077. * @param successCallback A callback that will be called after the mesh was simplified.
  70078. * @param errorCallback in case of an error, this callback will be called. optional.
  70079. */
  70080. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70081. }
  70082. /**
  70083. * Expected simplification settings.
  70084. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70085. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70086. */
  70087. export interface ISimplificationSettings {
  70088. /**
  70089. * Gets or sets the expected quality
  70090. */
  70091. quality: number;
  70092. /**
  70093. * Gets or sets the distance when this optimized version should be used
  70094. */
  70095. distance: number;
  70096. /**
  70097. * Gets an already optimized mesh
  70098. */
  70099. optimizeMesh?: boolean;
  70100. }
  70101. /**
  70102. * Class used to specify simplification options
  70103. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70104. */
  70105. export class SimplificationSettings implements ISimplificationSettings {
  70106. /** expected quality */
  70107. quality: number;
  70108. /** distance when this optimized version should be used */
  70109. distance: number;
  70110. /** already optimized mesh */
  70111. optimizeMesh?: boolean | undefined;
  70112. /**
  70113. * Creates a SimplificationSettings
  70114. * @param quality expected quality
  70115. * @param distance distance when this optimized version should be used
  70116. * @param optimizeMesh already optimized mesh
  70117. */
  70118. constructor(
  70119. /** expected quality */
  70120. quality: number,
  70121. /** distance when this optimized version should be used */
  70122. distance: number,
  70123. /** already optimized mesh */
  70124. optimizeMesh?: boolean | undefined);
  70125. }
  70126. /**
  70127. * Interface used to define a simplification task
  70128. */
  70129. export interface ISimplificationTask {
  70130. /**
  70131. * Array of settings
  70132. */
  70133. settings: Array<ISimplificationSettings>;
  70134. /**
  70135. * Simplification type
  70136. */
  70137. simplificationType: SimplificationType;
  70138. /**
  70139. * Mesh to simplify
  70140. */
  70141. mesh: Mesh;
  70142. /**
  70143. * Callback called on success
  70144. */
  70145. successCallback?: () => void;
  70146. /**
  70147. * Defines if parallel processing can be used
  70148. */
  70149. parallelProcessing: boolean;
  70150. }
  70151. /**
  70152. * Queue used to order the simplification tasks
  70153. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70154. */
  70155. export class SimplificationQueue {
  70156. private _simplificationArray;
  70157. /**
  70158. * Gets a boolean indicating that the process is still running
  70159. */
  70160. running: boolean;
  70161. /**
  70162. * Creates a new queue
  70163. */
  70164. constructor();
  70165. /**
  70166. * Adds a new simplification task
  70167. * @param task defines a task to add
  70168. */
  70169. addTask(task: ISimplificationTask): void;
  70170. /**
  70171. * Execute next task
  70172. */
  70173. executeNext(): void;
  70174. /**
  70175. * Execute a simplification task
  70176. * @param task defines the task to run
  70177. */
  70178. runSimplification(task: ISimplificationTask): void;
  70179. private getSimplifier;
  70180. }
  70181. /**
  70182. * The implemented types of simplification
  70183. * At the moment only Quadratic Error Decimation is implemented
  70184. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70185. */
  70186. export enum SimplificationType {
  70187. /** Quadratic error decimation */
  70188. QUADRATIC = 0
  70189. }
  70190. /**
  70191. * An implementation of the Quadratic Error simplification algorithm.
  70192. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70193. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70194. * @author RaananW
  70195. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70196. */
  70197. export class QuadraticErrorSimplification implements ISimplifier {
  70198. private _mesh;
  70199. private triangles;
  70200. private vertices;
  70201. private references;
  70202. private _reconstructedMesh;
  70203. /** Gets or sets the number pf sync interations */
  70204. syncIterations: number;
  70205. /** Gets or sets the aggressiveness of the simplifier */
  70206. aggressiveness: number;
  70207. /** Gets or sets the number of allowed iterations for decimation */
  70208. decimationIterations: number;
  70209. /** Gets or sets the espilon to use for bounding box computation */
  70210. boundingBoxEpsilon: number;
  70211. /**
  70212. * Creates a new QuadraticErrorSimplification
  70213. * @param _mesh defines the target mesh
  70214. */
  70215. constructor(_mesh: Mesh);
  70216. /**
  70217. * Simplification of a given mesh according to the given settings.
  70218. * Since this requires computation, it is assumed that the function runs async.
  70219. * @param settings The settings of the simplification, including quality and distance
  70220. * @param successCallback A callback that will be called after the mesh was simplified.
  70221. */
  70222. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70223. private runDecimation;
  70224. private initWithMesh;
  70225. private init;
  70226. private reconstructMesh;
  70227. private initDecimatedMesh;
  70228. private isFlipped;
  70229. private updateTriangles;
  70230. private identifyBorder;
  70231. private updateMesh;
  70232. private vertexError;
  70233. private calculateError;
  70234. }
  70235. }
  70236. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70237. import { Scene } from "babylonjs/scene";
  70238. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70239. import { ISceneComponent } from "babylonjs/sceneComponent";
  70240. module "babylonjs/scene" {
  70241. interface Scene {
  70242. /** @hidden (Backing field) */
  70243. _simplificationQueue: SimplificationQueue;
  70244. /**
  70245. * Gets or sets the simplification queue attached to the scene
  70246. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70247. */
  70248. simplificationQueue: SimplificationQueue;
  70249. }
  70250. }
  70251. module "babylonjs/Meshes/mesh" {
  70252. interface Mesh {
  70253. /**
  70254. * Simplify the mesh according to the given array of settings.
  70255. * Function will return immediately and will simplify async
  70256. * @param settings a collection of simplification settings
  70257. * @param parallelProcessing should all levels calculate parallel or one after the other
  70258. * @param simplificationType the type of simplification to run
  70259. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70260. * @returns the current mesh
  70261. */
  70262. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70263. }
  70264. }
  70265. /**
  70266. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70267. * created in a scene
  70268. */
  70269. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70270. /**
  70271. * The component name helpfull to identify the component in the list of scene components.
  70272. */
  70273. readonly name: string;
  70274. /**
  70275. * The scene the component belongs to.
  70276. */
  70277. scene: Scene;
  70278. /**
  70279. * Creates a new instance of the component for the given scene
  70280. * @param scene Defines the scene to register the component in
  70281. */
  70282. constructor(scene: Scene);
  70283. /**
  70284. * Registers the component in a given scene
  70285. */
  70286. register(): void;
  70287. /**
  70288. * Rebuilds the elements related to this component in case of
  70289. * context lost for instance.
  70290. */
  70291. rebuild(): void;
  70292. /**
  70293. * Disposes the component and the associated ressources
  70294. */
  70295. dispose(): void;
  70296. private _beforeCameraUpdate;
  70297. }
  70298. }
  70299. declare module "babylonjs/Meshes/Builders/index" {
  70300. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70301. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70302. export * from "babylonjs/Meshes/Builders/discBuilder";
  70303. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70304. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70305. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70306. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70307. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70308. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70309. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70310. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70311. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70312. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70313. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70314. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70315. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70316. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70317. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70318. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70319. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70320. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70321. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70322. }
  70323. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70324. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70325. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70326. import { Matrix } from "babylonjs/Maths/math.vector";
  70327. module "babylonjs/Meshes/mesh" {
  70328. interface Mesh {
  70329. /**
  70330. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70331. */
  70332. thinInstanceEnablePicking: boolean;
  70333. /**
  70334. * Creates a new thin instance
  70335. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70336. * @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
  70337. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70338. */
  70339. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70340. /**
  70341. * Adds the transformation (matrix) of the current mesh as a thin instance
  70342. * @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
  70343. * @returns the thin instance index number
  70344. */
  70345. thinInstanceAddSelf(refresh: boolean): number;
  70346. /**
  70347. * Registers a custom attribute to be used with thin instances
  70348. * @param kind name of the attribute
  70349. * @param stride size in floats of the attribute
  70350. */
  70351. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70352. /**
  70353. * Sets the matrix of a thin instance
  70354. * @param index index of the thin instance
  70355. * @param matrix matrix to set
  70356. * @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
  70357. */
  70358. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70359. /**
  70360. * Sets the value of a custom attribute for a thin instance
  70361. * @param kind name of the attribute
  70362. * @param index index of the thin instance
  70363. * @param value value to set
  70364. * @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
  70365. */
  70366. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70367. /**
  70368. * 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.
  70369. */
  70370. thinInstanceCount: number;
  70371. /**
  70372. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70373. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70374. * @param buffer buffer to set
  70375. * @param stride size in floats of each value of the buffer
  70376. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70377. */
  70378. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70379. /**
  70380. * Gets the list of world matrices
  70381. * @return an array containing all the world matrices from the thin instances
  70382. */
  70383. thinInstanceGetWorldMatrices(): Matrix[];
  70384. /**
  70385. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70386. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70387. */
  70388. thinInstanceBufferUpdated(kind: string): void;
  70389. /**
  70390. * Applies a partial update to a buffer directly on the GPU
  70391. * 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
  70392. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70393. * @param data the data to set in the GPU buffer
  70394. * @param offset the offset in the GPU buffer where to update the data
  70395. */
  70396. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70397. /**
  70398. * Refreshes the bounding info, taking into account all the thin instances defined
  70399. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70400. */
  70401. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70402. /** @hidden */
  70403. _thinInstanceInitializeUserStorage(): void;
  70404. /** @hidden */
  70405. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70406. /** @hidden */
  70407. _userThinInstanceBuffersStorage: {
  70408. data: {
  70409. [key: string]: Float32Array;
  70410. };
  70411. sizes: {
  70412. [key: string]: number;
  70413. };
  70414. vertexBuffers: {
  70415. [key: string]: Nullable<VertexBuffer>;
  70416. };
  70417. strides: {
  70418. [key: string]: number;
  70419. };
  70420. };
  70421. }
  70422. }
  70423. }
  70424. declare module "babylonjs/Meshes/index" {
  70425. export * from "babylonjs/Meshes/abstractMesh";
  70426. export * from "babylonjs/Meshes/buffer";
  70427. export * from "babylonjs/Meshes/Compression/index";
  70428. export * from "babylonjs/Meshes/csg";
  70429. export * from "babylonjs/Meshes/geometry";
  70430. export * from "babylonjs/Meshes/groundMesh";
  70431. export * from "babylonjs/Meshes/trailMesh";
  70432. export * from "babylonjs/Meshes/instancedMesh";
  70433. export * from "babylonjs/Meshes/linesMesh";
  70434. export * from "babylonjs/Meshes/mesh";
  70435. export * from "babylonjs/Meshes/mesh.vertexData";
  70436. export * from "babylonjs/Meshes/meshBuilder";
  70437. export * from "babylonjs/Meshes/meshSimplification";
  70438. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70439. export * from "babylonjs/Meshes/polygonMesh";
  70440. export * from "babylonjs/Meshes/subMesh";
  70441. export * from "babylonjs/Meshes/meshLODLevel";
  70442. export * from "babylonjs/Meshes/transformNode";
  70443. export * from "babylonjs/Meshes/Builders/index";
  70444. export * from "babylonjs/Meshes/dataBuffer";
  70445. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70446. import "babylonjs/Meshes/thinInstanceMesh";
  70447. export * from "babylonjs/Meshes/thinInstanceMesh";
  70448. }
  70449. declare module "babylonjs/Morph/index" {
  70450. export * from "babylonjs/Morph/morphTarget";
  70451. export * from "babylonjs/Morph/morphTargetManager";
  70452. }
  70453. declare module "babylonjs/Navigation/INavigationEngine" {
  70454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70455. import { Vector3 } from "babylonjs/Maths/math";
  70456. import { Mesh } from "babylonjs/Meshes/mesh";
  70457. import { Scene } from "babylonjs/scene";
  70458. /**
  70459. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70460. */
  70461. export interface INavigationEnginePlugin {
  70462. /**
  70463. * plugin name
  70464. */
  70465. name: string;
  70466. /**
  70467. * Creates a navigation mesh
  70468. * @param meshes array of all the geometry used to compute the navigatio mesh
  70469. * @param parameters bunch of parameters used to filter geometry
  70470. */
  70471. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70472. /**
  70473. * Create a navigation mesh debug mesh
  70474. * @param scene is where the mesh will be added
  70475. * @returns debug display mesh
  70476. */
  70477. createDebugNavMesh(scene: Scene): Mesh;
  70478. /**
  70479. * Get a navigation mesh constrained position, closest to the parameter position
  70480. * @param position world position
  70481. * @returns the closest point to position constrained by the navigation mesh
  70482. */
  70483. getClosestPoint(position: Vector3): Vector3;
  70484. /**
  70485. * Get a navigation mesh constrained position, closest to the parameter position
  70486. * @param position world position
  70487. * @param result output the closest point to position constrained by the navigation mesh
  70488. */
  70489. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70490. /**
  70491. * Get a navigation mesh constrained position, within a particular radius
  70492. * @param position world position
  70493. * @param maxRadius the maximum distance to the constrained world position
  70494. * @returns the closest point to position constrained by the navigation mesh
  70495. */
  70496. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70497. /**
  70498. * Get a navigation mesh constrained position, within a particular radius
  70499. * @param position world position
  70500. * @param maxRadius the maximum distance to the constrained world position
  70501. * @param result output the closest point to position constrained by the navigation mesh
  70502. */
  70503. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70504. /**
  70505. * Compute the final position from a segment made of destination-position
  70506. * @param position world position
  70507. * @param destination world position
  70508. * @returns the resulting point along the navmesh
  70509. */
  70510. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70511. /**
  70512. * Compute the final position from a segment made of destination-position
  70513. * @param position world position
  70514. * @param destination world position
  70515. * @param result output the resulting point along the navmesh
  70516. */
  70517. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70518. /**
  70519. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70520. * @param start world position
  70521. * @param end world position
  70522. * @returns array containing world position composing the path
  70523. */
  70524. computePath(start: Vector3, end: Vector3): Vector3[];
  70525. /**
  70526. * If this plugin is supported
  70527. * @returns true if plugin is supported
  70528. */
  70529. isSupported(): boolean;
  70530. /**
  70531. * Create a new Crowd so you can add agents
  70532. * @param maxAgents the maximum agent count in the crowd
  70533. * @param maxAgentRadius the maximum radius an agent can have
  70534. * @param scene to attach the crowd to
  70535. * @returns the crowd you can add agents to
  70536. */
  70537. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70538. /**
  70539. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70540. * The queries will try to find a solution within those bounds
  70541. * default is (1,1,1)
  70542. * @param extent x,y,z value that define the extent around the queries point of reference
  70543. */
  70544. setDefaultQueryExtent(extent: Vector3): void;
  70545. /**
  70546. * Get the Bounding box extent specified by setDefaultQueryExtent
  70547. * @returns the box extent values
  70548. */
  70549. getDefaultQueryExtent(): Vector3;
  70550. /**
  70551. * build the navmesh from a previously saved state using getNavmeshData
  70552. * @param data the Uint8Array returned by getNavmeshData
  70553. */
  70554. buildFromNavmeshData(data: Uint8Array): void;
  70555. /**
  70556. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70557. * @returns data the Uint8Array that can be saved and reused
  70558. */
  70559. getNavmeshData(): Uint8Array;
  70560. /**
  70561. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70562. * @param result output the box extent values
  70563. */
  70564. getDefaultQueryExtentToRef(result: Vector3): void;
  70565. /**
  70566. * Release all resources
  70567. */
  70568. dispose(): void;
  70569. }
  70570. /**
  70571. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70572. */
  70573. export interface ICrowd {
  70574. /**
  70575. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70576. * You can attach anything to that node. The node position is updated in the scene update tick.
  70577. * @param pos world position that will be constrained by the navigation mesh
  70578. * @param parameters agent parameters
  70579. * @param transform hooked to the agent that will be update by the scene
  70580. * @returns agent index
  70581. */
  70582. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70583. /**
  70584. * Returns the agent position in world space
  70585. * @param index agent index returned by addAgent
  70586. * @returns world space position
  70587. */
  70588. getAgentPosition(index: number): Vector3;
  70589. /**
  70590. * Gets the agent position result in world space
  70591. * @param index agent index returned by addAgent
  70592. * @param result output world space position
  70593. */
  70594. getAgentPositionToRef(index: number, result: Vector3): void;
  70595. /**
  70596. * Gets the agent velocity in world space
  70597. * @param index agent index returned by addAgent
  70598. * @returns world space velocity
  70599. */
  70600. getAgentVelocity(index: number): Vector3;
  70601. /**
  70602. * Gets the agent velocity result in world space
  70603. * @param index agent index returned by addAgent
  70604. * @param result output world space velocity
  70605. */
  70606. getAgentVelocityToRef(index: number, result: Vector3): void;
  70607. /**
  70608. * remove a particular agent previously created
  70609. * @param index agent index returned by addAgent
  70610. */
  70611. removeAgent(index: number): void;
  70612. /**
  70613. * get the list of all agents attached to this crowd
  70614. * @returns list of agent indices
  70615. */
  70616. getAgents(): number[];
  70617. /**
  70618. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70619. * @param deltaTime in seconds
  70620. */
  70621. update(deltaTime: number): void;
  70622. /**
  70623. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70624. * @param index agent index returned by addAgent
  70625. * @param destination targeted world position
  70626. */
  70627. agentGoto(index: number, destination: Vector3): void;
  70628. /**
  70629. * Teleport the agent to a new position
  70630. * @param index agent index returned by addAgent
  70631. * @param destination targeted world position
  70632. */
  70633. agentTeleport(index: number, destination: Vector3): void;
  70634. /**
  70635. * Update agent parameters
  70636. * @param index agent index returned by addAgent
  70637. * @param parameters agent parameters
  70638. */
  70639. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70640. /**
  70641. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70642. * The queries will try to find a solution within those bounds
  70643. * default is (1,1,1)
  70644. * @param extent x,y,z value that define the extent around the queries point of reference
  70645. */
  70646. setDefaultQueryExtent(extent: Vector3): void;
  70647. /**
  70648. * Get the Bounding box extent specified by setDefaultQueryExtent
  70649. * @returns the box extent values
  70650. */
  70651. getDefaultQueryExtent(): Vector3;
  70652. /**
  70653. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70654. * @param result output the box extent values
  70655. */
  70656. getDefaultQueryExtentToRef(result: Vector3): void;
  70657. /**
  70658. * Release all resources
  70659. */
  70660. dispose(): void;
  70661. }
  70662. /**
  70663. * Configures an agent
  70664. */
  70665. export interface IAgentParameters {
  70666. /**
  70667. * Agent radius. [Limit: >= 0]
  70668. */
  70669. radius: number;
  70670. /**
  70671. * Agent height. [Limit: > 0]
  70672. */
  70673. height: number;
  70674. /**
  70675. * Maximum allowed acceleration. [Limit: >= 0]
  70676. */
  70677. maxAcceleration: number;
  70678. /**
  70679. * Maximum allowed speed. [Limit: >= 0]
  70680. */
  70681. maxSpeed: number;
  70682. /**
  70683. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70684. */
  70685. collisionQueryRange: number;
  70686. /**
  70687. * The path visibility optimization range. [Limit: > 0]
  70688. */
  70689. pathOptimizationRange: number;
  70690. /**
  70691. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70692. */
  70693. separationWeight: number;
  70694. }
  70695. /**
  70696. * Configures the navigation mesh creation
  70697. */
  70698. export interface INavMeshParameters {
  70699. /**
  70700. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70701. */
  70702. cs: number;
  70703. /**
  70704. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70705. */
  70706. ch: number;
  70707. /**
  70708. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70709. */
  70710. walkableSlopeAngle: number;
  70711. /**
  70712. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70713. * be considered walkable. [Limit: >= 3] [Units: vx]
  70714. */
  70715. walkableHeight: number;
  70716. /**
  70717. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70718. */
  70719. walkableClimb: number;
  70720. /**
  70721. * The distance to erode/shrink the walkable area of the heightfield away from
  70722. * obstructions. [Limit: >=0] [Units: vx]
  70723. */
  70724. walkableRadius: number;
  70725. /**
  70726. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70727. */
  70728. maxEdgeLen: number;
  70729. /**
  70730. * The maximum distance a simplfied contour's border edges should deviate
  70731. * the original raw contour. [Limit: >=0] [Units: vx]
  70732. */
  70733. maxSimplificationError: number;
  70734. /**
  70735. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70736. */
  70737. minRegionArea: number;
  70738. /**
  70739. * Any regions with a span count smaller than this value will, if possible,
  70740. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70741. */
  70742. mergeRegionArea: number;
  70743. /**
  70744. * The maximum number of vertices allowed for polygons generated during the
  70745. * contour to polygon conversion process. [Limit: >= 3]
  70746. */
  70747. maxVertsPerPoly: number;
  70748. /**
  70749. * Sets the sampling distance to use when generating the detail mesh.
  70750. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70751. */
  70752. detailSampleDist: number;
  70753. /**
  70754. * The maximum distance the detail mesh surface should deviate from heightfield
  70755. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70756. */
  70757. detailSampleMaxError: number;
  70758. }
  70759. }
  70760. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70761. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70762. import { Mesh } from "babylonjs/Meshes/mesh";
  70763. import { Scene } from "babylonjs/scene";
  70764. import { Vector3 } from "babylonjs/Maths/math";
  70765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70766. /**
  70767. * RecastJS navigation plugin
  70768. */
  70769. export class RecastJSPlugin implements INavigationEnginePlugin {
  70770. /**
  70771. * Reference to the Recast library
  70772. */
  70773. bjsRECAST: any;
  70774. /**
  70775. * plugin name
  70776. */
  70777. name: string;
  70778. /**
  70779. * the first navmesh created. We might extend this to support multiple navmeshes
  70780. */
  70781. navMesh: any;
  70782. /**
  70783. * Initializes the recastJS plugin
  70784. * @param recastInjection can be used to inject your own recast reference
  70785. */
  70786. constructor(recastInjection?: any);
  70787. /**
  70788. * Creates a navigation mesh
  70789. * @param meshes array of all the geometry used to compute the navigatio mesh
  70790. * @param parameters bunch of parameters used to filter geometry
  70791. */
  70792. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70793. /**
  70794. * Create a navigation mesh debug mesh
  70795. * @param scene is where the mesh will be added
  70796. * @returns debug display mesh
  70797. */
  70798. createDebugNavMesh(scene: Scene): Mesh;
  70799. /**
  70800. * Get a navigation mesh constrained position, closest to the parameter position
  70801. * @param position world position
  70802. * @returns the closest point to position constrained by the navigation mesh
  70803. */
  70804. getClosestPoint(position: Vector3): Vector3;
  70805. /**
  70806. * Get a navigation mesh constrained position, closest to the parameter position
  70807. * @param position world position
  70808. * @param result output the closest point to position constrained by the navigation mesh
  70809. */
  70810. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70811. /**
  70812. * Get a navigation mesh constrained position, within a particular radius
  70813. * @param position world position
  70814. * @param maxRadius the maximum distance to the constrained world position
  70815. * @returns the closest point to position constrained by the navigation mesh
  70816. */
  70817. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70818. /**
  70819. * Get a navigation mesh constrained position, within a particular radius
  70820. * @param position world position
  70821. * @param maxRadius the maximum distance to the constrained world position
  70822. * @param result output the closest point to position constrained by the navigation mesh
  70823. */
  70824. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70825. /**
  70826. * Compute the final position from a segment made of destination-position
  70827. * @param position world position
  70828. * @param destination world position
  70829. * @returns the resulting point along the navmesh
  70830. */
  70831. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70832. /**
  70833. * Compute the final position from a segment made of destination-position
  70834. * @param position world position
  70835. * @param destination world position
  70836. * @param result output the resulting point along the navmesh
  70837. */
  70838. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70839. /**
  70840. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70841. * @param start world position
  70842. * @param end world position
  70843. * @returns array containing world position composing the path
  70844. */
  70845. computePath(start: Vector3, end: Vector3): Vector3[];
  70846. /**
  70847. * Create a new Crowd so you can add agents
  70848. * @param maxAgents the maximum agent count in the crowd
  70849. * @param maxAgentRadius the maximum radius an agent can have
  70850. * @param scene to attach the crowd to
  70851. * @returns the crowd you can add agents to
  70852. */
  70853. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70854. /**
  70855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70856. * The queries will try to find a solution within those bounds
  70857. * default is (1,1,1)
  70858. * @param extent x,y,z value that define the extent around the queries point of reference
  70859. */
  70860. setDefaultQueryExtent(extent: Vector3): void;
  70861. /**
  70862. * Get the Bounding box extent specified by setDefaultQueryExtent
  70863. * @returns the box extent values
  70864. */
  70865. getDefaultQueryExtent(): Vector3;
  70866. /**
  70867. * build the navmesh from a previously saved state using getNavmeshData
  70868. * @param data the Uint8Array returned by getNavmeshData
  70869. */
  70870. buildFromNavmeshData(data: Uint8Array): void;
  70871. /**
  70872. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70873. * @returns data the Uint8Array that can be saved and reused
  70874. */
  70875. getNavmeshData(): Uint8Array;
  70876. /**
  70877. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70878. * @param result output the box extent values
  70879. */
  70880. getDefaultQueryExtentToRef(result: Vector3): void;
  70881. /**
  70882. * Disposes
  70883. */
  70884. dispose(): void;
  70885. /**
  70886. * If this plugin is supported
  70887. * @returns true if plugin is supported
  70888. */
  70889. isSupported(): boolean;
  70890. }
  70891. /**
  70892. * Recast detour crowd implementation
  70893. */
  70894. export class RecastJSCrowd implements ICrowd {
  70895. /**
  70896. * Recast/detour plugin
  70897. */
  70898. bjsRECASTPlugin: RecastJSPlugin;
  70899. /**
  70900. * Link to the detour crowd
  70901. */
  70902. recastCrowd: any;
  70903. /**
  70904. * One transform per agent
  70905. */
  70906. transforms: TransformNode[];
  70907. /**
  70908. * All agents created
  70909. */
  70910. agents: number[];
  70911. /**
  70912. * Link to the scene is kept to unregister the crowd from the scene
  70913. */
  70914. private _scene;
  70915. /**
  70916. * Observer for crowd updates
  70917. */
  70918. private _onBeforeAnimationsObserver;
  70919. /**
  70920. * Constructor
  70921. * @param plugin recastJS plugin
  70922. * @param maxAgents the maximum agent count in the crowd
  70923. * @param maxAgentRadius the maximum radius an agent can have
  70924. * @param scene to attach the crowd to
  70925. * @returns the crowd you can add agents to
  70926. */
  70927. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70928. /**
  70929. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70930. * You can attach anything to that node. The node position is updated in the scene update tick.
  70931. * @param pos world position that will be constrained by the navigation mesh
  70932. * @param parameters agent parameters
  70933. * @param transform hooked to the agent that will be update by the scene
  70934. * @returns agent index
  70935. */
  70936. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70937. /**
  70938. * Returns the agent position in world space
  70939. * @param index agent index returned by addAgent
  70940. * @returns world space position
  70941. */
  70942. getAgentPosition(index: number): Vector3;
  70943. /**
  70944. * Returns the agent position result in world space
  70945. * @param index agent index returned by addAgent
  70946. * @param result output world space position
  70947. */
  70948. getAgentPositionToRef(index: number, result: Vector3): void;
  70949. /**
  70950. * Returns the agent velocity in world space
  70951. * @param index agent index returned by addAgent
  70952. * @returns world space velocity
  70953. */
  70954. getAgentVelocity(index: number): Vector3;
  70955. /**
  70956. * Returns the agent velocity result in world space
  70957. * @param index agent index returned by addAgent
  70958. * @param result output world space velocity
  70959. */
  70960. getAgentVelocityToRef(index: number, result: Vector3): void;
  70961. /**
  70962. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70963. * @param index agent index returned by addAgent
  70964. * @param destination targeted world position
  70965. */
  70966. agentGoto(index: number, destination: Vector3): void;
  70967. /**
  70968. * Teleport the agent to a new position
  70969. * @param index agent index returned by addAgent
  70970. * @param destination targeted world position
  70971. */
  70972. agentTeleport(index: number, destination: Vector3): void;
  70973. /**
  70974. * Update agent parameters
  70975. * @param index agent index returned by addAgent
  70976. * @param parameters agent parameters
  70977. */
  70978. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70979. /**
  70980. * remove a particular agent previously created
  70981. * @param index agent index returned by addAgent
  70982. */
  70983. removeAgent(index: number): void;
  70984. /**
  70985. * get the list of all agents attached to this crowd
  70986. * @returns list of agent indices
  70987. */
  70988. getAgents(): number[];
  70989. /**
  70990. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70991. * @param deltaTime in seconds
  70992. */
  70993. update(deltaTime: number): void;
  70994. /**
  70995. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70996. * The queries will try to find a solution within those bounds
  70997. * default is (1,1,1)
  70998. * @param extent x,y,z value that define the extent around the queries point of reference
  70999. */
  71000. setDefaultQueryExtent(extent: Vector3): void;
  71001. /**
  71002. * Get the Bounding box extent specified by setDefaultQueryExtent
  71003. * @returns the box extent values
  71004. */
  71005. getDefaultQueryExtent(): Vector3;
  71006. /**
  71007. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71008. * @param result output the box extent values
  71009. */
  71010. getDefaultQueryExtentToRef(result: Vector3): void;
  71011. /**
  71012. * Release all resources
  71013. */
  71014. dispose(): void;
  71015. }
  71016. }
  71017. declare module "babylonjs/Navigation/Plugins/index" {
  71018. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71019. }
  71020. declare module "babylonjs/Navigation/index" {
  71021. export * from "babylonjs/Navigation/INavigationEngine";
  71022. export * from "babylonjs/Navigation/Plugins/index";
  71023. }
  71024. declare module "babylonjs/Offline/database" {
  71025. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71026. /**
  71027. * Class used to enable access to IndexedDB
  71028. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71029. */
  71030. export class Database implements IOfflineProvider {
  71031. private _callbackManifestChecked;
  71032. private _currentSceneUrl;
  71033. private _db;
  71034. private _enableSceneOffline;
  71035. private _enableTexturesOffline;
  71036. private _manifestVersionFound;
  71037. private _mustUpdateRessources;
  71038. private _hasReachedQuota;
  71039. private _isSupported;
  71040. private _idbFactory;
  71041. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71042. private static IsUASupportingBlobStorage;
  71043. /**
  71044. * Gets a boolean indicating if Database storate is enabled (off by default)
  71045. */
  71046. static IDBStorageEnabled: boolean;
  71047. /**
  71048. * Gets a boolean indicating if scene must be saved in the database
  71049. */
  71050. get enableSceneOffline(): boolean;
  71051. /**
  71052. * Gets a boolean indicating if textures must be saved in the database
  71053. */
  71054. get enableTexturesOffline(): boolean;
  71055. /**
  71056. * Creates a new Database
  71057. * @param urlToScene defines the url to load the scene
  71058. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71059. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71060. */
  71061. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71062. private static _ParseURL;
  71063. private static _ReturnFullUrlLocation;
  71064. private _checkManifestFile;
  71065. /**
  71066. * Open the database and make it available
  71067. * @param successCallback defines the callback to call on success
  71068. * @param errorCallback defines the callback to call on error
  71069. */
  71070. open(successCallback: () => void, errorCallback: () => void): void;
  71071. /**
  71072. * Loads an image from the database
  71073. * @param url defines the url to load from
  71074. * @param image defines the target DOM image
  71075. */
  71076. loadImage(url: string, image: HTMLImageElement): void;
  71077. private _loadImageFromDBAsync;
  71078. private _saveImageIntoDBAsync;
  71079. private _checkVersionFromDB;
  71080. private _loadVersionFromDBAsync;
  71081. private _saveVersionIntoDBAsync;
  71082. /**
  71083. * Loads a file from database
  71084. * @param url defines the URL to load from
  71085. * @param sceneLoaded defines a callback to call on success
  71086. * @param progressCallBack defines a callback to call when progress changed
  71087. * @param errorCallback defines a callback to call on error
  71088. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71089. */
  71090. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71091. private _loadFileAsync;
  71092. private _saveFileAsync;
  71093. /**
  71094. * Validates if xhr data is correct
  71095. * @param xhr defines the request to validate
  71096. * @param dataType defines the expected data type
  71097. * @returns true if data is correct
  71098. */
  71099. private static _ValidateXHRData;
  71100. }
  71101. }
  71102. declare module "babylonjs/Offline/index" {
  71103. export * from "babylonjs/Offline/database";
  71104. export * from "babylonjs/Offline/IOfflineProvider";
  71105. }
  71106. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71107. /** @hidden */
  71108. export var gpuUpdateParticlesPixelShader: {
  71109. name: string;
  71110. shader: string;
  71111. };
  71112. }
  71113. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71114. /** @hidden */
  71115. export var gpuUpdateParticlesVertexShader: {
  71116. name: string;
  71117. shader: string;
  71118. };
  71119. }
  71120. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71121. /** @hidden */
  71122. export var clipPlaneFragmentDeclaration2: {
  71123. name: string;
  71124. shader: string;
  71125. };
  71126. }
  71127. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71128. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71129. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71130. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71131. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71132. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71133. /** @hidden */
  71134. export var gpuRenderParticlesPixelShader: {
  71135. name: string;
  71136. shader: string;
  71137. };
  71138. }
  71139. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71140. /** @hidden */
  71141. export var clipPlaneVertexDeclaration2: {
  71142. name: string;
  71143. shader: string;
  71144. };
  71145. }
  71146. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71147. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71148. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71149. /** @hidden */
  71150. export var gpuRenderParticlesVertexShader: {
  71151. name: string;
  71152. shader: string;
  71153. };
  71154. }
  71155. declare module "babylonjs/Particles/gpuParticleSystem" {
  71156. import { Nullable } from "babylonjs/types";
  71157. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71158. import { Observable } from "babylonjs/Misc/observable";
  71159. import { Matrix } from "babylonjs/Maths/math.vector";
  71160. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71161. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71162. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71163. import { IDisposable } from "babylonjs/scene";
  71164. import { Effect } from "babylonjs/Materials/effect";
  71165. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71168. import { Scene } from "babylonjs/scene";
  71169. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71170. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71171. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71172. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71173. /**
  71174. * This represents a GPU particle system in Babylon
  71175. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71176. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71177. */
  71178. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71179. /**
  71180. * The layer mask we are rendering the particles through.
  71181. */
  71182. layerMask: number;
  71183. private _capacity;
  71184. private _activeCount;
  71185. private _currentActiveCount;
  71186. private _accumulatedCount;
  71187. private _renderEffect;
  71188. private _updateEffect;
  71189. private _buffer0;
  71190. private _buffer1;
  71191. private _spriteBuffer;
  71192. private _updateVAO;
  71193. private _renderVAO;
  71194. private _targetIndex;
  71195. private _sourceBuffer;
  71196. private _targetBuffer;
  71197. private _currentRenderId;
  71198. private _started;
  71199. private _stopped;
  71200. private _timeDelta;
  71201. private _randomTexture;
  71202. private _randomTexture2;
  71203. private _attributesStrideSize;
  71204. private _updateEffectOptions;
  71205. private _randomTextureSize;
  71206. private _actualFrame;
  71207. private _customEffect;
  71208. private readonly _rawTextureWidth;
  71209. /**
  71210. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71211. */
  71212. static get IsSupported(): boolean;
  71213. /**
  71214. * An event triggered when the system is disposed.
  71215. */
  71216. onDisposeObservable: Observable<IParticleSystem>;
  71217. /**
  71218. * Gets the maximum number of particles active at the same time.
  71219. * @returns The max number of active particles.
  71220. */
  71221. getCapacity(): number;
  71222. /**
  71223. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71224. * to override the particles.
  71225. */
  71226. forceDepthWrite: boolean;
  71227. /**
  71228. * Gets or set the number of active particles
  71229. */
  71230. get activeParticleCount(): number;
  71231. set activeParticleCount(value: number);
  71232. private _preWarmDone;
  71233. /**
  71234. * Specifies if the particles are updated in emitter local space or world space.
  71235. */
  71236. isLocal: boolean;
  71237. /** Gets or sets a matrix to use to compute projection */
  71238. defaultProjectionMatrix: Matrix;
  71239. /**
  71240. * Is this system ready to be used/rendered
  71241. * @return true if the system is ready
  71242. */
  71243. isReady(): boolean;
  71244. /**
  71245. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71246. * @returns True if it has been started, otherwise false.
  71247. */
  71248. isStarted(): boolean;
  71249. /**
  71250. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71251. * @returns True if it has been stopped, otherwise false.
  71252. */
  71253. isStopped(): boolean;
  71254. /**
  71255. * Gets a boolean indicating that the system is stopping
  71256. * @returns true if the system is currently stopping
  71257. */
  71258. isStopping(): boolean;
  71259. /**
  71260. * Gets the number of particles active at the same time.
  71261. * @returns The number of active particles.
  71262. */
  71263. getActiveCount(): number;
  71264. /**
  71265. * Starts the particle system and begins to emit
  71266. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71267. */
  71268. start(delay?: number): void;
  71269. /**
  71270. * Stops the particle system.
  71271. */
  71272. stop(): void;
  71273. /**
  71274. * Remove all active particles
  71275. */
  71276. reset(): void;
  71277. /**
  71278. * Returns the string "GPUParticleSystem"
  71279. * @returns a string containing the class name
  71280. */
  71281. getClassName(): string;
  71282. /**
  71283. * Gets the custom effect used to render the particles
  71284. * @param blendMode Blend mode for which the effect should be retrieved
  71285. * @returns The effect
  71286. */
  71287. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71288. /**
  71289. * Sets the custom effect used to render the particles
  71290. * @param effect The effect to set
  71291. * @param blendMode Blend mode for which the effect should be set
  71292. */
  71293. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71294. /** @hidden */
  71295. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71296. /**
  71297. * Observable that will be called just before the particles are drawn
  71298. */
  71299. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71300. /**
  71301. * Gets the name of the particle vertex shader
  71302. */
  71303. get vertexShaderName(): string;
  71304. private _colorGradientsTexture;
  71305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71306. /**
  71307. * Adds a new color gradient
  71308. * @param gradient defines the gradient to use (between 0 and 1)
  71309. * @param color1 defines the color to affect to the specified gradient
  71310. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71311. * @returns the current particle system
  71312. */
  71313. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71314. private _refreshColorGradient;
  71315. /** Force the system to rebuild all gradients that need to be resync */
  71316. forceRefreshGradients(): void;
  71317. /**
  71318. * Remove a specific color gradient
  71319. * @param gradient defines the gradient to remove
  71320. * @returns the current particle system
  71321. */
  71322. removeColorGradient(gradient: number): GPUParticleSystem;
  71323. private _angularSpeedGradientsTexture;
  71324. private _sizeGradientsTexture;
  71325. private _velocityGradientsTexture;
  71326. private _limitVelocityGradientsTexture;
  71327. private _dragGradientsTexture;
  71328. private _addFactorGradient;
  71329. /**
  71330. * Adds a new size gradient
  71331. * @param gradient defines the gradient to use (between 0 and 1)
  71332. * @param factor defines the size factor to affect to the specified gradient
  71333. * @returns the current particle system
  71334. */
  71335. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71336. /**
  71337. * Remove a specific size gradient
  71338. * @param gradient defines the gradient to remove
  71339. * @returns the current particle system
  71340. */
  71341. removeSizeGradient(gradient: number): GPUParticleSystem;
  71342. private _refreshFactorGradient;
  71343. /**
  71344. * Adds a new angular speed gradient
  71345. * @param gradient defines the gradient to use (between 0 and 1)
  71346. * @param factor defines the angular speed to affect to the specified gradient
  71347. * @returns the current particle system
  71348. */
  71349. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71350. /**
  71351. * Remove a specific angular speed gradient
  71352. * @param gradient defines the gradient to remove
  71353. * @returns the current particle system
  71354. */
  71355. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71356. /**
  71357. * Adds a new velocity gradient
  71358. * @param gradient defines the gradient to use (between 0 and 1)
  71359. * @param factor defines the velocity to affect to the specified gradient
  71360. * @returns the current particle system
  71361. */
  71362. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71363. /**
  71364. * Remove a specific velocity gradient
  71365. * @param gradient defines the gradient to remove
  71366. * @returns the current particle system
  71367. */
  71368. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71369. /**
  71370. * Adds a new limit velocity gradient
  71371. * @param gradient defines the gradient to use (between 0 and 1)
  71372. * @param factor defines the limit velocity value to affect to the specified gradient
  71373. * @returns the current particle system
  71374. */
  71375. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71376. /**
  71377. * Remove a specific limit velocity gradient
  71378. * @param gradient defines the gradient to remove
  71379. * @returns the current particle system
  71380. */
  71381. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71382. /**
  71383. * Adds a new drag gradient
  71384. * @param gradient defines the gradient to use (between 0 and 1)
  71385. * @param factor defines the drag value to affect to the specified gradient
  71386. * @returns the current particle system
  71387. */
  71388. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71389. /**
  71390. * Remove a specific drag gradient
  71391. * @param gradient defines the gradient to remove
  71392. * @returns the current particle system
  71393. */
  71394. removeDragGradient(gradient: number): GPUParticleSystem;
  71395. /**
  71396. * Not supported by GPUParticleSystem
  71397. * @param gradient defines the gradient to use (between 0 and 1)
  71398. * @param factor defines the emit rate value to affect to the specified gradient
  71399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71400. * @returns the current particle system
  71401. */
  71402. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71403. /**
  71404. * Not supported by GPUParticleSystem
  71405. * @param gradient defines the gradient to remove
  71406. * @returns the current particle system
  71407. */
  71408. removeEmitRateGradient(gradient: number): IParticleSystem;
  71409. /**
  71410. * Not supported by GPUParticleSystem
  71411. * @param gradient defines the gradient to use (between 0 and 1)
  71412. * @param factor defines the start size value to affect to the specified gradient
  71413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71414. * @returns the current particle system
  71415. */
  71416. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71417. /**
  71418. * Not supported by GPUParticleSystem
  71419. * @param gradient defines the gradient to remove
  71420. * @returns the current particle system
  71421. */
  71422. removeStartSizeGradient(gradient: number): IParticleSystem;
  71423. /**
  71424. * Not supported by GPUParticleSystem
  71425. * @param gradient defines the gradient to use (between 0 and 1)
  71426. * @param min defines the color remap minimal range
  71427. * @param max defines the color remap maximal range
  71428. * @returns the current particle system
  71429. */
  71430. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71431. /**
  71432. * Not supported by GPUParticleSystem
  71433. * @param gradient defines the gradient to remove
  71434. * @returns the current particle system
  71435. */
  71436. removeColorRemapGradient(): IParticleSystem;
  71437. /**
  71438. * Not supported by GPUParticleSystem
  71439. * @param gradient defines the gradient to use (between 0 and 1)
  71440. * @param min defines the alpha remap minimal range
  71441. * @param max defines the alpha remap maximal range
  71442. * @returns the current particle system
  71443. */
  71444. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71445. /**
  71446. * Not supported by GPUParticleSystem
  71447. * @param gradient defines the gradient to remove
  71448. * @returns the current particle system
  71449. */
  71450. removeAlphaRemapGradient(): IParticleSystem;
  71451. /**
  71452. * Not supported by GPUParticleSystem
  71453. * @param gradient defines the gradient to use (between 0 and 1)
  71454. * @param color defines the color to affect to the specified gradient
  71455. * @returns the current particle system
  71456. */
  71457. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71458. /**
  71459. * Not supported by GPUParticleSystem
  71460. * @param gradient defines the gradient to remove
  71461. * @returns the current particle system
  71462. */
  71463. removeRampGradient(): IParticleSystem;
  71464. /**
  71465. * Not supported by GPUParticleSystem
  71466. * @returns the list of ramp gradients
  71467. */
  71468. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71469. /**
  71470. * Not supported by GPUParticleSystem
  71471. * Gets or sets a boolean indicating that ramp gradients must be used
  71472. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71473. */
  71474. get useRampGradients(): boolean;
  71475. set useRampGradients(value: boolean);
  71476. /**
  71477. * Not supported by GPUParticleSystem
  71478. * @param gradient defines the gradient to use (between 0 and 1)
  71479. * @param factor defines the life time factor to affect to the specified gradient
  71480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71481. * @returns the current particle system
  71482. */
  71483. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71484. /**
  71485. * Not supported by GPUParticleSystem
  71486. * @param gradient defines the gradient to remove
  71487. * @returns the current particle system
  71488. */
  71489. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71490. /**
  71491. * Instantiates a GPU particle system.
  71492. * 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.
  71493. * @param name The name of the particle system
  71494. * @param options The options used to create the system
  71495. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71496. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71497. * @param customEffect a custom effect used to change the way particles are rendered by default
  71498. */
  71499. constructor(name: string, options: Partial<{
  71500. capacity: number;
  71501. randomTextureSize: number;
  71502. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71503. protected _reset(): void;
  71504. private _createUpdateVAO;
  71505. private _createRenderVAO;
  71506. private _initialize;
  71507. /** @hidden */
  71508. _recreateUpdateEffect(): void;
  71509. private _getEffect;
  71510. /**
  71511. * Fill the defines array according to the current settings of the particle system
  71512. * @param defines Array to be updated
  71513. * @param blendMode blend mode to take into account when updating the array
  71514. */
  71515. fillDefines(defines: Array<string>, blendMode?: number): void;
  71516. /**
  71517. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71518. * @param uniforms Uniforms array to fill
  71519. * @param attributes Attributes array to fill
  71520. * @param samplers Samplers array to fill
  71521. */
  71522. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71523. /** @hidden */
  71524. _recreateRenderEffect(): Effect;
  71525. /**
  71526. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71527. * @param preWarm defines if we are in the pre-warmimg phase
  71528. */
  71529. animate(preWarm?: boolean): void;
  71530. private _createFactorGradientTexture;
  71531. private _createSizeGradientTexture;
  71532. private _createAngularSpeedGradientTexture;
  71533. private _createVelocityGradientTexture;
  71534. private _createLimitVelocityGradientTexture;
  71535. private _createDragGradientTexture;
  71536. private _createColorGradientTexture;
  71537. /**
  71538. * Renders the particle system in its current state
  71539. * @param preWarm defines if the system should only update the particles but not render them
  71540. * @returns the current number of particles
  71541. */
  71542. render(preWarm?: boolean): number;
  71543. /**
  71544. * Rebuilds the particle system
  71545. */
  71546. rebuild(): void;
  71547. private _releaseBuffers;
  71548. private _releaseVAOs;
  71549. /**
  71550. * Disposes the particle system and free the associated resources
  71551. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71552. */
  71553. dispose(disposeTexture?: boolean): void;
  71554. /**
  71555. * Clones the particle system.
  71556. * @param name The name of the cloned object
  71557. * @param newEmitter The new emitter to use
  71558. * @returns the cloned particle system
  71559. */
  71560. clone(name: string, newEmitter: any): GPUParticleSystem;
  71561. /**
  71562. * Serializes the particle system to a JSON object
  71563. * @param serializeTexture defines if the texture must be serialized as well
  71564. * @returns the JSON object
  71565. */
  71566. serialize(serializeTexture?: boolean): any;
  71567. /**
  71568. * Parses a JSON object to create a GPU particle system.
  71569. * @param parsedParticleSystem The JSON object to parse
  71570. * @param sceneOrEngine The scene or the engine to create the particle system in
  71571. * @param rootUrl The root url to use to load external dependencies like texture
  71572. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71573. * @returns the parsed GPU particle system
  71574. */
  71575. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71576. }
  71577. }
  71578. declare module "babylonjs/Particles/particleSystemSet" {
  71579. import { Nullable } from "babylonjs/types";
  71580. import { Color3 } from "babylonjs/Maths/math.color";
  71581. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71583. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71584. import { Scene, IDisposable } from "babylonjs/scene";
  71585. /**
  71586. * Represents a set of particle systems working together to create a specific effect
  71587. */
  71588. export class ParticleSystemSet implements IDisposable {
  71589. /**
  71590. * Gets or sets base Assets URL
  71591. */
  71592. static BaseAssetsUrl: string;
  71593. private _emitterCreationOptions;
  71594. private _emitterNode;
  71595. /**
  71596. * Gets the particle system list
  71597. */
  71598. systems: IParticleSystem[];
  71599. /**
  71600. * Gets the emitter node used with this set
  71601. */
  71602. get emitterNode(): Nullable<TransformNode>;
  71603. /**
  71604. * Creates a new emitter mesh as a sphere
  71605. * @param options defines the options used to create the sphere
  71606. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71607. * @param scene defines the hosting scene
  71608. */
  71609. setEmitterAsSphere(options: {
  71610. diameter: number;
  71611. segments: number;
  71612. color: Color3;
  71613. }, renderingGroupId: number, scene: Scene): void;
  71614. /**
  71615. * Starts all particle systems of the set
  71616. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71617. */
  71618. start(emitter?: AbstractMesh): void;
  71619. /**
  71620. * Release all associated resources
  71621. */
  71622. dispose(): void;
  71623. /**
  71624. * Serialize the set into a JSON compatible object
  71625. * @param serializeTexture defines if the texture must be serialized as well
  71626. * @returns a JSON compatible representation of the set
  71627. */
  71628. serialize(serializeTexture?: boolean): any;
  71629. /**
  71630. * Parse a new ParticleSystemSet from a serialized source
  71631. * @param data defines a JSON compatible representation of the set
  71632. * @param scene defines the hosting scene
  71633. * @param gpu defines if we want GPU particles or CPU particles
  71634. * @returns a new ParticleSystemSet
  71635. */
  71636. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71637. }
  71638. }
  71639. declare module "babylonjs/Particles/particleHelper" {
  71640. import { Nullable } from "babylonjs/types";
  71641. import { Scene } from "babylonjs/scene";
  71642. import { Vector3 } from "babylonjs/Maths/math.vector";
  71643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71645. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71646. /**
  71647. * This class is made for on one-liner static method to help creating particle system set.
  71648. */
  71649. export class ParticleHelper {
  71650. /**
  71651. * Gets or sets base Assets URL
  71652. */
  71653. static BaseAssetsUrl: string;
  71654. /** Define the Url to load snippets */
  71655. static SnippetUrl: string;
  71656. /**
  71657. * Create a default particle system that you can tweak
  71658. * @param emitter defines the emitter to use
  71659. * @param capacity defines the system capacity (default is 500 particles)
  71660. * @param scene defines the hosting scene
  71661. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71662. * @returns the new Particle system
  71663. */
  71664. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71665. /**
  71666. * This is the main static method (one-liner) of this helper to create different particle systems
  71667. * @param type This string represents the type to the particle system to create
  71668. * @param scene The scene where the particle system should live
  71669. * @param gpu If the system will use gpu
  71670. * @returns the ParticleSystemSet created
  71671. */
  71672. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71673. /**
  71674. * Static function used to export a particle system to a ParticleSystemSet variable.
  71675. * Please note that the emitter shape is not exported
  71676. * @param systems defines the particle systems to export
  71677. * @returns the created particle system set
  71678. */
  71679. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71680. /**
  71681. * Creates a particle system from a snippet saved in a remote file
  71682. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71683. * @param url defines the url to load from
  71684. * @param scene defines the hosting scene
  71685. * @param gpu If the system will use gpu
  71686. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71687. * @returns a promise that will resolve to the new particle system
  71688. */
  71689. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71690. /**
  71691. * Creates a particle system from a snippet saved by the particle system editor
  71692. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71693. * @param scene defines the hosting scene
  71694. * @param gpu If the system will use gpu
  71695. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71696. * @returns a promise that will resolve to the new particle system
  71697. */
  71698. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71699. }
  71700. }
  71701. declare module "babylonjs/Particles/particleSystemComponent" {
  71702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71703. import { Effect } from "babylonjs/Materials/effect";
  71704. import "babylonjs/Shaders/particles.vertex";
  71705. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71706. module "babylonjs/Engines/engine" {
  71707. interface Engine {
  71708. /**
  71709. * Create an effect to use with particle systems.
  71710. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71711. * the particle system for which you want to create a custom effect in the last parameter
  71712. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71713. * @param uniformsNames defines a list of attribute names
  71714. * @param samplers defines an array of string used to represent textures
  71715. * @param defines defines the string containing the defines to use to compile the shaders
  71716. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71717. * @param onCompiled defines a function to call when the effect creation is successful
  71718. * @param onError defines a function to call when the effect creation has failed
  71719. * @param particleSystem the particle system you want to create the effect for
  71720. * @returns the new Effect
  71721. */
  71722. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71723. }
  71724. }
  71725. module "babylonjs/Meshes/mesh" {
  71726. interface Mesh {
  71727. /**
  71728. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71729. * @returns an array of IParticleSystem
  71730. */
  71731. getEmittedParticleSystems(): IParticleSystem[];
  71732. /**
  71733. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71734. * @returns an array of IParticleSystem
  71735. */
  71736. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71737. }
  71738. }
  71739. }
  71740. declare module "babylonjs/Particles/pointsCloudSystem" {
  71741. import { Color4 } from "babylonjs/Maths/math";
  71742. import { Mesh } from "babylonjs/Meshes/mesh";
  71743. import { Scene, IDisposable } from "babylonjs/scene";
  71744. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71745. /** Defines the 4 color options */
  71746. export enum PointColor {
  71747. /** color value */
  71748. Color = 2,
  71749. /** uv value */
  71750. UV = 1,
  71751. /** random value */
  71752. Random = 0,
  71753. /** stated value */
  71754. Stated = 3
  71755. }
  71756. /**
  71757. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71758. * 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.
  71759. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71760. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71761. *
  71762. * Full documentation here : TO BE ENTERED
  71763. */
  71764. export class PointsCloudSystem implements IDisposable {
  71765. /**
  71766. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71767. * Example : var p = SPS.particles[i];
  71768. */
  71769. particles: CloudPoint[];
  71770. /**
  71771. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71772. */
  71773. nbParticles: number;
  71774. /**
  71775. * This a counter for your own usage. It's not set by any SPS functions.
  71776. */
  71777. counter: number;
  71778. /**
  71779. * The PCS name. This name is also given to the underlying mesh.
  71780. */
  71781. name: string;
  71782. /**
  71783. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71784. */
  71785. mesh: Mesh;
  71786. /**
  71787. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71788. * Please read :
  71789. */
  71790. vars: any;
  71791. /**
  71792. * @hidden
  71793. */
  71794. _size: number;
  71795. private _scene;
  71796. private _promises;
  71797. private _positions;
  71798. private _indices;
  71799. private _normals;
  71800. private _colors;
  71801. private _uvs;
  71802. private _indices32;
  71803. private _positions32;
  71804. private _colors32;
  71805. private _uvs32;
  71806. private _updatable;
  71807. private _isVisibilityBoxLocked;
  71808. private _alwaysVisible;
  71809. private _groups;
  71810. private _groupCounter;
  71811. private _computeParticleColor;
  71812. private _computeParticleTexture;
  71813. private _computeParticleRotation;
  71814. private _computeBoundingBox;
  71815. private _isReady;
  71816. /**
  71817. * Creates a PCS (Points Cloud System) object
  71818. * @param name (String) is the PCS name, this will be the underlying mesh name
  71819. * @param pointSize (number) is the size for each point
  71820. * @param scene (Scene) is the scene in which the PCS is added
  71821. * @param options defines the options of the PCS e.g.
  71822. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71823. */
  71824. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71825. updatable?: boolean;
  71826. });
  71827. /**
  71828. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71829. * If no points were added to the PCS, the returned mesh is just a single point.
  71830. * @returns a promise for the created mesh
  71831. */
  71832. buildMeshAsync(): Promise<Mesh>;
  71833. /**
  71834. * @hidden
  71835. */
  71836. private _buildMesh;
  71837. private _addParticle;
  71838. private _randomUnitVector;
  71839. private _getColorIndicesForCoord;
  71840. private _setPointsColorOrUV;
  71841. private _colorFromTexture;
  71842. private _calculateDensity;
  71843. /**
  71844. * Adds points to the PCS in random positions within a unit sphere
  71845. * @param nb (positive integer) the number of particles to be created from this model
  71846. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71847. * @returns the number of groups in the system
  71848. */
  71849. addPoints(nb: number, pointFunction?: any): number;
  71850. /**
  71851. * Adds points to the PCS from the surface of the model shape
  71852. * @param mesh is any Mesh object that will be used as a surface model for the points
  71853. * @param nb (positive integer) the number of particles to be created from this model
  71854. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71855. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71856. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71857. * @returns the number of groups in the system
  71858. */
  71859. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71860. /**
  71861. * Adds points to the PCS inside the model shape
  71862. * @param mesh is any Mesh object that will be used as a surface model for the points
  71863. * @param nb (positive integer) the number of particles to be created from this model
  71864. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71865. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71866. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71867. * @returns the number of groups in the system
  71868. */
  71869. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71870. /**
  71871. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71872. * This method calls `updateParticle()` for each particle of the SPS.
  71873. * For an animated SPS, it is usually called within the render loop.
  71874. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71875. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71876. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71877. * @returns the PCS.
  71878. */
  71879. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71880. /**
  71881. * Disposes the PCS.
  71882. */
  71883. dispose(): void;
  71884. /**
  71885. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71886. * doc :
  71887. * @returns the PCS.
  71888. */
  71889. refreshVisibleSize(): PointsCloudSystem;
  71890. /**
  71891. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71892. * @param size the size (float) of the visibility box
  71893. * note : this doesn't lock the PCS mesh bounding box.
  71894. * doc :
  71895. */
  71896. setVisibilityBox(size: number): void;
  71897. /**
  71898. * Gets whether the PCS is always visible or not
  71899. * doc :
  71900. */
  71901. get isAlwaysVisible(): boolean;
  71902. /**
  71903. * Sets the PCS as always visible or not
  71904. * doc :
  71905. */
  71906. set isAlwaysVisible(val: boolean);
  71907. /**
  71908. * Tells to `setParticles()` to compute the particle rotations or not
  71909. * Default value : false. The PCS is faster when it's set to false
  71910. * Note : particle rotations are only applied to parent particles
  71911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71912. */
  71913. set computeParticleRotation(val: boolean);
  71914. /**
  71915. * Tells to `setParticles()` to compute the particle colors or not.
  71916. * Default value : true. The PCS is faster when it's set to false.
  71917. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71918. */
  71919. set computeParticleColor(val: boolean);
  71920. set computeParticleTexture(val: boolean);
  71921. /**
  71922. * Gets if `setParticles()` computes the particle colors or not.
  71923. * Default value : false. The PCS is faster when it's set to false.
  71924. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71925. */
  71926. get computeParticleColor(): boolean;
  71927. /**
  71928. * Gets if `setParticles()` computes the particle textures or not.
  71929. * Default value : false. The PCS is faster when it's set to false.
  71930. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71931. */
  71932. get computeParticleTexture(): boolean;
  71933. /**
  71934. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71935. */
  71936. set computeBoundingBox(val: boolean);
  71937. /**
  71938. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71939. */
  71940. get computeBoundingBox(): boolean;
  71941. /**
  71942. * This function does nothing. It may be overwritten to set all the particle first values.
  71943. * The PCS doesn't call this function, you may have to call it by your own.
  71944. * doc :
  71945. */
  71946. initParticles(): void;
  71947. /**
  71948. * This function does nothing. It may be overwritten to recycle a particle
  71949. * The PCS doesn't call this function, you can to call it
  71950. * doc :
  71951. * @param particle The particle to recycle
  71952. * @returns the recycled particle
  71953. */
  71954. recycleParticle(particle: CloudPoint): CloudPoint;
  71955. /**
  71956. * Updates a particle : this function should be overwritten by the user.
  71957. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71958. * doc :
  71959. * @example : just set a particle position or velocity and recycle conditions
  71960. * @param particle The particle to update
  71961. * @returns the updated particle
  71962. */
  71963. updateParticle(particle: CloudPoint): CloudPoint;
  71964. /**
  71965. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71966. * This does nothing and may be overwritten by the user.
  71967. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71968. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71969. * @param update the boolean update value actually passed to setParticles()
  71970. */
  71971. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71972. /**
  71973. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71974. * This will be passed three parameters.
  71975. * This does nothing and may be overwritten by the user.
  71976. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71977. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71978. * @param update the boolean update value actually passed to setParticles()
  71979. */
  71980. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71981. }
  71982. }
  71983. declare module "babylonjs/Particles/cloudPoint" {
  71984. import { Nullable } from "babylonjs/types";
  71985. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71986. import { Mesh } from "babylonjs/Meshes/mesh";
  71987. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71988. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71989. /**
  71990. * Represents one particle of a points cloud system.
  71991. */
  71992. export class CloudPoint {
  71993. /**
  71994. * particle global index
  71995. */
  71996. idx: number;
  71997. /**
  71998. * The color of the particle
  71999. */
  72000. color: Nullable<Color4>;
  72001. /**
  72002. * The world space position of the particle.
  72003. */
  72004. position: Vector3;
  72005. /**
  72006. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72007. */
  72008. rotation: Vector3;
  72009. /**
  72010. * The world space rotation quaternion of the particle.
  72011. */
  72012. rotationQuaternion: Nullable<Quaternion>;
  72013. /**
  72014. * The uv of the particle.
  72015. */
  72016. uv: Nullable<Vector2>;
  72017. /**
  72018. * The current speed of the particle.
  72019. */
  72020. velocity: Vector3;
  72021. /**
  72022. * The pivot point in the particle local space.
  72023. */
  72024. pivot: Vector3;
  72025. /**
  72026. * Must the particle be translated from its pivot point in its local space ?
  72027. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72028. * Default : false
  72029. */
  72030. translateFromPivot: boolean;
  72031. /**
  72032. * Index of this particle in the global "positions" array (Internal use)
  72033. * @hidden
  72034. */
  72035. _pos: number;
  72036. /**
  72037. * @hidden Index of this particle in the global "indices" array (Internal use)
  72038. */
  72039. _ind: number;
  72040. /**
  72041. * Group this particle belongs to
  72042. */
  72043. _group: PointsGroup;
  72044. /**
  72045. * Group id of this particle
  72046. */
  72047. groupId: number;
  72048. /**
  72049. * Index of the particle in its group id (Internal use)
  72050. */
  72051. idxInGroup: number;
  72052. /**
  72053. * @hidden Particle BoundingInfo object (Internal use)
  72054. */
  72055. _boundingInfo: BoundingInfo;
  72056. /**
  72057. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72058. */
  72059. _pcs: PointsCloudSystem;
  72060. /**
  72061. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72062. */
  72063. _stillInvisible: boolean;
  72064. /**
  72065. * @hidden Last computed particle rotation matrix
  72066. */
  72067. _rotationMatrix: number[];
  72068. /**
  72069. * Parent particle Id, if any.
  72070. * Default null.
  72071. */
  72072. parentId: Nullable<number>;
  72073. /**
  72074. * @hidden Internal global position in the PCS.
  72075. */
  72076. _globalPosition: Vector3;
  72077. /**
  72078. * Creates a Point Cloud object.
  72079. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72080. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72081. * @param group (PointsGroup) is the group the particle belongs to
  72082. * @param groupId (integer) is the group identifier in the PCS.
  72083. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72084. * @param pcs defines the PCS it is associated to
  72085. */
  72086. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72087. /**
  72088. * get point size
  72089. */
  72090. get size(): Vector3;
  72091. /**
  72092. * Set point size
  72093. */
  72094. set size(scale: Vector3);
  72095. /**
  72096. * Legacy support, changed quaternion to rotationQuaternion
  72097. */
  72098. get quaternion(): Nullable<Quaternion>;
  72099. /**
  72100. * Legacy support, changed quaternion to rotationQuaternion
  72101. */
  72102. set quaternion(q: Nullable<Quaternion>);
  72103. /**
  72104. * Returns a boolean. True if the particle intersects a mesh, else false
  72105. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72106. * @param target is the object (point or mesh) what the intersection is computed against
  72107. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72108. * @returns true if it intersects
  72109. */
  72110. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72111. /**
  72112. * get the rotation matrix of the particle
  72113. * @hidden
  72114. */
  72115. getRotationMatrix(m: Matrix): void;
  72116. }
  72117. /**
  72118. * Represents a group of points in a points cloud system
  72119. * * PCS internal tool, don't use it manually.
  72120. */
  72121. export class PointsGroup {
  72122. /**
  72123. * The group id
  72124. * @hidden
  72125. */
  72126. groupID: number;
  72127. /**
  72128. * image data for group (internal use)
  72129. * @hidden
  72130. */
  72131. _groupImageData: Nullable<ArrayBufferView>;
  72132. /**
  72133. * Image Width (internal use)
  72134. * @hidden
  72135. */
  72136. _groupImgWidth: number;
  72137. /**
  72138. * Image Height (internal use)
  72139. * @hidden
  72140. */
  72141. _groupImgHeight: number;
  72142. /**
  72143. * Custom position function (internal use)
  72144. * @hidden
  72145. */
  72146. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72147. /**
  72148. * density per facet for surface points
  72149. * @hidden
  72150. */
  72151. _groupDensity: number[];
  72152. /**
  72153. * Only when points are colored by texture carries pointer to texture list array
  72154. * @hidden
  72155. */
  72156. _textureNb: number;
  72157. /**
  72158. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72159. * PCS internal tool, don't use it manually.
  72160. * @hidden
  72161. */
  72162. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72163. }
  72164. }
  72165. declare module "babylonjs/Particles/index" {
  72166. export * from "babylonjs/Particles/baseParticleSystem";
  72167. export * from "babylonjs/Particles/EmitterTypes/index";
  72168. export * from "babylonjs/Particles/gpuParticleSystem";
  72169. export * from "babylonjs/Particles/IParticleSystem";
  72170. export * from "babylonjs/Particles/particle";
  72171. export * from "babylonjs/Particles/particleHelper";
  72172. export * from "babylonjs/Particles/particleSystem";
  72173. import "babylonjs/Particles/particleSystemComponent";
  72174. export * from "babylonjs/Particles/particleSystemComponent";
  72175. export * from "babylonjs/Particles/particleSystemSet";
  72176. export * from "babylonjs/Particles/solidParticle";
  72177. export * from "babylonjs/Particles/solidParticleSystem";
  72178. export * from "babylonjs/Particles/cloudPoint";
  72179. export * from "babylonjs/Particles/pointsCloudSystem";
  72180. export * from "babylonjs/Particles/subEmitter";
  72181. }
  72182. declare module "babylonjs/Physics/physicsEngineComponent" {
  72183. import { Nullable } from "babylonjs/types";
  72184. import { Observable, Observer } from "babylonjs/Misc/observable";
  72185. import { Vector3 } from "babylonjs/Maths/math.vector";
  72186. import { Mesh } from "babylonjs/Meshes/mesh";
  72187. import { ISceneComponent } from "babylonjs/sceneComponent";
  72188. import { Scene } from "babylonjs/scene";
  72189. import { Node } from "babylonjs/node";
  72190. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72191. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72192. module "babylonjs/scene" {
  72193. interface Scene {
  72194. /** @hidden (Backing field) */
  72195. _physicsEngine: Nullable<IPhysicsEngine>;
  72196. /** @hidden */
  72197. _physicsTimeAccumulator: number;
  72198. /**
  72199. * Gets the current physics engine
  72200. * @returns a IPhysicsEngine or null if none attached
  72201. */
  72202. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72203. /**
  72204. * Enables physics to the current scene
  72205. * @param gravity defines the scene's gravity for the physics engine
  72206. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72207. * @return a boolean indicating if the physics engine was initialized
  72208. */
  72209. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72210. /**
  72211. * Disables and disposes the physics engine associated with the scene
  72212. */
  72213. disablePhysicsEngine(): void;
  72214. /**
  72215. * Gets a boolean indicating if there is an active physics engine
  72216. * @returns a boolean indicating if there is an active physics engine
  72217. */
  72218. isPhysicsEnabled(): boolean;
  72219. /**
  72220. * Deletes a physics compound impostor
  72221. * @param compound defines the compound to delete
  72222. */
  72223. deleteCompoundImpostor(compound: any): void;
  72224. /**
  72225. * An event triggered when physic simulation is about to be run
  72226. */
  72227. onBeforePhysicsObservable: Observable<Scene>;
  72228. /**
  72229. * An event triggered when physic simulation has been done
  72230. */
  72231. onAfterPhysicsObservable: Observable<Scene>;
  72232. }
  72233. }
  72234. module "babylonjs/Meshes/abstractMesh" {
  72235. interface AbstractMesh {
  72236. /** @hidden */
  72237. _physicsImpostor: Nullable<PhysicsImpostor>;
  72238. /**
  72239. * Gets or sets impostor used for physic simulation
  72240. * @see https://doc.babylonjs.com/features/physics_engine
  72241. */
  72242. physicsImpostor: Nullable<PhysicsImpostor>;
  72243. /**
  72244. * Gets the current physics impostor
  72245. * @see https://doc.babylonjs.com/features/physics_engine
  72246. * @returns a physics impostor or null
  72247. */
  72248. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72249. /** Apply a physic impulse to the mesh
  72250. * @param force defines the force to apply
  72251. * @param contactPoint defines where to apply the force
  72252. * @returns the current mesh
  72253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72254. */
  72255. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72256. /**
  72257. * Creates a physic joint between two meshes
  72258. * @param otherMesh defines the other mesh to use
  72259. * @param pivot1 defines the pivot to use on this mesh
  72260. * @param pivot2 defines the pivot to use on the other mesh
  72261. * @param options defines additional options (can be plugin dependent)
  72262. * @returns the current mesh
  72263. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72264. */
  72265. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72266. /** @hidden */
  72267. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72268. }
  72269. }
  72270. /**
  72271. * Defines the physics engine scene component responsible to manage a physics engine
  72272. */
  72273. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72274. /**
  72275. * The component name helpful to identify the component in the list of scene components.
  72276. */
  72277. readonly name: string;
  72278. /**
  72279. * The scene the component belongs to.
  72280. */
  72281. scene: Scene;
  72282. /**
  72283. * Creates a new instance of the component for the given scene
  72284. * @param scene Defines the scene to register the component in
  72285. */
  72286. constructor(scene: Scene);
  72287. /**
  72288. * Registers the component in a given scene
  72289. */
  72290. register(): void;
  72291. /**
  72292. * Rebuilds the elements related to this component in case of
  72293. * context lost for instance.
  72294. */
  72295. rebuild(): void;
  72296. /**
  72297. * Disposes the component and the associated ressources
  72298. */
  72299. dispose(): void;
  72300. }
  72301. }
  72302. declare module "babylonjs/Physics/physicsHelper" {
  72303. import { Nullable } from "babylonjs/types";
  72304. import { Vector3 } from "babylonjs/Maths/math.vector";
  72305. import { Mesh } from "babylonjs/Meshes/mesh";
  72306. import { Scene } from "babylonjs/scene";
  72307. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72308. /**
  72309. * A helper for physics simulations
  72310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72311. */
  72312. export class PhysicsHelper {
  72313. private _scene;
  72314. private _physicsEngine;
  72315. /**
  72316. * Initializes the Physics helper
  72317. * @param scene Babylon.js scene
  72318. */
  72319. constructor(scene: Scene);
  72320. /**
  72321. * Applies a radial explosion impulse
  72322. * @param origin the origin of the explosion
  72323. * @param radiusOrEventOptions the radius or the options of radial explosion
  72324. * @param strength the explosion strength
  72325. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72326. * @returns A physics radial explosion event, or null
  72327. */
  72328. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72329. /**
  72330. * Applies a radial explosion force
  72331. * @param origin the origin of the explosion
  72332. * @param radiusOrEventOptions the radius or the options of radial explosion
  72333. * @param strength the explosion strength
  72334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72335. * @returns A physics radial explosion event, or null
  72336. */
  72337. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72338. /**
  72339. * Creates a gravitational field
  72340. * @param origin the origin of the explosion
  72341. * @param radiusOrEventOptions the radius or the options of radial explosion
  72342. * @param strength the explosion strength
  72343. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72344. * @returns A physics gravitational field event, or null
  72345. */
  72346. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72347. /**
  72348. * Creates a physics updraft event
  72349. * @param origin the origin of the updraft
  72350. * @param radiusOrEventOptions the radius or the options of the updraft
  72351. * @param strength the strength of the updraft
  72352. * @param height the height of the updraft
  72353. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72354. * @returns A physics updraft event, or null
  72355. */
  72356. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72357. /**
  72358. * Creates a physics vortex event
  72359. * @param origin the of the vortex
  72360. * @param radiusOrEventOptions the radius or the options of the vortex
  72361. * @param strength the strength of the vortex
  72362. * @param height the height of the vortex
  72363. * @returns a Physics vortex event, or null
  72364. * A physics vortex event or null
  72365. */
  72366. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72367. }
  72368. /**
  72369. * Represents a physics radial explosion event
  72370. */
  72371. class PhysicsRadialExplosionEvent {
  72372. private _scene;
  72373. private _options;
  72374. private _sphere;
  72375. private _dataFetched;
  72376. /**
  72377. * Initializes a radial explosioin event
  72378. * @param _scene BabylonJS scene
  72379. * @param _options The options for the vortex event
  72380. */
  72381. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72382. /**
  72383. * Returns the data related to the radial explosion event (sphere).
  72384. * @returns The radial explosion event data
  72385. */
  72386. getData(): PhysicsRadialExplosionEventData;
  72387. /**
  72388. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72389. * @param impostor A physics imposter
  72390. * @param origin the origin of the explosion
  72391. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72392. */
  72393. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72394. /**
  72395. * Triggers affecterd impostors callbacks
  72396. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72397. */
  72398. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72399. /**
  72400. * Disposes the sphere.
  72401. * @param force Specifies if the sphere should be disposed by force
  72402. */
  72403. dispose(force?: boolean): void;
  72404. /*** Helpers ***/
  72405. private _prepareSphere;
  72406. private _intersectsWithSphere;
  72407. }
  72408. /**
  72409. * Represents a gravitational field event
  72410. */
  72411. class PhysicsGravitationalFieldEvent {
  72412. private _physicsHelper;
  72413. private _scene;
  72414. private _origin;
  72415. private _options;
  72416. private _tickCallback;
  72417. private _sphere;
  72418. private _dataFetched;
  72419. /**
  72420. * Initializes the physics gravitational field event
  72421. * @param _physicsHelper A physics helper
  72422. * @param _scene BabylonJS scene
  72423. * @param _origin The origin position of the gravitational field event
  72424. * @param _options The options for the vortex event
  72425. */
  72426. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72427. /**
  72428. * Returns the data related to the gravitational field event (sphere).
  72429. * @returns A gravitational field event
  72430. */
  72431. getData(): PhysicsGravitationalFieldEventData;
  72432. /**
  72433. * Enables the gravitational field.
  72434. */
  72435. enable(): void;
  72436. /**
  72437. * Disables the gravitational field.
  72438. */
  72439. disable(): void;
  72440. /**
  72441. * Disposes the sphere.
  72442. * @param force The force to dispose from the gravitational field event
  72443. */
  72444. dispose(force?: boolean): void;
  72445. private _tick;
  72446. }
  72447. /**
  72448. * Represents a physics updraft event
  72449. */
  72450. class PhysicsUpdraftEvent {
  72451. private _scene;
  72452. private _origin;
  72453. private _options;
  72454. private _physicsEngine;
  72455. private _originTop;
  72456. private _originDirection;
  72457. private _tickCallback;
  72458. private _cylinder;
  72459. private _cylinderPosition;
  72460. private _dataFetched;
  72461. /**
  72462. * Initializes the physics updraft event
  72463. * @param _scene BabylonJS scene
  72464. * @param _origin The origin position of the updraft
  72465. * @param _options The options for the updraft event
  72466. */
  72467. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72468. /**
  72469. * Returns the data related to the updraft event (cylinder).
  72470. * @returns A physics updraft event
  72471. */
  72472. getData(): PhysicsUpdraftEventData;
  72473. /**
  72474. * Enables the updraft.
  72475. */
  72476. enable(): void;
  72477. /**
  72478. * Disables the updraft.
  72479. */
  72480. disable(): void;
  72481. /**
  72482. * Disposes the cylinder.
  72483. * @param force Specifies if the updraft should be disposed by force
  72484. */
  72485. dispose(force?: boolean): void;
  72486. private getImpostorHitData;
  72487. private _tick;
  72488. /*** Helpers ***/
  72489. private _prepareCylinder;
  72490. private _intersectsWithCylinder;
  72491. }
  72492. /**
  72493. * Represents a physics vortex event
  72494. */
  72495. class PhysicsVortexEvent {
  72496. private _scene;
  72497. private _origin;
  72498. private _options;
  72499. private _physicsEngine;
  72500. private _originTop;
  72501. private _tickCallback;
  72502. private _cylinder;
  72503. private _cylinderPosition;
  72504. private _dataFetched;
  72505. /**
  72506. * Initializes the physics vortex event
  72507. * @param _scene The BabylonJS scene
  72508. * @param _origin The origin position of the vortex
  72509. * @param _options The options for the vortex event
  72510. */
  72511. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72512. /**
  72513. * Returns the data related to the vortex event (cylinder).
  72514. * @returns The physics vortex event data
  72515. */
  72516. getData(): PhysicsVortexEventData;
  72517. /**
  72518. * Enables the vortex.
  72519. */
  72520. enable(): void;
  72521. /**
  72522. * Disables the cortex.
  72523. */
  72524. disable(): void;
  72525. /**
  72526. * Disposes the sphere.
  72527. * @param force
  72528. */
  72529. dispose(force?: boolean): void;
  72530. private getImpostorHitData;
  72531. private _tick;
  72532. /*** Helpers ***/
  72533. private _prepareCylinder;
  72534. private _intersectsWithCylinder;
  72535. }
  72536. /**
  72537. * Options fot the radial explosion event
  72538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72539. */
  72540. export class PhysicsRadialExplosionEventOptions {
  72541. /**
  72542. * The radius of the sphere for the radial explosion.
  72543. */
  72544. radius: number;
  72545. /**
  72546. * The strenth of the explosion.
  72547. */
  72548. strength: number;
  72549. /**
  72550. * The strenght of the force in correspondence to the distance of the affected object
  72551. */
  72552. falloff: PhysicsRadialImpulseFalloff;
  72553. /**
  72554. * Sphere options for the radial explosion.
  72555. */
  72556. sphere: {
  72557. segments: number;
  72558. diameter: number;
  72559. };
  72560. /**
  72561. * Sphere options for the radial explosion.
  72562. */
  72563. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72564. }
  72565. /**
  72566. * Options fot the updraft event
  72567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72568. */
  72569. export class PhysicsUpdraftEventOptions {
  72570. /**
  72571. * The radius of the cylinder for the vortex
  72572. */
  72573. radius: number;
  72574. /**
  72575. * The strenth of the updraft.
  72576. */
  72577. strength: number;
  72578. /**
  72579. * The height of the cylinder for the updraft.
  72580. */
  72581. height: number;
  72582. /**
  72583. * The mode for the the updraft.
  72584. */
  72585. updraftMode: PhysicsUpdraftMode;
  72586. }
  72587. /**
  72588. * Options fot the vortex event
  72589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72590. */
  72591. export class PhysicsVortexEventOptions {
  72592. /**
  72593. * The radius of the cylinder for the vortex
  72594. */
  72595. radius: number;
  72596. /**
  72597. * The strenth of the vortex.
  72598. */
  72599. strength: number;
  72600. /**
  72601. * The height of the cylinder for the vortex.
  72602. */
  72603. height: number;
  72604. /**
  72605. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72606. */
  72607. centripetalForceThreshold: number;
  72608. /**
  72609. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72610. */
  72611. centripetalForceMultiplier: number;
  72612. /**
  72613. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72614. */
  72615. centrifugalForceMultiplier: number;
  72616. /**
  72617. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72618. */
  72619. updraftForceMultiplier: number;
  72620. }
  72621. /**
  72622. * The strenght of the force in correspondence to the distance of the affected object
  72623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72624. */
  72625. export enum PhysicsRadialImpulseFalloff {
  72626. /** Defines that impulse is constant in strength across it's whole radius */
  72627. Constant = 0,
  72628. /** Defines that impulse gets weaker if it's further from the origin */
  72629. Linear = 1
  72630. }
  72631. /**
  72632. * The strength of the force in correspondence to the distance of the affected object
  72633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72634. */
  72635. export enum PhysicsUpdraftMode {
  72636. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72637. Center = 0,
  72638. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72639. Perpendicular = 1
  72640. }
  72641. /**
  72642. * Interface for a physics hit data
  72643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72644. */
  72645. export interface PhysicsHitData {
  72646. /**
  72647. * The force applied at the contact point
  72648. */
  72649. force: Vector3;
  72650. /**
  72651. * The contact point
  72652. */
  72653. contactPoint: Vector3;
  72654. /**
  72655. * The distance from the origin to the contact point
  72656. */
  72657. distanceFromOrigin: number;
  72658. }
  72659. /**
  72660. * Interface for radial explosion event data
  72661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72662. */
  72663. export interface PhysicsRadialExplosionEventData {
  72664. /**
  72665. * A sphere used for the radial explosion event
  72666. */
  72667. sphere: Mesh;
  72668. }
  72669. /**
  72670. * Interface for gravitational field event data
  72671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72672. */
  72673. export interface PhysicsGravitationalFieldEventData {
  72674. /**
  72675. * A sphere mesh used for the gravitational field event
  72676. */
  72677. sphere: Mesh;
  72678. }
  72679. /**
  72680. * Interface for updraft event data
  72681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72682. */
  72683. export interface PhysicsUpdraftEventData {
  72684. /**
  72685. * A cylinder used for the updraft event
  72686. */
  72687. cylinder: Mesh;
  72688. }
  72689. /**
  72690. * Interface for vortex event data
  72691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72692. */
  72693. export interface PhysicsVortexEventData {
  72694. /**
  72695. * A cylinder used for the vortex event
  72696. */
  72697. cylinder: Mesh;
  72698. }
  72699. /**
  72700. * Interface for an affected physics impostor
  72701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72702. */
  72703. export interface PhysicsAffectedImpostorWithData {
  72704. /**
  72705. * The impostor affected by the effect
  72706. */
  72707. impostor: PhysicsImpostor;
  72708. /**
  72709. * The data about the hit/horce from the explosion
  72710. */
  72711. hitData: PhysicsHitData;
  72712. }
  72713. }
  72714. declare module "babylonjs/Physics/Plugins/index" {
  72715. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72716. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72717. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72718. }
  72719. declare module "babylonjs/Physics/index" {
  72720. export * from "babylonjs/Physics/IPhysicsEngine";
  72721. export * from "babylonjs/Physics/physicsEngine";
  72722. export * from "babylonjs/Physics/physicsEngineComponent";
  72723. export * from "babylonjs/Physics/physicsHelper";
  72724. export * from "babylonjs/Physics/physicsImpostor";
  72725. export * from "babylonjs/Physics/physicsJoint";
  72726. export * from "babylonjs/Physics/Plugins/index";
  72727. }
  72728. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72729. /** @hidden */
  72730. export var blackAndWhitePixelShader: {
  72731. name: string;
  72732. shader: string;
  72733. };
  72734. }
  72735. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72737. import { Camera } from "babylonjs/Cameras/camera";
  72738. import { Engine } from "babylonjs/Engines/engine";
  72739. import "babylonjs/Shaders/blackAndWhite.fragment";
  72740. import { Nullable } from "babylonjs/types";
  72741. import { Scene } from "babylonjs/scene";
  72742. /**
  72743. * Post process used to render in black and white
  72744. */
  72745. export class BlackAndWhitePostProcess extends PostProcess {
  72746. /**
  72747. * Linear about to convert he result to black and white (default: 1)
  72748. */
  72749. degree: number;
  72750. /**
  72751. * Gets a string identifying the name of the class
  72752. * @returns "BlackAndWhitePostProcess" string
  72753. */
  72754. getClassName(): string;
  72755. /**
  72756. * Creates a black and white post process
  72757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72758. * @param name The name of the effect.
  72759. * @param options The required width/height ratio to downsize to before computing the render pass.
  72760. * @param camera The camera to apply the render pass to.
  72761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72762. * @param engine The engine which the post process will be applied. (default: current engine)
  72763. * @param reusable If the post process can be reused on the same frame. (default: false)
  72764. */
  72765. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72766. /** @hidden */
  72767. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72768. }
  72769. }
  72770. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72771. import { Nullable } from "babylonjs/types";
  72772. import { Camera } from "babylonjs/Cameras/camera";
  72773. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72774. import { Engine } from "babylonjs/Engines/engine";
  72775. /**
  72776. * This represents a set of one or more post processes in Babylon.
  72777. * A post process can be used to apply a shader to a texture after it is rendered.
  72778. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72779. */
  72780. export class PostProcessRenderEffect {
  72781. private _postProcesses;
  72782. private _getPostProcesses;
  72783. private _singleInstance;
  72784. private _cameras;
  72785. private _indicesForCamera;
  72786. /**
  72787. * Name of the effect
  72788. * @hidden
  72789. */
  72790. _name: string;
  72791. /**
  72792. * Instantiates a post process render effect.
  72793. * A post process can be used to apply a shader to a texture after it is rendered.
  72794. * @param engine The engine the effect is tied to
  72795. * @param name The name of the effect
  72796. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72797. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72798. */
  72799. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72800. /**
  72801. * Checks if all the post processes in the effect are supported.
  72802. */
  72803. get isSupported(): boolean;
  72804. /**
  72805. * Updates the current state of the effect
  72806. * @hidden
  72807. */
  72808. _update(): void;
  72809. /**
  72810. * Attaches the effect on cameras
  72811. * @param cameras The camera to attach to.
  72812. * @hidden
  72813. */
  72814. _attachCameras(cameras: Camera): void;
  72815. /**
  72816. * Attaches the effect on cameras
  72817. * @param cameras The camera to attach to.
  72818. * @hidden
  72819. */
  72820. _attachCameras(cameras: Camera[]): void;
  72821. /**
  72822. * Detaches the effect on cameras
  72823. * @param cameras The camera to detatch from.
  72824. * @hidden
  72825. */
  72826. _detachCameras(cameras: Camera): void;
  72827. /**
  72828. * Detatches the effect on cameras
  72829. * @param cameras The camera to detatch from.
  72830. * @hidden
  72831. */
  72832. _detachCameras(cameras: Camera[]): void;
  72833. /**
  72834. * Enables the effect on given cameras
  72835. * @param cameras The camera to enable.
  72836. * @hidden
  72837. */
  72838. _enable(cameras: Camera): void;
  72839. /**
  72840. * Enables the effect on given cameras
  72841. * @param cameras The camera to enable.
  72842. * @hidden
  72843. */
  72844. _enable(cameras: Nullable<Camera[]>): void;
  72845. /**
  72846. * Disables the effect on the given cameras
  72847. * @param cameras The camera to disable.
  72848. * @hidden
  72849. */
  72850. _disable(cameras: Camera): void;
  72851. /**
  72852. * Disables the effect on the given cameras
  72853. * @param cameras The camera to disable.
  72854. * @hidden
  72855. */
  72856. _disable(cameras: Nullable<Camera[]>): void;
  72857. /**
  72858. * Gets a list of the post processes contained in the effect.
  72859. * @param camera The camera to get the post processes on.
  72860. * @returns The list of the post processes in the effect.
  72861. */
  72862. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72863. }
  72864. }
  72865. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72866. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72867. /** @hidden */
  72868. export var extractHighlightsPixelShader: {
  72869. name: string;
  72870. shader: string;
  72871. };
  72872. }
  72873. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72874. import { Nullable } from "babylonjs/types";
  72875. import { Camera } from "babylonjs/Cameras/camera";
  72876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72877. import { Engine } from "babylonjs/Engines/engine";
  72878. import "babylonjs/Shaders/extractHighlights.fragment";
  72879. /**
  72880. * 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.
  72881. */
  72882. export class ExtractHighlightsPostProcess extends PostProcess {
  72883. /**
  72884. * The luminance threshold, pixels below this value will be set to black.
  72885. */
  72886. threshold: number;
  72887. /** @hidden */
  72888. _exposure: number;
  72889. /**
  72890. * Post process which has the input texture to be used when performing highlight extraction
  72891. * @hidden
  72892. */
  72893. _inputPostProcess: Nullable<PostProcess>;
  72894. /**
  72895. * Gets a string identifying the name of the class
  72896. * @returns "ExtractHighlightsPostProcess" string
  72897. */
  72898. getClassName(): string;
  72899. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72900. }
  72901. }
  72902. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72903. /** @hidden */
  72904. export var bloomMergePixelShader: {
  72905. name: string;
  72906. shader: string;
  72907. };
  72908. }
  72909. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72911. import { Nullable } from "babylonjs/types";
  72912. import { Engine } from "babylonjs/Engines/engine";
  72913. import { Camera } from "babylonjs/Cameras/camera";
  72914. import "babylonjs/Shaders/bloomMerge.fragment";
  72915. /**
  72916. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72917. */
  72918. export class BloomMergePostProcess extends PostProcess {
  72919. /** Weight of the bloom to be added to the original input. */
  72920. weight: number;
  72921. /**
  72922. * Gets a string identifying the name of the class
  72923. * @returns "BloomMergePostProcess" string
  72924. */
  72925. getClassName(): string;
  72926. /**
  72927. * Creates a new instance of @see BloomMergePostProcess
  72928. * @param name The name of the effect.
  72929. * @param originalFromInput Post process which's input will be used for the merge.
  72930. * @param blurred Blurred highlights post process which's output will be used.
  72931. * @param weight Weight of the bloom to be added to the original input.
  72932. * @param options The required width/height ratio to downsize to before computing the render pass.
  72933. * @param camera The camera to apply the render pass to.
  72934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72935. * @param engine The engine which the post process will be applied. (default: current engine)
  72936. * @param reusable If the post process can be reused on the same frame. (default: false)
  72937. * @param textureType Type of textures used when performing the post process. (default: 0)
  72938. * @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)
  72939. */
  72940. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72941. /** Weight of the bloom to be added to the original input. */
  72942. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72943. }
  72944. }
  72945. declare module "babylonjs/PostProcesses/bloomEffect" {
  72946. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72948. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72949. import { Camera } from "babylonjs/Cameras/camera";
  72950. import { Scene } from "babylonjs/scene";
  72951. /**
  72952. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72953. */
  72954. export class BloomEffect extends PostProcessRenderEffect {
  72955. private bloomScale;
  72956. /**
  72957. * @hidden Internal
  72958. */
  72959. _effects: Array<PostProcess>;
  72960. /**
  72961. * @hidden Internal
  72962. */
  72963. _downscale: ExtractHighlightsPostProcess;
  72964. private _blurX;
  72965. private _blurY;
  72966. private _merge;
  72967. /**
  72968. * The luminance threshold to find bright areas of the image to bloom.
  72969. */
  72970. get threshold(): number;
  72971. set threshold(value: number);
  72972. /**
  72973. * The strength of the bloom.
  72974. */
  72975. get weight(): number;
  72976. set weight(value: number);
  72977. /**
  72978. * Specifies the size of the bloom blur kernel, relative to the final output size
  72979. */
  72980. get kernel(): number;
  72981. set kernel(value: number);
  72982. /**
  72983. * Creates a new instance of @see BloomEffect
  72984. * @param scene The scene the effect belongs to.
  72985. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72986. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72987. * @param bloomWeight The the strength of bloom.
  72988. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72989. * @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)
  72990. */
  72991. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72992. /**
  72993. * Disposes each of the internal effects for a given camera.
  72994. * @param camera The camera to dispose the effect on.
  72995. */
  72996. disposeEffects(camera: Camera): void;
  72997. /**
  72998. * @hidden Internal
  72999. */
  73000. _updateEffects(): void;
  73001. /**
  73002. * Internal
  73003. * @returns if all the contained post processes are ready.
  73004. * @hidden
  73005. */
  73006. _isReady(): boolean;
  73007. }
  73008. }
  73009. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73010. /** @hidden */
  73011. export var chromaticAberrationPixelShader: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73017. import { Vector2 } from "babylonjs/Maths/math.vector";
  73018. import { Nullable } from "babylonjs/types";
  73019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73020. import { Camera } from "babylonjs/Cameras/camera";
  73021. import { Engine } from "babylonjs/Engines/engine";
  73022. import "babylonjs/Shaders/chromaticAberration.fragment";
  73023. import { Scene } from "babylonjs/scene";
  73024. /**
  73025. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73026. */
  73027. export class ChromaticAberrationPostProcess extends PostProcess {
  73028. /**
  73029. * The amount of seperation of rgb channels (default: 30)
  73030. */
  73031. aberrationAmount: number;
  73032. /**
  73033. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73034. */
  73035. radialIntensity: number;
  73036. /**
  73037. * 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))
  73038. */
  73039. direction: Vector2;
  73040. /**
  73041. * 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))
  73042. */
  73043. centerPosition: Vector2;
  73044. /** The width of the screen to apply the effect on */
  73045. screenWidth: number;
  73046. /** The height of the screen to apply the effect on */
  73047. screenHeight: number;
  73048. /**
  73049. * Gets a string identifying the name of the class
  73050. * @returns "ChromaticAberrationPostProcess" string
  73051. */
  73052. getClassName(): string;
  73053. /**
  73054. * Creates a new instance ChromaticAberrationPostProcess
  73055. * @param name The name of the effect.
  73056. * @param screenWidth The width of the screen to apply the effect on.
  73057. * @param screenHeight The height of the screen to apply the effect on.
  73058. * @param options The required width/height ratio to downsize to before computing the render pass.
  73059. * @param camera The camera to apply the render pass to.
  73060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73061. * @param engine The engine which the post process will be applied. (default: current engine)
  73062. * @param reusable If the post process can be reused on the same frame. (default: false)
  73063. * @param textureType Type of textures used when performing the post process. (default: 0)
  73064. * @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)
  73065. */
  73066. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73067. /** @hidden */
  73068. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73069. }
  73070. }
  73071. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73072. /** @hidden */
  73073. export var circleOfConfusionPixelShader: {
  73074. name: string;
  73075. shader: string;
  73076. };
  73077. }
  73078. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73079. import { Nullable } from "babylonjs/types";
  73080. import { Engine } from "babylonjs/Engines/engine";
  73081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73083. import { Camera } from "babylonjs/Cameras/camera";
  73084. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73085. /**
  73086. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73087. */
  73088. export class CircleOfConfusionPostProcess extends PostProcess {
  73089. /**
  73090. * 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.
  73091. */
  73092. lensSize: number;
  73093. /**
  73094. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73095. */
  73096. fStop: number;
  73097. /**
  73098. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73099. */
  73100. focusDistance: number;
  73101. /**
  73102. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73103. */
  73104. focalLength: number;
  73105. /**
  73106. * Gets a string identifying the name of the class
  73107. * @returns "CircleOfConfusionPostProcess" string
  73108. */
  73109. getClassName(): string;
  73110. private _depthTexture;
  73111. /**
  73112. * Creates a new instance CircleOfConfusionPostProcess
  73113. * @param name The name of the effect.
  73114. * @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.
  73115. * @param options The required width/height ratio to downsize to before computing the render pass.
  73116. * @param camera The camera to apply the render pass to.
  73117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73118. * @param engine The engine which the post process will be applied. (default: current engine)
  73119. * @param reusable If the post process can be reused on the same frame. (default: false)
  73120. * @param textureType Type of textures used when performing the post process. (default: 0)
  73121. * @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)
  73122. */
  73123. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73124. /**
  73125. * 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.
  73126. */
  73127. set depthTexture(value: RenderTargetTexture);
  73128. }
  73129. }
  73130. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73131. /** @hidden */
  73132. export var colorCorrectionPixelShader: {
  73133. name: string;
  73134. shader: string;
  73135. };
  73136. }
  73137. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73138. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73139. import { Engine } from "babylonjs/Engines/engine";
  73140. import { Camera } from "babylonjs/Cameras/camera";
  73141. import "babylonjs/Shaders/colorCorrection.fragment";
  73142. import { Nullable } from "babylonjs/types";
  73143. import { Scene } from "babylonjs/scene";
  73144. /**
  73145. *
  73146. * This post-process allows the modification of rendered colors by using
  73147. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73148. *
  73149. * The object needs to be provided an url to a texture containing the color
  73150. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73151. * Use an image editing software to tweak the LUT to match your needs.
  73152. *
  73153. * For an example of a color LUT, see here:
  73154. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73155. * For explanations on color grading, see here:
  73156. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73157. *
  73158. */
  73159. export class ColorCorrectionPostProcess extends PostProcess {
  73160. private _colorTableTexture;
  73161. /**
  73162. * Gets the color table url used to create the LUT texture
  73163. */
  73164. colorTableUrl: string;
  73165. /**
  73166. * Gets a string identifying the name of the class
  73167. * @returns "ColorCorrectionPostProcess" string
  73168. */
  73169. getClassName(): string;
  73170. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73171. /** @hidden */
  73172. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73173. }
  73174. }
  73175. declare module "babylonjs/Shaders/convolution.fragment" {
  73176. /** @hidden */
  73177. export var convolutionPixelShader: {
  73178. name: string;
  73179. shader: string;
  73180. };
  73181. }
  73182. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73184. import { Nullable } from "babylonjs/types";
  73185. import { Camera } from "babylonjs/Cameras/camera";
  73186. import { Engine } from "babylonjs/Engines/engine";
  73187. import "babylonjs/Shaders/convolution.fragment";
  73188. import { Scene } from "babylonjs/scene";
  73189. /**
  73190. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73191. * input texture to perform effects such as edge detection or sharpening
  73192. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73193. */
  73194. export class ConvolutionPostProcess extends PostProcess {
  73195. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73196. kernel: number[];
  73197. /**
  73198. * Gets a string identifying the name of the class
  73199. * @returns "ConvolutionPostProcess" string
  73200. */
  73201. getClassName(): string;
  73202. /**
  73203. * Creates a new instance ConvolutionPostProcess
  73204. * @param name The name of the effect.
  73205. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73206. * @param options The required width/height ratio to downsize to before computing the render pass.
  73207. * @param camera The camera to apply the render pass to.
  73208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73209. * @param engine The engine which the post process will be applied. (default: current engine)
  73210. * @param reusable If the post process can be reused on the same frame. (default: false)
  73211. * @param textureType Type of textures used when performing the post process. (default: 0)
  73212. */
  73213. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73214. /** @hidden */
  73215. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73216. /**
  73217. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73218. */
  73219. static EdgeDetect0Kernel: number[];
  73220. /**
  73221. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73222. */
  73223. static EdgeDetect1Kernel: number[];
  73224. /**
  73225. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73226. */
  73227. static EdgeDetect2Kernel: number[];
  73228. /**
  73229. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73230. */
  73231. static SharpenKernel: number[];
  73232. /**
  73233. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73234. */
  73235. static EmbossKernel: number[];
  73236. /**
  73237. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73238. */
  73239. static GaussianKernel: number[];
  73240. }
  73241. }
  73242. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73243. import { Nullable } from "babylonjs/types";
  73244. import { Vector2 } from "babylonjs/Maths/math.vector";
  73245. import { Camera } from "babylonjs/Cameras/camera";
  73246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73247. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73248. import { Engine } from "babylonjs/Engines/engine";
  73249. import { Scene } from "babylonjs/scene";
  73250. /**
  73251. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73252. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73253. * based on samples that have a large difference in distance than the center pixel.
  73254. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73255. */
  73256. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73257. /**
  73258. * The direction the blur should be applied
  73259. */
  73260. direction: Vector2;
  73261. /**
  73262. * Gets a string identifying the name of the class
  73263. * @returns "DepthOfFieldBlurPostProcess" string
  73264. */
  73265. getClassName(): string;
  73266. /**
  73267. * Creates a new instance CircleOfConfusionPostProcess
  73268. * @param name The name of the effect.
  73269. * @param scene The scene the effect belongs to.
  73270. * @param direction The direction the blur should be applied.
  73271. * @param kernel The size of the kernel used to blur.
  73272. * @param options The required width/height ratio to downsize to before computing the render pass.
  73273. * @param camera The camera to apply the render pass to.
  73274. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73275. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73277. * @param engine The engine which the post process will be applied. (default: current engine)
  73278. * @param reusable If the post process can be reused on the same frame. (default: false)
  73279. * @param textureType Type of textures used when performing the post process. (default: 0)
  73280. * @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)
  73281. */
  73282. 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);
  73283. }
  73284. }
  73285. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73286. /** @hidden */
  73287. export var depthOfFieldMergePixelShader: {
  73288. name: string;
  73289. shader: string;
  73290. };
  73291. }
  73292. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73293. import { Nullable } from "babylonjs/types";
  73294. import { Camera } from "babylonjs/Cameras/camera";
  73295. import { Effect } from "babylonjs/Materials/effect";
  73296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73297. import { Engine } from "babylonjs/Engines/engine";
  73298. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73299. /**
  73300. * Options to be set when merging outputs from the default pipeline.
  73301. */
  73302. export class DepthOfFieldMergePostProcessOptions {
  73303. /**
  73304. * The original image to merge on top of
  73305. */
  73306. originalFromInput: PostProcess;
  73307. /**
  73308. * Parameters to perform the merge of the depth of field effect
  73309. */
  73310. depthOfField?: {
  73311. circleOfConfusion: PostProcess;
  73312. blurSteps: Array<PostProcess>;
  73313. };
  73314. /**
  73315. * Parameters to perform the merge of bloom effect
  73316. */
  73317. bloom?: {
  73318. blurred: PostProcess;
  73319. weight: number;
  73320. };
  73321. }
  73322. /**
  73323. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73324. */
  73325. export class DepthOfFieldMergePostProcess extends PostProcess {
  73326. private blurSteps;
  73327. /**
  73328. * Gets a string identifying the name of the class
  73329. * @returns "DepthOfFieldMergePostProcess" string
  73330. */
  73331. getClassName(): string;
  73332. /**
  73333. * Creates a new instance of DepthOfFieldMergePostProcess
  73334. * @param name The name of the effect.
  73335. * @param originalFromInput Post process which's input will be used for the merge.
  73336. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73337. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73338. * @param options The required width/height ratio to downsize to before computing the render pass.
  73339. * @param camera The camera to apply the render pass to.
  73340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73341. * @param engine The engine which the post process will be applied. (default: current engine)
  73342. * @param reusable If the post process can be reused on the same frame. (default: false)
  73343. * @param textureType Type of textures used when performing the post process. (default: 0)
  73344. * @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)
  73345. */
  73346. 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);
  73347. /**
  73348. * Updates the effect with the current post process compile time values and recompiles the shader.
  73349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73352. * @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
  73353. * @param onCompiled Called when the shader has been compiled.
  73354. * @param onError Called if there is an error when compiling a shader.
  73355. */
  73356. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73357. }
  73358. }
  73359. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73360. import { Nullable } from "babylonjs/types";
  73361. import { Camera } from "babylonjs/Cameras/camera";
  73362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73364. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73365. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73366. import { Scene } from "babylonjs/scene";
  73367. /**
  73368. * Specifies the level of max blur that should be applied when using the depth of field effect
  73369. */
  73370. export enum DepthOfFieldEffectBlurLevel {
  73371. /**
  73372. * Subtle blur
  73373. */
  73374. Low = 0,
  73375. /**
  73376. * Medium blur
  73377. */
  73378. Medium = 1,
  73379. /**
  73380. * Large blur
  73381. */
  73382. High = 2
  73383. }
  73384. /**
  73385. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73386. */
  73387. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73388. private _circleOfConfusion;
  73389. /**
  73390. * @hidden Internal, blurs from high to low
  73391. */
  73392. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73393. private _depthOfFieldBlurY;
  73394. private _dofMerge;
  73395. /**
  73396. * @hidden Internal post processes in depth of field effect
  73397. */
  73398. _effects: Array<PostProcess>;
  73399. /**
  73400. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73401. */
  73402. set focalLength(value: number);
  73403. get focalLength(): number;
  73404. /**
  73405. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73406. */
  73407. set fStop(value: number);
  73408. get fStop(): number;
  73409. /**
  73410. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73411. */
  73412. set focusDistance(value: number);
  73413. get focusDistance(): number;
  73414. /**
  73415. * 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.
  73416. */
  73417. set lensSize(value: number);
  73418. get lensSize(): number;
  73419. /**
  73420. * Creates a new instance DepthOfFieldEffect
  73421. * @param scene The scene the effect belongs to.
  73422. * @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.
  73423. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73424. * @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)
  73425. */
  73426. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73427. /**
  73428. * Get the current class name of the current effet
  73429. * @returns "DepthOfFieldEffect"
  73430. */
  73431. getClassName(): string;
  73432. /**
  73433. * 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.
  73434. */
  73435. set depthTexture(value: RenderTargetTexture);
  73436. /**
  73437. * Disposes each of the internal effects for a given camera.
  73438. * @param camera The camera to dispose the effect on.
  73439. */
  73440. disposeEffects(camera: Camera): void;
  73441. /**
  73442. * @hidden Internal
  73443. */
  73444. _updateEffects(): void;
  73445. /**
  73446. * Internal
  73447. * @returns if all the contained post processes are ready.
  73448. * @hidden
  73449. */
  73450. _isReady(): boolean;
  73451. }
  73452. }
  73453. declare module "babylonjs/Shaders/displayPass.fragment" {
  73454. /** @hidden */
  73455. export var displayPassPixelShader: {
  73456. name: string;
  73457. shader: string;
  73458. };
  73459. }
  73460. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73461. import { Nullable } from "babylonjs/types";
  73462. import { Camera } from "babylonjs/Cameras/camera";
  73463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73464. import { Engine } from "babylonjs/Engines/engine";
  73465. import "babylonjs/Shaders/displayPass.fragment";
  73466. import { Scene } from "babylonjs/scene";
  73467. /**
  73468. * DisplayPassPostProcess which produces an output the same as it's input
  73469. */
  73470. export class DisplayPassPostProcess extends PostProcess {
  73471. /**
  73472. * Gets a string identifying the name of the class
  73473. * @returns "DisplayPassPostProcess" string
  73474. */
  73475. getClassName(): string;
  73476. /**
  73477. * Creates the DisplayPassPostProcess
  73478. * @param name The name of the effect.
  73479. * @param options The required width/height ratio to downsize to before computing the render pass.
  73480. * @param camera The camera to apply the render pass to.
  73481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73482. * @param engine The engine which the post process will be applied. (default: current engine)
  73483. * @param reusable If the post process can be reused on the same frame. (default: false)
  73484. */
  73485. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73486. /** @hidden */
  73487. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73488. }
  73489. }
  73490. declare module "babylonjs/Shaders/filter.fragment" {
  73491. /** @hidden */
  73492. export var filterPixelShader: {
  73493. name: string;
  73494. shader: string;
  73495. };
  73496. }
  73497. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73498. import { Nullable } from "babylonjs/types";
  73499. import { Matrix } from "babylonjs/Maths/math.vector";
  73500. import { Camera } from "babylonjs/Cameras/camera";
  73501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73502. import { Engine } from "babylonjs/Engines/engine";
  73503. import "babylonjs/Shaders/filter.fragment";
  73504. import { Scene } from "babylonjs/scene";
  73505. /**
  73506. * Applies a kernel filter to the image
  73507. */
  73508. export class FilterPostProcess extends PostProcess {
  73509. /** The matrix to be applied to the image */
  73510. kernelMatrix: Matrix;
  73511. /**
  73512. * Gets a string identifying the name of the class
  73513. * @returns "FilterPostProcess" string
  73514. */
  73515. getClassName(): string;
  73516. /**
  73517. *
  73518. * @param name The name of the effect.
  73519. * @param kernelMatrix The matrix to be applied to the image
  73520. * @param options The required width/height ratio to downsize to before computing the render pass.
  73521. * @param camera The camera to apply the render pass to.
  73522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73523. * @param engine The engine which the post process will be applied. (default: current engine)
  73524. * @param reusable If the post process can be reused on the same frame. (default: false)
  73525. */
  73526. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73527. /** @hidden */
  73528. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73529. }
  73530. }
  73531. declare module "babylonjs/Shaders/fxaa.fragment" {
  73532. /** @hidden */
  73533. export var fxaaPixelShader: {
  73534. name: string;
  73535. shader: string;
  73536. };
  73537. }
  73538. declare module "babylonjs/Shaders/fxaa.vertex" {
  73539. /** @hidden */
  73540. export var fxaaVertexShader: {
  73541. name: string;
  73542. shader: string;
  73543. };
  73544. }
  73545. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73546. import { Nullable } from "babylonjs/types";
  73547. import { Camera } from "babylonjs/Cameras/camera";
  73548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73549. import { Engine } from "babylonjs/Engines/engine";
  73550. import "babylonjs/Shaders/fxaa.fragment";
  73551. import "babylonjs/Shaders/fxaa.vertex";
  73552. import { Scene } from "babylonjs/scene";
  73553. /**
  73554. * Fxaa post process
  73555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73556. */
  73557. export class FxaaPostProcess extends PostProcess {
  73558. /**
  73559. * Gets a string identifying the name of the class
  73560. * @returns "FxaaPostProcess" string
  73561. */
  73562. getClassName(): string;
  73563. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73564. private _getDefines;
  73565. /** @hidden */
  73566. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73567. }
  73568. }
  73569. declare module "babylonjs/Shaders/grain.fragment" {
  73570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73571. /** @hidden */
  73572. export var grainPixelShader: {
  73573. name: string;
  73574. shader: string;
  73575. };
  73576. }
  73577. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73578. import { Nullable } from "babylonjs/types";
  73579. import { Camera } from "babylonjs/Cameras/camera";
  73580. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73581. import { Engine } from "babylonjs/Engines/engine";
  73582. import "babylonjs/Shaders/grain.fragment";
  73583. import { Scene } from "babylonjs/scene";
  73584. /**
  73585. * The GrainPostProcess adds noise to the image at mid luminance levels
  73586. */
  73587. export class GrainPostProcess extends PostProcess {
  73588. /**
  73589. * The intensity of the grain added (default: 30)
  73590. */
  73591. intensity: number;
  73592. /**
  73593. * If the grain should be randomized on every frame
  73594. */
  73595. animated: boolean;
  73596. /**
  73597. * Gets a string identifying the name of the class
  73598. * @returns "GrainPostProcess" string
  73599. */
  73600. getClassName(): string;
  73601. /**
  73602. * Creates a new instance of @see GrainPostProcess
  73603. * @param name The name of the effect.
  73604. * @param options The required width/height ratio to downsize to before computing the render pass.
  73605. * @param camera The camera to apply the render pass to.
  73606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73607. * @param engine The engine which the post process will be applied. (default: current engine)
  73608. * @param reusable If the post process can be reused on the same frame. (default: false)
  73609. * @param textureType Type of textures used when performing the post process. (default: 0)
  73610. * @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)
  73611. */
  73612. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73613. /** @hidden */
  73614. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73615. }
  73616. }
  73617. declare module "babylonjs/Shaders/highlights.fragment" {
  73618. /** @hidden */
  73619. export var highlightsPixelShader: {
  73620. name: string;
  73621. shader: string;
  73622. };
  73623. }
  73624. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73625. import { Nullable } from "babylonjs/types";
  73626. import { Camera } from "babylonjs/Cameras/camera";
  73627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73628. import { Engine } from "babylonjs/Engines/engine";
  73629. import "babylonjs/Shaders/highlights.fragment";
  73630. /**
  73631. * Extracts highlights from the image
  73632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73633. */
  73634. export class HighlightsPostProcess extends PostProcess {
  73635. /**
  73636. * Gets a string identifying the name of the class
  73637. * @returns "HighlightsPostProcess" string
  73638. */
  73639. getClassName(): string;
  73640. /**
  73641. * Extracts highlights from the image
  73642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73643. * @param name The name of the effect.
  73644. * @param options The required width/height ratio to downsize to before computing the render pass.
  73645. * @param camera The camera to apply the render pass to.
  73646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73647. * @param engine The engine which the post process will be applied. (default: current engine)
  73648. * @param reusable If the post process can be reused on the same frame. (default: false)
  73649. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73650. */
  73651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73652. }
  73653. }
  73654. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73655. /** @hidden */
  73656. export var mrtFragmentDeclaration: {
  73657. name: string;
  73658. shader: string;
  73659. };
  73660. }
  73661. declare module "babylonjs/Shaders/geometry.fragment" {
  73662. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73663. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73664. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73665. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73666. /** @hidden */
  73667. export var geometryPixelShader: {
  73668. name: string;
  73669. shader: string;
  73670. };
  73671. }
  73672. declare module "babylonjs/Shaders/geometry.vertex" {
  73673. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73675. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73676. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73677. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73678. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73679. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73680. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73681. /** @hidden */
  73682. export var geometryVertexShader: {
  73683. name: string;
  73684. shader: string;
  73685. };
  73686. }
  73687. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73688. import { Matrix } from "babylonjs/Maths/math.vector";
  73689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73690. import { Mesh } from "babylonjs/Meshes/mesh";
  73691. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73692. import { Effect } from "babylonjs/Materials/effect";
  73693. import { Scene } from "babylonjs/scene";
  73694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73695. import "babylonjs/Shaders/geometry.fragment";
  73696. import "babylonjs/Shaders/geometry.vertex";
  73697. /** @hidden */
  73698. interface ISavedTransformationMatrix {
  73699. world: Matrix;
  73700. viewProjection: Matrix;
  73701. }
  73702. /**
  73703. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73704. */
  73705. export class GeometryBufferRenderer {
  73706. /**
  73707. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73708. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73709. */
  73710. static readonly POSITION_TEXTURE_TYPE: number;
  73711. /**
  73712. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73713. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73714. */
  73715. static readonly VELOCITY_TEXTURE_TYPE: number;
  73716. /**
  73717. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73718. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73719. */
  73720. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73721. /**
  73722. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73723. * in order to compute objects velocities when enableVelocity is set to "true"
  73724. * @hidden
  73725. */
  73726. _previousTransformationMatrices: {
  73727. [index: number]: ISavedTransformationMatrix;
  73728. };
  73729. /**
  73730. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73731. * in order to compute objects velocities when enableVelocity is set to "true"
  73732. * @hidden
  73733. */
  73734. _previousBonesTransformationMatrices: {
  73735. [index: number]: Float32Array;
  73736. };
  73737. /**
  73738. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73739. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73740. */
  73741. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73742. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73743. renderTransparentMeshes: boolean;
  73744. private _scene;
  73745. private _resizeObserver;
  73746. private _multiRenderTarget;
  73747. private _ratio;
  73748. private _enablePosition;
  73749. private _enableVelocity;
  73750. private _enableReflectivity;
  73751. private _positionIndex;
  73752. private _velocityIndex;
  73753. private _reflectivityIndex;
  73754. protected _effect: Effect;
  73755. protected _cachedDefines: string;
  73756. /**
  73757. * Set the render list (meshes to be rendered) used in the G buffer.
  73758. */
  73759. set renderList(meshes: Mesh[]);
  73760. /**
  73761. * Gets wether or not G buffer are supported by the running hardware.
  73762. * This requires draw buffer supports
  73763. */
  73764. get isSupported(): boolean;
  73765. /**
  73766. * Returns the index of the given texture type in the G-Buffer textures array
  73767. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73768. * @returns the index of the given texture type in the G-Buffer textures array
  73769. */
  73770. getTextureIndex(textureType: number): number;
  73771. /**
  73772. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73773. */
  73774. get enablePosition(): boolean;
  73775. /**
  73776. * Sets whether or not objects positions are enabled for the G buffer.
  73777. */
  73778. set enablePosition(enable: boolean);
  73779. /**
  73780. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73781. */
  73782. get enableVelocity(): boolean;
  73783. /**
  73784. * Sets wether or not objects velocities are enabled for the G buffer.
  73785. */
  73786. set enableVelocity(enable: boolean);
  73787. /**
  73788. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73789. */
  73790. get enableReflectivity(): boolean;
  73791. /**
  73792. * Sets wether or not objects roughness are enabled for the G buffer.
  73793. */
  73794. set enableReflectivity(enable: boolean);
  73795. /**
  73796. * Gets the scene associated with the buffer.
  73797. */
  73798. get scene(): Scene;
  73799. /**
  73800. * Gets the ratio used by the buffer during its creation.
  73801. * How big is the buffer related to the main canvas.
  73802. */
  73803. get ratio(): number;
  73804. /** @hidden */
  73805. static _SceneComponentInitialization: (scene: Scene) => void;
  73806. /**
  73807. * Creates a new G Buffer for the scene
  73808. * @param scene The scene the buffer belongs to
  73809. * @param ratio How big is the buffer related to the main canvas.
  73810. */
  73811. constructor(scene: Scene, ratio?: number);
  73812. /**
  73813. * Checks wether everything is ready to render a submesh to the G buffer.
  73814. * @param subMesh the submesh to check readiness for
  73815. * @param useInstances is the mesh drawn using instance or not
  73816. * @returns true if ready otherwise false
  73817. */
  73818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73819. /**
  73820. * Gets the current underlying G Buffer.
  73821. * @returns the buffer
  73822. */
  73823. getGBuffer(): MultiRenderTarget;
  73824. /**
  73825. * Gets the number of samples used to render the buffer (anti aliasing).
  73826. */
  73827. get samples(): number;
  73828. /**
  73829. * Sets the number of samples used to render the buffer (anti aliasing).
  73830. */
  73831. set samples(value: number);
  73832. /**
  73833. * Disposes the renderer and frees up associated resources.
  73834. */
  73835. dispose(): void;
  73836. protected _createRenderTargets(): void;
  73837. private _copyBonesTransformationMatrices;
  73838. }
  73839. }
  73840. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73841. import { Nullable } from "babylonjs/types";
  73842. import { Scene } from "babylonjs/scene";
  73843. import { ISceneComponent } from "babylonjs/sceneComponent";
  73844. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73845. module "babylonjs/scene" {
  73846. interface Scene {
  73847. /** @hidden (Backing field) */
  73848. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73849. /**
  73850. * Gets or Sets the current geometry buffer associated to the scene.
  73851. */
  73852. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73853. /**
  73854. * Enables a GeometryBufferRender and associates it with the scene
  73855. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73856. * @returns the GeometryBufferRenderer
  73857. */
  73858. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73859. /**
  73860. * Disables the GeometryBufferRender associated with the scene
  73861. */
  73862. disableGeometryBufferRenderer(): void;
  73863. }
  73864. }
  73865. /**
  73866. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73867. * in several rendering techniques.
  73868. */
  73869. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73870. /**
  73871. * The component name helpful to identify the component in the list of scene components.
  73872. */
  73873. readonly name: string;
  73874. /**
  73875. * The scene the component belongs to.
  73876. */
  73877. scene: Scene;
  73878. /**
  73879. * Creates a new instance of the component for the given scene
  73880. * @param scene Defines the scene to register the component in
  73881. */
  73882. constructor(scene: Scene);
  73883. /**
  73884. * Registers the component in a given scene
  73885. */
  73886. register(): void;
  73887. /**
  73888. * Rebuilds the elements related to this component in case of
  73889. * context lost for instance.
  73890. */
  73891. rebuild(): void;
  73892. /**
  73893. * Disposes the component and the associated ressources
  73894. */
  73895. dispose(): void;
  73896. private _gatherRenderTargets;
  73897. }
  73898. }
  73899. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73900. /** @hidden */
  73901. export var motionBlurPixelShader: {
  73902. name: string;
  73903. shader: string;
  73904. };
  73905. }
  73906. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73907. import { Nullable } from "babylonjs/types";
  73908. import { Camera } from "babylonjs/Cameras/camera";
  73909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73911. import "babylonjs/Animations/animatable";
  73912. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73913. import "babylonjs/Shaders/motionBlur.fragment";
  73914. import { Engine } from "babylonjs/Engines/engine";
  73915. import { Scene } from "babylonjs/scene";
  73916. /**
  73917. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73918. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73919. * As an example, all you have to do is to create the post-process:
  73920. * var mb = new BABYLON.MotionBlurPostProcess(
  73921. * 'mb', // The name of the effect.
  73922. * scene, // The scene containing the objects to blur according to their velocity.
  73923. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73924. * camera // The camera to apply the render pass to.
  73925. * );
  73926. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73927. */
  73928. export class MotionBlurPostProcess extends PostProcess {
  73929. /**
  73930. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73931. */
  73932. motionStrength: number;
  73933. /**
  73934. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73935. */
  73936. get motionBlurSamples(): number;
  73937. /**
  73938. * Sets the number of iterations to be used for motion blur quality
  73939. */
  73940. set motionBlurSamples(samples: number);
  73941. private _motionBlurSamples;
  73942. private _geometryBufferRenderer;
  73943. /**
  73944. * Gets a string identifying the name of the class
  73945. * @returns "MotionBlurPostProcess" string
  73946. */
  73947. getClassName(): string;
  73948. /**
  73949. * Creates a new instance MotionBlurPostProcess
  73950. * @param name The name of the effect.
  73951. * @param scene The scene containing the objects to blur according to their velocity.
  73952. * @param options The required width/height ratio to downsize to before computing the render pass.
  73953. * @param camera The camera to apply the render pass to.
  73954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73955. * @param engine The engine which the post process will be applied. (default: current engine)
  73956. * @param reusable If the post process can be reused on the same frame. (default: false)
  73957. * @param textureType Type of textures used when performing the post process. (default: 0)
  73958. * @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)
  73959. */
  73960. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73961. /**
  73962. * Excludes the given skinned mesh from computing bones velocities.
  73963. * 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.
  73964. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73965. */
  73966. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73967. /**
  73968. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73969. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73970. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73971. */
  73972. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73973. /**
  73974. * Disposes the post process.
  73975. * @param camera The camera to dispose the post process on.
  73976. */
  73977. dispose(camera?: Camera): void;
  73978. /** @hidden */
  73979. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73980. }
  73981. }
  73982. declare module "babylonjs/Shaders/refraction.fragment" {
  73983. /** @hidden */
  73984. export var refractionPixelShader: {
  73985. name: string;
  73986. shader: string;
  73987. };
  73988. }
  73989. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73990. import { Color3 } from "babylonjs/Maths/math.color";
  73991. import { Camera } from "babylonjs/Cameras/camera";
  73992. import { Texture } from "babylonjs/Materials/Textures/texture";
  73993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73994. import { Engine } from "babylonjs/Engines/engine";
  73995. import "babylonjs/Shaders/refraction.fragment";
  73996. import { Scene } from "babylonjs/scene";
  73997. /**
  73998. * Post process which applies a refractin texture
  73999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74000. */
  74001. export class RefractionPostProcess extends PostProcess {
  74002. private _refTexture;
  74003. private _ownRefractionTexture;
  74004. /** the base color of the refraction (used to taint the rendering) */
  74005. color: Color3;
  74006. /** simulated refraction depth */
  74007. depth: number;
  74008. /** the coefficient of the base color (0 to remove base color tainting) */
  74009. colorLevel: number;
  74010. /** Gets the url used to load the refraction texture */
  74011. refractionTextureUrl: string;
  74012. /**
  74013. * Gets or sets the refraction texture
  74014. * Please note that you are responsible for disposing the texture if you set it manually
  74015. */
  74016. get refractionTexture(): Texture;
  74017. set refractionTexture(value: Texture);
  74018. /**
  74019. * Gets a string identifying the name of the class
  74020. * @returns "RefractionPostProcess" string
  74021. */
  74022. getClassName(): string;
  74023. /**
  74024. * Initializes the RefractionPostProcess
  74025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74026. * @param name The name of the effect.
  74027. * @param refractionTextureUrl Url of the refraction texture to use
  74028. * @param color the base color of the refraction (used to taint the rendering)
  74029. * @param depth simulated refraction depth
  74030. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74031. * @param camera The camera to apply the render pass to.
  74032. * @param options The required width/height ratio to downsize to before computing the render pass.
  74033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74034. * @param engine The engine which the post process will be applied. (default: current engine)
  74035. * @param reusable If the post process can be reused on the same frame. (default: false)
  74036. */
  74037. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74038. /**
  74039. * Disposes of the post process
  74040. * @param camera Camera to dispose post process on
  74041. */
  74042. dispose(camera: Camera): void;
  74043. /** @hidden */
  74044. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74045. }
  74046. }
  74047. declare module "babylonjs/Shaders/sharpen.fragment" {
  74048. /** @hidden */
  74049. export var sharpenPixelShader: {
  74050. name: string;
  74051. shader: string;
  74052. };
  74053. }
  74054. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74055. import { Nullable } from "babylonjs/types";
  74056. import { Camera } from "babylonjs/Cameras/camera";
  74057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74058. import "babylonjs/Shaders/sharpen.fragment";
  74059. import { Engine } from "babylonjs/Engines/engine";
  74060. import { Scene } from "babylonjs/scene";
  74061. /**
  74062. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74063. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74064. */
  74065. export class SharpenPostProcess extends PostProcess {
  74066. /**
  74067. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74068. */
  74069. colorAmount: number;
  74070. /**
  74071. * How much sharpness should be applied (default: 0.3)
  74072. */
  74073. edgeAmount: number;
  74074. /**
  74075. * Gets a string identifying the name of the class
  74076. * @returns "SharpenPostProcess" string
  74077. */
  74078. getClassName(): string;
  74079. /**
  74080. * Creates a new instance ConvolutionPostProcess
  74081. * @param name The name of the effect.
  74082. * @param options The required width/height ratio to downsize to before computing the render pass.
  74083. * @param camera The camera to apply the render pass to.
  74084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74085. * @param engine The engine which the post process will be applied. (default: current engine)
  74086. * @param reusable If the post process can be reused on the same frame. (default: false)
  74087. * @param textureType Type of textures used when performing the post process. (default: 0)
  74088. * @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)
  74089. */
  74090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74091. /** @hidden */
  74092. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74093. }
  74094. }
  74095. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74096. import { Nullable } from "babylonjs/types";
  74097. import { Camera } from "babylonjs/Cameras/camera";
  74098. import { Engine } from "babylonjs/Engines/engine";
  74099. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74101. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74102. /**
  74103. * PostProcessRenderPipeline
  74104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74105. */
  74106. export class PostProcessRenderPipeline {
  74107. private engine;
  74108. private _renderEffects;
  74109. private _renderEffectsForIsolatedPass;
  74110. /**
  74111. * List of inspectable custom properties (used by the Inspector)
  74112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74113. */
  74114. inspectableCustomProperties: IInspectable[];
  74115. /**
  74116. * @hidden
  74117. */
  74118. protected _cameras: Camera[];
  74119. /** @hidden */
  74120. _name: string;
  74121. /**
  74122. * Gets pipeline name
  74123. */
  74124. get name(): string;
  74125. /** Gets the list of attached cameras */
  74126. get cameras(): Camera[];
  74127. /**
  74128. * Initializes a PostProcessRenderPipeline
  74129. * @param engine engine to add the pipeline to
  74130. * @param name name of the pipeline
  74131. */
  74132. constructor(engine: Engine, name: string);
  74133. /**
  74134. * Gets the class name
  74135. * @returns "PostProcessRenderPipeline"
  74136. */
  74137. getClassName(): string;
  74138. /**
  74139. * If all the render effects in the pipeline are supported
  74140. */
  74141. get isSupported(): boolean;
  74142. /**
  74143. * Adds an effect to the pipeline
  74144. * @param renderEffect the effect to add
  74145. */
  74146. addEffect(renderEffect: PostProcessRenderEffect): void;
  74147. /** @hidden */
  74148. _rebuild(): void;
  74149. /** @hidden */
  74150. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74151. /** @hidden */
  74152. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74153. /** @hidden */
  74154. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74155. /** @hidden */
  74156. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74157. /** @hidden */
  74158. _attachCameras(cameras: Camera, unique: boolean): void;
  74159. /** @hidden */
  74160. _attachCameras(cameras: Camera[], unique: boolean): void;
  74161. /** @hidden */
  74162. _detachCameras(cameras: Camera): void;
  74163. /** @hidden */
  74164. _detachCameras(cameras: Nullable<Camera[]>): void;
  74165. /** @hidden */
  74166. _update(): void;
  74167. /** @hidden */
  74168. _reset(): void;
  74169. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74170. /**
  74171. * Sets the required values to the prepass renderer.
  74172. * @param prePassRenderer defines the prepass renderer to setup.
  74173. * @returns true if the pre pass is needed.
  74174. */
  74175. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74176. /**
  74177. * Disposes of the pipeline
  74178. */
  74179. dispose(): void;
  74180. }
  74181. }
  74182. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74183. import { Camera } from "babylonjs/Cameras/camera";
  74184. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74185. /**
  74186. * PostProcessRenderPipelineManager class
  74187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74188. */
  74189. export class PostProcessRenderPipelineManager {
  74190. private _renderPipelines;
  74191. /**
  74192. * Initializes a PostProcessRenderPipelineManager
  74193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74194. */
  74195. constructor();
  74196. /**
  74197. * Gets the list of supported render pipelines
  74198. */
  74199. get supportedPipelines(): PostProcessRenderPipeline[];
  74200. /**
  74201. * Adds a pipeline to the manager
  74202. * @param renderPipeline The pipeline to add
  74203. */
  74204. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74205. /**
  74206. * Attaches a camera to the pipeline
  74207. * @param renderPipelineName The name of the pipeline to attach to
  74208. * @param cameras the camera to attach
  74209. * @param unique if the camera can be attached multiple times to the pipeline
  74210. */
  74211. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74212. /**
  74213. * Detaches a camera from the pipeline
  74214. * @param renderPipelineName The name of the pipeline to detach from
  74215. * @param cameras the camera to detach
  74216. */
  74217. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74218. /**
  74219. * Enables an effect by name on a pipeline
  74220. * @param renderPipelineName the name of the pipeline to enable the effect in
  74221. * @param renderEffectName the name of the effect to enable
  74222. * @param cameras the cameras that the effect should be enabled on
  74223. */
  74224. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74225. /**
  74226. * Disables an effect by name on a pipeline
  74227. * @param renderPipelineName the name of the pipeline to disable the effect in
  74228. * @param renderEffectName the name of the effect to disable
  74229. * @param cameras the cameras that the effect should be disabled on
  74230. */
  74231. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74232. /**
  74233. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74234. */
  74235. update(): void;
  74236. /** @hidden */
  74237. _rebuild(): void;
  74238. /**
  74239. * Disposes of the manager and pipelines
  74240. */
  74241. dispose(): void;
  74242. }
  74243. }
  74244. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74245. import { ISceneComponent } from "babylonjs/sceneComponent";
  74246. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74247. import { Scene } from "babylonjs/scene";
  74248. module "babylonjs/scene" {
  74249. interface Scene {
  74250. /** @hidden (Backing field) */
  74251. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74252. /**
  74253. * Gets the postprocess render pipeline manager
  74254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74255. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74256. */
  74257. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74258. }
  74259. }
  74260. /**
  74261. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74262. */
  74263. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74264. /**
  74265. * The component name helpfull to identify the component in the list of scene components.
  74266. */
  74267. readonly name: string;
  74268. /**
  74269. * The scene the component belongs to.
  74270. */
  74271. scene: Scene;
  74272. /**
  74273. * Creates a new instance of the component for the given scene
  74274. * @param scene Defines the scene to register the component in
  74275. */
  74276. constructor(scene: Scene);
  74277. /**
  74278. * Registers the component in a given scene
  74279. */
  74280. register(): void;
  74281. /**
  74282. * Rebuilds the elements related to this component in case of
  74283. * context lost for instance.
  74284. */
  74285. rebuild(): void;
  74286. /**
  74287. * Disposes the component and the associated ressources
  74288. */
  74289. dispose(): void;
  74290. private _gatherRenderTargets;
  74291. }
  74292. }
  74293. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74294. import { Nullable } from "babylonjs/types";
  74295. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74296. import { Camera } from "babylonjs/Cameras/camera";
  74297. import { IDisposable } from "babylonjs/scene";
  74298. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74299. import { Scene } from "babylonjs/scene";
  74300. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74301. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74302. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74303. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74304. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74305. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74306. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74307. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74308. import { Animation } from "babylonjs/Animations/animation";
  74309. /**
  74310. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74311. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74312. */
  74313. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74314. private _scene;
  74315. private _camerasToBeAttached;
  74316. /**
  74317. * ID of the sharpen post process,
  74318. */
  74319. private readonly SharpenPostProcessId;
  74320. /**
  74321. * @ignore
  74322. * ID of the image processing post process;
  74323. */
  74324. readonly ImageProcessingPostProcessId: string;
  74325. /**
  74326. * @ignore
  74327. * ID of the Fast Approximate Anti-Aliasing post process;
  74328. */
  74329. readonly FxaaPostProcessId: string;
  74330. /**
  74331. * ID of the chromatic aberration post process,
  74332. */
  74333. private readonly ChromaticAberrationPostProcessId;
  74334. /**
  74335. * ID of the grain post process
  74336. */
  74337. private readonly GrainPostProcessId;
  74338. /**
  74339. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74340. */
  74341. sharpen: SharpenPostProcess;
  74342. private _sharpenEffect;
  74343. private bloom;
  74344. /**
  74345. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74346. */
  74347. depthOfField: DepthOfFieldEffect;
  74348. /**
  74349. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74350. */
  74351. fxaa: FxaaPostProcess;
  74352. /**
  74353. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74354. */
  74355. imageProcessing: ImageProcessingPostProcess;
  74356. /**
  74357. * Chromatic aberration post process which will shift rgb colors in the image
  74358. */
  74359. chromaticAberration: ChromaticAberrationPostProcess;
  74360. private _chromaticAberrationEffect;
  74361. /**
  74362. * Grain post process which add noise to the image
  74363. */
  74364. grain: GrainPostProcess;
  74365. private _grainEffect;
  74366. /**
  74367. * Glow post process which adds a glow to emissive areas of the image
  74368. */
  74369. private _glowLayer;
  74370. /**
  74371. * Animations which can be used to tweak settings over a period of time
  74372. */
  74373. animations: Animation[];
  74374. private _imageProcessingConfigurationObserver;
  74375. private _sharpenEnabled;
  74376. private _bloomEnabled;
  74377. private _depthOfFieldEnabled;
  74378. private _depthOfFieldBlurLevel;
  74379. private _fxaaEnabled;
  74380. private _imageProcessingEnabled;
  74381. private _defaultPipelineTextureType;
  74382. private _bloomScale;
  74383. private _chromaticAberrationEnabled;
  74384. private _grainEnabled;
  74385. private _buildAllowed;
  74386. /**
  74387. * Gets active scene
  74388. */
  74389. get scene(): Scene;
  74390. /**
  74391. * Enable or disable the sharpen process from the pipeline
  74392. */
  74393. set sharpenEnabled(enabled: boolean);
  74394. get sharpenEnabled(): boolean;
  74395. private _resizeObserver;
  74396. private _hardwareScaleLevel;
  74397. private _bloomKernel;
  74398. /**
  74399. * Specifies the size of the bloom blur kernel, relative to the final output size
  74400. */
  74401. get bloomKernel(): number;
  74402. set bloomKernel(value: number);
  74403. /**
  74404. * Specifies the weight of the bloom in the final rendering
  74405. */
  74406. private _bloomWeight;
  74407. /**
  74408. * Specifies the luma threshold for the area that will be blurred by the bloom
  74409. */
  74410. private _bloomThreshold;
  74411. private _hdr;
  74412. /**
  74413. * The strength of the bloom.
  74414. */
  74415. set bloomWeight(value: number);
  74416. get bloomWeight(): number;
  74417. /**
  74418. * The strength of the bloom.
  74419. */
  74420. set bloomThreshold(value: number);
  74421. get bloomThreshold(): number;
  74422. /**
  74423. * The scale of the bloom, lower value will provide better performance.
  74424. */
  74425. set bloomScale(value: number);
  74426. get bloomScale(): number;
  74427. /**
  74428. * Enable or disable the bloom from the pipeline
  74429. */
  74430. set bloomEnabled(enabled: boolean);
  74431. get bloomEnabled(): boolean;
  74432. private _rebuildBloom;
  74433. /**
  74434. * If the depth of field is enabled.
  74435. */
  74436. get depthOfFieldEnabled(): boolean;
  74437. set depthOfFieldEnabled(enabled: boolean);
  74438. /**
  74439. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74440. */
  74441. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74442. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74443. /**
  74444. * If the anti aliasing is enabled.
  74445. */
  74446. set fxaaEnabled(enabled: boolean);
  74447. get fxaaEnabled(): boolean;
  74448. private _samples;
  74449. /**
  74450. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74451. */
  74452. set samples(sampleCount: number);
  74453. get samples(): number;
  74454. /**
  74455. * If image processing is enabled.
  74456. */
  74457. set imageProcessingEnabled(enabled: boolean);
  74458. get imageProcessingEnabled(): boolean;
  74459. /**
  74460. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74461. */
  74462. set glowLayerEnabled(enabled: boolean);
  74463. get glowLayerEnabled(): boolean;
  74464. /**
  74465. * Gets the glow layer (or null if not defined)
  74466. */
  74467. get glowLayer(): Nullable<GlowLayer>;
  74468. /**
  74469. * Enable or disable the chromaticAberration process from the pipeline
  74470. */
  74471. set chromaticAberrationEnabled(enabled: boolean);
  74472. get chromaticAberrationEnabled(): boolean;
  74473. /**
  74474. * Enable or disable the grain process from the pipeline
  74475. */
  74476. set grainEnabled(enabled: boolean);
  74477. get grainEnabled(): boolean;
  74478. /**
  74479. * @constructor
  74480. * @param name - The rendering pipeline name (default: "")
  74481. * @param hdr - If high dynamic range textures should be used (default: true)
  74482. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74483. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74484. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74485. */
  74486. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74487. /**
  74488. * Get the class name
  74489. * @returns "DefaultRenderingPipeline"
  74490. */
  74491. getClassName(): string;
  74492. /**
  74493. * Force the compilation of the entire pipeline.
  74494. */
  74495. prepare(): void;
  74496. private _hasCleared;
  74497. private _prevPostProcess;
  74498. private _prevPrevPostProcess;
  74499. private _setAutoClearAndTextureSharing;
  74500. private _depthOfFieldSceneObserver;
  74501. private _buildPipeline;
  74502. private _disposePostProcesses;
  74503. /**
  74504. * Adds a camera to the pipeline
  74505. * @param camera the camera to be added
  74506. */
  74507. addCamera(camera: Camera): void;
  74508. /**
  74509. * Removes a camera from the pipeline
  74510. * @param camera the camera to remove
  74511. */
  74512. removeCamera(camera: Camera): void;
  74513. /**
  74514. * Dispose of the pipeline and stop all post processes
  74515. */
  74516. dispose(): void;
  74517. /**
  74518. * Serialize the rendering pipeline (Used when exporting)
  74519. * @returns the serialized object
  74520. */
  74521. serialize(): any;
  74522. /**
  74523. * Parse the serialized pipeline
  74524. * @param source Source pipeline.
  74525. * @param scene The scene to load the pipeline to.
  74526. * @param rootUrl The URL of the serialized pipeline.
  74527. * @returns An instantiated pipeline from the serialized object.
  74528. */
  74529. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74530. }
  74531. }
  74532. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74533. /** @hidden */
  74534. export var lensHighlightsPixelShader: {
  74535. name: string;
  74536. shader: string;
  74537. };
  74538. }
  74539. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74540. /** @hidden */
  74541. export var depthOfFieldPixelShader: {
  74542. name: string;
  74543. shader: string;
  74544. };
  74545. }
  74546. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74547. import { Camera } from "babylonjs/Cameras/camera";
  74548. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74549. import { Scene } from "babylonjs/scene";
  74550. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74551. import "babylonjs/Shaders/chromaticAberration.fragment";
  74552. import "babylonjs/Shaders/lensHighlights.fragment";
  74553. import "babylonjs/Shaders/depthOfField.fragment";
  74554. /**
  74555. * BABYLON.JS Chromatic Aberration GLSL Shader
  74556. * Author: Olivier Guyot
  74557. * Separates very slightly R, G and B colors on the edges of the screen
  74558. * Inspired by Francois Tarlier & Martins Upitis
  74559. */
  74560. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74561. /**
  74562. * @ignore
  74563. * The chromatic aberration PostProcess id in the pipeline
  74564. */
  74565. LensChromaticAberrationEffect: string;
  74566. /**
  74567. * @ignore
  74568. * The highlights enhancing PostProcess id in the pipeline
  74569. */
  74570. HighlightsEnhancingEffect: string;
  74571. /**
  74572. * @ignore
  74573. * The depth-of-field PostProcess id in the pipeline
  74574. */
  74575. LensDepthOfFieldEffect: string;
  74576. private _scene;
  74577. private _depthTexture;
  74578. private _grainTexture;
  74579. private _chromaticAberrationPostProcess;
  74580. private _highlightsPostProcess;
  74581. private _depthOfFieldPostProcess;
  74582. private _edgeBlur;
  74583. private _grainAmount;
  74584. private _chromaticAberration;
  74585. private _distortion;
  74586. private _highlightsGain;
  74587. private _highlightsThreshold;
  74588. private _dofDistance;
  74589. private _dofAperture;
  74590. private _dofDarken;
  74591. private _dofPentagon;
  74592. private _blurNoise;
  74593. /**
  74594. * @constructor
  74595. *
  74596. * Effect parameters are as follow:
  74597. * {
  74598. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74599. * edge_blur: number; // from 0 to x (1 for realism)
  74600. * distortion: number; // from 0 to x (1 for realism)
  74601. * grain_amount: number; // from 0 to 1
  74602. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74603. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74604. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74605. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74606. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74607. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74608. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74609. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74610. * }
  74611. * Note: if an effect parameter is unset, effect is disabled
  74612. *
  74613. * @param name The rendering pipeline name
  74614. * @param parameters - An object containing all parameters (see above)
  74615. * @param scene The scene linked to this pipeline
  74616. * @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)
  74617. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74618. */
  74619. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74620. /**
  74621. * Get the class name
  74622. * @returns "LensRenderingPipeline"
  74623. */
  74624. getClassName(): string;
  74625. /**
  74626. * Gets associated scene
  74627. */
  74628. get scene(): Scene;
  74629. /**
  74630. * Gets or sets the edge blur
  74631. */
  74632. get edgeBlur(): number;
  74633. set edgeBlur(value: number);
  74634. /**
  74635. * Gets or sets the grain amount
  74636. */
  74637. get grainAmount(): number;
  74638. set grainAmount(value: number);
  74639. /**
  74640. * Gets or sets the chromatic aberration amount
  74641. */
  74642. get chromaticAberration(): number;
  74643. set chromaticAberration(value: number);
  74644. /**
  74645. * Gets or sets the depth of field aperture
  74646. */
  74647. get dofAperture(): number;
  74648. set dofAperture(value: number);
  74649. /**
  74650. * Gets or sets the edge distortion
  74651. */
  74652. get edgeDistortion(): number;
  74653. set edgeDistortion(value: number);
  74654. /**
  74655. * Gets or sets the depth of field distortion
  74656. */
  74657. get dofDistortion(): number;
  74658. set dofDistortion(value: number);
  74659. /**
  74660. * Gets or sets the darken out of focus amount
  74661. */
  74662. get darkenOutOfFocus(): number;
  74663. set darkenOutOfFocus(value: number);
  74664. /**
  74665. * Gets or sets a boolean indicating if blur noise is enabled
  74666. */
  74667. get blurNoise(): boolean;
  74668. set blurNoise(value: boolean);
  74669. /**
  74670. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74671. */
  74672. get pentagonBokeh(): boolean;
  74673. set pentagonBokeh(value: boolean);
  74674. /**
  74675. * Gets or sets the highlight grain amount
  74676. */
  74677. get highlightsGain(): number;
  74678. set highlightsGain(value: number);
  74679. /**
  74680. * Gets or sets the highlight threshold
  74681. */
  74682. get highlightsThreshold(): number;
  74683. set highlightsThreshold(value: number);
  74684. /**
  74685. * Sets the amount of blur at the edges
  74686. * @param amount blur amount
  74687. */
  74688. setEdgeBlur(amount: number): void;
  74689. /**
  74690. * Sets edge blur to 0
  74691. */
  74692. disableEdgeBlur(): void;
  74693. /**
  74694. * Sets the amout of grain
  74695. * @param amount Amount of grain
  74696. */
  74697. setGrainAmount(amount: number): void;
  74698. /**
  74699. * Set grain amount to 0
  74700. */
  74701. disableGrain(): void;
  74702. /**
  74703. * Sets the chromatic aberration amount
  74704. * @param amount amount of chromatic aberration
  74705. */
  74706. setChromaticAberration(amount: number): void;
  74707. /**
  74708. * Sets chromatic aberration amount to 0
  74709. */
  74710. disableChromaticAberration(): void;
  74711. /**
  74712. * Sets the EdgeDistortion amount
  74713. * @param amount amount of EdgeDistortion
  74714. */
  74715. setEdgeDistortion(amount: number): void;
  74716. /**
  74717. * Sets edge distortion to 0
  74718. */
  74719. disableEdgeDistortion(): void;
  74720. /**
  74721. * Sets the FocusDistance amount
  74722. * @param amount amount of FocusDistance
  74723. */
  74724. setFocusDistance(amount: number): void;
  74725. /**
  74726. * Disables depth of field
  74727. */
  74728. disableDepthOfField(): void;
  74729. /**
  74730. * Sets the Aperture amount
  74731. * @param amount amount of Aperture
  74732. */
  74733. setAperture(amount: number): void;
  74734. /**
  74735. * Sets the DarkenOutOfFocus amount
  74736. * @param amount amount of DarkenOutOfFocus
  74737. */
  74738. setDarkenOutOfFocus(amount: number): void;
  74739. private _pentagonBokehIsEnabled;
  74740. /**
  74741. * Creates a pentagon bokeh effect
  74742. */
  74743. enablePentagonBokeh(): void;
  74744. /**
  74745. * Disables the pentagon bokeh effect
  74746. */
  74747. disablePentagonBokeh(): void;
  74748. /**
  74749. * Enables noise blur
  74750. */
  74751. enableNoiseBlur(): void;
  74752. /**
  74753. * Disables noise blur
  74754. */
  74755. disableNoiseBlur(): void;
  74756. /**
  74757. * Sets the HighlightsGain amount
  74758. * @param amount amount of HighlightsGain
  74759. */
  74760. setHighlightsGain(amount: number): void;
  74761. /**
  74762. * Sets the HighlightsThreshold amount
  74763. * @param amount amount of HighlightsThreshold
  74764. */
  74765. setHighlightsThreshold(amount: number): void;
  74766. /**
  74767. * Disables highlights
  74768. */
  74769. disableHighlights(): void;
  74770. /**
  74771. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74772. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74773. */
  74774. dispose(disableDepthRender?: boolean): void;
  74775. private _createChromaticAberrationPostProcess;
  74776. private _createHighlightsPostProcess;
  74777. private _createDepthOfFieldPostProcess;
  74778. private _createGrainTexture;
  74779. }
  74780. }
  74781. declare module "babylonjs/Rendering/ssao2Configuration" {
  74782. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74783. /**
  74784. * Contains all parameters needed for the prepass to perform
  74785. * screen space subsurface scattering
  74786. */
  74787. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74788. /**
  74789. * Is subsurface enabled
  74790. */
  74791. enabled: boolean;
  74792. /**
  74793. * Name of the configuration
  74794. */
  74795. name: string;
  74796. /**
  74797. * Textures that should be present in the MRT for this effect to work
  74798. */
  74799. readonly texturesRequired: number[];
  74800. /**
  74801. * Builds a ssao2 configuration object
  74802. * @param scene The scene
  74803. */
  74804. constructor();
  74805. /**
  74806. * Disposes the configuration
  74807. */
  74808. dispose(): void;
  74809. }
  74810. }
  74811. declare module "babylonjs/Shaders/ssao2.fragment" {
  74812. /** @hidden */
  74813. export var ssao2PixelShader: {
  74814. name: string;
  74815. shader: string;
  74816. };
  74817. }
  74818. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74819. /** @hidden */
  74820. export var ssaoCombinePixelShader: {
  74821. name: string;
  74822. shader: string;
  74823. };
  74824. }
  74825. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74826. import { Camera } from "babylonjs/Cameras/camera";
  74827. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74828. import { Scene } from "babylonjs/scene";
  74829. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74830. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74831. import "babylonjs/Shaders/ssao2.fragment";
  74832. import "babylonjs/Shaders/ssaoCombine.fragment";
  74833. /**
  74834. * Render pipeline to produce ssao effect
  74835. */
  74836. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74837. /**
  74838. * @ignore
  74839. * The PassPostProcess id in the pipeline that contains the original scene color
  74840. */
  74841. SSAOOriginalSceneColorEffect: string;
  74842. /**
  74843. * @ignore
  74844. * The SSAO PostProcess id in the pipeline
  74845. */
  74846. SSAORenderEffect: string;
  74847. /**
  74848. * @ignore
  74849. * The horizontal blur PostProcess id in the pipeline
  74850. */
  74851. SSAOBlurHRenderEffect: string;
  74852. /**
  74853. * @ignore
  74854. * The vertical blur PostProcess id in the pipeline
  74855. */
  74856. SSAOBlurVRenderEffect: string;
  74857. /**
  74858. * @ignore
  74859. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74860. */
  74861. SSAOCombineRenderEffect: string;
  74862. /**
  74863. * The output strength of the SSAO post-process. Default value is 1.0.
  74864. */
  74865. totalStrength: number;
  74866. /**
  74867. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74868. */
  74869. maxZ: number;
  74870. /**
  74871. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74872. */
  74873. minZAspect: number;
  74874. private _samples;
  74875. /**
  74876. * Number of samples used for the SSAO calculations. Default value is 8
  74877. */
  74878. set samples(n: number);
  74879. get samples(): number;
  74880. private _textureSamples;
  74881. /**
  74882. * Number of samples to use for antialiasing
  74883. */
  74884. set textureSamples(n: number);
  74885. get textureSamples(): number;
  74886. /**
  74887. * Force rendering the geometry through geometry buffer
  74888. */
  74889. private _forceGeometryBuffer;
  74890. /**
  74891. * Ratio object used for SSAO ratio and blur ratio
  74892. */
  74893. private _ratio;
  74894. /**
  74895. * Dynamically generated sphere sampler.
  74896. */
  74897. private _sampleSphere;
  74898. private _ssao2PrePassConfiguration;
  74899. /**
  74900. * Blur filter offsets
  74901. */
  74902. private _samplerOffsets;
  74903. private _expensiveBlur;
  74904. /**
  74905. * If bilateral blur should be used
  74906. */
  74907. set expensiveBlur(b: boolean);
  74908. get expensiveBlur(): boolean;
  74909. /**
  74910. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74911. */
  74912. radius: number;
  74913. /**
  74914. * The base color of the SSAO post-process
  74915. * The final result is "base + ssao" between [0, 1]
  74916. */
  74917. base: number;
  74918. /**
  74919. * Support test.
  74920. */
  74921. static get IsSupported(): boolean;
  74922. private _scene;
  74923. private _randomTexture;
  74924. private _originalColorPostProcess;
  74925. private _ssaoPostProcess;
  74926. private _blurHPostProcess;
  74927. private _blurVPostProcess;
  74928. private _ssaoCombinePostProcess;
  74929. private _prePassRenderer;
  74930. /**
  74931. * Gets active scene
  74932. */
  74933. get scene(): Scene;
  74934. /**
  74935. * @constructor
  74936. * @param name The rendering pipeline name
  74937. * @param scene The scene linked to this pipeline
  74938. * @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 }
  74939. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74940. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74941. */
  74942. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74943. /**
  74944. * Get the class name
  74945. * @returns "SSAO2RenderingPipeline"
  74946. */
  74947. getClassName(): string;
  74948. /**
  74949. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74950. */
  74951. dispose(disableGeometryBufferRenderer?: boolean): void;
  74952. private _createBlurPostProcess;
  74953. /** @hidden */
  74954. _rebuild(): void;
  74955. private _bits;
  74956. private _radicalInverse_VdC;
  74957. private _hammersley;
  74958. private _hemisphereSample_uniform;
  74959. private _generateHemisphere;
  74960. private _getDefinesForSSAO;
  74961. private _createSSAOPostProcess;
  74962. private _createSSAOCombinePostProcess;
  74963. private _createRandomTexture;
  74964. /**
  74965. * Serialize the rendering pipeline (Used when exporting)
  74966. * @returns the serialized object
  74967. */
  74968. serialize(): any;
  74969. /**
  74970. * Parse the serialized pipeline
  74971. * @param source Source pipeline.
  74972. * @param scene The scene to load the pipeline to.
  74973. * @param rootUrl The URL of the serialized pipeline.
  74974. * @returns An instantiated pipeline from the serialized object.
  74975. */
  74976. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74977. /**
  74978. * Sets the required values to the prepass renderer.
  74979. * @param prePassRenderer defines the prepass renderer to setup
  74980. * @returns true if the pre pass is needed.
  74981. */
  74982. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74983. }
  74984. }
  74985. declare module "babylonjs/Shaders/ssao.fragment" {
  74986. /** @hidden */
  74987. export var ssaoPixelShader: {
  74988. name: string;
  74989. shader: string;
  74990. };
  74991. }
  74992. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74993. import { Camera } from "babylonjs/Cameras/camera";
  74994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74995. import { Scene } from "babylonjs/scene";
  74996. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74997. import "babylonjs/Shaders/ssao.fragment";
  74998. import "babylonjs/Shaders/ssaoCombine.fragment";
  74999. /**
  75000. * Render pipeline to produce ssao effect
  75001. */
  75002. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75003. /**
  75004. * @ignore
  75005. * The PassPostProcess id in the pipeline that contains the original scene color
  75006. */
  75007. SSAOOriginalSceneColorEffect: string;
  75008. /**
  75009. * @ignore
  75010. * The SSAO PostProcess id in the pipeline
  75011. */
  75012. SSAORenderEffect: string;
  75013. /**
  75014. * @ignore
  75015. * The horizontal blur PostProcess id in the pipeline
  75016. */
  75017. SSAOBlurHRenderEffect: string;
  75018. /**
  75019. * @ignore
  75020. * The vertical blur PostProcess id in the pipeline
  75021. */
  75022. SSAOBlurVRenderEffect: string;
  75023. /**
  75024. * @ignore
  75025. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75026. */
  75027. SSAOCombineRenderEffect: string;
  75028. /**
  75029. * The output strength of the SSAO post-process. Default value is 1.0.
  75030. */
  75031. totalStrength: number;
  75032. /**
  75033. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75034. */
  75035. radius: number;
  75036. /**
  75037. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75038. * Must not be equal to fallOff and superior to fallOff.
  75039. * Default value is 0.0075
  75040. */
  75041. area: number;
  75042. /**
  75043. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75044. * Must not be equal to area and inferior to area.
  75045. * Default value is 0.000001
  75046. */
  75047. fallOff: number;
  75048. /**
  75049. * The base color of the SSAO post-process
  75050. * The final result is "base + ssao" between [0, 1]
  75051. */
  75052. base: number;
  75053. private _scene;
  75054. private _depthTexture;
  75055. private _randomTexture;
  75056. private _originalColorPostProcess;
  75057. private _ssaoPostProcess;
  75058. private _blurHPostProcess;
  75059. private _blurVPostProcess;
  75060. private _ssaoCombinePostProcess;
  75061. private _firstUpdate;
  75062. /**
  75063. * Gets active scene
  75064. */
  75065. get scene(): Scene;
  75066. /**
  75067. * @constructor
  75068. * @param name - The rendering pipeline name
  75069. * @param scene - The scene linked to this pipeline
  75070. * @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 }
  75071. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75072. */
  75073. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75074. /**
  75075. * Get the class name
  75076. * @returns "SSAORenderingPipeline"
  75077. */
  75078. getClassName(): string;
  75079. /**
  75080. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75081. */
  75082. dispose(disableDepthRender?: boolean): void;
  75083. private _createBlurPostProcess;
  75084. /** @hidden */
  75085. _rebuild(): void;
  75086. private _createSSAOPostProcess;
  75087. private _createSSAOCombinePostProcess;
  75088. private _createRandomTexture;
  75089. }
  75090. }
  75091. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75092. /** @hidden */
  75093. export var screenSpaceReflectionPixelShader: {
  75094. name: string;
  75095. shader: string;
  75096. };
  75097. }
  75098. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75099. import { Nullable } from "babylonjs/types";
  75100. import { Camera } from "babylonjs/Cameras/camera";
  75101. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75102. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75103. import { Engine } from "babylonjs/Engines/engine";
  75104. import { Scene } from "babylonjs/scene";
  75105. /**
  75106. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75107. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75108. */
  75109. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75110. /**
  75111. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75112. */
  75113. threshold: number;
  75114. /**
  75115. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75116. */
  75117. strength: number;
  75118. /**
  75119. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75120. */
  75121. reflectionSpecularFalloffExponent: number;
  75122. /**
  75123. * 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]
  75124. */
  75125. step: number;
  75126. /**
  75127. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75128. */
  75129. roughnessFactor: number;
  75130. private _geometryBufferRenderer;
  75131. private _enableSmoothReflections;
  75132. private _reflectionSamples;
  75133. private _smoothSteps;
  75134. /**
  75135. * Gets a string identifying the name of the class
  75136. * @returns "ScreenSpaceReflectionPostProcess" string
  75137. */
  75138. getClassName(): string;
  75139. /**
  75140. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75141. * @param name The name of the effect.
  75142. * @param scene The scene containing the objects to calculate reflections.
  75143. * @param options The required width/height ratio to downsize to before computing the render pass.
  75144. * @param camera The camera to apply the render pass to.
  75145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75146. * @param engine The engine which the post process will be applied. (default: current engine)
  75147. * @param reusable If the post process can be reused on the same frame. (default: false)
  75148. * @param textureType Type of textures used when performing the post process. (default: 0)
  75149. * @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)
  75150. */
  75151. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75152. /**
  75153. * Gets wether or not smoothing reflections is enabled.
  75154. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75155. */
  75156. get enableSmoothReflections(): boolean;
  75157. /**
  75158. * Sets wether or not smoothing reflections is enabled.
  75159. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75160. */
  75161. set enableSmoothReflections(enabled: boolean);
  75162. /**
  75163. * Gets the number of samples taken while computing reflections. More samples count is high,
  75164. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75165. */
  75166. get reflectionSamples(): number;
  75167. /**
  75168. * Sets the number of samples taken while computing reflections. More samples count is high,
  75169. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75170. */
  75171. set reflectionSamples(samples: number);
  75172. /**
  75173. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75174. * more the post-process will require GPU power and can generate a drop in FPS.
  75175. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75176. */
  75177. get smoothSteps(): number;
  75178. set smoothSteps(steps: number);
  75179. private _updateEffectDefines;
  75180. /** @hidden */
  75181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75182. }
  75183. }
  75184. declare module "babylonjs/Shaders/standard.fragment" {
  75185. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75186. /** @hidden */
  75187. export var standardPixelShader: {
  75188. name: string;
  75189. shader: string;
  75190. };
  75191. }
  75192. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75193. import { Nullable } from "babylonjs/types";
  75194. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75195. import { Camera } from "babylonjs/Cameras/camera";
  75196. import { Texture } from "babylonjs/Materials/Textures/texture";
  75197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75198. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75199. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75200. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75201. import { IDisposable } from "babylonjs/scene";
  75202. import { SpotLight } from "babylonjs/Lights/spotLight";
  75203. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75204. import { Scene } from "babylonjs/scene";
  75205. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75206. import { Animation } from "babylonjs/Animations/animation";
  75207. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75208. import "babylonjs/Shaders/standard.fragment";
  75209. /**
  75210. * Standard rendering pipeline
  75211. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75212. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75213. */
  75214. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75215. /**
  75216. * Public members
  75217. */
  75218. /**
  75219. * Post-process which contains the original scene color before the pipeline applies all the effects
  75220. */
  75221. originalPostProcess: Nullable<PostProcess>;
  75222. /**
  75223. * Post-process used to down scale an image x4
  75224. */
  75225. downSampleX4PostProcess: Nullable<PostProcess>;
  75226. /**
  75227. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75228. */
  75229. brightPassPostProcess: Nullable<PostProcess>;
  75230. /**
  75231. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75232. */
  75233. blurHPostProcesses: PostProcess[];
  75234. /**
  75235. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75236. */
  75237. blurVPostProcesses: PostProcess[];
  75238. /**
  75239. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75240. */
  75241. textureAdderPostProcess: Nullable<PostProcess>;
  75242. /**
  75243. * Post-process used to create volumetric lighting effect
  75244. */
  75245. volumetricLightPostProcess: Nullable<PostProcess>;
  75246. /**
  75247. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75248. */
  75249. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75250. /**
  75251. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75252. */
  75253. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75254. /**
  75255. * Post-process used to merge the volumetric light effect and the real scene color
  75256. */
  75257. volumetricLightMergePostProces: Nullable<PostProcess>;
  75258. /**
  75259. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75260. */
  75261. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75262. /**
  75263. * Base post-process used to calculate the average luminance of the final image for HDR
  75264. */
  75265. luminancePostProcess: Nullable<PostProcess>;
  75266. /**
  75267. * Post-processes used to create down sample post-processes in order to get
  75268. * the average luminance of the final image for HDR
  75269. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75270. */
  75271. luminanceDownSamplePostProcesses: PostProcess[];
  75272. /**
  75273. * Post-process used to create a HDR effect (light adaptation)
  75274. */
  75275. hdrPostProcess: Nullable<PostProcess>;
  75276. /**
  75277. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75278. */
  75279. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75280. /**
  75281. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75282. */
  75283. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75284. /**
  75285. * Post-process used to merge the final HDR post-process and the real scene color
  75286. */
  75287. hdrFinalPostProcess: Nullable<PostProcess>;
  75288. /**
  75289. * Post-process used to create a lens flare effect
  75290. */
  75291. lensFlarePostProcess: Nullable<PostProcess>;
  75292. /**
  75293. * Post-process that merges the result of the lens flare post-process and the real scene color
  75294. */
  75295. lensFlareComposePostProcess: Nullable<PostProcess>;
  75296. /**
  75297. * Post-process used to create a motion blur effect
  75298. */
  75299. motionBlurPostProcess: Nullable<PostProcess>;
  75300. /**
  75301. * Post-process used to create a depth of field effect
  75302. */
  75303. depthOfFieldPostProcess: Nullable<PostProcess>;
  75304. /**
  75305. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75306. */
  75307. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75308. /**
  75309. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75310. */
  75311. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75312. /**
  75313. * Represents the brightness threshold in order to configure the illuminated surfaces
  75314. */
  75315. brightThreshold: number;
  75316. /**
  75317. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75318. */
  75319. blurWidth: number;
  75320. /**
  75321. * Sets if the blur for highlighted surfaces must be only horizontal
  75322. */
  75323. horizontalBlur: boolean;
  75324. /**
  75325. * Gets the overall exposure used by the pipeline
  75326. */
  75327. get exposure(): number;
  75328. /**
  75329. * Sets the overall exposure used by the pipeline
  75330. */
  75331. set exposure(value: number);
  75332. /**
  75333. * Texture used typically to simulate "dirty" on camera lens
  75334. */
  75335. lensTexture: Nullable<Texture>;
  75336. /**
  75337. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75338. */
  75339. volumetricLightCoefficient: number;
  75340. /**
  75341. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75342. */
  75343. volumetricLightPower: number;
  75344. /**
  75345. * Used the set the blur intensity to smooth the volumetric lights
  75346. */
  75347. volumetricLightBlurScale: number;
  75348. /**
  75349. * Light (spot or directional) used to generate the volumetric lights rays
  75350. * The source light must have a shadow generate so the pipeline can get its
  75351. * depth map
  75352. */
  75353. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75354. /**
  75355. * For eye adaptation, represents the minimum luminance the eye can see
  75356. */
  75357. hdrMinimumLuminance: number;
  75358. /**
  75359. * For eye adaptation, represents the decrease luminance speed
  75360. */
  75361. hdrDecreaseRate: number;
  75362. /**
  75363. * For eye adaptation, represents the increase luminance speed
  75364. */
  75365. hdrIncreaseRate: number;
  75366. /**
  75367. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75368. */
  75369. get hdrAutoExposure(): boolean;
  75370. /**
  75371. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75372. */
  75373. set hdrAutoExposure(value: boolean);
  75374. /**
  75375. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75376. */
  75377. lensColorTexture: Nullable<Texture>;
  75378. /**
  75379. * The overall strengh for the lens flare effect
  75380. */
  75381. lensFlareStrength: number;
  75382. /**
  75383. * Dispersion coefficient for lens flare ghosts
  75384. */
  75385. lensFlareGhostDispersal: number;
  75386. /**
  75387. * Main lens flare halo width
  75388. */
  75389. lensFlareHaloWidth: number;
  75390. /**
  75391. * Based on the lens distortion effect, defines how much the lens flare result
  75392. * is distorted
  75393. */
  75394. lensFlareDistortionStrength: number;
  75395. /**
  75396. * Configures the blur intensity used for for lens flare (halo)
  75397. */
  75398. lensFlareBlurWidth: number;
  75399. /**
  75400. * Lens star texture must be used to simulate rays on the flares and is available
  75401. * in the documentation
  75402. */
  75403. lensStarTexture: Nullable<Texture>;
  75404. /**
  75405. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75406. * flare effect by taking account of the dirt texture
  75407. */
  75408. lensFlareDirtTexture: Nullable<Texture>;
  75409. /**
  75410. * Represents the focal length for the depth of field effect
  75411. */
  75412. depthOfFieldDistance: number;
  75413. /**
  75414. * Represents the blur intensity for the blurred part of the depth of field effect
  75415. */
  75416. depthOfFieldBlurWidth: number;
  75417. /**
  75418. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75419. */
  75420. get motionStrength(): number;
  75421. /**
  75422. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75423. */
  75424. set motionStrength(strength: number);
  75425. /**
  75426. * Gets wether or not the motion blur post-process is object based or screen based.
  75427. */
  75428. get objectBasedMotionBlur(): boolean;
  75429. /**
  75430. * Sets wether or not the motion blur post-process should be object based or screen based
  75431. */
  75432. set objectBasedMotionBlur(value: boolean);
  75433. /**
  75434. * List of animations for the pipeline (IAnimatable implementation)
  75435. */
  75436. animations: Animation[];
  75437. /**
  75438. * Private members
  75439. */
  75440. private _scene;
  75441. private _currentDepthOfFieldSource;
  75442. private _basePostProcess;
  75443. private _fixedExposure;
  75444. private _currentExposure;
  75445. private _hdrAutoExposure;
  75446. private _hdrCurrentLuminance;
  75447. private _motionStrength;
  75448. private _isObjectBasedMotionBlur;
  75449. private _floatTextureType;
  75450. private _camerasToBeAttached;
  75451. private _ratio;
  75452. private _bloomEnabled;
  75453. private _depthOfFieldEnabled;
  75454. private _vlsEnabled;
  75455. private _lensFlareEnabled;
  75456. private _hdrEnabled;
  75457. private _motionBlurEnabled;
  75458. private _fxaaEnabled;
  75459. private _screenSpaceReflectionsEnabled;
  75460. private _motionBlurSamples;
  75461. private _volumetricLightStepsCount;
  75462. private _samples;
  75463. /**
  75464. * @ignore
  75465. * Specifies if the bloom pipeline is enabled
  75466. */
  75467. get BloomEnabled(): boolean;
  75468. set BloomEnabled(enabled: boolean);
  75469. /**
  75470. * @ignore
  75471. * Specifies if the depth of field pipeline is enabed
  75472. */
  75473. get DepthOfFieldEnabled(): boolean;
  75474. set DepthOfFieldEnabled(enabled: boolean);
  75475. /**
  75476. * @ignore
  75477. * Specifies if the lens flare pipeline is enabed
  75478. */
  75479. get LensFlareEnabled(): boolean;
  75480. set LensFlareEnabled(enabled: boolean);
  75481. /**
  75482. * @ignore
  75483. * Specifies if the HDR pipeline is enabled
  75484. */
  75485. get HDREnabled(): boolean;
  75486. set HDREnabled(enabled: boolean);
  75487. /**
  75488. * @ignore
  75489. * Specifies if the volumetric lights scattering effect is enabled
  75490. */
  75491. get VLSEnabled(): boolean;
  75492. set VLSEnabled(enabled: boolean);
  75493. /**
  75494. * @ignore
  75495. * Specifies if the motion blur effect is enabled
  75496. */
  75497. get MotionBlurEnabled(): boolean;
  75498. set MotionBlurEnabled(enabled: boolean);
  75499. /**
  75500. * Specifies if anti-aliasing is enabled
  75501. */
  75502. get fxaaEnabled(): boolean;
  75503. set fxaaEnabled(enabled: boolean);
  75504. /**
  75505. * Specifies if screen space reflections are enabled.
  75506. */
  75507. get screenSpaceReflectionsEnabled(): boolean;
  75508. set screenSpaceReflectionsEnabled(enabled: boolean);
  75509. /**
  75510. * Specifies the number of steps used to calculate the volumetric lights
  75511. * Typically in interval [50, 200]
  75512. */
  75513. get volumetricLightStepsCount(): number;
  75514. set volumetricLightStepsCount(count: number);
  75515. /**
  75516. * Specifies the number of samples used for the motion blur effect
  75517. * Typically in interval [16, 64]
  75518. */
  75519. get motionBlurSamples(): number;
  75520. set motionBlurSamples(samples: number);
  75521. /**
  75522. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75523. */
  75524. get samples(): number;
  75525. set samples(sampleCount: number);
  75526. /**
  75527. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75528. * @constructor
  75529. * @param name The rendering pipeline name
  75530. * @param scene The scene linked to this pipeline
  75531. * @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)
  75532. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75533. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75534. */
  75535. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75536. private _buildPipeline;
  75537. private _createDownSampleX4PostProcess;
  75538. private _createBrightPassPostProcess;
  75539. private _createBlurPostProcesses;
  75540. private _createTextureAdderPostProcess;
  75541. private _createVolumetricLightPostProcess;
  75542. private _createLuminancePostProcesses;
  75543. private _createHdrPostProcess;
  75544. private _createLensFlarePostProcess;
  75545. private _createDepthOfFieldPostProcess;
  75546. private _createMotionBlurPostProcess;
  75547. private _getDepthTexture;
  75548. private _disposePostProcesses;
  75549. /**
  75550. * Dispose of the pipeline and stop all post processes
  75551. */
  75552. dispose(): void;
  75553. /**
  75554. * Serialize the rendering pipeline (Used when exporting)
  75555. * @returns the serialized object
  75556. */
  75557. serialize(): any;
  75558. /**
  75559. * Parse the serialized pipeline
  75560. * @param source Source pipeline.
  75561. * @param scene The scene to load the pipeline to.
  75562. * @param rootUrl The URL of the serialized pipeline.
  75563. * @returns An instantiated pipeline from the serialized object.
  75564. */
  75565. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75566. /**
  75567. * Luminance steps
  75568. */
  75569. static LuminanceSteps: number;
  75570. }
  75571. }
  75572. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75573. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75574. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75575. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75576. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75577. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75578. }
  75579. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75581. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75582. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75583. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75584. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75585. }
  75586. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75587. /** @hidden */
  75588. export var stereoscopicInterlacePixelShader: {
  75589. name: string;
  75590. shader: string;
  75591. };
  75592. }
  75593. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75594. import { Camera } from "babylonjs/Cameras/camera";
  75595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75596. import { Engine } from "babylonjs/Engines/engine";
  75597. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75598. /**
  75599. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75600. */
  75601. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75602. private _stepSize;
  75603. private _passedProcess;
  75604. /**
  75605. * Gets a string identifying the name of the class
  75606. * @returns "StereoscopicInterlacePostProcessI" string
  75607. */
  75608. getClassName(): string;
  75609. /**
  75610. * Initializes a StereoscopicInterlacePostProcessI
  75611. * @param name The name of the effect.
  75612. * @param rigCameras The rig cameras to be appled to the post process
  75613. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75614. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75616. * @param engine The engine which the post process will be applied. (default: current engine)
  75617. * @param reusable If the post process can be reused on the same frame. (default: false)
  75618. */
  75619. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75620. }
  75621. /**
  75622. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75623. */
  75624. export class StereoscopicInterlacePostProcess extends PostProcess {
  75625. private _stepSize;
  75626. private _passedProcess;
  75627. /**
  75628. * Gets a string identifying the name of the class
  75629. * @returns "StereoscopicInterlacePostProcess" string
  75630. */
  75631. getClassName(): string;
  75632. /**
  75633. * Initializes a StereoscopicInterlacePostProcess
  75634. * @param name The name of the effect.
  75635. * @param rigCameras The rig cameras to be appled to the post process
  75636. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75638. * @param engine The engine which the post process will be applied. (default: current engine)
  75639. * @param reusable If the post process can be reused on the same frame. (default: false)
  75640. */
  75641. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75642. }
  75643. }
  75644. declare module "babylonjs/Shaders/tonemap.fragment" {
  75645. /** @hidden */
  75646. export var tonemapPixelShader: {
  75647. name: string;
  75648. shader: string;
  75649. };
  75650. }
  75651. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75652. import { Camera } from "babylonjs/Cameras/camera";
  75653. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75654. import "babylonjs/Shaders/tonemap.fragment";
  75655. import { Engine } from "babylonjs/Engines/engine";
  75656. /** Defines operator used for tonemapping */
  75657. export enum TonemappingOperator {
  75658. /** Hable */
  75659. Hable = 0,
  75660. /** Reinhard */
  75661. Reinhard = 1,
  75662. /** HejiDawson */
  75663. HejiDawson = 2,
  75664. /** Photographic */
  75665. Photographic = 3
  75666. }
  75667. /**
  75668. * Defines a post process to apply tone mapping
  75669. */
  75670. export class TonemapPostProcess extends PostProcess {
  75671. private _operator;
  75672. /** Defines the required exposure adjustement */
  75673. exposureAdjustment: number;
  75674. /**
  75675. * Gets a string identifying the name of the class
  75676. * @returns "TonemapPostProcess" string
  75677. */
  75678. getClassName(): string;
  75679. /**
  75680. * Creates a new TonemapPostProcess
  75681. * @param name defines the name of the postprocess
  75682. * @param _operator defines the operator to use
  75683. * @param exposureAdjustment defines the required exposure adjustement
  75684. * @param camera defines the camera to use (can be null)
  75685. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75686. * @param engine defines the hosting engine (can be ignore if camera is set)
  75687. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75688. */
  75689. constructor(name: string, _operator: TonemappingOperator,
  75690. /** Defines the required exposure adjustement */
  75691. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75692. }
  75693. }
  75694. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75695. /** @hidden */
  75696. export var volumetricLightScatteringPixelShader: {
  75697. name: string;
  75698. shader: string;
  75699. };
  75700. }
  75701. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75703. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75704. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75706. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75707. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75708. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75709. /** @hidden */
  75710. export var volumetricLightScatteringPassVertexShader: {
  75711. name: string;
  75712. shader: string;
  75713. };
  75714. }
  75715. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75716. /** @hidden */
  75717. export var volumetricLightScatteringPassPixelShader: {
  75718. name: string;
  75719. shader: string;
  75720. };
  75721. }
  75722. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75723. import { Vector3 } from "babylonjs/Maths/math.vector";
  75724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75725. import { Mesh } from "babylonjs/Meshes/mesh";
  75726. import { Camera } from "babylonjs/Cameras/camera";
  75727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75729. import { Scene } from "babylonjs/scene";
  75730. import "babylonjs/Meshes/Builders/planeBuilder";
  75731. import "babylonjs/Shaders/depth.vertex";
  75732. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75733. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75734. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75735. import { Engine } from "babylonjs/Engines/engine";
  75736. /**
  75737. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75738. */
  75739. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75740. private _volumetricLightScatteringPass;
  75741. private _volumetricLightScatteringRTT;
  75742. private _viewPort;
  75743. private _screenCoordinates;
  75744. private _cachedDefines;
  75745. /**
  75746. * If not undefined, the mesh position is computed from the attached node position
  75747. */
  75748. attachedNode: {
  75749. position: Vector3;
  75750. };
  75751. /**
  75752. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75753. */
  75754. customMeshPosition: Vector3;
  75755. /**
  75756. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75757. */
  75758. useCustomMeshPosition: boolean;
  75759. /**
  75760. * If the post-process should inverse the light scattering direction
  75761. */
  75762. invert: boolean;
  75763. /**
  75764. * The internal mesh used by the post-process
  75765. */
  75766. mesh: Mesh;
  75767. /**
  75768. * @hidden
  75769. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75770. */
  75771. get useDiffuseColor(): boolean;
  75772. set useDiffuseColor(useDiffuseColor: boolean);
  75773. /**
  75774. * Array containing the excluded meshes not rendered in the internal pass
  75775. */
  75776. excludedMeshes: AbstractMesh[];
  75777. /**
  75778. * Controls the overall intensity of the post-process
  75779. */
  75780. exposure: number;
  75781. /**
  75782. * Dissipates each sample's contribution in range [0, 1]
  75783. */
  75784. decay: number;
  75785. /**
  75786. * Controls the overall intensity of each sample
  75787. */
  75788. weight: number;
  75789. /**
  75790. * Controls the density of each sample
  75791. */
  75792. density: number;
  75793. /**
  75794. * @constructor
  75795. * @param name The post-process name
  75796. * @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)
  75797. * @param camera The camera that the post-process will be attached to
  75798. * @param mesh The mesh used to create the light scattering
  75799. * @param samples The post-process quality, default 100
  75800. * @param samplingModeThe post-process filtering mode
  75801. * @param engine The babylon engine
  75802. * @param reusable If the post-process is reusable
  75803. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75804. */
  75805. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75806. /**
  75807. * Returns the string "VolumetricLightScatteringPostProcess"
  75808. * @returns "VolumetricLightScatteringPostProcess"
  75809. */
  75810. getClassName(): string;
  75811. private _isReady;
  75812. /**
  75813. * Sets the new light position for light scattering effect
  75814. * @param position The new custom light position
  75815. */
  75816. setCustomMeshPosition(position: Vector3): void;
  75817. /**
  75818. * Returns the light position for light scattering effect
  75819. * @return Vector3 The custom light position
  75820. */
  75821. getCustomMeshPosition(): Vector3;
  75822. /**
  75823. * Disposes the internal assets and detaches the post-process from the camera
  75824. */
  75825. dispose(camera: Camera): void;
  75826. /**
  75827. * Returns the render target texture used by the post-process
  75828. * @return the render target texture used by the post-process
  75829. */
  75830. getPass(): RenderTargetTexture;
  75831. private _meshExcluded;
  75832. private _createPass;
  75833. private _updateMeshScreenCoordinates;
  75834. /**
  75835. * Creates a default mesh for the Volumeric Light Scattering post-process
  75836. * @param name The mesh name
  75837. * @param scene The scene where to create the mesh
  75838. * @return the default mesh
  75839. */
  75840. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75841. }
  75842. }
  75843. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75844. /** @hidden */
  75845. export var screenSpaceCurvaturePixelShader: {
  75846. name: string;
  75847. shader: string;
  75848. };
  75849. }
  75850. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75851. import { Nullable } from "babylonjs/types";
  75852. import { Camera } from "babylonjs/Cameras/camera";
  75853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75854. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75855. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75856. import { Engine } from "babylonjs/Engines/engine";
  75857. import { Scene } from "babylonjs/scene";
  75858. /**
  75859. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75860. */
  75861. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75862. /**
  75863. * Defines how much ridge the curvature effect displays.
  75864. */
  75865. ridge: number;
  75866. /**
  75867. * Defines how much valley the curvature effect displays.
  75868. */
  75869. valley: number;
  75870. private _geometryBufferRenderer;
  75871. /**
  75872. * Gets a string identifying the name of the class
  75873. * @returns "ScreenSpaceCurvaturePostProcess" string
  75874. */
  75875. getClassName(): string;
  75876. /**
  75877. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75878. * @param name The name of the effect.
  75879. * @param scene The scene containing the objects to blur according to their velocity.
  75880. * @param options The required width/height ratio to downsize to before computing the render pass.
  75881. * @param camera The camera to apply the render pass to.
  75882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75883. * @param engine The engine which the post process will be applied. (default: current engine)
  75884. * @param reusable If the post process can be reused on the same frame. (default: false)
  75885. * @param textureType Type of textures used when performing the post process. (default: 0)
  75886. * @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)
  75887. */
  75888. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75889. /**
  75890. * Support test.
  75891. */
  75892. static get IsSupported(): boolean;
  75893. /** @hidden */
  75894. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75895. }
  75896. }
  75897. declare module "babylonjs/PostProcesses/index" {
  75898. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75899. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75900. export * from "babylonjs/PostProcesses/bloomEffect";
  75901. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75902. export * from "babylonjs/PostProcesses/blurPostProcess";
  75903. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75904. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75905. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75906. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75907. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75908. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75909. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75910. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75911. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75912. export * from "babylonjs/PostProcesses/filterPostProcess";
  75913. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75914. export * from "babylonjs/PostProcesses/grainPostProcess";
  75915. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75916. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75917. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75918. export * from "babylonjs/PostProcesses/passPostProcess";
  75919. export * from "babylonjs/PostProcesses/postProcess";
  75920. export * from "babylonjs/PostProcesses/postProcessManager";
  75921. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75922. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75923. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75924. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75925. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75926. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75927. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75928. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75929. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75930. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75931. }
  75932. declare module "babylonjs/Probes/index" {
  75933. export * from "babylonjs/Probes/reflectionProbe";
  75934. }
  75935. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75936. import { Scene } from "babylonjs/scene";
  75937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75938. import { SmartArray } from "babylonjs/Misc/smartArray";
  75939. import { ISceneComponent } from "babylonjs/sceneComponent";
  75940. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75941. import "babylonjs/Meshes/Builders/boxBuilder";
  75942. import "babylonjs/Shaders/color.fragment";
  75943. import "babylonjs/Shaders/color.vertex";
  75944. import { Color3 } from "babylonjs/Maths/math.color";
  75945. import { Observable } from "babylonjs/Misc/observable";
  75946. module "babylonjs/scene" {
  75947. interface Scene {
  75948. /** @hidden (Backing field) */
  75949. _boundingBoxRenderer: BoundingBoxRenderer;
  75950. /** @hidden (Backing field) */
  75951. _forceShowBoundingBoxes: boolean;
  75952. /**
  75953. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75954. */
  75955. forceShowBoundingBoxes: boolean;
  75956. /**
  75957. * Gets the bounding box renderer associated with the scene
  75958. * @returns a BoundingBoxRenderer
  75959. */
  75960. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75961. }
  75962. }
  75963. module "babylonjs/Meshes/abstractMesh" {
  75964. interface AbstractMesh {
  75965. /** @hidden (Backing field) */
  75966. _showBoundingBox: boolean;
  75967. /**
  75968. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75969. */
  75970. showBoundingBox: boolean;
  75971. }
  75972. }
  75973. /**
  75974. * Component responsible of rendering the bounding box of the meshes in a scene.
  75975. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75976. */
  75977. export class BoundingBoxRenderer implements ISceneComponent {
  75978. /**
  75979. * The component name helpfull to identify the component in the list of scene components.
  75980. */
  75981. readonly name: string;
  75982. /**
  75983. * The scene the component belongs to.
  75984. */
  75985. scene: Scene;
  75986. /**
  75987. * Color of the bounding box lines placed in front of an object
  75988. */
  75989. frontColor: Color3;
  75990. /**
  75991. * Color of the bounding box lines placed behind an object
  75992. */
  75993. backColor: Color3;
  75994. /**
  75995. * Defines if the renderer should show the back lines or not
  75996. */
  75997. showBackLines: boolean;
  75998. /**
  75999. * Observable raised before rendering a bounding box
  76000. */
  76001. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76002. /**
  76003. * Observable raised after rendering a bounding box
  76004. */
  76005. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76006. /**
  76007. * @hidden
  76008. */
  76009. renderList: SmartArray<BoundingBox>;
  76010. private _colorShader;
  76011. private _vertexBuffers;
  76012. private _indexBuffer;
  76013. private _fillIndexBuffer;
  76014. private _fillIndexData;
  76015. /**
  76016. * Instantiates a new bounding box renderer in a scene.
  76017. * @param scene the scene the renderer renders in
  76018. */
  76019. constructor(scene: Scene);
  76020. /**
  76021. * Registers the component in a given scene
  76022. */
  76023. register(): void;
  76024. private _evaluateSubMesh;
  76025. private _activeMesh;
  76026. private _prepareRessources;
  76027. private _createIndexBuffer;
  76028. /**
  76029. * Rebuilds the elements related to this component in case of
  76030. * context lost for instance.
  76031. */
  76032. rebuild(): void;
  76033. /**
  76034. * @hidden
  76035. */
  76036. reset(): void;
  76037. /**
  76038. * Render the bounding boxes of a specific rendering group
  76039. * @param renderingGroupId defines the rendering group to render
  76040. */
  76041. render(renderingGroupId: number): void;
  76042. /**
  76043. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76044. * @param mesh Define the mesh to render the occlusion bounding box for
  76045. */
  76046. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76047. /**
  76048. * Dispose and release the resources attached to this renderer.
  76049. */
  76050. dispose(): void;
  76051. }
  76052. }
  76053. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76054. import { Nullable } from "babylonjs/types";
  76055. import { Scene } from "babylonjs/scene";
  76056. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76057. import { Camera } from "babylonjs/Cameras/camera";
  76058. import { ISceneComponent } from "babylonjs/sceneComponent";
  76059. module "babylonjs/scene" {
  76060. interface Scene {
  76061. /** @hidden (Backing field) */
  76062. _depthRenderer: {
  76063. [id: string]: DepthRenderer;
  76064. };
  76065. /**
  76066. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76067. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76068. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76069. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76070. * @returns the created depth renderer
  76071. */
  76072. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76073. /**
  76074. * Disables a depth renderer for a given camera
  76075. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76076. */
  76077. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76078. }
  76079. }
  76080. /**
  76081. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76082. * in several rendering techniques.
  76083. */
  76084. export class DepthRendererSceneComponent implements ISceneComponent {
  76085. /**
  76086. * The component name helpfull to identify the component in the list of scene components.
  76087. */
  76088. readonly name: string;
  76089. /**
  76090. * The scene the component belongs to.
  76091. */
  76092. scene: Scene;
  76093. /**
  76094. * Creates a new instance of the component for the given scene
  76095. * @param scene Defines the scene to register the component in
  76096. */
  76097. constructor(scene: Scene);
  76098. /**
  76099. * Registers the component in a given scene
  76100. */
  76101. register(): void;
  76102. /**
  76103. * Rebuilds the elements related to this component in case of
  76104. * context lost for instance.
  76105. */
  76106. rebuild(): void;
  76107. /**
  76108. * Disposes the component and the associated ressources
  76109. */
  76110. dispose(): void;
  76111. private _gatherRenderTargets;
  76112. private _gatherActiveCameraRenderTargets;
  76113. }
  76114. }
  76115. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76116. import { Nullable } from "babylonjs/types";
  76117. import { Scene } from "babylonjs/scene";
  76118. import { ISceneComponent } from "babylonjs/sceneComponent";
  76119. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76120. module "babylonjs/abstractScene" {
  76121. interface AbstractScene {
  76122. /** @hidden (Backing field) */
  76123. _prePassRenderer: Nullable<PrePassRenderer>;
  76124. /**
  76125. * Gets or Sets the current prepass renderer associated to the scene.
  76126. */
  76127. prePassRenderer: Nullable<PrePassRenderer>;
  76128. /**
  76129. * Enables the prepass and associates it with the scene
  76130. * @returns the PrePassRenderer
  76131. */
  76132. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76133. /**
  76134. * Disables the prepass associated with the scene
  76135. */
  76136. disablePrePassRenderer(): void;
  76137. }
  76138. }
  76139. /**
  76140. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76141. * in several rendering techniques.
  76142. */
  76143. export class PrePassRendererSceneComponent implements ISceneComponent {
  76144. /**
  76145. * The component name helpful to identify the component in the list of scene components.
  76146. */
  76147. readonly name: string;
  76148. /**
  76149. * The scene the component belongs to.
  76150. */
  76151. scene: Scene;
  76152. /**
  76153. * Creates a new instance of the component for the given scene
  76154. * @param scene Defines the scene to register the component in
  76155. */
  76156. constructor(scene: Scene);
  76157. /**
  76158. * Registers the component in a given scene
  76159. */
  76160. register(): void;
  76161. private _beforeCameraDraw;
  76162. private _afterCameraDraw;
  76163. private _beforeClearStage;
  76164. /**
  76165. * Rebuilds the elements related to this component in case of
  76166. * context lost for instance.
  76167. */
  76168. rebuild(): void;
  76169. /**
  76170. * Disposes the component and the associated ressources
  76171. */
  76172. dispose(): void;
  76173. }
  76174. }
  76175. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76176. /** @hidden */
  76177. export var fibonacci: {
  76178. name: string;
  76179. shader: string;
  76180. };
  76181. }
  76182. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76183. /** @hidden */
  76184. export var diffusionProfile: {
  76185. name: string;
  76186. shader: string;
  76187. };
  76188. }
  76189. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76190. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76191. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76192. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76193. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76194. /** @hidden */
  76195. export var subSurfaceScatteringPixelShader: {
  76196. name: string;
  76197. shader: string;
  76198. };
  76199. }
  76200. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76201. import { Nullable } from "babylonjs/types";
  76202. import { Camera } from "babylonjs/Cameras/camera";
  76203. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76204. import { Engine } from "babylonjs/Engines/engine";
  76205. import { Scene } from "babylonjs/scene";
  76206. import "babylonjs/Shaders/imageProcessing.fragment";
  76207. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76208. import "babylonjs/Shaders/postprocess.vertex";
  76209. /**
  76210. * Sub surface scattering post process
  76211. */
  76212. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76213. /**
  76214. * Gets a string identifying the name of the class
  76215. * @returns "SubSurfaceScatteringPostProcess" string
  76216. */
  76217. getClassName(): string;
  76218. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76219. }
  76220. }
  76221. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76222. import { Scene } from "babylonjs/scene";
  76223. import { Color3 } from "babylonjs/Maths/math.color";
  76224. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76225. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76226. /**
  76227. * Contains all parameters needed for the prepass to perform
  76228. * screen space subsurface scattering
  76229. */
  76230. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76231. /** @hidden */
  76232. static _SceneComponentInitialization: (scene: Scene) => void;
  76233. private _ssDiffusionS;
  76234. private _ssFilterRadii;
  76235. private _ssDiffusionD;
  76236. /**
  76237. * Post process to attach for screen space subsurface scattering
  76238. */
  76239. postProcess: SubSurfaceScatteringPostProcess;
  76240. /**
  76241. * Diffusion profile color for subsurface scattering
  76242. */
  76243. get ssDiffusionS(): number[];
  76244. /**
  76245. * Diffusion profile max color channel value for subsurface scattering
  76246. */
  76247. get ssDiffusionD(): number[];
  76248. /**
  76249. * Diffusion profile filter radius for subsurface scattering
  76250. */
  76251. get ssFilterRadii(): number[];
  76252. /**
  76253. * Is subsurface enabled
  76254. */
  76255. enabled: boolean;
  76256. /**
  76257. * Name of the configuration
  76258. */
  76259. name: string;
  76260. /**
  76261. * Diffusion profile colors for subsurface scattering
  76262. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76263. * See ...
  76264. * Note that you can only store up to 5 of them
  76265. */
  76266. ssDiffusionProfileColors: Color3[];
  76267. /**
  76268. * Defines the ratio real world => scene units.
  76269. * Used for subsurface scattering
  76270. */
  76271. metersPerUnit: number;
  76272. /**
  76273. * Textures that should be present in the MRT for this effect to work
  76274. */
  76275. readonly texturesRequired: number[];
  76276. private _scene;
  76277. /**
  76278. * Builds a subsurface configuration object
  76279. * @param scene The scene
  76280. */
  76281. constructor(scene: Scene);
  76282. /**
  76283. * Adds a new diffusion profile.
  76284. * Useful for more realistic subsurface scattering on diverse materials.
  76285. * @param color The color of the diffusion profile. Should be the average color of the material.
  76286. * @return The index of the diffusion profile for the material subsurface configuration
  76287. */
  76288. addDiffusionProfile(color: Color3): number;
  76289. /**
  76290. * Creates the sss post process
  76291. * @return The created post process
  76292. */
  76293. createPostProcess(): SubSurfaceScatteringPostProcess;
  76294. /**
  76295. * Deletes all diffusion profiles.
  76296. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76297. */
  76298. clearAllDiffusionProfiles(): void;
  76299. /**
  76300. * Disposes this object
  76301. */
  76302. dispose(): void;
  76303. /**
  76304. * @hidden
  76305. * https://zero-radiance.github.io/post/sampling-diffusion/
  76306. *
  76307. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76308. * ------------------------------------------------------------------------------------
  76309. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76310. * PDF[r, phi, s] = r * R[r, phi, s]
  76311. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76312. * ------------------------------------------------------------------------------------
  76313. * We importance sample the color channel with the widest scattering distance.
  76314. */
  76315. getDiffusionProfileParameters(color: Color3): number;
  76316. /**
  76317. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76318. * 'u' is the random number (the value of the CDF): [0, 1).
  76319. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76320. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76321. */
  76322. private _sampleBurleyDiffusionProfile;
  76323. }
  76324. }
  76325. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76326. import { Nullable } from "babylonjs/types";
  76327. import { Scene } from "babylonjs/scene";
  76328. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76329. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76330. import { AbstractScene } from "babylonjs/abstractScene";
  76331. module "babylonjs/abstractScene" {
  76332. interface AbstractScene {
  76333. /** @hidden (Backing field) */
  76334. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76335. /**
  76336. * Gets or Sets the current prepass renderer associated to the scene.
  76337. */
  76338. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76339. /**
  76340. * Enables the subsurface effect for prepass
  76341. * @returns the SubSurfaceConfiguration
  76342. */
  76343. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76344. /**
  76345. * Disables the subsurface effect for prepass
  76346. */
  76347. disableSubSurfaceForPrePass(): void;
  76348. }
  76349. }
  76350. /**
  76351. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76352. * in several rendering techniques.
  76353. */
  76354. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76355. /**
  76356. * The component name helpful to identify the component in the list of scene components.
  76357. */
  76358. readonly name: string;
  76359. /**
  76360. * The scene the component belongs to.
  76361. */
  76362. scene: Scene;
  76363. /**
  76364. * Creates a new instance of the component for the given scene
  76365. * @param scene Defines the scene to register the component in
  76366. */
  76367. constructor(scene: Scene);
  76368. /**
  76369. * Registers the component in a given scene
  76370. */
  76371. register(): void;
  76372. /**
  76373. * Serializes the component data to the specified json object
  76374. * @param serializationObject The object to serialize to
  76375. */
  76376. serialize(serializationObject: any): void;
  76377. /**
  76378. * Adds all the elements from the container to the scene
  76379. * @param container the container holding the elements
  76380. */
  76381. addFromContainer(container: AbstractScene): void;
  76382. /**
  76383. * Removes all the elements in the container from the scene
  76384. * @param container contains the elements to remove
  76385. * @param dispose if the removed element should be disposed (default: false)
  76386. */
  76387. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76388. /**
  76389. * Rebuilds the elements related to this component in case of
  76390. * context lost for instance.
  76391. */
  76392. rebuild(): void;
  76393. /**
  76394. * Disposes the component and the associated ressources
  76395. */
  76396. dispose(): void;
  76397. }
  76398. }
  76399. declare module "babylonjs/Shaders/outline.fragment" {
  76400. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76401. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76402. /** @hidden */
  76403. export var outlinePixelShader: {
  76404. name: string;
  76405. shader: string;
  76406. };
  76407. }
  76408. declare module "babylonjs/Shaders/outline.vertex" {
  76409. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76412. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76413. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76414. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76415. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76416. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76417. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76418. /** @hidden */
  76419. export var outlineVertexShader: {
  76420. name: string;
  76421. shader: string;
  76422. };
  76423. }
  76424. declare module "babylonjs/Rendering/outlineRenderer" {
  76425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76426. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76427. import { Scene } from "babylonjs/scene";
  76428. import { ISceneComponent } from "babylonjs/sceneComponent";
  76429. import "babylonjs/Shaders/outline.fragment";
  76430. import "babylonjs/Shaders/outline.vertex";
  76431. module "babylonjs/scene" {
  76432. interface Scene {
  76433. /** @hidden */
  76434. _outlineRenderer: OutlineRenderer;
  76435. /**
  76436. * Gets the outline renderer associated with the scene
  76437. * @returns a OutlineRenderer
  76438. */
  76439. getOutlineRenderer(): OutlineRenderer;
  76440. }
  76441. }
  76442. module "babylonjs/Meshes/abstractMesh" {
  76443. interface AbstractMesh {
  76444. /** @hidden (Backing field) */
  76445. _renderOutline: boolean;
  76446. /**
  76447. * Gets or sets a boolean indicating if the outline must be rendered as well
  76448. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76449. */
  76450. renderOutline: boolean;
  76451. /** @hidden (Backing field) */
  76452. _renderOverlay: boolean;
  76453. /**
  76454. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76455. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76456. */
  76457. renderOverlay: boolean;
  76458. }
  76459. }
  76460. /**
  76461. * This class is responsible to draw bothe outline/overlay of meshes.
  76462. * It should not be used directly but through the available method on mesh.
  76463. */
  76464. export class OutlineRenderer implements ISceneComponent {
  76465. /**
  76466. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76467. */
  76468. private static _StencilReference;
  76469. /**
  76470. * The name of the component. Each component must have a unique name.
  76471. */
  76472. name: string;
  76473. /**
  76474. * The scene the component belongs to.
  76475. */
  76476. scene: Scene;
  76477. /**
  76478. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76479. */
  76480. zOffset: number;
  76481. private _engine;
  76482. private _effect;
  76483. private _cachedDefines;
  76484. private _savedDepthWrite;
  76485. /**
  76486. * Instantiates a new outline renderer. (There could be only one per scene).
  76487. * @param scene Defines the scene it belongs to
  76488. */
  76489. constructor(scene: Scene);
  76490. /**
  76491. * Register the component to one instance of a scene.
  76492. */
  76493. register(): void;
  76494. /**
  76495. * Rebuilds the elements related to this component in case of
  76496. * context lost for instance.
  76497. */
  76498. rebuild(): void;
  76499. /**
  76500. * Disposes the component and the associated ressources.
  76501. */
  76502. dispose(): void;
  76503. /**
  76504. * Renders the outline in the canvas.
  76505. * @param subMesh Defines the sumesh to render
  76506. * @param batch Defines the batch of meshes in case of instances
  76507. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76508. */
  76509. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76510. /**
  76511. * Returns whether or not the outline renderer is ready for a given submesh.
  76512. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76513. * @param subMesh Defines the submesh to check readyness for
  76514. * @param useInstances Defines wheter wee are trying to render instances or not
  76515. * @returns true if ready otherwise false
  76516. */
  76517. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76518. private _beforeRenderingMesh;
  76519. private _afterRenderingMesh;
  76520. }
  76521. }
  76522. declare module "babylonjs/Rendering/index" {
  76523. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76524. export * from "babylonjs/Rendering/depthRenderer";
  76525. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76526. export * from "babylonjs/Rendering/edgesRenderer";
  76527. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76528. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76529. export * from "babylonjs/Rendering/prePassRenderer";
  76530. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76531. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76532. export * from "babylonjs/Rendering/outlineRenderer";
  76533. export * from "babylonjs/Rendering/renderingGroup";
  76534. export * from "babylonjs/Rendering/renderingManager";
  76535. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76536. }
  76537. declare module "babylonjs/Sprites/ISprites" {
  76538. /**
  76539. * Defines the basic options interface of a Sprite Frame Source Size.
  76540. */
  76541. export interface ISpriteJSONSpriteSourceSize {
  76542. /**
  76543. * number of the original width of the Frame
  76544. */
  76545. w: number;
  76546. /**
  76547. * number of the original height of the Frame
  76548. */
  76549. h: number;
  76550. }
  76551. /**
  76552. * Defines the basic options interface of a Sprite Frame Data.
  76553. */
  76554. export interface ISpriteJSONSpriteFrameData {
  76555. /**
  76556. * number of the x offset of the Frame
  76557. */
  76558. x: number;
  76559. /**
  76560. * number of the y offset of the Frame
  76561. */
  76562. y: number;
  76563. /**
  76564. * number of the width of the Frame
  76565. */
  76566. w: number;
  76567. /**
  76568. * number of the height of the Frame
  76569. */
  76570. h: number;
  76571. }
  76572. /**
  76573. * Defines the basic options interface of a JSON Sprite.
  76574. */
  76575. export interface ISpriteJSONSprite {
  76576. /**
  76577. * string name of the Frame
  76578. */
  76579. filename: string;
  76580. /**
  76581. * ISpriteJSONSpriteFrame basic object of the frame data
  76582. */
  76583. frame: ISpriteJSONSpriteFrameData;
  76584. /**
  76585. * boolean to flag is the frame was rotated.
  76586. */
  76587. rotated: boolean;
  76588. /**
  76589. * boolean to flag is the frame was trimmed.
  76590. */
  76591. trimmed: boolean;
  76592. /**
  76593. * ISpriteJSONSpriteFrame basic object of the source data
  76594. */
  76595. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76596. /**
  76597. * ISpriteJSONSpriteFrame basic object of the source data
  76598. */
  76599. sourceSize: ISpriteJSONSpriteSourceSize;
  76600. }
  76601. /**
  76602. * Defines the basic options interface of a JSON atlas.
  76603. */
  76604. export interface ISpriteJSONAtlas {
  76605. /**
  76606. * Array of objects that contain the frame data.
  76607. */
  76608. frames: Array<ISpriteJSONSprite>;
  76609. /**
  76610. * object basic object containing the sprite meta data.
  76611. */
  76612. meta?: object;
  76613. }
  76614. }
  76615. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76616. /** @hidden */
  76617. export var spriteMapPixelShader: {
  76618. name: string;
  76619. shader: string;
  76620. };
  76621. }
  76622. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76623. /** @hidden */
  76624. export var spriteMapVertexShader: {
  76625. name: string;
  76626. shader: string;
  76627. };
  76628. }
  76629. declare module "babylonjs/Sprites/spriteMap" {
  76630. import { IDisposable, Scene } from "babylonjs/scene";
  76631. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76632. import { Texture } from "babylonjs/Materials/Textures/texture";
  76633. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76634. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76635. import "babylonjs/Meshes/Builders/planeBuilder";
  76636. import "babylonjs/Shaders/spriteMap.fragment";
  76637. import "babylonjs/Shaders/spriteMap.vertex";
  76638. /**
  76639. * Defines the basic options interface of a SpriteMap
  76640. */
  76641. export interface ISpriteMapOptions {
  76642. /**
  76643. * Vector2 of the number of cells in the grid.
  76644. */
  76645. stageSize?: Vector2;
  76646. /**
  76647. * Vector2 of the size of the output plane in World Units.
  76648. */
  76649. outputSize?: Vector2;
  76650. /**
  76651. * Vector3 of the position of the output plane in World Units.
  76652. */
  76653. outputPosition?: Vector3;
  76654. /**
  76655. * Vector3 of the rotation of the output plane.
  76656. */
  76657. outputRotation?: Vector3;
  76658. /**
  76659. * number of layers that the system will reserve in resources.
  76660. */
  76661. layerCount?: number;
  76662. /**
  76663. * number of max animation frames a single cell will reserve in resources.
  76664. */
  76665. maxAnimationFrames?: number;
  76666. /**
  76667. * number cell index of the base tile when the system compiles.
  76668. */
  76669. baseTile?: number;
  76670. /**
  76671. * boolean flip the sprite after its been repositioned by the framing data.
  76672. */
  76673. flipU?: boolean;
  76674. /**
  76675. * Vector3 scalar of the global RGB values of the SpriteMap.
  76676. */
  76677. colorMultiply?: Vector3;
  76678. }
  76679. /**
  76680. * Defines the IDisposable interface in order to be cleanable from resources.
  76681. */
  76682. export interface ISpriteMap extends IDisposable {
  76683. /**
  76684. * String name of the SpriteMap.
  76685. */
  76686. name: string;
  76687. /**
  76688. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76689. */
  76690. atlasJSON: ISpriteJSONAtlas;
  76691. /**
  76692. * Texture of the SpriteMap.
  76693. */
  76694. spriteSheet: Texture;
  76695. /**
  76696. * The parameters to initialize the SpriteMap with.
  76697. */
  76698. options: ISpriteMapOptions;
  76699. }
  76700. /**
  76701. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76702. */
  76703. export class SpriteMap implements ISpriteMap {
  76704. /** The Name of the spriteMap */
  76705. name: string;
  76706. /** The JSON file with the frame and meta data */
  76707. atlasJSON: ISpriteJSONAtlas;
  76708. /** The systems Sprite Sheet Texture */
  76709. spriteSheet: Texture;
  76710. /** Arguments passed with the Constructor */
  76711. options: ISpriteMapOptions;
  76712. /** Public Sprite Storage array, parsed from atlasJSON */
  76713. sprites: Array<ISpriteJSONSprite>;
  76714. /** Returns the Number of Sprites in the System */
  76715. get spriteCount(): number;
  76716. /** Returns the Position of Output Plane*/
  76717. get position(): Vector3;
  76718. /** Returns the Position of Output Plane*/
  76719. set position(v: Vector3);
  76720. /** Returns the Rotation of Output Plane*/
  76721. get rotation(): Vector3;
  76722. /** Returns the Rotation of Output Plane*/
  76723. set rotation(v: Vector3);
  76724. /** Sets the AnimationMap*/
  76725. get animationMap(): RawTexture;
  76726. /** Sets the AnimationMap*/
  76727. set animationMap(v: RawTexture);
  76728. /** Scene that the SpriteMap was created in */
  76729. private _scene;
  76730. /** Texture Buffer of Float32 that holds tile frame data*/
  76731. private _frameMap;
  76732. /** Texture Buffers of Float32 that holds tileMap data*/
  76733. private _tileMaps;
  76734. /** Texture Buffer of Float32 that holds Animation Data*/
  76735. private _animationMap;
  76736. /** Custom ShaderMaterial Central to the System*/
  76737. private _material;
  76738. /** Custom ShaderMaterial Central to the System*/
  76739. private _output;
  76740. /** Systems Time Ticker*/
  76741. private _time;
  76742. /**
  76743. * Creates a new SpriteMap
  76744. * @param name defines the SpriteMaps Name
  76745. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76746. * @param spriteSheet is the Texture that the Sprites are on.
  76747. * @param options a basic deployment configuration
  76748. * @param scene The Scene that the map is deployed on
  76749. */
  76750. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76751. /**
  76752. * Returns tileID location
  76753. * @returns Vector2 the cell position ID
  76754. */
  76755. getTileID(): Vector2;
  76756. /**
  76757. * Gets the UV location of the mouse over the SpriteMap.
  76758. * @returns Vector2 the UV position of the mouse interaction
  76759. */
  76760. getMousePosition(): Vector2;
  76761. /**
  76762. * Creates the "frame" texture Buffer
  76763. * -------------------------------------
  76764. * Structure of frames
  76765. * "filename": "Falling-Water-2.png",
  76766. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76767. * "rotated": true,
  76768. * "trimmed": true,
  76769. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76770. * "sourceSize": {"w":32,"h":32}
  76771. * @returns RawTexture of the frameMap
  76772. */
  76773. private _createFrameBuffer;
  76774. /**
  76775. * Creates the tileMap texture Buffer
  76776. * @param buffer normally and array of numbers, or a false to generate from scratch
  76777. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76778. * @returns RawTexture of the tileMap
  76779. */
  76780. private _createTileBuffer;
  76781. /**
  76782. * Modifies the data of the tileMaps
  76783. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76784. * @param pos is the iVector2 Coordinates of the Tile
  76785. * @param tile The SpriteIndex of the new Tile
  76786. */
  76787. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76788. /**
  76789. * Creates the animationMap texture Buffer
  76790. * @param buffer normally and array of numbers, or a false to generate from scratch
  76791. * @returns RawTexture of the animationMap
  76792. */
  76793. private _createTileAnimationBuffer;
  76794. /**
  76795. * Modifies the data of the animationMap
  76796. * @param cellID is the Index of the Sprite
  76797. * @param _frame is the target Animation frame
  76798. * @param toCell is the Target Index of the next frame of the animation
  76799. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76800. * @param speed is a global scalar of the time variable on the map.
  76801. */
  76802. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76803. /**
  76804. * Exports the .tilemaps file
  76805. */
  76806. saveTileMaps(): void;
  76807. /**
  76808. * Imports the .tilemaps file
  76809. * @param url of the .tilemaps file
  76810. */
  76811. loadTileMaps(url: string): void;
  76812. /**
  76813. * Release associated resources
  76814. */
  76815. dispose(): void;
  76816. }
  76817. }
  76818. declare module "babylonjs/Sprites/spritePackedManager" {
  76819. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76820. import { Scene } from "babylonjs/scene";
  76821. /**
  76822. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76823. * @see https://doc.babylonjs.com/babylon101/sprites
  76824. */
  76825. export class SpritePackedManager extends SpriteManager {
  76826. /** defines the packed manager's name */
  76827. name: string;
  76828. /**
  76829. * Creates a new sprite manager from a packed sprite sheet
  76830. * @param name defines the manager's name
  76831. * @param imgUrl defines the sprite sheet url
  76832. * @param capacity defines the maximum allowed number of sprites
  76833. * @param scene defines the hosting scene
  76834. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76835. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76836. * @param samplingMode defines the smapling mode to use with spritesheet
  76837. * @param fromPacked set to true; do not alter
  76838. */
  76839. constructor(
  76840. /** defines the packed manager's name */
  76841. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76842. }
  76843. }
  76844. declare module "babylonjs/Sprites/index" {
  76845. export * from "babylonjs/Sprites/sprite";
  76846. export * from "babylonjs/Sprites/ISprites";
  76847. export * from "babylonjs/Sprites/spriteManager";
  76848. export * from "babylonjs/Sprites/spriteMap";
  76849. export * from "babylonjs/Sprites/spritePackedManager";
  76850. export * from "babylonjs/Sprites/spriteSceneComponent";
  76851. }
  76852. declare module "babylonjs/States/index" {
  76853. export * from "babylonjs/States/alphaCullingState";
  76854. export * from "babylonjs/States/depthCullingState";
  76855. export * from "babylonjs/States/stencilState";
  76856. }
  76857. declare module "babylonjs/Misc/assetsManager" {
  76858. import { Scene } from "babylonjs/scene";
  76859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76860. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76861. import { Skeleton } from "babylonjs/Bones/skeleton";
  76862. import { Observable } from "babylonjs/Misc/observable";
  76863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76864. import { Texture } from "babylonjs/Materials/Textures/texture";
  76865. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76866. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76867. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76868. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76869. import { AssetContainer } from "babylonjs/assetContainer";
  76870. /**
  76871. * Defines the list of states available for a task inside a AssetsManager
  76872. */
  76873. export enum AssetTaskState {
  76874. /**
  76875. * Initialization
  76876. */
  76877. INIT = 0,
  76878. /**
  76879. * Running
  76880. */
  76881. RUNNING = 1,
  76882. /**
  76883. * Done
  76884. */
  76885. DONE = 2,
  76886. /**
  76887. * Error
  76888. */
  76889. ERROR = 3
  76890. }
  76891. /**
  76892. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76893. */
  76894. export abstract class AbstractAssetTask {
  76895. /**
  76896. * Task name
  76897. */ name: string;
  76898. /**
  76899. * Callback called when the task is successful
  76900. */
  76901. onSuccess: (task: any) => void;
  76902. /**
  76903. * Callback called when the task is not successful
  76904. */
  76905. onError: (task: any, message?: string, exception?: any) => void;
  76906. /**
  76907. * Creates a new AssetsManager
  76908. * @param name defines the name of the task
  76909. */
  76910. constructor(
  76911. /**
  76912. * Task name
  76913. */ name: string);
  76914. private _isCompleted;
  76915. private _taskState;
  76916. private _errorObject;
  76917. /**
  76918. * Get if the task is completed
  76919. */
  76920. get isCompleted(): boolean;
  76921. /**
  76922. * Gets the current state of the task
  76923. */
  76924. get taskState(): AssetTaskState;
  76925. /**
  76926. * Gets the current error object (if task is in error)
  76927. */
  76928. get errorObject(): {
  76929. message?: string;
  76930. exception?: any;
  76931. };
  76932. /**
  76933. * Internal only
  76934. * @hidden
  76935. */
  76936. _setErrorObject(message?: string, exception?: any): void;
  76937. /**
  76938. * Execute the current task
  76939. * @param scene defines the scene where you want your assets to be loaded
  76940. * @param onSuccess is a callback called when the task is successfully executed
  76941. * @param onError is a callback called if an error occurs
  76942. */
  76943. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76944. /**
  76945. * Execute the current task
  76946. * @param scene defines the scene where you want your assets to be loaded
  76947. * @param onSuccess is a callback called when the task is successfully executed
  76948. * @param onError is a callback called if an error occurs
  76949. */
  76950. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76951. /**
  76952. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76953. * This can be used with failed tasks that have the reason for failure fixed.
  76954. */
  76955. reset(): void;
  76956. private onErrorCallback;
  76957. private onDoneCallback;
  76958. }
  76959. /**
  76960. * Define the interface used by progress events raised during assets loading
  76961. */
  76962. export interface IAssetsProgressEvent {
  76963. /**
  76964. * Defines the number of remaining tasks to process
  76965. */
  76966. remainingCount: number;
  76967. /**
  76968. * Defines the total number of tasks
  76969. */
  76970. totalCount: number;
  76971. /**
  76972. * Defines the task that was just processed
  76973. */
  76974. task: AbstractAssetTask;
  76975. }
  76976. /**
  76977. * Class used to share progress information about assets loading
  76978. */
  76979. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76980. /**
  76981. * Defines the number of remaining tasks to process
  76982. */
  76983. remainingCount: number;
  76984. /**
  76985. * Defines the total number of tasks
  76986. */
  76987. totalCount: number;
  76988. /**
  76989. * Defines the task that was just processed
  76990. */
  76991. task: AbstractAssetTask;
  76992. /**
  76993. * Creates a AssetsProgressEvent
  76994. * @param remainingCount defines the number of remaining tasks to process
  76995. * @param totalCount defines the total number of tasks
  76996. * @param task defines the task that was just processed
  76997. */
  76998. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76999. }
  77000. /**
  77001. * Define a task used by AssetsManager to load assets into a container
  77002. */
  77003. export class ContainerAssetTask extends AbstractAssetTask {
  77004. /**
  77005. * Defines the name of the task
  77006. */
  77007. name: string;
  77008. /**
  77009. * Defines the list of mesh's names you want to load
  77010. */
  77011. meshesNames: any;
  77012. /**
  77013. * Defines the root url to use as a base to load your meshes and associated resources
  77014. */
  77015. rootUrl: string;
  77016. /**
  77017. * Defines the filename or File of the scene to load from
  77018. */
  77019. sceneFilename: string | File;
  77020. /**
  77021. * Get the loaded asset container
  77022. */
  77023. loadedContainer: AssetContainer;
  77024. /**
  77025. * Gets the list of loaded meshes
  77026. */
  77027. loadedMeshes: Array<AbstractMesh>;
  77028. /**
  77029. * Gets the list of loaded particle systems
  77030. */
  77031. loadedParticleSystems: Array<IParticleSystem>;
  77032. /**
  77033. * Gets the list of loaded skeletons
  77034. */
  77035. loadedSkeletons: Array<Skeleton>;
  77036. /**
  77037. * Gets the list of loaded animation groups
  77038. */
  77039. loadedAnimationGroups: Array<AnimationGroup>;
  77040. /**
  77041. * Callback called when the task is successful
  77042. */
  77043. onSuccess: (task: ContainerAssetTask) => void;
  77044. /**
  77045. * Callback called when the task is successful
  77046. */
  77047. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77048. /**
  77049. * Creates a new ContainerAssetTask
  77050. * @param name defines the name of the task
  77051. * @param meshesNames defines the list of mesh's names you want to load
  77052. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77053. * @param sceneFilename defines the filename or File of the scene to load from
  77054. */
  77055. constructor(
  77056. /**
  77057. * Defines the name of the task
  77058. */
  77059. name: string,
  77060. /**
  77061. * Defines the list of mesh's names you want to load
  77062. */
  77063. meshesNames: any,
  77064. /**
  77065. * Defines the root url to use as a base to load your meshes and associated resources
  77066. */
  77067. rootUrl: string,
  77068. /**
  77069. * Defines the filename or File of the scene to load from
  77070. */
  77071. sceneFilename: string | File);
  77072. /**
  77073. * Execute the current task
  77074. * @param scene defines the scene where you want your assets to be loaded
  77075. * @param onSuccess is a callback called when the task is successfully executed
  77076. * @param onError is a callback called if an error occurs
  77077. */
  77078. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77079. }
  77080. /**
  77081. * Define a task used by AssetsManager to load meshes
  77082. */
  77083. export class MeshAssetTask extends AbstractAssetTask {
  77084. /**
  77085. * Defines the name of the task
  77086. */
  77087. name: string;
  77088. /**
  77089. * Defines the list of mesh's names you want to load
  77090. */
  77091. meshesNames: any;
  77092. /**
  77093. * Defines the root url to use as a base to load your meshes and associated resources
  77094. */
  77095. rootUrl: string;
  77096. /**
  77097. * Defines the filename or File of the scene to load from
  77098. */
  77099. sceneFilename: string | File;
  77100. /**
  77101. * Gets the list of loaded meshes
  77102. */
  77103. loadedMeshes: Array<AbstractMesh>;
  77104. /**
  77105. * Gets the list of loaded particle systems
  77106. */
  77107. loadedParticleSystems: Array<IParticleSystem>;
  77108. /**
  77109. * Gets the list of loaded skeletons
  77110. */
  77111. loadedSkeletons: Array<Skeleton>;
  77112. /**
  77113. * Gets the list of loaded animation groups
  77114. */
  77115. loadedAnimationGroups: Array<AnimationGroup>;
  77116. /**
  77117. * Callback called when the task is successful
  77118. */
  77119. onSuccess: (task: MeshAssetTask) => void;
  77120. /**
  77121. * Callback called when the task is successful
  77122. */
  77123. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77124. /**
  77125. * Creates a new MeshAssetTask
  77126. * @param name defines the name of the task
  77127. * @param meshesNames defines the list of mesh's names you want to load
  77128. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77129. * @param sceneFilename defines the filename or File of the scene to load from
  77130. */
  77131. constructor(
  77132. /**
  77133. * Defines the name of the task
  77134. */
  77135. name: string,
  77136. /**
  77137. * Defines the list of mesh's names you want to load
  77138. */
  77139. meshesNames: any,
  77140. /**
  77141. * Defines the root url to use as a base to load your meshes and associated resources
  77142. */
  77143. rootUrl: string,
  77144. /**
  77145. * Defines the filename or File of the scene to load from
  77146. */
  77147. sceneFilename: string | File);
  77148. /**
  77149. * Execute the current task
  77150. * @param scene defines the scene where you want your assets to be loaded
  77151. * @param onSuccess is a callback called when the task is successfully executed
  77152. * @param onError is a callback called if an error occurs
  77153. */
  77154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77155. }
  77156. /**
  77157. * Define a task used by AssetsManager to load text content
  77158. */
  77159. export class TextFileAssetTask extends AbstractAssetTask {
  77160. /**
  77161. * Defines the name of the task
  77162. */
  77163. name: string;
  77164. /**
  77165. * Defines the location of the file to load
  77166. */
  77167. url: string;
  77168. /**
  77169. * Gets the loaded text string
  77170. */
  77171. text: string;
  77172. /**
  77173. * Callback called when the task is successful
  77174. */
  77175. onSuccess: (task: TextFileAssetTask) => void;
  77176. /**
  77177. * Callback called when the task is successful
  77178. */
  77179. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77180. /**
  77181. * Creates a new TextFileAssetTask object
  77182. * @param name defines the name of the task
  77183. * @param url defines the location of the file to load
  77184. */
  77185. constructor(
  77186. /**
  77187. * Defines the name of the task
  77188. */
  77189. name: string,
  77190. /**
  77191. * Defines the location of the file to load
  77192. */
  77193. url: string);
  77194. /**
  77195. * Execute the current task
  77196. * @param scene defines the scene where you want your assets to be loaded
  77197. * @param onSuccess is a callback called when the task is successfully executed
  77198. * @param onError is a callback called if an error occurs
  77199. */
  77200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77201. }
  77202. /**
  77203. * Define a task used by AssetsManager to load binary data
  77204. */
  77205. export class BinaryFileAssetTask extends AbstractAssetTask {
  77206. /**
  77207. * Defines the name of the task
  77208. */
  77209. name: string;
  77210. /**
  77211. * Defines the location of the file to load
  77212. */
  77213. url: string;
  77214. /**
  77215. * Gets the lodaded data (as an array buffer)
  77216. */
  77217. data: ArrayBuffer;
  77218. /**
  77219. * Callback called when the task is successful
  77220. */
  77221. onSuccess: (task: BinaryFileAssetTask) => void;
  77222. /**
  77223. * Callback called when the task is successful
  77224. */
  77225. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77226. /**
  77227. * Creates a new BinaryFileAssetTask object
  77228. * @param name defines the name of the new task
  77229. * @param url defines the location of the file to load
  77230. */
  77231. constructor(
  77232. /**
  77233. * Defines the name of the task
  77234. */
  77235. name: string,
  77236. /**
  77237. * Defines the location of the file to load
  77238. */
  77239. url: string);
  77240. /**
  77241. * Execute the current task
  77242. * @param scene defines the scene where you want your assets to be loaded
  77243. * @param onSuccess is a callback called when the task is successfully executed
  77244. * @param onError is a callback called if an error occurs
  77245. */
  77246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77247. }
  77248. /**
  77249. * Define a task used by AssetsManager to load images
  77250. */
  77251. export class ImageAssetTask extends AbstractAssetTask {
  77252. /**
  77253. * Defines the name of the task
  77254. */
  77255. name: string;
  77256. /**
  77257. * Defines the location of the image to load
  77258. */
  77259. url: string;
  77260. /**
  77261. * Gets the loaded images
  77262. */
  77263. image: HTMLImageElement;
  77264. /**
  77265. * Callback called when the task is successful
  77266. */
  77267. onSuccess: (task: ImageAssetTask) => void;
  77268. /**
  77269. * Callback called when the task is successful
  77270. */
  77271. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77272. /**
  77273. * Creates a new ImageAssetTask
  77274. * @param name defines the name of the task
  77275. * @param url defines the location of the image to load
  77276. */
  77277. constructor(
  77278. /**
  77279. * Defines the name of the task
  77280. */
  77281. name: string,
  77282. /**
  77283. * Defines the location of the image to load
  77284. */
  77285. url: string);
  77286. /**
  77287. * Execute the current task
  77288. * @param scene defines the scene where you want your assets to be loaded
  77289. * @param onSuccess is a callback called when the task is successfully executed
  77290. * @param onError is a callback called if an error occurs
  77291. */
  77292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77293. }
  77294. /**
  77295. * Defines the interface used by texture loading tasks
  77296. */
  77297. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77298. /**
  77299. * Gets the loaded texture
  77300. */
  77301. texture: TEX;
  77302. }
  77303. /**
  77304. * Define a task used by AssetsManager to load 2D textures
  77305. */
  77306. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77307. /**
  77308. * Defines the name of the task
  77309. */
  77310. name: string;
  77311. /**
  77312. * Defines the location of the file to load
  77313. */
  77314. url: string;
  77315. /**
  77316. * Defines if mipmap should not be generated (default is false)
  77317. */
  77318. noMipmap?: boolean | undefined;
  77319. /**
  77320. * Defines if texture must be inverted on Y axis (default is true)
  77321. */
  77322. invertY: boolean;
  77323. /**
  77324. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77325. */
  77326. samplingMode: number;
  77327. /**
  77328. * Gets the loaded texture
  77329. */
  77330. texture: Texture;
  77331. /**
  77332. * Callback called when the task is successful
  77333. */
  77334. onSuccess: (task: TextureAssetTask) => void;
  77335. /**
  77336. * Callback called when the task is successful
  77337. */
  77338. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77339. /**
  77340. * Creates a new TextureAssetTask object
  77341. * @param name defines the name of the task
  77342. * @param url defines the location of the file to load
  77343. * @param noMipmap defines if mipmap should not be generated (default is false)
  77344. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77345. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77346. */
  77347. constructor(
  77348. /**
  77349. * Defines the name of the task
  77350. */
  77351. name: string,
  77352. /**
  77353. * Defines the location of the file to load
  77354. */
  77355. url: string,
  77356. /**
  77357. * Defines if mipmap should not be generated (default is false)
  77358. */
  77359. noMipmap?: boolean | undefined,
  77360. /**
  77361. * Defines if texture must be inverted on Y axis (default is true)
  77362. */
  77363. invertY?: boolean,
  77364. /**
  77365. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77366. */
  77367. samplingMode?: number);
  77368. /**
  77369. * Execute the current task
  77370. * @param scene defines the scene where you want your assets to be loaded
  77371. * @param onSuccess is a callback called when the task is successfully executed
  77372. * @param onError is a callback called if an error occurs
  77373. */
  77374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77375. }
  77376. /**
  77377. * Define a task used by AssetsManager to load cube textures
  77378. */
  77379. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77380. /**
  77381. * Defines the name of the task
  77382. */
  77383. name: string;
  77384. /**
  77385. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77386. */
  77387. url: string;
  77388. /**
  77389. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77390. */
  77391. extensions?: string[] | undefined;
  77392. /**
  77393. * Defines if mipmaps should not be generated (default is false)
  77394. */
  77395. noMipmap?: boolean | undefined;
  77396. /**
  77397. * Defines the explicit list of files (undefined by default)
  77398. */
  77399. files?: string[] | undefined;
  77400. /**
  77401. * Gets the loaded texture
  77402. */
  77403. texture: CubeTexture;
  77404. /**
  77405. * Callback called when the task is successful
  77406. */
  77407. onSuccess: (task: CubeTextureAssetTask) => void;
  77408. /**
  77409. * Callback called when the task is successful
  77410. */
  77411. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77412. /**
  77413. * Creates a new CubeTextureAssetTask
  77414. * @param name defines the name of the task
  77415. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77416. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77417. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77418. * @param files defines the explicit list of files (undefined by default)
  77419. */
  77420. constructor(
  77421. /**
  77422. * Defines the name of the task
  77423. */
  77424. name: string,
  77425. /**
  77426. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77427. */
  77428. url: string,
  77429. /**
  77430. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77431. */
  77432. extensions?: string[] | undefined,
  77433. /**
  77434. * Defines if mipmaps should not be generated (default is false)
  77435. */
  77436. noMipmap?: boolean | undefined,
  77437. /**
  77438. * Defines the explicit list of files (undefined by default)
  77439. */
  77440. files?: string[] | undefined);
  77441. /**
  77442. * Execute the current task
  77443. * @param scene defines the scene where you want your assets to be loaded
  77444. * @param onSuccess is a callback called when the task is successfully executed
  77445. * @param onError is a callback called if an error occurs
  77446. */
  77447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77448. }
  77449. /**
  77450. * Define a task used by AssetsManager to load HDR cube textures
  77451. */
  77452. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77453. /**
  77454. * Defines the name of the task
  77455. */
  77456. name: string;
  77457. /**
  77458. * Defines the location of the file to load
  77459. */
  77460. url: string;
  77461. /**
  77462. * Defines the desired size (the more it increases the longer the generation will be)
  77463. */
  77464. size: number;
  77465. /**
  77466. * Defines if mipmaps should not be generated (default is false)
  77467. */
  77468. noMipmap: boolean;
  77469. /**
  77470. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77471. */
  77472. generateHarmonics: boolean;
  77473. /**
  77474. * 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)
  77475. */
  77476. gammaSpace: boolean;
  77477. /**
  77478. * Internal Use Only
  77479. */
  77480. reserved: boolean;
  77481. /**
  77482. * Gets the loaded texture
  77483. */
  77484. texture: HDRCubeTexture;
  77485. /**
  77486. * Callback called when the task is successful
  77487. */
  77488. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77489. /**
  77490. * Callback called when the task is successful
  77491. */
  77492. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77493. /**
  77494. * Creates a new HDRCubeTextureAssetTask object
  77495. * @param name defines the name of the task
  77496. * @param url defines the location of the file to load
  77497. * @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.
  77498. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77499. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77500. * @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)
  77501. * @param reserved Internal use only
  77502. */
  77503. constructor(
  77504. /**
  77505. * Defines the name of the task
  77506. */
  77507. name: string,
  77508. /**
  77509. * Defines the location of the file to load
  77510. */
  77511. url: string,
  77512. /**
  77513. * Defines the desired size (the more it increases the longer the generation will be)
  77514. */
  77515. size: number,
  77516. /**
  77517. * Defines if mipmaps should not be generated (default is false)
  77518. */
  77519. noMipmap?: boolean,
  77520. /**
  77521. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77522. */
  77523. generateHarmonics?: boolean,
  77524. /**
  77525. * 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)
  77526. */
  77527. gammaSpace?: boolean,
  77528. /**
  77529. * Internal Use Only
  77530. */
  77531. reserved?: boolean);
  77532. /**
  77533. * Execute the current task
  77534. * @param scene defines the scene where you want your assets to be loaded
  77535. * @param onSuccess is a callback called when the task is successfully executed
  77536. * @param onError is a callback called if an error occurs
  77537. */
  77538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77539. }
  77540. /**
  77541. * Define a task used by AssetsManager to load Equirectangular cube textures
  77542. */
  77543. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77544. /**
  77545. * Defines the name of the task
  77546. */
  77547. name: string;
  77548. /**
  77549. * Defines the location of the file to load
  77550. */
  77551. url: string;
  77552. /**
  77553. * Defines the desired size (the more it increases the longer the generation will be)
  77554. */
  77555. size: number;
  77556. /**
  77557. * Defines if mipmaps should not be generated (default is false)
  77558. */
  77559. noMipmap: boolean;
  77560. /**
  77561. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77562. * but the standard material would require them in Gamma space) (default is true)
  77563. */
  77564. gammaSpace: boolean;
  77565. /**
  77566. * Gets the loaded texture
  77567. */
  77568. texture: EquiRectangularCubeTexture;
  77569. /**
  77570. * Callback called when the task is successful
  77571. */
  77572. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77573. /**
  77574. * Callback called when the task is successful
  77575. */
  77576. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77577. /**
  77578. * Creates a new EquiRectangularCubeTextureAssetTask object
  77579. * @param name defines the name of the task
  77580. * @param url defines the location of the file to load
  77581. * @param size defines the desired size (the more it increases the longer the generation will be)
  77582. * If the size is omitted this implies you are using a preprocessed cubemap.
  77583. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77584. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77585. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77586. * (default is true)
  77587. */
  77588. constructor(
  77589. /**
  77590. * Defines the name of the task
  77591. */
  77592. name: string,
  77593. /**
  77594. * Defines the location of the file to load
  77595. */
  77596. url: string,
  77597. /**
  77598. * Defines the desired size (the more it increases the longer the generation will be)
  77599. */
  77600. size: number,
  77601. /**
  77602. * Defines if mipmaps should not be generated (default is false)
  77603. */
  77604. noMipmap?: boolean,
  77605. /**
  77606. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77607. * but the standard material would require them in Gamma space) (default is true)
  77608. */
  77609. gammaSpace?: boolean);
  77610. /**
  77611. * Execute the current task
  77612. * @param scene defines the scene where you want your assets to be loaded
  77613. * @param onSuccess is a callback called when the task is successfully executed
  77614. * @param onError is a callback called if an error occurs
  77615. */
  77616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77617. }
  77618. /**
  77619. * This class can be used to easily import assets into a scene
  77620. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77621. */
  77622. export class AssetsManager {
  77623. private _scene;
  77624. private _isLoading;
  77625. protected _tasks: AbstractAssetTask[];
  77626. protected _waitingTasksCount: number;
  77627. protected _totalTasksCount: number;
  77628. /**
  77629. * Callback called when all tasks are processed
  77630. */
  77631. onFinish: (tasks: AbstractAssetTask[]) => void;
  77632. /**
  77633. * Callback called when a task is successful
  77634. */
  77635. onTaskSuccess: (task: AbstractAssetTask) => void;
  77636. /**
  77637. * Callback called when a task had an error
  77638. */
  77639. onTaskError: (task: AbstractAssetTask) => void;
  77640. /**
  77641. * Callback called when a task is done (whatever the result is)
  77642. */
  77643. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77644. /**
  77645. * Observable called when all tasks are processed
  77646. */
  77647. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77648. /**
  77649. * Observable called when a task had an error
  77650. */
  77651. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77652. /**
  77653. * Observable called when all tasks were executed
  77654. */
  77655. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77656. /**
  77657. * Observable called when a task is done (whatever the result is)
  77658. */
  77659. onProgressObservable: Observable<IAssetsProgressEvent>;
  77660. /**
  77661. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77662. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77663. */
  77664. useDefaultLoadingScreen: boolean;
  77665. /**
  77666. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77667. * when all assets have been downloaded.
  77668. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77669. */
  77670. autoHideLoadingUI: boolean;
  77671. /**
  77672. * Creates a new AssetsManager
  77673. * @param scene defines the scene to work on
  77674. */
  77675. constructor(scene: Scene);
  77676. /**
  77677. * Add a ContainerAssetTask to the list of active tasks
  77678. * @param taskName defines the name of the new task
  77679. * @param meshesNames defines the name of meshes to load
  77680. * @param rootUrl defines the root url to use to locate files
  77681. * @param sceneFilename defines the filename of the scene file
  77682. * @returns a new ContainerAssetTask object
  77683. */
  77684. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77685. /**
  77686. * Add a MeshAssetTask to the list of active tasks
  77687. * @param taskName defines the name of the new task
  77688. * @param meshesNames defines the name of meshes to load
  77689. * @param rootUrl defines the root url to use to locate files
  77690. * @param sceneFilename defines the filename of the scene file
  77691. * @returns a new MeshAssetTask object
  77692. */
  77693. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77694. /**
  77695. * Add a TextFileAssetTask to the list of active tasks
  77696. * @param taskName defines the name of the new task
  77697. * @param url defines the url of the file to load
  77698. * @returns a new TextFileAssetTask object
  77699. */
  77700. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77701. /**
  77702. * Add a BinaryFileAssetTask to the list of active tasks
  77703. * @param taskName defines the name of the new task
  77704. * @param url defines the url of the file to load
  77705. * @returns a new BinaryFileAssetTask object
  77706. */
  77707. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77708. /**
  77709. * Add a ImageAssetTask to the list of active tasks
  77710. * @param taskName defines the name of the new task
  77711. * @param url defines the url of the file to load
  77712. * @returns a new ImageAssetTask object
  77713. */
  77714. addImageTask(taskName: string, url: string): ImageAssetTask;
  77715. /**
  77716. * Add a TextureAssetTask to the list of active tasks
  77717. * @param taskName defines the name of the new task
  77718. * @param url defines the url of the file to load
  77719. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77720. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77721. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77722. * @returns a new TextureAssetTask object
  77723. */
  77724. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77725. /**
  77726. * Add a CubeTextureAssetTask to the list of active tasks
  77727. * @param taskName defines the name of the new task
  77728. * @param url defines the url of the file to load
  77729. * @param extensions defines the extension to use to load the cube map (can be null)
  77730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77731. * @param files defines the list of files to load (can be null)
  77732. * @returns a new CubeTextureAssetTask object
  77733. */
  77734. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77735. /**
  77736. *
  77737. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77738. * @param taskName defines the name of the new task
  77739. * @param url defines the url of the file to load
  77740. * @param size defines the size you want for the cubemap (can be null)
  77741. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77742. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77743. * @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)
  77744. * @param reserved Internal use only
  77745. * @returns a new HDRCubeTextureAssetTask object
  77746. */
  77747. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77748. /**
  77749. *
  77750. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77751. * @param taskName defines the name of the new task
  77752. * @param url defines the url of the file to load
  77753. * @param size defines the size you want for the cubemap (can be null)
  77754. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77755. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77756. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77757. * @returns a new EquiRectangularCubeTextureAssetTask object
  77758. */
  77759. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77760. /**
  77761. * Remove a task from the assets manager.
  77762. * @param task the task to remove
  77763. */
  77764. removeTask(task: AbstractAssetTask): void;
  77765. private _decreaseWaitingTasksCount;
  77766. private _runTask;
  77767. /**
  77768. * Reset the AssetsManager and remove all tasks
  77769. * @return the current instance of the AssetsManager
  77770. */
  77771. reset(): AssetsManager;
  77772. /**
  77773. * Start the loading process
  77774. * @return the current instance of the AssetsManager
  77775. */
  77776. load(): AssetsManager;
  77777. /**
  77778. * Start the loading process as an async operation
  77779. * @return a promise returning the list of failed tasks
  77780. */
  77781. loadAsync(): Promise<void>;
  77782. }
  77783. }
  77784. declare module "babylonjs/Misc/deferred" {
  77785. /**
  77786. * Wrapper class for promise with external resolve and reject.
  77787. */
  77788. export class Deferred<T> {
  77789. /**
  77790. * The promise associated with this deferred object.
  77791. */
  77792. readonly promise: Promise<T>;
  77793. private _resolve;
  77794. private _reject;
  77795. /**
  77796. * The resolve method of the promise associated with this deferred object.
  77797. */
  77798. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77799. /**
  77800. * The reject method of the promise associated with this deferred object.
  77801. */
  77802. get reject(): (reason?: any) => void;
  77803. /**
  77804. * Constructor for this deferred object.
  77805. */
  77806. constructor();
  77807. }
  77808. }
  77809. declare module "babylonjs/Misc/meshExploder" {
  77810. import { Mesh } from "babylonjs/Meshes/mesh";
  77811. /**
  77812. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77813. */
  77814. export class MeshExploder {
  77815. private _centerMesh;
  77816. private _meshes;
  77817. private _meshesOrigins;
  77818. private _toCenterVectors;
  77819. private _scaledDirection;
  77820. private _newPosition;
  77821. private _centerPosition;
  77822. /**
  77823. * Explodes meshes from a center mesh.
  77824. * @param meshes The meshes to explode.
  77825. * @param centerMesh The mesh to be center of explosion.
  77826. */
  77827. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77828. private _setCenterMesh;
  77829. /**
  77830. * Get class name
  77831. * @returns "MeshExploder"
  77832. */
  77833. getClassName(): string;
  77834. /**
  77835. * "Exploded meshes"
  77836. * @returns Array of meshes with the centerMesh at index 0.
  77837. */
  77838. getMeshes(): Array<Mesh>;
  77839. /**
  77840. * Explodes meshes giving a specific direction
  77841. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77842. */
  77843. explode(direction?: number): void;
  77844. }
  77845. }
  77846. declare module "babylonjs/Misc/filesInput" {
  77847. import { Engine } from "babylonjs/Engines/engine";
  77848. import { Scene } from "babylonjs/scene";
  77849. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77850. import { Nullable } from "babylonjs/types";
  77851. /**
  77852. * Class used to help managing file picking and drag'n'drop
  77853. */
  77854. export class FilesInput {
  77855. /**
  77856. * List of files ready to be loaded
  77857. */
  77858. static get FilesToLoad(): {
  77859. [key: string]: File;
  77860. };
  77861. /**
  77862. * Callback called when a file is processed
  77863. */
  77864. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77865. private _engine;
  77866. private _currentScene;
  77867. private _sceneLoadedCallback;
  77868. private _progressCallback;
  77869. private _additionalRenderLoopLogicCallback;
  77870. private _textureLoadingCallback;
  77871. private _startingProcessingFilesCallback;
  77872. private _onReloadCallback;
  77873. private _errorCallback;
  77874. private _elementToMonitor;
  77875. private _sceneFileToLoad;
  77876. private _filesToLoad;
  77877. /**
  77878. * Creates a new FilesInput
  77879. * @param engine defines the rendering engine
  77880. * @param scene defines the hosting scene
  77881. * @param sceneLoadedCallback callback called when scene is loaded
  77882. * @param progressCallback callback called to track progress
  77883. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77884. * @param textureLoadingCallback callback called when a texture is loading
  77885. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77886. * @param onReloadCallback callback called when a reload is requested
  77887. * @param errorCallback callback call if an error occurs
  77888. */
  77889. 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>);
  77890. private _dragEnterHandler;
  77891. private _dragOverHandler;
  77892. private _dropHandler;
  77893. /**
  77894. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77895. * @param elementToMonitor defines the DOM element to track
  77896. */
  77897. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77898. /** Gets the current list of files to load */
  77899. get filesToLoad(): File[];
  77900. /**
  77901. * Release all associated resources
  77902. */
  77903. dispose(): void;
  77904. private renderFunction;
  77905. private drag;
  77906. private drop;
  77907. private _traverseFolder;
  77908. private _processFiles;
  77909. /**
  77910. * Load files from a drop event
  77911. * @param event defines the drop event to use as source
  77912. */
  77913. loadFiles(event: any): void;
  77914. private _processReload;
  77915. /**
  77916. * Reload the current scene from the loaded files
  77917. */
  77918. reload(): void;
  77919. }
  77920. }
  77921. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77922. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77923. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77924. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77925. }
  77926. declare module "babylonjs/Misc/sceneOptimizer" {
  77927. import { Scene, IDisposable } from "babylonjs/scene";
  77928. import { Observable } from "babylonjs/Misc/observable";
  77929. /**
  77930. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77931. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77932. */
  77933. export class SceneOptimization {
  77934. /**
  77935. * Defines the priority of this optimization (0 by default which means first in the list)
  77936. */
  77937. priority: number;
  77938. /**
  77939. * Gets a string describing the action executed by the current optimization
  77940. * @returns description string
  77941. */
  77942. getDescription(): string;
  77943. /**
  77944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77945. * @param scene defines the current scene where to apply this optimization
  77946. * @param optimizer defines the current optimizer
  77947. * @returns true if everything that can be done was applied
  77948. */
  77949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77950. /**
  77951. * Creates the SceneOptimization object
  77952. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77953. * @param desc defines the description associated with the optimization
  77954. */
  77955. constructor(
  77956. /**
  77957. * Defines the priority of this optimization (0 by default which means first in the list)
  77958. */
  77959. priority?: number);
  77960. }
  77961. /**
  77962. * Defines an optimization used to reduce the size of render target textures
  77963. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77964. */
  77965. export class TextureOptimization extends SceneOptimization {
  77966. /**
  77967. * Defines the priority of this optimization (0 by default which means first in the list)
  77968. */
  77969. priority: number;
  77970. /**
  77971. * 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
  77972. */
  77973. maximumSize: number;
  77974. /**
  77975. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77976. */
  77977. step: number;
  77978. /**
  77979. * Gets a string describing the action executed by the current optimization
  77980. * @returns description string
  77981. */
  77982. getDescription(): string;
  77983. /**
  77984. * Creates the TextureOptimization object
  77985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77986. * @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
  77987. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77988. */
  77989. constructor(
  77990. /**
  77991. * Defines the priority of this optimization (0 by default which means first in the list)
  77992. */
  77993. priority?: number,
  77994. /**
  77995. * 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
  77996. */
  77997. maximumSize?: number,
  77998. /**
  77999. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78000. */
  78001. step?: number);
  78002. /**
  78003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78004. * @param scene defines the current scene where to apply this optimization
  78005. * @param optimizer defines the current optimizer
  78006. * @returns true if everything that can be done was applied
  78007. */
  78008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78009. }
  78010. /**
  78011. * Defines an optimization used to increase or decrease the rendering resolution
  78012. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78013. */
  78014. export class HardwareScalingOptimization extends SceneOptimization {
  78015. /**
  78016. * Defines the priority of this optimization (0 by default which means first in the list)
  78017. */
  78018. priority: number;
  78019. /**
  78020. * Defines the maximum scale to use (2 by default)
  78021. */
  78022. maximumScale: number;
  78023. /**
  78024. * Defines the step to use between two passes (0.5 by default)
  78025. */
  78026. step: number;
  78027. private _currentScale;
  78028. private _directionOffset;
  78029. /**
  78030. * Gets a string describing the action executed by the current optimization
  78031. * @return description string
  78032. */
  78033. getDescription(): string;
  78034. /**
  78035. * Creates the HardwareScalingOptimization object
  78036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78037. * @param maximumScale defines the maximum scale to use (2 by default)
  78038. * @param step defines the step to use between two passes (0.5 by default)
  78039. */
  78040. constructor(
  78041. /**
  78042. * Defines the priority of this optimization (0 by default which means first in the list)
  78043. */
  78044. priority?: number,
  78045. /**
  78046. * Defines the maximum scale to use (2 by default)
  78047. */
  78048. maximumScale?: number,
  78049. /**
  78050. * Defines the step to use between two passes (0.5 by default)
  78051. */
  78052. step?: number);
  78053. /**
  78054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78055. * @param scene defines the current scene where to apply this optimization
  78056. * @param optimizer defines the current optimizer
  78057. * @returns true if everything that can be done was applied
  78058. */
  78059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78060. }
  78061. /**
  78062. * Defines an optimization used to remove shadows
  78063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78064. */
  78065. export class ShadowsOptimization extends SceneOptimization {
  78066. /**
  78067. * Gets a string describing the action executed by the current optimization
  78068. * @return description string
  78069. */
  78070. getDescription(): string;
  78071. /**
  78072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78073. * @param scene defines the current scene where to apply this optimization
  78074. * @param optimizer defines the current optimizer
  78075. * @returns true if everything that can be done was applied
  78076. */
  78077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78078. }
  78079. /**
  78080. * Defines an optimization used to turn post-processes off
  78081. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78082. */
  78083. export class PostProcessesOptimization extends SceneOptimization {
  78084. /**
  78085. * Gets a string describing the action executed by the current optimization
  78086. * @return description string
  78087. */
  78088. getDescription(): string;
  78089. /**
  78090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78091. * @param scene defines the current scene where to apply this optimization
  78092. * @param optimizer defines the current optimizer
  78093. * @returns true if everything that can be done was applied
  78094. */
  78095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78096. }
  78097. /**
  78098. * Defines an optimization used to turn lens flares off
  78099. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78100. */
  78101. export class LensFlaresOptimization extends SceneOptimization {
  78102. /**
  78103. * Gets a string describing the action executed by the current optimization
  78104. * @return description string
  78105. */
  78106. getDescription(): string;
  78107. /**
  78108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78109. * @param scene defines the current scene where to apply this optimization
  78110. * @param optimizer defines the current optimizer
  78111. * @returns true if everything that can be done was applied
  78112. */
  78113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78114. }
  78115. /**
  78116. * Defines an optimization based on user defined callback.
  78117. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78118. */
  78119. export class CustomOptimization extends SceneOptimization {
  78120. /**
  78121. * Callback called to apply the custom optimization.
  78122. */
  78123. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78124. /**
  78125. * Callback called to get custom description
  78126. */
  78127. onGetDescription: () => string;
  78128. /**
  78129. * Gets a string describing the action executed by the current optimization
  78130. * @returns description string
  78131. */
  78132. getDescription(): string;
  78133. /**
  78134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78135. * @param scene defines the current scene where to apply this optimization
  78136. * @param optimizer defines the current optimizer
  78137. * @returns true if everything that can be done was applied
  78138. */
  78139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78140. }
  78141. /**
  78142. * Defines an optimization used to turn particles off
  78143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78144. */
  78145. export class ParticlesOptimization extends SceneOptimization {
  78146. /**
  78147. * Gets a string describing the action executed by the current optimization
  78148. * @return description string
  78149. */
  78150. getDescription(): string;
  78151. /**
  78152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78153. * @param scene defines the current scene where to apply this optimization
  78154. * @param optimizer defines the current optimizer
  78155. * @returns true if everything that can be done was applied
  78156. */
  78157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78158. }
  78159. /**
  78160. * Defines an optimization used to turn render targets off
  78161. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78162. */
  78163. export class RenderTargetsOptimization extends SceneOptimization {
  78164. /**
  78165. * Gets a string describing the action executed by the current optimization
  78166. * @return description string
  78167. */
  78168. getDescription(): string;
  78169. /**
  78170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78171. * @param scene defines the current scene where to apply this optimization
  78172. * @param optimizer defines the current optimizer
  78173. * @returns true if everything that can be done was applied
  78174. */
  78175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78176. }
  78177. /**
  78178. * Defines an optimization used to merge meshes with compatible materials
  78179. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78180. */
  78181. export class MergeMeshesOptimization extends SceneOptimization {
  78182. private static _UpdateSelectionTree;
  78183. /**
  78184. * Gets or sets a boolean which defines if optimization octree has to be updated
  78185. */
  78186. static get UpdateSelectionTree(): boolean;
  78187. /**
  78188. * Gets or sets a boolean which defines if optimization octree has to be updated
  78189. */
  78190. static set UpdateSelectionTree(value: boolean);
  78191. /**
  78192. * Gets a string describing the action executed by the current optimization
  78193. * @return description string
  78194. */
  78195. getDescription(): string;
  78196. private _canBeMerged;
  78197. /**
  78198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78199. * @param scene defines the current scene where to apply this optimization
  78200. * @param optimizer defines the current optimizer
  78201. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78202. * @returns true if everything that can be done was applied
  78203. */
  78204. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78205. }
  78206. /**
  78207. * Defines a list of options used by SceneOptimizer
  78208. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78209. */
  78210. export class SceneOptimizerOptions {
  78211. /**
  78212. * Defines the target frame rate to reach (60 by default)
  78213. */
  78214. targetFrameRate: number;
  78215. /**
  78216. * Defines the interval between two checkes (2000ms by default)
  78217. */
  78218. trackerDuration: number;
  78219. /**
  78220. * Gets the list of optimizations to apply
  78221. */
  78222. optimizations: SceneOptimization[];
  78223. /**
  78224. * Creates a new list of options used by SceneOptimizer
  78225. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78226. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78227. */
  78228. constructor(
  78229. /**
  78230. * Defines the target frame rate to reach (60 by default)
  78231. */
  78232. targetFrameRate?: number,
  78233. /**
  78234. * Defines the interval between two checkes (2000ms by default)
  78235. */
  78236. trackerDuration?: number);
  78237. /**
  78238. * Add a new optimization
  78239. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78240. * @returns the current SceneOptimizerOptions
  78241. */
  78242. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78243. /**
  78244. * Add a new custom optimization
  78245. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78246. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78247. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78248. * @returns the current SceneOptimizerOptions
  78249. */
  78250. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78251. /**
  78252. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78253. * @param targetFrameRate defines the target frame rate (60 by default)
  78254. * @returns a SceneOptimizerOptions object
  78255. */
  78256. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78257. /**
  78258. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78259. * @param targetFrameRate defines the target frame rate (60 by default)
  78260. * @returns a SceneOptimizerOptions object
  78261. */
  78262. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78263. /**
  78264. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78265. * @param targetFrameRate defines the target frame rate (60 by default)
  78266. * @returns a SceneOptimizerOptions object
  78267. */
  78268. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78269. }
  78270. /**
  78271. * Class used to run optimizations in order to reach a target frame rate
  78272. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78273. */
  78274. export class SceneOptimizer implements IDisposable {
  78275. private _isRunning;
  78276. private _options;
  78277. private _scene;
  78278. private _currentPriorityLevel;
  78279. private _targetFrameRate;
  78280. private _trackerDuration;
  78281. private _currentFrameRate;
  78282. private _sceneDisposeObserver;
  78283. private _improvementMode;
  78284. /**
  78285. * Defines an observable called when the optimizer reaches the target frame rate
  78286. */
  78287. onSuccessObservable: Observable<SceneOptimizer>;
  78288. /**
  78289. * Defines an observable called when the optimizer enables an optimization
  78290. */
  78291. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78292. /**
  78293. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78294. */
  78295. onFailureObservable: Observable<SceneOptimizer>;
  78296. /**
  78297. * Gets a boolean indicating if the optimizer is in improvement mode
  78298. */
  78299. get isInImprovementMode(): boolean;
  78300. /**
  78301. * Gets the current priority level (0 at start)
  78302. */
  78303. get currentPriorityLevel(): number;
  78304. /**
  78305. * Gets the current frame rate checked by the SceneOptimizer
  78306. */
  78307. get currentFrameRate(): number;
  78308. /**
  78309. * Gets or sets the current target frame rate (60 by default)
  78310. */
  78311. get targetFrameRate(): number;
  78312. /**
  78313. * Gets or sets the current target frame rate (60 by default)
  78314. */
  78315. set targetFrameRate(value: number);
  78316. /**
  78317. * Gets or sets the current interval between two checks (every 2000ms by default)
  78318. */
  78319. get trackerDuration(): number;
  78320. /**
  78321. * Gets or sets the current interval between two checks (every 2000ms by default)
  78322. */
  78323. set trackerDuration(value: number);
  78324. /**
  78325. * Gets the list of active optimizations
  78326. */
  78327. get optimizations(): SceneOptimization[];
  78328. /**
  78329. * Creates a new SceneOptimizer
  78330. * @param scene defines the scene to work on
  78331. * @param options defines the options to use with the SceneOptimizer
  78332. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78333. * @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)
  78334. */
  78335. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78336. /**
  78337. * Stops the current optimizer
  78338. */
  78339. stop(): void;
  78340. /**
  78341. * Reset the optimizer to initial step (current priority level = 0)
  78342. */
  78343. reset(): void;
  78344. /**
  78345. * Start the optimizer. By default it will try to reach a specific framerate
  78346. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78347. */
  78348. start(): void;
  78349. private _checkCurrentState;
  78350. /**
  78351. * Release all resources
  78352. */
  78353. dispose(): void;
  78354. /**
  78355. * Helper function to create a SceneOptimizer with one single line of code
  78356. * @param scene defines the scene to work on
  78357. * @param options defines the options to use with the SceneOptimizer
  78358. * @param onSuccess defines a callback to call on success
  78359. * @param onFailure defines a callback to call on failure
  78360. * @returns the new SceneOptimizer object
  78361. */
  78362. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78363. }
  78364. }
  78365. declare module "babylonjs/Misc/sceneSerializer" {
  78366. import { Scene } from "babylonjs/scene";
  78367. /**
  78368. * Class used to serialize a scene into a string
  78369. */
  78370. export class SceneSerializer {
  78371. /**
  78372. * Clear cache used by a previous serialization
  78373. */
  78374. static ClearCache(): void;
  78375. /**
  78376. * Serialize a scene into a JSON compatible object
  78377. * @param scene defines the scene to serialize
  78378. * @returns a JSON compatible object
  78379. */
  78380. static Serialize(scene: Scene): any;
  78381. /**
  78382. * Serialize a mesh into a JSON compatible object
  78383. * @param toSerialize defines the mesh to serialize
  78384. * @param withParents defines if parents must be serialized as well
  78385. * @param withChildren defines if children must be serialized as well
  78386. * @returns a JSON compatible object
  78387. */
  78388. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78389. }
  78390. }
  78391. declare module "babylonjs/Misc/textureTools" {
  78392. import { Texture } from "babylonjs/Materials/Textures/texture";
  78393. /**
  78394. * Class used to host texture specific utilities
  78395. */
  78396. export class TextureTools {
  78397. /**
  78398. * Uses the GPU to create a copy texture rescaled at a given size
  78399. * @param texture Texture to copy from
  78400. * @param width defines the desired width
  78401. * @param height defines the desired height
  78402. * @param useBilinearMode defines if bilinear mode has to be used
  78403. * @return the generated texture
  78404. */
  78405. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78406. }
  78407. }
  78408. declare module "babylonjs/Misc/videoRecorder" {
  78409. import { Nullable } from "babylonjs/types";
  78410. import { Engine } from "babylonjs/Engines/engine";
  78411. /**
  78412. * This represents the different options available for the video capture.
  78413. */
  78414. export interface VideoRecorderOptions {
  78415. /** Defines the mime type of the video. */
  78416. mimeType: string;
  78417. /** Defines the FPS the video should be recorded at. */
  78418. fps: number;
  78419. /** Defines the chunk size for the recording data. */
  78420. recordChunckSize: number;
  78421. /** The audio tracks to attach to the recording. */
  78422. audioTracks?: MediaStreamTrack[];
  78423. }
  78424. /**
  78425. * This can help with recording videos from BabylonJS.
  78426. * This is based on the available WebRTC functionalities of the browser.
  78427. *
  78428. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78429. */
  78430. export class VideoRecorder {
  78431. private static readonly _defaultOptions;
  78432. /**
  78433. * Returns whether or not the VideoRecorder is available in your browser.
  78434. * @param engine Defines the Babylon Engine.
  78435. * @returns true if supported otherwise false.
  78436. */
  78437. static IsSupported(engine: Engine): boolean;
  78438. private readonly _options;
  78439. private _canvas;
  78440. private _mediaRecorder;
  78441. private _recordedChunks;
  78442. private _fileName;
  78443. private _resolve;
  78444. private _reject;
  78445. /**
  78446. * True when a recording is already in progress.
  78447. */
  78448. get isRecording(): boolean;
  78449. /**
  78450. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78451. * @param engine Defines the BabylonJS Engine you wish to record.
  78452. * @param options Defines options that can be used to customize the capture.
  78453. */
  78454. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78455. /**
  78456. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78457. */
  78458. stopRecording(): void;
  78459. /**
  78460. * Starts recording the canvas for a max duration specified in parameters.
  78461. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78462. * If null no automatic download will start and you can rely on the promise to get the data back.
  78463. * @param maxDuration Defines the maximum recording time in seconds.
  78464. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78465. * @return A promise callback at the end of the recording with the video data in Blob.
  78466. */
  78467. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78468. /**
  78469. * Releases internal resources used during the recording.
  78470. */
  78471. dispose(): void;
  78472. private _handleDataAvailable;
  78473. private _handleError;
  78474. private _handleStop;
  78475. }
  78476. }
  78477. declare module "babylonjs/Misc/screenshotTools" {
  78478. import { Camera } from "babylonjs/Cameras/camera";
  78479. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78480. import { Engine } from "babylonjs/Engines/engine";
  78481. /**
  78482. * Class containing a set of static utilities functions for screenshots
  78483. */
  78484. export class ScreenshotTools {
  78485. /**
  78486. * Captures a screenshot of the current rendering
  78487. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78488. * @param engine defines the rendering engine
  78489. * @param camera defines the source camera
  78490. * @param size This parameter can be set to a single number or to an object with the
  78491. * following (optional) properties: precision, width, height. If a single number is passed,
  78492. * it will be used for both width and height. If an object is passed, the screenshot size
  78493. * will be derived from the parameters. The precision property is a multiplier allowing
  78494. * rendering at a higher or lower resolution
  78495. * @param successCallback defines the callback receives a single parameter which contains the
  78496. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78497. * src parameter of an <img> to display it
  78498. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78499. * Check your browser for supported MIME types
  78500. */
  78501. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78502. /**
  78503. * Captures a screenshot of the current rendering
  78504. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78505. * @param engine defines the rendering engine
  78506. * @param camera defines the source camera
  78507. * @param size This parameter can be set to a single number or to an object with the
  78508. * following (optional) properties: precision, width, height. If a single number is passed,
  78509. * it will be used for both width and height. If an object is passed, the screenshot size
  78510. * will be derived from the parameters. The precision property is a multiplier allowing
  78511. * rendering at a higher or lower resolution
  78512. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78513. * Check your browser for supported MIME types
  78514. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78515. * to the src parameter of an <img> to display it
  78516. */
  78517. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78518. /**
  78519. * Generates an image screenshot from the specified camera.
  78520. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78521. * @param engine The engine to use for rendering
  78522. * @param camera The camera to use for rendering
  78523. * @param size This parameter can be set to a single number or to an object with the
  78524. * following (optional) properties: precision, width, height. If a single number is passed,
  78525. * it will be used for both width and height. If an object is passed, the screenshot size
  78526. * will be derived from the parameters. The precision property is a multiplier allowing
  78527. * rendering at a higher or lower resolution
  78528. * @param successCallback The callback receives a single parameter which contains the
  78529. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78530. * src parameter of an <img> to display it
  78531. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78532. * Check your browser for supported MIME types
  78533. * @param samples Texture samples (default: 1)
  78534. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78535. * @param fileName A name for for the downloaded file.
  78536. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78537. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78538. */
  78539. 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;
  78540. /**
  78541. * Generates an image screenshot from the specified camera.
  78542. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78543. * @param engine The engine to use for rendering
  78544. * @param camera The camera to use for rendering
  78545. * @param size This parameter can be set to a single number or to an object with the
  78546. * following (optional) properties: precision, width, height. If a single number is passed,
  78547. * it will be used for both width and height. If an object is passed, the screenshot size
  78548. * will be derived from the parameters. The precision property is a multiplier allowing
  78549. * rendering at a higher or lower resolution
  78550. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78551. * Check your browser for supported MIME types
  78552. * @param samples Texture samples (default: 1)
  78553. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78554. * @param fileName A name for for the downloaded file.
  78555. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78556. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78557. * to the src parameter of an <img> to display it
  78558. */
  78559. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78560. /**
  78561. * Gets height and width for screenshot size
  78562. * @private
  78563. */
  78564. private static _getScreenshotSize;
  78565. }
  78566. }
  78567. declare module "babylonjs/Misc/dataReader" {
  78568. /**
  78569. * Interface for a data buffer
  78570. */
  78571. export interface IDataBuffer {
  78572. /**
  78573. * Reads bytes from the data buffer.
  78574. * @param byteOffset The byte offset to read
  78575. * @param byteLength The byte length to read
  78576. * @returns A promise that resolves when the bytes are read
  78577. */
  78578. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78579. /**
  78580. * The byte length of the buffer.
  78581. */
  78582. readonly byteLength: number;
  78583. }
  78584. /**
  78585. * Utility class for reading from a data buffer
  78586. */
  78587. export class DataReader {
  78588. /**
  78589. * The data buffer associated with this data reader.
  78590. */
  78591. readonly buffer: IDataBuffer;
  78592. /**
  78593. * The current byte offset from the beginning of the data buffer.
  78594. */
  78595. byteOffset: number;
  78596. private _dataView;
  78597. private _dataByteOffset;
  78598. /**
  78599. * Constructor
  78600. * @param buffer The buffer to read
  78601. */
  78602. constructor(buffer: IDataBuffer);
  78603. /**
  78604. * Loads the given byte length.
  78605. * @param byteLength The byte length to load
  78606. * @returns A promise that resolves when the load is complete
  78607. */
  78608. loadAsync(byteLength: number): Promise<void>;
  78609. /**
  78610. * Read a unsigned 32-bit integer from the currently loaded data range.
  78611. * @returns The 32-bit integer read
  78612. */
  78613. readUint32(): number;
  78614. /**
  78615. * Read a byte array from the currently loaded data range.
  78616. * @param byteLength The byte length to read
  78617. * @returns The byte array read
  78618. */
  78619. readUint8Array(byteLength: number): Uint8Array;
  78620. /**
  78621. * Read a string from the currently loaded data range.
  78622. * @param byteLength The byte length to read
  78623. * @returns The string read
  78624. */
  78625. readString(byteLength: number): string;
  78626. /**
  78627. * Skips the given byte length the currently loaded data range.
  78628. * @param byteLength The byte length to skip
  78629. */
  78630. skipBytes(byteLength: number): void;
  78631. }
  78632. }
  78633. declare module "babylonjs/Misc/dataStorage" {
  78634. /**
  78635. * Class for storing data to local storage if available or in-memory storage otherwise
  78636. */
  78637. export class DataStorage {
  78638. private static _Storage;
  78639. private static _GetStorage;
  78640. /**
  78641. * Reads a string from the data storage
  78642. * @param key The key to read
  78643. * @param defaultValue The value if the key doesn't exist
  78644. * @returns The string value
  78645. */
  78646. static ReadString(key: string, defaultValue: string): string;
  78647. /**
  78648. * Writes a string to the data storage
  78649. * @param key The key to write
  78650. * @param value The value to write
  78651. */
  78652. static WriteString(key: string, value: string): void;
  78653. /**
  78654. * Reads a boolean from the data storage
  78655. * @param key The key to read
  78656. * @param defaultValue The value if the key doesn't exist
  78657. * @returns The boolean value
  78658. */
  78659. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78660. /**
  78661. * Writes a boolean to the data storage
  78662. * @param key The key to write
  78663. * @param value The value to write
  78664. */
  78665. static WriteBoolean(key: string, value: boolean): void;
  78666. /**
  78667. * Reads a number from the data storage
  78668. * @param key The key to read
  78669. * @param defaultValue The value if the key doesn't exist
  78670. * @returns The number value
  78671. */
  78672. static ReadNumber(key: string, defaultValue: number): number;
  78673. /**
  78674. * Writes a number to the data storage
  78675. * @param key The key to write
  78676. * @param value The value to write
  78677. */
  78678. static WriteNumber(key: string, value: number): void;
  78679. }
  78680. }
  78681. declare module "babylonjs/Misc/sceneRecorder" {
  78682. import { Scene } from "babylonjs/scene";
  78683. /**
  78684. * Class used to record delta files between 2 scene states
  78685. */
  78686. export class SceneRecorder {
  78687. private _trackedScene;
  78688. private _savedJSON;
  78689. /**
  78690. * Track a given scene. This means the current scene state will be considered the original state
  78691. * @param scene defines the scene to track
  78692. */
  78693. track(scene: Scene): void;
  78694. /**
  78695. * Get the delta between current state and original state
  78696. * @returns a string containing the delta
  78697. */
  78698. getDelta(): any;
  78699. private _compareArray;
  78700. private _compareObjects;
  78701. private _compareCollections;
  78702. private static GetShadowGeneratorById;
  78703. /**
  78704. * Apply a given delta to a given scene
  78705. * @param deltaJSON defines the JSON containing the delta
  78706. * @param scene defines the scene to apply the delta to
  78707. */
  78708. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78709. private static _ApplyPropertiesToEntity;
  78710. private static _ApplyDeltaForEntity;
  78711. }
  78712. }
  78713. declare module "babylonjs/Misc/trajectoryClassifier" {
  78714. import { DeepImmutable, Nullable } from "babylonjs/types";
  78715. import { Vector3 } from "babylonjs/Maths/math.vector";
  78716. /**
  78717. * A 3D trajectory consisting of an order list of vectors describing a
  78718. * path of motion through 3D space.
  78719. */
  78720. export class Trajectory {
  78721. private _points;
  78722. private readonly _segmentLength;
  78723. /**
  78724. * Serialize to JSON.
  78725. * @returns serialized JSON string
  78726. */
  78727. serialize(): string;
  78728. /**
  78729. * Deserialize from JSON.
  78730. * @param json serialized JSON string
  78731. * @returns deserialized Trajectory
  78732. */
  78733. static Deserialize(json: string): Trajectory;
  78734. /**
  78735. * Create a new empty Trajectory.
  78736. * @param segmentLength radius of discretization for Trajectory points
  78737. */
  78738. constructor(segmentLength?: number);
  78739. /**
  78740. * Get the length of the Trajectory.
  78741. * @returns length of the Trajectory
  78742. */
  78743. getLength(): number;
  78744. /**
  78745. * Append a new point to the Trajectory.
  78746. * NOTE: This implementation has many allocations.
  78747. * @param point point to append to the Trajectory
  78748. */
  78749. add(point: DeepImmutable<Vector3>): void;
  78750. /**
  78751. * Create a new Trajectory with a segment length chosen to make it
  78752. * probable that the new Trajectory will have a specified number of
  78753. * segments. This operation is imprecise.
  78754. * @param targetResolution number of segments desired
  78755. * @returns new Trajectory with approximately the requested number of segments
  78756. */
  78757. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78758. /**
  78759. * Convert Trajectory segments into tokenized representation. This
  78760. * representation is an array of numbers where each nth number is the
  78761. * index of the token which is most similar to the nth segment of the
  78762. * Trajectory.
  78763. * @param tokens list of vectors which serve as discrete tokens
  78764. * @returns list of indices of most similar token per segment
  78765. */
  78766. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78767. private static _forwardDir;
  78768. private static _inverseFromVec;
  78769. private static _upDir;
  78770. private static _fromToVec;
  78771. private static _lookMatrix;
  78772. /**
  78773. * Transform the rotation (i.e., direction) of a segment to isolate
  78774. * the relative transformation represented by the segment. This operation
  78775. * may or may not succeed due to singularities in the equations that define
  78776. * motion relativity in this context.
  78777. * @param priorVec the origin of the prior segment
  78778. * @param fromVec the origin of the current segment
  78779. * @param toVec the destination of the current segment
  78780. * @param result reference to output variable
  78781. * @returns whether or not transformation was successful
  78782. */
  78783. private static _transformSegmentDirToRef;
  78784. private static _bestMatch;
  78785. private static _score;
  78786. private static _bestScore;
  78787. /**
  78788. * Determine which token vector is most similar to the
  78789. * segment vector.
  78790. * @param segment segment vector
  78791. * @param tokens token vector list
  78792. * @returns index of the most similar token to the segment
  78793. */
  78794. private static _tokenizeSegment;
  78795. }
  78796. /**
  78797. * Class representing a set of known, named trajectories to which Trajectories can be
  78798. * added and using which Trajectories can be recognized.
  78799. */
  78800. export class TrajectoryClassifier {
  78801. private _maximumAllowableMatchCost;
  78802. private _vector3Alphabet;
  78803. private _levenshteinAlphabet;
  78804. private _nameToDescribedTrajectory;
  78805. /**
  78806. * Serialize to JSON.
  78807. * @returns JSON serialization
  78808. */
  78809. serialize(): string;
  78810. /**
  78811. * Deserialize from JSON.
  78812. * @param json JSON serialization
  78813. * @returns deserialized TrajectorySet
  78814. */
  78815. static Deserialize(json: string): TrajectoryClassifier;
  78816. /**
  78817. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78818. * VERY naive, need to be generating these things from known
  78819. * sets. Better version later, probably eliminating this one.
  78820. * @returns auto-generated TrajectorySet
  78821. */
  78822. static Generate(): TrajectoryClassifier;
  78823. private constructor();
  78824. /**
  78825. * Add a new Trajectory to the set with a given name.
  78826. * @param trajectory new Trajectory to be added
  78827. * @param classification name to which to add the Trajectory
  78828. */
  78829. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78830. /**
  78831. * Remove a known named trajectory and all Trajectories associated with it.
  78832. * @param classification name to remove
  78833. * @returns whether anything was removed
  78834. */
  78835. deleteClassification(classification: string): boolean;
  78836. /**
  78837. * Attempt to recognize a Trajectory from among all the classifications
  78838. * already known to the classifier.
  78839. * @param trajectory Trajectory to be recognized
  78840. * @returns classification of Trajectory if recognized, null otherwise
  78841. */
  78842. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78843. }
  78844. }
  78845. declare module "babylonjs/Misc/index" {
  78846. export * from "babylonjs/Misc/andOrNotEvaluator";
  78847. export * from "babylonjs/Misc/assetsManager";
  78848. export * from "babylonjs/Misc/basis";
  78849. export * from "babylonjs/Misc/dds";
  78850. export * from "babylonjs/Misc/decorators";
  78851. export * from "babylonjs/Misc/deferred";
  78852. export * from "babylonjs/Misc/environmentTextureTools";
  78853. export * from "babylonjs/Misc/meshExploder";
  78854. export * from "babylonjs/Misc/filesInput";
  78855. export * from "babylonjs/Misc/HighDynamicRange/index";
  78856. export * from "babylonjs/Misc/khronosTextureContainer";
  78857. export * from "babylonjs/Misc/observable";
  78858. export * from "babylonjs/Misc/performanceMonitor";
  78859. export * from "babylonjs/Misc/promise";
  78860. export * from "babylonjs/Misc/sceneOptimizer";
  78861. export * from "babylonjs/Misc/sceneSerializer";
  78862. export * from "babylonjs/Misc/smartArray";
  78863. export * from "babylonjs/Misc/stringDictionary";
  78864. export * from "babylonjs/Misc/tags";
  78865. export * from "babylonjs/Misc/textureTools";
  78866. export * from "babylonjs/Misc/tga";
  78867. export * from "babylonjs/Misc/tools";
  78868. export * from "babylonjs/Misc/videoRecorder";
  78869. export * from "babylonjs/Misc/virtualJoystick";
  78870. export * from "babylonjs/Misc/workerPool";
  78871. export * from "babylonjs/Misc/logger";
  78872. export * from "babylonjs/Misc/typeStore";
  78873. export * from "babylonjs/Misc/filesInputStore";
  78874. export * from "babylonjs/Misc/deepCopier";
  78875. export * from "babylonjs/Misc/pivotTools";
  78876. export * from "babylonjs/Misc/precisionDate";
  78877. export * from "babylonjs/Misc/screenshotTools";
  78878. export * from "babylonjs/Misc/typeStore";
  78879. export * from "babylonjs/Misc/webRequest";
  78880. export * from "babylonjs/Misc/iInspectable";
  78881. export * from "babylonjs/Misc/brdfTextureTools";
  78882. export * from "babylonjs/Misc/rgbdTextureTools";
  78883. export * from "babylonjs/Misc/gradients";
  78884. export * from "babylonjs/Misc/perfCounter";
  78885. export * from "babylonjs/Misc/fileRequest";
  78886. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78887. export * from "babylonjs/Misc/retryStrategy";
  78888. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78889. export * from "babylonjs/Misc/canvasGenerator";
  78890. export * from "babylonjs/Misc/fileTools";
  78891. export * from "babylonjs/Misc/stringTools";
  78892. export * from "babylonjs/Misc/dataReader";
  78893. export * from "babylonjs/Misc/minMaxReducer";
  78894. export * from "babylonjs/Misc/depthReducer";
  78895. export * from "babylonjs/Misc/dataStorage";
  78896. export * from "babylonjs/Misc/sceneRecorder";
  78897. export * from "babylonjs/Misc/khronosTextureContainer2";
  78898. export * from "babylonjs/Misc/trajectoryClassifier";
  78899. }
  78900. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78901. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78902. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78903. import { Observable } from "babylonjs/Misc/observable";
  78904. import { Matrix } from "babylonjs/Maths/math.vector";
  78905. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78906. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78907. /**
  78908. * An interface for all Hit test features
  78909. */
  78910. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78911. /**
  78912. * Triggered when new babylon (transformed) hit test results are available
  78913. */
  78914. onHitTestResultObservable: Observable<T[]>;
  78915. }
  78916. /**
  78917. * Options used for hit testing
  78918. */
  78919. export interface IWebXRLegacyHitTestOptions {
  78920. /**
  78921. * Only test when user interacted with the scene. Default - hit test every frame
  78922. */
  78923. testOnPointerDownOnly?: boolean;
  78924. /**
  78925. * The node to use to transform the local results to world coordinates
  78926. */
  78927. worldParentNode?: TransformNode;
  78928. }
  78929. /**
  78930. * Interface defining the babylon result of raycasting/hit-test
  78931. */
  78932. export interface IWebXRLegacyHitResult {
  78933. /**
  78934. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78935. */
  78936. transformationMatrix: Matrix;
  78937. /**
  78938. * The native hit test result
  78939. */
  78940. xrHitResult: XRHitResult | XRHitTestResult;
  78941. }
  78942. /**
  78943. * The currently-working hit-test module.
  78944. * Hit test (or Ray-casting) is used to interact with the real world.
  78945. * For further information read here - https://github.com/immersive-web/hit-test
  78946. */
  78947. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78948. /**
  78949. * options to use when constructing this feature
  78950. */
  78951. readonly options: IWebXRLegacyHitTestOptions;
  78952. private _direction;
  78953. private _mat;
  78954. private _onSelectEnabled;
  78955. private _origin;
  78956. /**
  78957. * The module's name
  78958. */
  78959. static readonly Name: string;
  78960. /**
  78961. * The (Babylon) version of this module.
  78962. * This is an integer representing the implementation version.
  78963. * This number does not correspond to the WebXR specs version
  78964. */
  78965. static readonly Version: number;
  78966. /**
  78967. * Populated with the last native XR Hit Results
  78968. */
  78969. lastNativeXRHitResults: XRHitResult[];
  78970. /**
  78971. * Triggered when new babylon (transformed) hit test results are available
  78972. */
  78973. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78974. /**
  78975. * Creates a new instance of the (legacy version) hit test feature
  78976. * @param _xrSessionManager an instance of WebXRSessionManager
  78977. * @param options options to use when constructing this feature
  78978. */
  78979. constructor(_xrSessionManager: WebXRSessionManager,
  78980. /**
  78981. * options to use when constructing this feature
  78982. */
  78983. options?: IWebXRLegacyHitTestOptions);
  78984. /**
  78985. * execute a hit test with an XR Ray
  78986. *
  78987. * @param xrSession a native xrSession that will execute this hit test
  78988. * @param xrRay the ray (position and direction) to use for ray-casting
  78989. * @param referenceSpace native XR reference space to use for the hit-test
  78990. * @param filter filter function that will filter the results
  78991. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78992. */
  78993. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78994. /**
  78995. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78996. * @param event the (select) event to use to select with
  78997. * @param referenceSpace the reference space to use for this hit test
  78998. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78999. */
  79000. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79001. /**
  79002. * attach this feature
  79003. * Will usually be called by the features manager
  79004. *
  79005. * @returns true if successful.
  79006. */
  79007. attach(): boolean;
  79008. /**
  79009. * detach this feature.
  79010. * Will usually be called by the features manager
  79011. *
  79012. * @returns true if successful.
  79013. */
  79014. detach(): boolean;
  79015. /**
  79016. * Dispose this feature and all of the resources attached
  79017. */
  79018. dispose(): void;
  79019. protected _onXRFrame(frame: XRFrame): void;
  79020. private _onHitTestResults;
  79021. private _onSelect;
  79022. }
  79023. }
  79024. declare module "babylonjs/XR/features/WebXRHitTest" {
  79025. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79026. import { Observable } from "babylonjs/Misc/observable";
  79027. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79028. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79029. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79030. /**
  79031. * Options used for hit testing (version 2)
  79032. */
  79033. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79034. /**
  79035. * Do not create a permanent hit test. Will usually be used when only
  79036. * transient inputs are needed.
  79037. */
  79038. disablePermanentHitTest?: boolean;
  79039. /**
  79040. * Enable transient (for example touch-based) hit test inspections
  79041. */
  79042. enableTransientHitTest?: boolean;
  79043. /**
  79044. * Offset ray for the permanent hit test
  79045. */
  79046. offsetRay?: Vector3;
  79047. /**
  79048. * Offset ray for the transient hit test
  79049. */
  79050. transientOffsetRay?: Vector3;
  79051. /**
  79052. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79053. */
  79054. useReferenceSpace?: boolean;
  79055. /**
  79056. * Override the default entity type(s) of the hit-test result
  79057. */
  79058. entityTypes?: XRHitTestTrackableType[];
  79059. }
  79060. /**
  79061. * Interface defining the babylon result of hit-test
  79062. */
  79063. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79064. /**
  79065. * The input source that generated this hit test (if transient)
  79066. */
  79067. inputSource?: XRInputSource;
  79068. /**
  79069. * Is this a transient hit test
  79070. */
  79071. isTransient?: boolean;
  79072. /**
  79073. * Position of the hit test result
  79074. */
  79075. position: Vector3;
  79076. /**
  79077. * Rotation of the hit test result
  79078. */
  79079. rotationQuaternion: Quaternion;
  79080. /**
  79081. * The native hit test result
  79082. */
  79083. xrHitResult: XRHitTestResult;
  79084. }
  79085. /**
  79086. * The currently-working hit-test module.
  79087. * Hit test (or Ray-casting) is used to interact with the real world.
  79088. * For further information read here - https://github.com/immersive-web/hit-test
  79089. *
  79090. * Tested on chrome (mobile) 80.
  79091. */
  79092. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79093. /**
  79094. * options to use when constructing this feature
  79095. */
  79096. readonly options: IWebXRHitTestOptions;
  79097. private _tmpMat;
  79098. private _tmpPos;
  79099. private _tmpQuat;
  79100. private _transientXrHitTestSource;
  79101. private _xrHitTestSource;
  79102. private initHitTestSource;
  79103. /**
  79104. * The module's name
  79105. */
  79106. static readonly Name: string;
  79107. /**
  79108. * The (Babylon) version of this module.
  79109. * This is an integer representing the implementation version.
  79110. * This number does not correspond to the WebXR specs version
  79111. */
  79112. static readonly Version: number;
  79113. /**
  79114. * When set to true, each hit test will have its own position/rotation objects
  79115. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79116. * the developers will clone them or copy them as they see fit.
  79117. */
  79118. autoCloneTransformation: boolean;
  79119. /**
  79120. * Triggered when new babylon (transformed) hit test results are available
  79121. * Note - this will be called when results come back from the device. It can be an empty array!!
  79122. */
  79123. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79124. /**
  79125. * Use this to temporarily pause hit test checks.
  79126. */
  79127. paused: boolean;
  79128. /**
  79129. * Creates a new instance of the hit test feature
  79130. * @param _xrSessionManager an instance of WebXRSessionManager
  79131. * @param options options to use when constructing this feature
  79132. */
  79133. constructor(_xrSessionManager: WebXRSessionManager,
  79134. /**
  79135. * options to use when constructing this feature
  79136. */
  79137. options?: IWebXRHitTestOptions);
  79138. /**
  79139. * attach this feature
  79140. * Will usually be called by the features manager
  79141. *
  79142. * @returns true if successful.
  79143. */
  79144. attach(): boolean;
  79145. /**
  79146. * detach this feature.
  79147. * Will usually be called by the features manager
  79148. *
  79149. * @returns true if successful.
  79150. */
  79151. detach(): boolean;
  79152. /**
  79153. * Dispose this feature and all of the resources attached
  79154. */
  79155. dispose(): void;
  79156. protected _onXRFrame(frame: XRFrame): void;
  79157. private _processWebXRHitTestResult;
  79158. }
  79159. }
  79160. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79161. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79162. import { Observable } from "babylonjs/Misc/observable";
  79163. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79165. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79166. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79167. /**
  79168. * Configuration options of the anchor system
  79169. */
  79170. export interface IWebXRAnchorSystemOptions {
  79171. /**
  79172. * a node that will be used to convert local to world coordinates
  79173. */
  79174. worldParentNode?: TransformNode;
  79175. /**
  79176. * If set to true a reference of the created anchors will be kept until the next session starts
  79177. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79178. */
  79179. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79180. }
  79181. /**
  79182. * A babylon container for an XR Anchor
  79183. */
  79184. export interface IWebXRAnchor {
  79185. /**
  79186. * A babylon-assigned ID for this anchor
  79187. */
  79188. id: number;
  79189. /**
  79190. * Transformation matrix to apply to an object attached to this anchor
  79191. */
  79192. transformationMatrix: Matrix;
  79193. /**
  79194. * The native anchor object
  79195. */
  79196. xrAnchor: XRAnchor;
  79197. /**
  79198. * if defined, this object will be constantly updated by the anchor's position and rotation
  79199. */
  79200. attachedNode?: TransformNode;
  79201. }
  79202. /**
  79203. * An implementation of the anchor system for WebXR.
  79204. * For further information see https://github.com/immersive-web/anchors/
  79205. */
  79206. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79207. private _options;
  79208. private _lastFrameDetected;
  79209. private _trackedAnchors;
  79210. private _referenceSpaceForFrameAnchors;
  79211. private _futureAnchors;
  79212. /**
  79213. * The module's name
  79214. */
  79215. static readonly Name: string;
  79216. /**
  79217. * The (Babylon) version of this module.
  79218. * This is an integer representing the implementation version.
  79219. * This number does not correspond to the WebXR specs version
  79220. */
  79221. static readonly Version: number;
  79222. /**
  79223. * Observers registered here will be executed when a new anchor was added to the session
  79224. */
  79225. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79226. /**
  79227. * Observers registered here will be executed when an anchor was removed from the session
  79228. */
  79229. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79230. /**
  79231. * Observers registered here will be executed when an existing anchor updates
  79232. * This can execute N times every frame
  79233. */
  79234. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79235. /**
  79236. * Set the reference space to use for anchor creation, when not using a hit test.
  79237. * Will default to the session's reference space if not defined
  79238. */
  79239. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79240. /**
  79241. * constructs a new anchor system
  79242. * @param _xrSessionManager an instance of WebXRSessionManager
  79243. * @param _options configuration object for this feature
  79244. */
  79245. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79246. private _tmpVector;
  79247. private _tmpQuaternion;
  79248. private _populateTmpTransformation;
  79249. /**
  79250. * Create a new anchor point using a hit test result at a specific point in the scene
  79251. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79252. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79253. *
  79254. * @param hitTestResult The hit test result to use for this anchor creation
  79255. * @param position an optional position offset for this anchor
  79256. * @param rotationQuaternion an optional rotation offset for this anchor
  79257. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79258. */
  79259. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79260. /**
  79261. * Add a new anchor at a specific position and rotation
  79262. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79263. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79264. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79265. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79266. *
  79267. * @param position the position in which to add an anchor
  79268. * @param rotationQuaternion an optional rotation for the anchor transformation
  79269. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79270. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79271. */
  79272. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79273. /**
  79274. * detach this feature.
  79275. * Will usually be called by the features manager
  79276. *
  79277. * @returns true if successful.
  79278. */
  79279. detach(): boolean;
  79280. /**
  79281. * Dispose this feature and all of the resources attached
  79282. */
  79283. dispose(): void;
  79284. protected _onXRFrame(frame: XRFrame): void;
  79285. /**
  79286. * avoiding using Array.find for global support.
  79287. * @param xrAnchor the plane to find in the array
  79288. */
  79289. private _findIndexInAnchorArray;
  79290. private _updateAnchorWithXRFrame;
  79291. private _createAnchorAtTransformation;
  79292. }
  79293. }
  79294. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79296. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79297. import { Observable } from "babylonjs/Misc/observable";
  79298. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79299. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79300. /**
  79301. * Options used in the plane detector module
  79302. */
  79303. export interface IWebXRPlaneDetectorOptions {
  79304. /**
  79305. * The node to use to transform the local results to world coordinates
  79306. */
  79307. worldParentNode?: TransformNode;
  79308. /**
  79309. * If set to true a reference of the created planes will be kept until the next session starts
  79310. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79311. */
  79312. doNotRemovePlanesOnSessionEnded?: boolean;
  79313. }
  79314. /**
  79315. * A babylon interface for a WebXR plane.
  79316. * A Plane is actually a polygon, built from N points in space
  79317. *
  79318. * Supported in chrome 79, not supported in canary 81 ATM
  79319. */
  79320. export interface IWebXRPlane {
  79321. /**
  79322. * a babylon-assigned ID for this polygon
  79323. */
  79324. id: number;
  79325. /**
  79326. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79327. */
  79328. polygonDefinition: Array<Vector3>;
  79329. /**
  79330. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79331. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79332. */
  79333. transformationMatrix: Matrix;
  79334. /**
  79335. * the native xr-plane object
  79336. */
  79337. xrPlane: XRPlane;
  79338. }
  79339. /**
  79340. * The plane detector is used to detect planes in the real world when in AR
  79341. * For more information see https://github.com/immersive-web/real-world-geometry/
  79342. */
  79343. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79344. private _options;
  79345. private _detectedPlanes;
  79346. private _enabled;
  79347. private _lastFrameDetected;
  79348. /**
  79349. * The module's name
  79350. */
  79351. static readonly Name: string;
  79352. /**
  79353. * The (Babylon) version of this module.
  79354. * This is an integer representing the implementation version.
  79355. * This number does not correspond to the WebXR specs version
  79356. */
  79357. static readonly Version: number;
  79358. /**
  79359. * Observers registered here will be executed when a new plane was added to the session
  79360. */
  79361. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79362. /**
  79363. * Observers registered here will be executed when a plane is no longer detected in the session
  79364. */
  79365. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79366. /**
  79367. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79368. * This can execute N times every frame
  79369. */
  79370. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79371. /**
  79372. * construct a new Plane Detector
  79373. * @param _xrSessionManager an instance of xr Session manager
  79374. * @param _options configuration to use when constructing this feature
  79375. */
  79376. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79377. /**
  79378. * detach this feature.
  79379. * Will usually be called by the features manager
  79380. *
  79381. * @returns true if successful.
  79382. */
  79383. detach(): boolean;
  79384. /**
  79385. * Dispose this feature and all of the resources attached
  79386. */
  79387. dispose(): void;
  79388. protected _onXRFrame(frame: XRFrame): void;
  79389. private _init;
  79390. private _updatePlaneWithXRPlane;
  79391. /**
  79392. * avoiding using Array.find for global support.
  79393. * @param xrPlane the plane to find in the array
  79394. */
  79395. private findIndexInPlaneArray;
  79396. }
  79397. }
  79398. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79401. import { Observable } from "babylonjs/Misc/observable";
  79402. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79403. /**
  79404. * Options interface for the background remover plugin
  79405. */
  79406. export interface IWebXRBackgroundRemoverOptions {
  79407. /**
  79408. * Further background meshes to disable when entering AR
  79409. */
  79410. backgroundMeshes?: AbstractMesh[];
  79411. /**
  79412. * flags to configure the removal of the environment helper.
  79413. * If not set, the entire background will be removed. If set, flags should be set as well.
  79414. */
  79415. environmentHelperRemovalFlags?: {
  79416. /**
  79417. * Should the skybox be removed (default false)
  79418. */
  79419. skyBox?: boolean;
  79420. /**
  79421. * Should the ground be removed (default false)
  79422. */
  79423. ground?: boolean;
  79424. };
  79425. /**
  79426. * don't disable the environment helper
  79427. */
  79428. ignoreEnvironmentHelper?: boolean;
  79429. }
  79430. /**
  79431. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79432. */
  79433. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79434. /**
  79435. * read-only options to be used in this module
  79436. */
  79437. readonly options: IWebXRBackgroundRemoverOptions;
  79438. /**
  79439. * The module's name
  79440. */
  79441. static readonly Name: string;
  79442. /**
  79443. * The (Babylon) version of this module.
  79444. * This is an integer representing the implementation version.
  79445. * This number does not correspond to the WebXR specs version
  79446. */
  79447. static readonly Version: number;
  79448. /**
  79449. * registered observers will be triggered when the background state changes
  79450. */
  79451. onBackgroundStateChangedObservable: Observable<boolean>;
  79452. /**
  79453. * constructs a new background remover module
  79454. * @param _xrSessionManager the session manager for this module
  79455. * @param options read-only options to be used in this module
  79456. */
  79457. constructor(_xrSessionManager: WebXRSessionManager,
  79458. /**
  79459. * read-only options to be used in this module
  79460. */
  79461. options?: IWebXRBackgroundRemoverOptions);
  79462. /**
  79463. * attach this feature
  79464. * Will usually be called by the features manager
  79465. *
  79466. * @returns true if successful.
  79467. */
  79468. attach(): boolean;
  79469. /**
  79470. * detach this feature.
  79471. * Will usually be called by the features manager
  79472. *
  79473. * @returns true if successful.
  79474. */
  79475. detach(): boolean;
  79476. /**
  79477. * Dispose this feature and all of the resources attached
  79478. */
  79479. dispose(): void;
  79480. protected _onXRFrame(_xrFrame: XRFrame): void;
  79481. private _setBackgroundState;
  79482. }
  79483. }
  79484. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79485. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79486. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79487. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79488. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79489. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79490. import { Nullable } from "babylonjs/types";
  79491. /**
  79492. * Options for the controller physics feature
  79493. */
  79494. export class IWebXRControllerPhysicsOptions {
  79495. /**
  79496. * Should the headset get its own impostor
  79497. */
  79498. enableHeadsetImpostor?: boolean;
  79499. /**
  79500. * Optional parameters for the headset impostor
  79501. */
  79502. headsetImpostorParams?: {
  79503. /**
  79504. * The type of impostor to create. Default is sphere
  79505. */
  79506. impostorType: number;
  79507. /**
  79508. * the size of the impostor. Defaults to 10cm
  79509. */
  79510. impostorSize?: number | {
  79511. width: number;
  79512. height: number;
  79513. depth: number;
  79514. };
  79515. /**
  79516. * Friction definitions
  79517. */
  79518. friction?: number;
  79519. /**
  79520. * Restitution
  79521. */
  79522. restitution?: number;
  79523. };
  79524. /**
  79525. * The physics properties of the future impostors
  79526. */
  79527. physicsProperties?: {
  79528. /**
  79529. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79530. * Note that this requires a physics engine that supports mesh impostors!
  79531. */
  79532. useControllerMesh?: boolean;
  79533. /**
  79534. * The type of impostor to create. Default is sphere
  79535. */
  79536. impostorType?: number;
  79537. /**
  79538. * the size of the impostor. Defaults to 10cm
  79539. */
  79540. impostorSize?: number | {
  79541. width: number;
  79542. height: number;
  79543. depth: number;
  79544. };
  79545. /**
  79546. * Friction definitions
  79547. */
  79548. friction?: number;
  79549. /**
  79550. * Restitution
  79551. */
  79552. restitution?: number;
  79553. };
  79554. /**
  79555. * the xr input to use with this pointer selection
  79556. */
  79557. xrInput: WebXRInput;
  79558. }
  79559. /**
  79560. * Add physics impostor to your webxr controllers,
  79561. * including naive calculation of their linear and angular velocity
  79562. */
  79563. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79564. private readonly _options;
  79565. private _attachController;
  79566. private _controllers;
  79567. private _debugMode;
  79568. private _delta;
  79569. private _headsetImpostor?;
  79570. private _headsetMesh?;
  79571. private _lastTimestamp;
  79572. private _tmpQuaternion;
  79573. private _tmpVector;
  79574. /**
  79575. * The module's name
  79576. */
  79577. static readonly Name: string;
  79578. /**
  79579. * The (Babylon) version of this module.
  79580. * This is an integer representing the implementation version.
  79581. * This number does not correspond to the webxr specs version
  79582. */
  79583. static readonly Version: number;
  79584. /**
  79585. * Construct a new Controller Physics Feature
  79586. * @param _xrSessionManager the corresponding xr session manager
  79587. * @param _options options to create this feature with
  79588. */
  79589. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79590. /**
  79591. * @hidden
  79592. * enable debugging - will show console outputs and the impostor mesh
  79593. */
  79594. _enablePhysicsDebug(): void;
  79595. /**
  79596. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79597. * @param xrController the controller to add
  79598. */
  79599. addController(xrController: WebXRInputSource): void;
  79600. /**
  79601. * attach this feature
  79602. * Will usually be called by the features manager
  79603. *
  79604. * @returns true if successful.
  79605. */
  79606. attach(): boolean;
  79607. /**
  79608. * detach this feature.
  79609. * Will usually be called by the features manager
  79610. *
  79611. * @returns true if successful.
  79612. */
  79613. detach(): boolean;
  79614. /**
  79615. * Get the headset impostor, if enabled
  79616. * @returns the impostor
  79617. */
  79618. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79619. /**
  79620. * Get the physics impostor of a specific controller.
  79621. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79622. * @param controller the controller or the controller id of which to get the impostor
  79623. * @returns the impostor or null
  79624. */
  79625. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79626. /**
  79627. * Update the physics properties provided in the constructor
  79628. * @param newProperties the new properties object
  79629. */
  79630. setPhysicsProperties(newProperties: {
  79631. impostorType?: number;
  79632. impostorSize?: number | {
  79633. width: number;
  79634. height: number;
  79635. depth: number;
  79636. };
  79637. friction?: number;
  79638. restitution?: number;
  79639. }): void;
  79640. protected _onXRFrame(_xrFrame: any): void;
  79641. private _detachController;
  79642. }
  79643. }
  79644. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79645. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79646. import { Observable } from "babylonjs/Misc/observable";
  79647. import { Vector3 } from "babylonjs/Maths/math.vector";
  79648. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79649. /**
  79650. * A babylon interface for a "WebXR" feature point.
  79651. * Represents the position and confidence value of a given feature point.
  79652. */
  79653. export interface IWebXRFeaturePoint {
  79654. /**
  79655. * Represents the position of the feature point in world space.
  79656. */
  79657. position: Vector3;
  79658. /**
  79659. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79660. */
  79661. confidenceValue: number;
  79662. }
  79663. /**
  79664. * The feature point system is used to detect feature points from real world geometry.
  79665. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79666. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79667. */
  79668. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79669. private _enabled;
  79670. private _featurePointCloud;
  79671. /**
  79672. * The module's name
  79673. */
  79674. static readonly Name: string;
  79675. /**
  79676. * The (Babylon) version of this module.
  79677. * This is an integer representing the implementation version.
  79678. * This number does not correspond to the WebXR specs version
  79679. */
  79680. static readonly Version: number;
  79681. /**
  79682. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79683. * Will notify the observers about which feature points have been added.
  79684. */
  79685. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79686. /**
  79687. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79688. * Will notify the observers about which feature points have been updated.
  79689. */
  79690. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79691. /**
  79692. * The current feature point cloud maintained across frames.
  79693. */
  79694. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79695. /**
  79696. * construct the feature point system
  79697. * @param _xrSessionManager an instance of xr Session manager
  79698. */
  79699. constructor(_xrSessionManager: WebXRSessionManager);
  79700. /**
  79701. * Detach this feature.
  79702. * Will usually be called by the features manager
  79703. *
  79704. * @returns true if successful.
  79705. */
  79706. detach(): boolean;
  79707. /**
  79708. * Dispose this feature and all of the resources attached
  79709. */
  79710. dispose(): void;
  79711. /**
  79712. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79713. */
  79714. protected _onXRFrame(frame: XRFrame): void;
  79715. /**
  79716. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79717. */
  79718. private _init;
  79719. }
  79720. }
  79721. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79722. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79723. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79725. import { Mesh } from "babylonjs/Meshes/mesh";
  79726. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79727. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79728. import { Nullable } from "babylonjs/types";
  79729. import { IDisposable } from "babylonjs/scene";
  79730. import { Observable } from "babylonjs/Misc/observable";
  79731. /**
  79732. * Configuration interface for the hand tracking feature
  79733. */
  79734. export interface IWebXRHandTrackingOptions {
  79735. /**
  79736. * The xrInput that will be used as source for new hands
  79737. */
  79738. xrInput: WebXRInput;
  79739. /**
  79740. * Configuration object for the joint meshes
  79741. */
  79742. jointMeshes?: {
  79743. /**
  79744. * Should the meshes created be invisible (defaults to false)
  79745. */
  79746. invisible?: boolean;
  79747. /**
  79748. * A source mesh to be used to create instances. Defaults to a sphere.
  79749. * This mesh will be the source for all other (25) meshes.
  79750. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79751. */
  79752. sourceMesh?: Mesh;
  79753. /**
  79754. * Should the source mesh stay visible. Defaults to false
  79755. */
  79756. keepOriginalVisible?: boolean;
  79757. /**
  79758. * Scale factor for all instances (defaults to 2)
  79759. */
  79760. scaleFactor?: number;
  79761. /**
  79762. * Should each instance have its own physics impostor
  79763. */
  79764. enablePhysics?: boolean;
  79765. /**
  79766. * If enabled, override default physics properties
  79767. */
  79768. physicsProps?: {
  79769. friction?: number;
  79770. restitution?: number;
  79771. impostorType?: number;
  79772. };
  79773. /**
  79774. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79775. */
  79776. handMesh?: AbstractMesh;
  79777. };
  79778. }
  79779. /**
  79780. * Parts of the hands divided to writs and finger names
  79781. */
  79782. export const enum HandPart {
  79783. /**
  79784. * HandPart - Wrist
  79785. */
  79786. WRIST = "wrist",
  79787. /**
  79788. * HandPart - The THumb
  79789. */
  79790. THUMB = "thumb",
  79791. /**
  79792. * HandPart - Index finger
  79793. */
  79794. INDEX = "index",
  79795. /**
  79796. * HandPart - Middle finger
  79797. */
  79798. MIDDLE = "middle",
  79799. /**
  79800. * HandPart - Ring finger
  79801. */
  79802. RING = "ring",
  79803. /**
  79804. * HandPart - Little finger
  79805. */
  79806. LITTLE = "little"
  79807. }
  79808. /**
  79809. * Representing a single hand (with its corresponding native XRHand object)
  79810. */
  79811. export class WebXRHand implements IDisposable {
  79812. /** the controller to which the hand correlates */
  79813. readonly xrController: WebXRInputSource;
  79814. /** the meshes to be used to track the hand joints */
  79815. readonly trackedMeshes: AbstractMesh[];
  79816. /**
  79817. * Hand-parts definition (key is HandPart)
  79818. */
  79819. handPartsDefinition: {
  79820. [key: string]: number[];
  79821. };
  79822. /**
  79823. * Populate the HandPartsDefinition object.
  79824. * This is called as a side effect since certain browsers don't have XRHand defined.
  79825. */
  79826. private generateHandPartsDefinition;
  79827. /**
  79828. * Construct a new hand object
  79829. * @param xrController the controller to which the hand correlates
  79830. * @param trackedMeshes the meshes to be used to track the hand joints
  79831. */
  79832. constructor(
  79833. /** the controller to which the hand correlates */
  79834. xrController: WebXRInputSource,
  79835. /** the meshes to be used to track the hand joints */
  79836. trackedMeshes: AbstractMesh[]);
  79837. /**
  79838. * Update this hand from the latest xr frame
  79839. * @param xrFrame xrFrame to update from
  79840. * @param referenceSpace The current viewer reference space
  79841. * @param scaleFactor optional scale factor for the meshes
  79842. */
  79843. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79844. /**
  79845. * Get meshes of part of the hand
  79846. * @param part the part of hand to get
  79847. * @returns An array of meshes that correlate to the hand part requested
  79848. */
  79849. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79850. /**
  79851. * Dispose this Hand object
  79852. */
  79853. dispose(): void;
  79854. }
  79855. /**
  79856. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79857. */
  79858. export class WebXRHandTracking extends WebXRAbstractFeature {
  79859. /**
  79860. * options to use when constructing this feature
  79861. */
  79862. readonly options: IWebXRHandTrackingOptions;
  79863. private static _idCounter;
  79864. /**
  79865. * The module's name
  79866. */
  79867. static readonly Name: string;
  79868. /**
  79869. * The (Babylon) version of this module.
  79870. * This is an integer representing the implementation version.
  79871. * This number does not correspond to the WebXR specs version
  79872. */
  79873. static readonly Version: number;
  79874. /**
  79875. * This observable will notify registered observers when a new hand object was added and initialized
  79876. */
  79877. onHandAddedObservable: Observable<WebXRHand>;
  79878. /**
  79879. * This observable will notify its observers right before the hand object is disposed
  79880. */
  79881. onHandRemovedObservable: Observable<WebXRHand>;
  79882. private _hands;
  79883. /**
  79884. * Creates a new instance of the hit test feature
  79885. * @param _xrSessionManager an instance of WebXRSessionManager
  79886. * @param options options to use when constructing this feature
  79887. */
  79888. constructor(_xrSessionManager: WebXRSessionManager,
  79889. /**
  79890. * options to use when constructing this feature
  79891. */
  79892. options: IWebXRHandTrackingOptions);
  79893. /**
  79894. * Check if the needed objects are defined.
  79895. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79896. */
  79897. isCompatible(): boolean;
  79898. /**
  79899. * attach this feature
  79900. * Will usually be called by the features manager
  79901. *
  79902. * @returns true if successful.
  79903. */
  79904. attach(): boolean;
  79905. /**
  79906. * detach this feature.
  79907. * Will usually be called by the features manager
  79908. *
  79909. * @returns true if successful.
  79910. */
  79911. detach(): boolean;
  79912. /**
  79913. * Dispose this feature and all of the resources attached
  79914. */
  79915. dispose(): void;
  79916. /**
  79917. * Get the hand object according to the controller id
  79918. * @param controllerId the controller id to which we want to get the hand
  79919. * @returns null if not found or the WebXRHand object if found
  79920. */
  79921. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79922. /**
  79923. * Get a hand object according to the requested handedness
  79924. * @param handedness the handedness to request
  79925. * @returns null if not found or the WebXRHand object if found
  79926. */
  79927. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79928. protected _onXRFrame(_xrFrame: XRFrame): void;
  79929. private _attachHand;
  79930. private _detachHand;
  79931. }
  79932. }
  79933. declare module "babylonjs/XR/features/index" {
  79934. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79935. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79936. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79937. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79938. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79939. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79940. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79941. export * from "babylonjs/XR/features/WebXRHitTest";
  79942. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79943. export * from "babylonjs/XR/features/WebXRHandTracking";
  79944. }
  79945. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79946. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79948. import { Scene } from "babylonjs/scene";
  79949. /**
  79950. * The motion controller class for all microsoft mixed reality controllers
  79951. */
  79952. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79953. protected readonly _mapping: {
  79954. defaultButton: {
  79955. valueNodeName: string;
  79956. unpressedNodeName: string;
  79957. pressedNodeName: string;
  79958. };
  79959. defaultAxis: {
  79960. valueNodeName: string;
  79961. minNodeName: string;
  79962. maxNodeName: string;
  79963. };
  79964. buttons: {
  79965. "xr-standard-trigger": {
  79966. rootNodeName: string;
  79967. componentProperty: string;
  79968. states: string[];
  79969. };
  79970. "xr-standard-squeeze": {
  79971. rootNodeName: string;
  79972. componentProperty: string;
  79973. states: string[];
  79974. };
  79975. "xr-standard-touchpad": {
  79976. rootNodeName: string;
  79977. labelAnchorNodeName: string;
  79978. touchPointNodeName: string;
  79979. };
  79980. "xr-standard-thumbstick": {
  79981. rootNodeName: string;
  79982. componentProperty: string;
  79983. states: string[];
  79984. };
  79985. };
  79986. axes: {
  79987. "xr-standard-touchpad": {
  79988. "x-axis": {
  79989. rootNodeName: string;
  79990. };
  79991. "y-axis": {
  79992. rootNodeName: string;
  79993. };
  79994. };
  79995. "xr-standard-thumbstick": {
  79996. "x-axis": {
  79997. rootNodeName: string;
  79998. };
  79999. "y-axis": {
  80000. rootNodeName: string;
  80001. };
  80002. };
  80003. };
  80004. };
  80005. /**
  80006. * The base url used to load the left and right controller models
  80007. */
  80008. static MODEL_BASE_URL: string;
  80009. /**
  80010. * The name of the left controller model file
  80011. */
  80012. static MODEL_LEFT_FILENAME: string;
  80013. /**
  80014. * The name of the right controller model file
  80015. */
  80016. static MODEL_RIGHT_FILENAME: string;
  80017. profileId: string;
  80018. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80019. protected _getFilenameAndPath(): {
  80020. filename: string;
  80021. path: string;
  80022. };
  80023. protected _getModelLoadingConstraints(): boolean;
  80024. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80025. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80026. protected _updateModel(): void;
  80027. }
  80028. }
  80029. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80030. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80032. import { Scene } from "babylonjs/scene";
  80033. /**
  80034. * The motion controller class for oculus touch (quest, rift).
  80035. * This class supports legacy mapping as well the standard xr mapping
  80036. */
  80037. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80038. private _forceLegacyControllers;
  80039. private _modelRootNode;
  80040. /**
  80041. * The base url used to load the left and right controller models
  80042. */
  80043. static MODEL_BASE_URL: string;
  80044. /**
  80045. * The name of the left controller model file
  80046. */
  80047. static MODEL_LEFT_FILENAME: string;
  80048. /**
  80049. * The name of the right controller model file
  80050. */
  80051. static MODEL_RIGHT_FILENAME: string;
  80052. /**
  80053. * Base Url for the Quest controller model.
  80054. */
  80055. static QUEST_MODEL_BASE_URL: string;
  80056. profileId: string;
  80057. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80058. protected _getFilenameAndPath(): {
  80059. filename: string;
  80060. path: string;
  80061. };
  80062. protected _getModelLoadingConstraints(): boolean;
  80063. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80064. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80065. protected _updateModel(): void;
  80066. /**
  80067. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80068. * between the touch and touch 2.
  80069. */
  80070. private _isQuest;
  80071. }
  80072. }
  80073. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80074. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80075. import { Scene } from "babylonjs/scene";
  80076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80077. /**
  80078. * The motion controller class for the standard HTC-Vive controllers
  80079. */
  80080. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80081. private _modelRootNode;
  80082. /**
  80083. * The base url used to load the left and right controller models
  80084. */
  80085. static MODEL_BASE_URL: string;
  80086. /**
  80087. * File name for the controller model.
  80088. */
  80089. static MODEL_FILENAME: string;
  80090. profileId: string;
  80091. /**
  80092. * Create a new Vive motion controller object
  80093. * @param scene the scene to use to create this controller
  80094. * @param gamepadObject the corresponding gamepad object
  80095. * @param handedness the handedness of the controller
  80096. */
  80097. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80098. protected _getFilenameAndPath(): {
  80099. filename: string;
  80100. path: string;
  80101. };
  80102. protected _getModelLoadingConstraints(): boolean;
  80103. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80104. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80105. protected _updateModel(): void;
  80106. }
  80107. }
  80108. declare module "babylonjs/XR/motionController/index" {
  80109. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80110. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80111. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80112. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80113. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80114. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80115. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80116. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80117. }
  80118. declare module "babylonjs/XR/index" {
  80119. export * from "babylonjs/XR/webXRCamera";
  80120. export * from "babylonjs/XR/webXREnterExitUI";
  80121. export * from "babylonjs/XR/webXRExperienceHelper";
  80122. export * from "babylonjs/XR/webXRInput";
  80123. export * from "babylonjs/XR/webXRInputSource";
  80124. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80125. export * from "babylonjs/XR/webXRTypes";
  80126. export * from "babylonjs/XR/webXRSessionManager";
  80127. export * from "babylonjs/XR/webXRDefaultExperience";
  80128. export * from "babylonjs/XR/webXRFeaturesManager";
  80129. export * from "babylonjs/XR/features/index";
  80130. export * from "babylonjs/XR/motionController/index";
  80131. }
  80132. declare module "babylonjs/index" {
  80133. export * from "babylonjs/abstractScene";
  80134. export * from "babylonjs/Actions/index";
  80135. export * from "babylonjs/Animations/index";
  80136. export * from "babylonjs/assetContainer";
  80137. export * from "babylonjs/Audio/index";
  80138. export * from "babylonjs/Behaviors/index";
  80139. export * from "babylonjs/Bones/index";
  80140. export * from "babylonjs/Cameras/index";
  80141. export * from "babylonjs/Collisions/index";
  80142. export * from "babylonjs/Culling/index";
  80143. export * from "babylonjs/Debug/index";
  80144. export * from "babylonjs/DeviceInput/index";
  80145. export * from "babylonjs/Engines/index";
  80146. export * from "babylonjs/Events/index";
  80147. export * from "babylonjs/Gamepads/index";
  80148. export * from "babylonjs/Gizmos/index";
  80149. export * from "babylonjs/Helpers/index";
  80150. export * from "babylonjs/Instrumentation/index";
  80151. export * from "babylonjs/Layers/index";
  80152. export * from "babylonjs/LensFlares/index";
  80153. export * from "babylonjs/Lights/index";
  80154. export * from "babylonjs/Loading/index";
  80155. export * from "babylonjs/Materials/index";
  80156. export * from "babylonjs/Maths/index";
  80157. export * from "babylonjs/Meshes/index";
  80158. export * from "babylonjs/Morph/index";
  80159. export * from "babylonjs/Navigation/index";
  80160. export * from "babylonjs/node";
  80161. export * from "babylonjs/Offline/index";
  80162. export * from "babylonjs/Particles/index";
  80163. export * from "babylonjs/Physics/index";
  80164. export * from "babylonjs/PostProcesses/index";
  80165. export * from "babylonjs/Probes/index";
  80166. export * from "babylonjs/Rendering/index";
  80167. export * from "babylonjs/scene";
  80168. export * from "babylonjs/sceneComponent";
  80169. export * from "babylonjs/Sprites/index";
  80170. export * from "babylonjs/States/index";
  80171. export * from "babylonjs/Misc/index";
  80172. export * from "babylonjs/XR/index";
  80173. export * from "babylonjs/types";
  80174. }
  80175. declare module "babylonjs/Animations/pathCursor" {
  80176. import { Vector3 } from "babylonjs/Maths/math.vector";
  80177. import { Path2 } from "babylonjs/Maths/math.path";
  80178. /**
  80179. * A cursor which tracks a point on a path
  80180. */
  80181. export class PathCursor {
  80182. private path;
  80183. /**
  80184. * Stores path cursor callbacks for when an onchange event is triggered
  80185. */
  80186. private _onchange;
  80187. /**
  80188. * The value of the path cursor
  80189. */
  80190. value: number;
  80191. /**
  80192. * The animation array of the path cursor
  80193. */
  80194. animations: Animation[];
  80195. /**
  80196. * Initializes the path cursor
  80197. * @param path The path to track
  80198. */
  80199. constructor(path: Path2);
  80200. /**
  80201. * Gets the cursor point on the path
  80202. * @returns A point on the path cursor at the cursor location
  80203. */
  80204. getPoint(): Vector3;
  80205. /**
  80206. * Moves the cursor ahead by the step amount
  80207. * @param step The amount to move the cursor forward
  80208. * @returns This path cursor
  80209. */
  80210. moveAhead(step?: number): PathCursor;
  80211. /**
  80212. * Moves the cursor behind by the step amount
  80213. * @param step The amount to move the cursor back
  80214. * @returns This path cursor
  80215. */
  80216. moveBack(step?: number): PathCursor;
  80217. /**
  80218. * Moves the cursor by the step amount
  80219. * If the step amount is greater than one, an exception is thrown
  80220. * @param step The amount to move the cursor
  80221. * @returns This path cursor
  80222. */
  80223. move(step: number): PathCursor;
  80224. /**
  80225. * Ensures that the value is limited between zero and one
  80226. * @returns This path cursor
  80227. */
  80228. private ensureLimits;
  80229. /**
  80230. * Runs onchange callbacks on change (used by the animation engine)
  80231. * @returns This path cursor
  80232. */
  80233. private raiseOnChange;
  80234. /**
  80235. * Executes a function on change
  80236. * @param f A path cursor onchange callback
  80237. * @returns This path cursor
  80238. */
  80239. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80240. }
  80241. }
  80242. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80245. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80246. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80247. }
  80248. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80249. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80250. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80251. }
  80252. declare module "babylonjs/Engines/Processors/index" {
  80253. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80254. export * from "babylonjs/Engines/Processors/Expressions/index";
  80255. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80256. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80257. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80258. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80259. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80260. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80261. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80262. }
  80263. declare module "babylonjs/Legacy/legacy" {
  80264. import * as Babylon from "babylonjs/index";
  80265. export * from "babylonjs/index";
  80266. }
  80267. declare module "babylonjs/Shaders/blur.fragment" {
  80268. /** @hidden */
  80269. export var blurPixelShader: {
  80270. name: string;
  80271. shader: string;
  80272. };
  80273. }
  80274. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80275. /** @hidden */
  80276. export var pointCloudVertexDeclaration: {
  80277. name: string;
  80278. shader: string;
  80279. };
  80280. }
  80281. declare module "babylonjs" {
  80282. export * from "babylonjs/Legacy/legacy";
  80283. }
  80284. declare module BABYLON {
  80285. /** Alias type for value that can be null */
  80286. export type Nullable<T> = T | null;
  80287. /**
  80288. * Alias type for number that are floats
  80289. * @ignorenaming
  80290. */
  80291. export type float = number;
  80292. /**
  80293. * Alias type for number that are doubles.
  80294. * @ignorenaming
  80295. */
  80296. export type double = number;
  80297. /**
  80298. * Alias type for number that are integer
  80299. * @ignorenaming
  80300. */
  80301. export type int = number;
  80302. /** Alias type for number array or Float32Array */
  80303. export type FloatArray = number[] | Float32Array;
  80304. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80305. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80306. /**
  80307. * Alias for types that can be used by a Buffer or VertexBuffer.
  80308. */
  80309. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80310. /**
  80311. * Alias type for primitive types
  80312. * @ignorenaming
  80313. */
  80314. type Primitive = undefined | null | boolean | string | number | Function;
  80315. /**
  80316. * Type modifier to make all the properties of an object Readonly
  80317. */
  80318. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80319. /**
  80320. * Type modifier to make all the properties of an object Readonly recursively
  80321. */
  80322. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80323. /**
  80324. * Type modifier to make object properties readonly.
  80325. */
  80326. export type DeepImmutableObject<T> = {
  80327. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80328. };
  80329. /** @hidden */
  80330. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * A class serves as a medium between the observable and its observers
  80336. */
  80337. export class EventState {
  80338. /**
  80339. * Create a new EventState
  80340. * @param mask defines the mask associated with this state
  80341. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80342. * @param target defines the original target of the state
  80343. * @param currentTarget defines the current target of the state
  80344. */
  80345. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80346. /**
  80347. * Initialize the current event state
  80348. * @param mask defines the mask associated with this state
  80349. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80350. * @param target defines the original target of the state
  80351. * @param currentTarget defines the current target of the state
  80352. * @returns the current event state
  80353. */
  80354. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80355. /**
  80356. * An Observer can set this property to true to prevent subsequent observers of being notified
  80357. */
  80358. skipNextObservers: boolean;
  80359. /**
  80360. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80361. */
  80362. mask: number;
  80363. /**
  80364. * The object that originally notified the event
  80365. */
  80366. target?: any;
  80367. /**
  80368. * The current object in the bubbling phase
  80369. */
  80370. currentTarget?: any;
  80371. /**
  80372. * This will be populated with the return value of the last function that was executed.
  80373. * If it is the first function in the callback chain it will be the event data.
  80374. */
  80375. lastReturnValue?: any;
  80376. }
  80377. /**
  80378. * Represent an Observer registered to a given Observable object.
  80379. */
  80380. export class Observer<T> {
  80381. /**
  80382. * Defines the callback to call when the observer is notified
  80383. */
  80384. callback: (eventData: T, eventState: EventState) => void;
  80385. /**
  80386. * Defines the mask of the observer (used to filter notifications)
  80387. */
  80388. mask: number;
  80389. /**
  80390. * Defines the current scope used to restore the JS context
  80391. */
  80392. scope: any;
  80393. /** @hidden */
  80394. _willBeUnregistered: boolean;
  80395. /**
  80396. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80397. */
  80398. unregisterOnNextCall: boolean;
  80399. /**
  80400. * Creates a new observer
  80401. * @param callback defines the callback to call when the observer is notified
  80402. * @param mask defines the mask of the observer (used to filter notifications)
  80403. * @param scope defines the current scope used to restore the JS context
  80404. */
  80405. constructor(
  80406. /**
  80407. * Defines the callback to call when the observer is notified
  80408. */
  80409. callback: (eventData: T, eventState: EventState) => void,
  80410. /**
  80411. * Defines the mask of the observer (used to filter notifications)
  80412. */
  80413. mask: number,
  80414. /**
  80415. * Defines the current scope used to restore the JS context
  80416. */
  80417. scope?: any);
  80418. }
  80419. /**
  80420. * Represent a list of observers registered to multiple Observables object.
  80421. */
  80422. export class MultiObserver<T> {
  80423. private _observers;
  80424. private _observables;
  80425. /**
  80426. * Release associated resources
  80427. */
  80428. dispose(): void;
  80429. /**
  80430. * Raise a callback when one of the observable will notify
  80431. * @param observables defines a list of observables to watch
  80432. * @param callback defines the callback to call on notification
  80433. * @param mask defines the mask used to filter notifications
  80434. * @param scope defines the current scope used to restore the JS context
  80435. * @returns the new MultiObserver
  80436. */
  80437. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80438. }
  80439. /**
  80440. * The Observable class is a simple implementation of the Observable pattern.
  80441. *
  80442. * 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.
  80443. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80444. * 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).
  80445. * 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.
  80446. */
  80447. export class Observable<T> {
  80448. private _observers;
  80449. private _eventState;
  80450. private _onObserverAdded;
  80451. /**
  80452. * Gets the list of observers
  80453. */
  80454. get observers(): Array<Observer<T>>;
  80455. /**
  80456. * Creates a new observable
  80457. * @param onObserverAdded defines a callback to call when a new observer is added
  80458. */
  80459. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80460. /**
  80461. * Create a new Observer with the specified callback
  80462. * @param callback the callback that will be executed for that Observer
  80463. * @param mask the mask used to filter observers
  80464. * @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.
  80465. * @param scope optional scope for the callback to be called from
  80466. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80467. * @returns the new observer created for the callback
  80468. */
  80469. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80470. /**
  80471. * Create a new Observer with the specified callback and unregisters after the next notification
  80472. * @param callback the callback that will be executed for that Observer
  80473. * @returns the new observer created for the callback
  80474. */
  80475. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80476. /**
  80477. * Remove an Observer from the Observable object
  80478. * @param observer the instance of the Observer to remove
  80479. * @returns false if it doesn't belong to this Observable
  80480. */
  80481. remove(observer: Nullable<Observer<T>>): boolean;
  80482. /**
  80483. * Remove a callback from the Observable object
  80484. * @param callback the callback to remove
  80485. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80486. * @returns false if it doesn't belong to this Observable
  80487. */
  80488. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80489. private _deferUnregister;
  80490. private _remove;
  80491. /**
  80492. * Moves the observable to the top of the observer list making it get called first when notified
  80493. * @param observer the observer to move
  80494. */
  80495. makeObserverTopPriority(observer: Observer<T>): void;
  80496. /**
  80497. * Moves the observable to the bottom of the observer list making it get called last when notified
  80498. * @param observer the observer to move
  80499. */
  80500. makeObserverBottomPriority(observer: Observer<T>): void;
  80501. /**
  80502. * Notify all Observers by calling their respective callback with the given data
  80503. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80504. * @param eventData defines the data to send to all observers
  80505. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80506. * @param target defines the original target of the state
  80507. * @param currentTarget defines the current target of the state
  80508. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80509. */
  80510. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80511. /**
  80512. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80513. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80514. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80515. * and it is crucial that all callbacks will be executed.
  80516. * The order of the callbacks is kept, callbacks are not executed parallel.
  80517. *
  80518. * @param eventData The data to be sent to each callback
  80519. * @param mask is used to filter observers defaults to -1
  80520. * @param target defines the callback target (see EventState)
  80521. * @param currentTarget defines he current object in the bubbling phase
  80522. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80523. */
  80524. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80525. /**
  80526. * Notify a specific observer
  80527. * @param observer defines the observer to notify
  80528. * @param eventData defines the data to be sent to each callback
  80529. * @param mask is used to filter observers defaults to -1
  80530. */
  80531. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80532. /**
  80533. * Gets a boolean indicating if the observable has at least one observer
  80534. * @returns true is the Observable has at least one Observer registered
  80535. */
  80536. hasObservers(): boolean;
  80537. /**
  80538. * Clear the list of observers
  80539. */
  80540. clear(): void;
  80541. /**
  80542. * Clone the current observable
  80543. * @returns a new observable
  80544. */
  80545. clone(): Observable<T>;
  80546. /**
  80547. * Does this observable handles observer registered with a given mask
  80548. * @param mask defines the mask to be tested
  80549. * @return whether or not one observer registered with the given mask is handeled
  80550. **/
  80551. hasSpecificMask(mask?: number): boolean;
  80552. }
  80553. }
  80554. declare module BABYLON {
  80555. /**
  80556. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80557. * Babylon.js
  80558. */
  80559. export class DomManagement {
  80560. /**
  80561. * Checks if the window object exists
  80562. * @returns true if the window object exists
  80563. */
  80564. static IsWindowObjectExist(): boolean;
  80565. /**
  80566. * Checks if the navigator object exists
  80567. * @returns true if the navigator object exists
  80568. */
  80569. static IsNavigatorAvailable(): boolean;
  80570. /**
  80571. * Check if the document object exists
  80572. * @returns true if the document object exists
  80573. */
  80574. static IsDocumentAvailable(): boolean;
  80575. /**
  80576. * Extracts text content from a DOM element hierarchy
  80577. * @param element defines the root element
  80578. * @returns a string
  80579. */
  80580. static GetDOMTextContent(element: HTMLElement): string;
  80581. }
  80582. }
  80583. declare module BABYLON {
  80584. /**
  80585. * Logger used througouht the application to allow configuration of
  80586. * the log level required for the messages.
  80587. */
  80588. export class Logger {
  80589. /**
  80590. * No log
  80591. */
  80592. static readonly NoneLogLevel: number;
  80593. /**
  80594. * Only message logs
  80595. */
  80596. static readonly MessageLogLevel: number;
  80597. /**
  80598. * Only warning logs
  80599. */
  80600. static readonly WarningLogLevel: number;
  80601. /**
  80602. * Only error logs
  80603. */
  80604. static readonly ErrorLogLevel: number;
  80605. /**
  80606. * All logs
  80607. */
  80608. static readonly AllLogLevel: number;
  80609. private static _LogCache;
  80610. /**
  80611. * Gets a value indicating the number of loading errors
  80612. * @ignorenaming
  80613. */
  80614. static errorsCount: number;
  80615. /**
  80616. * Callback called when a new log is added
  80617. */
  80618. static OnNewCacheEntry: (entry: string) => void;
  80619. private static _AddLogEntry;
  80620. private static _FormatMessage;
  80621. private static _LogDisabled;
  80622. private static _LogEnabled;
  80623. private static _WarnDisabled;
  80624. private static _WarnEnabled;
  80625. private static _ErrorDisabled;
  80626. private static _ErrorEnabled;
  80627. /**
  80628. * Log a message to the console
  80629. */
  80630. static Log: (message: string) => void;
  80631. /**
  80632. * Write a warning message to the console
  80633. */
  80634. static Warn: (message: string) => void;
  80635. /**
  80636. * Write an error message to the console
  80637. */
  80638. static Error: (message: string) => void;
  80639. /**
  80640. * Gets current log cache (list of logs)
  80641. */
  80642. static get LogCache(): string;
  80643. /**
  80644. * Clears the log cache
  80645. */
  80646. static ClearLogCache(): void;
  80647. /**
  80648. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80649. */
  80650. static set LogLevels(level: number);
  80651. }
  80652. }
  80653. declare module BABYLON {
  80654. /** @hidden */
  80655. export class _TypeStore {
  80656. /** @hidden */
  80657. static RegisteredTypes: {
  80658. [key: string]: Object;
  80659. };
  80660. /** @hidden */
  80661. static GetClass(fqdn: string): any;
  80662. }
  80663. }
  80664. declare module BABYLON {
  80665. /**
  80666. * Helper to manipulate strings
  80667. */
  80668. export class StringTools {
  80669. /**
  80670. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80671. * @param str Source string
  80672. * @param suffix Suffix to search for in the source string
  80673. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80674. */
  80675. static EndsWith(str: string, suffix: string): boolean;
  80676. /**
  80677. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80678. * @param str Source string
  80679. * @param suffix Suffix to search for in the source string
  80680. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80681. */
  80682. static StartsWith(str: string, suffix: string): boolean;
  80683. /**
  80684. * Decodes a buffer into a string
  80685. * @param buffer The buffer to decode
  80686. * @returns The decoded string
  80687. */
  80688. static Decode(buffer: Uint8Array | Uint16Array): string;
  80689. /**
  80690. * Encode a buffer to a base64 string
  80691. * @param buffer defines the buffer to encode
  80692. * @returns the encoded string
  80693. */
  80694. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80695. /**
  80696. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80697. * @param num the number to convert and pad
  80698. * @param length the expected length of the string
  80699. * @returns the padded string
  80700. */
  80701. static PadNumber(num: number, length: number): string;
  80702. }
  80703. }
  80704. declare module BABYLON {
  80705. /**
  80706. * Class containing a set of static utilities functions for deep copy.
  80707. */
  80708. export class DeepCopier {
  80709. /**
  80710. * Tries to copy an object by duplicating every property
  80711. * @param source defines the source object
  80712. * @param destination defines the target object
  80713. * @param doNotCopyList defines a list of properties to avoid
  80714. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80715. */
  80716. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80717. }
  80718. }
  80719. declare module BABYLON {
  80720. /**
  80721. * Class containing a set of static utilities functions for precision date
  80722. */
  80723. export class PrecisionDate {
  80724. /**
  80725. * Gets either window.performance.now() if supported or Date.now() else
  80726. */
  80727. static get Now(): number;
  80728. }
  80729. }
  80730. declare module BABYLON {
  80731. /** @hidden */
  80732. export class _DevTools {
  80733. static WarnImport(name: string): string;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /**
  80738. * Interface used to define the mechanism to get data from the network
  80739. */
  80740. export interface IWebRequest {
  80741. /**
  80742. * Returns client's response url
  80743. */
  80744. responseURL: string;
  80745. /**
  80746. * Returns client's status
  80747. */
  80748. status: number;
  80749. /**
  80750. * Returns client's status as a text
  80751. */
  80752. statusText: string;
  80753. }
  80754. }
  80755. declare module BABYLON {
  80756. /**
  80757. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80758. */
  80759. export class WebRequest implements IWebRequest {
  80760. private _xhr;
  80761. /**
  80762. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80763. * i.e. when loading files, where the server/service expects an Authorization header
  80764. */
  80765. static CustomRequestHeaders: {
  80766. [key: string]: string;
  80767. };
  80768. /**
  80769. * Add callback functions in this array to update all the requests before they get sent to the network
  80770. */
  80771. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80772. private _injectCustomRequestHeaders;
  80773. /**
  80774. * Gets or sets a function to be called when loading progress changes
  80775. */
  80776. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80777. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80778. /**
  80779. * Returns client's state
  80780. */
  80781. get readyState(): number;
  80782. /**
  80783. * Returns client's status
  80784. */
  80785. get status(): number;
  80786. /**
  80787. * Returns client's status as a text
  80788. */
  80789. get statusText(): string;
  80790. /**
  80791. * Returns client's response
  80792. */
  80793. get response(): any;
  80794. /**
  80795. * Returns client's response url
  80796. */
  80797. get responseURL(): string;
  80798. /**
  80799. * Returns client's response as text
  80800. */
  80801. get responseText(): string;
  80802. /**
  80803. * Gets or sets the expected response type
  80804. */
  80805. get responseType(): XMLHttpRequestResponseType;
  80806. set responseType(value: XMLHttpRequestResponseType);
  80807. /** @hidden */
  80808. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80809. /** @hidden */
  80810. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80811. /**
  80812. * Cancels any network activity
  80813. */
  80814. abort(): void;
  80815. /**
  80816. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80817. * @param body defines an optional request body
  80818. */
  80819. send(body?: Document | BodyInit | null): void;
  80820. /**
  80821. * Sets the request method, request URL
  80822. * @param method defines the method to use (GET, POST, etc..)
  80823. * @param url defines the url to connect with
  80824. */
  80825. open(method: string, url: string): void;
  80826. /**
  80827. * Sets the value of a request header.
  80828. * @param name The name of the header whose value is to be set
  80829. * @param value The value to set as the body of the header
  80830. */
  80831. setRequestHeader(name: string, value: string): void;
  80832. /**
  80833. * Get the string containing the text of a particular header's value.
  80834. * @param name The name of the header
  80835. * @returns The string containing the text of the given header name
  80836. */
  80837. getResponseHeader(name: string): Nullable<string>;
  80838. }
  80839. }
  80840. declare module BABYLON {
  80841. /**
  80842. * File request interface
  80843. */
  80844. export interface IFileRequest {
  80845. /**
  80846. * Raised when the request is complete (success or error).
  80847. */
  80848. onCompleteObservable: Observable<IFileRequest>;
  80849. /**
  80850. * Aborts the request for a file.
  80851. */
  80852. abort: () => void;
  80853. }
  80854. }
  80855. declare module BABYLON {
  80856. /**
  80857. * Define options used to create a render target texture
  80858. */
  80859. export class RenderTargetCreationOptions {
  80860. /**
  80861. * Specifies is mipmaps must be generated
  80862. */
  80863. generateMipMaps?: boolean;
  80864. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80865. generateDepthBuffer?: boolean;
  80866. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80867. generateStencilBuffer?: boolean;
  80868. /** Defines texture type (int by default) */
  80869. type?: number;
  80870. /** Defines sampling mode (trilinear by default) */
  80871. samplingMode?: number;
  80872. /** Defines format (RGBA by default) */
  80873. format?: number;
  80874. }
  80875. }
  80876. declare module BABYLON {
  80877. /** Defines the cross module used constants to avoid circular dependncies */
  80878. export class Constants {
  80879. /** Defines that alpha blending is disabled */
  80880. static readonly ALPHA_DISABLE: number;
  80881. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80882. static readonly ALPHA_ADD: number;
  80883. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80884. static readonly ALPHA_COMBINE: number;
  80885. /** Defines that alpha blending is DEST - SRC * DEST */
  80886. static readonly ALPHA_SUBTRACT: number;
  80887. /** Defines that alpha blending is SRC * DEST */
  80888. static readonly ALPHA_MULTIPLY: number;
  80889. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80890. static readonly ALPHA_MAXIMIZED: number;
  80891. /** Defines that alpha blending is SRC + DEST */
  80892. static readonly ALPHA_ONEONE: number;
  80893. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80894. static readonly ALPHA_PREMULTIPLIED: number;
  80895. /**
  80896. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80897. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80898. */
  80899. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80900. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80901. static readonly ALPHA_INTERPOLATE: number;
  80902. /**
  80903. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80904. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80905. */
  80906. static readonly ALPHA_SCREENMODE: number;
  80907. /**
  80908. * Defines that alpha blending is SRC + DST
  80909. * Alpha will be set to SRC ALPHA + DST ALPHA
  80910. */
  80911. static readonly ALPHA_ONEONE_ONEONE: number;
  80912. /**
  80913. * Defines that alpha blending is SRC * DST ALPHA + DST
  80914. * Alpha will be set to 0
  80915. */
  80916. static readonly ALPHA_ALPHATOCOLOR: number;
  80917. /**
  80918. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80919. */
  80920. static readonly ALPHA_REVERSEONEMINUS: number;
  80921. /**
  80922. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80923. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80924. */
  80925. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80926. /**
  80927. * Defines that alpha blending is SRC + DST
  80928. * Alpha will be set to SRC ALPHA
  80929. */
  80930. static readonly ALPHA_ONEONE_ONEZERO: number;
  80931. /**
  80932. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80933. * Alpha will be set to DST ALPHA
  80934. */
  80935. static readonly ALPHA_EXCLUSION: number;
  80936. /** Defines that alpha blending equation a SUM */
  80937. static readonly ALPHA_EQUATION_ADD: number;
  80938. /** Defines that alpha blending equation a SUBSTRACTION */
  80939. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80940. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80941. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80942. /** Defines that alpha blending equation a MAX operation */
  80943. static readonly ALPHA_EQUATION_MAX: number;
  80944. /** Defines that alpha blending equation a MIN operation */
  80945. static readonly ALPHA_EQUATION_MIN: number;
  80946. /**
  80947. * Defines that alpha blending equation a DARKEN operation:
  80948. * It takes the min of the src and sums the alpha channels.
  80949. */
  80950. static readonly ALPHA_EQUATION_DARKEN: number;
  80951. /** Defines that the ressource is not delayed*/
  80952. static readonly DELAYLOADSTATE_NONE: number;
  80953. /** Defines that the ressource was successfully delay loaded */
  80954. static readonly DELAYLOADSTATE_LOADED: number;
  80955. /** Defines that the ressource is currently delay loading */
  80956. static readonly DELAYLOADSTATE_LOADING: number;
  80957. /** Defines that the ressource is delayed and has not started loading */
  80958. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80959. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80960. static readonly NEVER: number;
  80961. /** 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 */
  80962. static readonly ALWAYS: number;
  80963. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80964. static readonly LESS: number;
  80965. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80966. static readonly EQUAL: number;
  80967. /** 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 */
  80968. static readonly LEQUAL: number;
  80969. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80970. static readonly GREATER: number;
  80971. /** 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 */
  80972. static readonly GEQUAL: number;
  80973. /** 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 */
  80974. static readonly NOTEQUAL: number;
  80975. /** Passed to stencilOperation to specify that stencil value must be kept */
  80976. static readonly KEEP: number;
  80977. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80978. static readonly REPLACE: number;
  80979. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80980. static readonly INCR: number;
  80981. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80982. static readonly DECR: number;
  80983. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80984. static readonly INVERT: number;
  80985. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80986. static readonly INCR_WRAP: number;
  80987. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80988. static readonly DECR_WRAP: number;
  80989. /** Texture is not repeating outside of 0..1 UVs */
  80990. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80991. /** Texture is repeating outside of 0..1 UVs */
  80992. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80993. /** Texture is repeating and mirrored */
  80994. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80995. /** ALPHA */
  80996. static readonly TEXTUREFORMAT_ALPHA: number;
  80997. /** LUMINANCE */
  80998. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80999. /** LUMINANCE_ALPHA */
  81000. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81001. /** RGB */
  81002. static readonly TEXTUREFORMAT_RGB: number;
  81003. /** RGBA */
  81004. static readonly TEXTUREFORMAT_RGBA: number;
  81005. /** RED */
  81006. static readonly TEXTUREFORMAT_RED: number;
  81007. /** RED (2nd reference) */
  81008. static readonly TEXTUREFORMAT_R: number;
  81009. /** RG */
  81010. static readonly TEXTUREFORMAT_RG: number;
  81011. /** RED_INTEGER */
  81012. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81013. /** RED_INTEGER (2nd reference) */
  81014. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81015. /** RG_INTEGER */
  81016. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81017. /** RGB_INTEGER */
  81018. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81019. /** RGBA_INTEGER */
  81020. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81021. /** UNSIGNED_BYTE */
  81022. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81023. /** UNSIGNED_BYTE (2nd reference) */
  81024. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81025. /** FLOAT */
  81026. static readonly TEXTURETYPE_FLOAT: number;
  81027. /** HALF_FLOAT */
  81028. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81029. /** BYTE */
  81030. static readonly TEXTURETYPE_BYTE: number;
  81031. /** SHORT */
  81032. static readonly TEXTURETYPE_SHORT: number;
  81033. /** UNSIGNED_SHORT */
  81034. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81035. /** INT */
  81036. static readonly TEXTURETYPE_INT: number;
  81037. /** UNSIGNED_INT */
  81038. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81039. /** UNSIGNED_SHORT_4_4_4_4 */
  81040. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81041. /** UNSIGNED_SHORT_5_5_5_1 */
  81042. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81043. /** UNSIGNED_SHORT_5_6_5 */
  81044. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81045. /** UNSIGNED_INT_2_10_10_10_REV */
  81046. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81047. /** UNSIGNED_INT_24_8 */
  81048. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81049. /** UNSIGNED_INT_10F_11F_11F_REV */
  81050. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81051. /** UNSIGNED_INT_5_9_9_9_REV */
  81052. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81053. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81054. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81055. /** nearest is mag = nearest and min = nearest and no mip */
  81056. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81057. /** mag = nearest and min = nearest and mip = none */
  81058. static readonly TEXTURE_NEAREST_NEAREST: number;
  81059. /** Bilinear is mag = linear and min = linear and no mip */
  81060. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81061. /** mag = linear and min = linear and mip = none */
  81062. static readonly TEXTURE_LINEAR_LINEAR: number;
  81063. /** Trilinear is mag = linear and min = linear and mip = linear */
  81064. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81065. /** Trilinear is mag = linear and min = linear and mip = linear */
  81066. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81067. /** mag = nearest and min = nearest and mip = nearest */
  81068. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81069. /** mag = nearest and min = linear and mip = nearest */
  81070. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81071. /** mag = nearest and min = linear and mip = linear */
  81072. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81073. /** mag = nearest and min = linear and mip = none */
  81074. static readonly TEXTURE_NEAREST_LINEAR: number;
  81075. /** nearest is mag = nearest and min = nearest and mip = linear */
  81076. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81077. /** mag = linear and min = nearest and mip = nearest */
  81078. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81079. /** mag = linear and min = nearest and mip = linear */
  81080. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81082. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81083. /** mag = linear and min = nearest and mip = none */
  81084. static readonly TEXTURE_LINEAR_NEAREST: number;
  81085. /** Explicit coordinates mode */
  81086. static readonly TEXTURE_EXPLICIT_MODE: number;
  81087. /** Spherical coordinates mode */
  81088. static readonly TEXTURE_SPHERICAL_MODE: number;
  81089. /** Planar coordinates mode */
  81090. static readonly TEXTURE_PLANAR_MODE: number;
  81091. /** Cubic coordinates mode */
  81092. static readonly TEXTURE_CUBIC_MODE: number;
  81093. /** Projection coordinates mode */
  81094. static readonly TEXTURE_PROJECTION_MODE: number;
  81095. /** Skybox coordinates mode */
  81096. static readonly TEXTURE_SKYBOX_MODE: number;
  81097. /** Inverse Cubic coordinates mode */
  81098. static readonly TEXTURE_INVCUBIC_MODE: number;
  81099. /** Equirectangular coordinates mode */
  81100. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81101. /** Equirectangular Fixed coordinates mode */
  81102. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81103. /** Equirectangular Fixed Mirrored coordinates mode */
  81104. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81105. /** Offline (baking) quality for texture filtering */
  81106. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81107. /** High quality for texture filtering */
  81108. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81109. /** Medium quality for texture filtering */
  81110. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81111. /** Low quality for texture filtering */
  81112. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81113. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81114. static readonly SCALEMODE_FLOOR: number;
  81115. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81116. static readonly SCALEMODE_NEAREST: number;
  81117. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81118. static readonly SCALEMODE_CEILING: number;
  81119. /**
  81120. * The dirty texture flag value
  81121. */
  81122. static readonly MATERIAL_TextureDirtyFlag: number;
  81123. /**
  81124. * The dirty light flag value
  81125. */
  81126. static readonly MATERIAL_LightDirtyFlag: number;
  81127. /**
  81128. * The dirty fresnel flag value
  81129. */
  81130. static readonly MATERIAL_FresnelDirtyFlag: number;
  81131. /**
  81132. * The dirty attribute flag value
  81133. */
  81134. static readonly MATERIAL_AttributesDirtyFlag: number;
  81135. /**
  81136. * The dirty misc flag value
  81137. */
  81138. static readonly MATERIAL_MiscDirtyFlag: number;
  81139. /**
  81140. * The all dirty flag value
  81141. */
  81142. static readonly MATERIAL_AllDirtyFlag: number;
  81143. /**
  81144. * Returns the triangle fill mode
  81145. */
  81146. static readonly MATERIAL_TriangleFillMode: number;
  81147. /**
  81148. * Returns the wireframe mode
  81149. */
  81150. static readonly MATERIAL_WireFrameFillMode: number;
  81151. /**
  81152. * Returns the point fill mode
  81153. */
  81154. static readonly MATERIAL_PointFillMode: number;
  81155. /**
  81156. * Returns the point list draw mode
  81157. */
  81158. static readonly MATERIAL_PointListDrawMode: number;
  81159. /**
  81160. * Returns the line list draw mode
  81161. */
  81162. static readonly MATERIAL_LineListDrawMode: number;
  81163. /**
  81164. * Returns the line loop draw mode
  81165. */
  81166. static readonly MATERIAL_LineLoopDrawMode: number;
  81167. /**
  81168. * Returns the line strip draw mode
  81169. */
  81170. static readonly MATERIAL_LineStripDrawMode: number;
  81171. /**
  81172. * Returns the triangle strip draw mode
  81173. */
  81174. static readonly MATERIAL_TriangleStripDrawMode: number;
  81175. /**
  81176. * Returns the triangle fan draw mode
  81177. */
  81178. static readonly MATERIAL_TriangleFanDrawMode: number;
  81179. /**
  81180. * Stores the clock-wise side orientation
  81181. */
  81182. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81183. /**
  81184. * Stores the counter clock-wise side orientation
  81185. */
  81186. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81187. /**
  81188. * Nothing
  81189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81190. */
  81191. static readonly ACTION_NothingTrigger: number;
  81192. /**
  81193. * On pick
  81194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81195. */
  81196. static readonly ACTION_OnPickTrigger: number;
  81197. /**
  81198. * On left pick
  81199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81200. */
  81201. static readonly ACTION_OnLeftPickTrigger: number;
  81202. /**
  81203. * On right pick
  81204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81205. */
  81206. static readonly ACTION_OnRightPickTrigger: number;
  81207. /**
  81208. * On center pick
  81209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81210. */
  81211. static readonly ACTION_OnCenterPickTrigger: number;
  81212. /**
  81213. * On pick down
  81214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81215. */
  81216. static readonly ACTION_OnPickDownTrigger: number;
  81217. /**
  81218. * On double pick
  81219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81220. */
  81221. static readonly ACTION_OnDoublePickTrigger: number;
  81222. /**
  81223. * On pick up
  81224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81225. */
  81226. static readonly ACTION_OnPickUpTrigger: number;
  81227. /**
  81228. * On pick out.
  81229. * This trigger will only be raised if you also declared a OnPickDown
  81230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81231. */
  81232. static readonly ACTION_OnPickOutTrigger: number;
  81233. /**
  81234. * On long press
  81235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81236. */
  81237. static readonly ACTION_OnLongPressTrigger: number;
  81238. /**
  81239. * On pointer over
  81240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81241. */
  81242. static readonly ACTION_OnPointerOverTrigger: number;
  81243. /**
  81244. * On pointer out
  81245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81246. */
  81247. static readonly ACTION_OnPointerOutTrigger: number;
  81248. /**
  81249. * On every frame
  81250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81251. */
  81252. static readonly ACTION_OnEveryFrameTrigger: number;
  81253. /**
  81254. * On intersection enter
  81255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81256. */
  81257. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81258. /**
  81259. * On intersection exit
  81260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81261. */
  81262. static readonly ACTION_OnIntersectionExitTrigger: number;
  81263. /**
  81264. * On key down
  81265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81266. */
  81267. static readonly ACTION_OnKeyDownTrigger: number;
  81268. /**
  81269. * On key up
  81270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81271. */
  81272. static readonly ACTION_OnKeyUpTrigger: number;
  81273. /**
  81274. * Billboard mode will only apply to Y axis
  81275. */
  81276. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81277. /**
  81278. * Billboard mode will apply to all axes
  81279. */
  81280. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81281. /**
  81282. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81283. */
  81284. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81285. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81286. * Test order :
  81287. * Is the bounding sphere outside the frustum ?
  81288. * If not, are the bounding box vertices outside the frustum ?
  81289. * It not, then the cullable object is in the frustum.
  81290. */
  81291. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81292. /** Culling strategy : Bounding Sphere Only.
  81293. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81294. * It's also less accurate than the standard because some not visible objects can still be selected.
  81295. * Test : is the bounding sphere outside the frustum ?
  81296. * If not, then the cullable object is in the frustum.
  81297. */
  81298. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81299. /** Culling strategy : Optimistic Inclusion.
  81300. * This in an inclusion test first, then the standard exclusion test.
  81301. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81302. * 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.
  81303. * Anyway, it's as accurate as the standard strategy.
  81304. * Test :
  81305. * Is the cullable object bounding sphere center in the frustum ?
  81306. * If not, apply the default culling strategy.
  81307. */
  81308. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81309. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81310. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81311. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81312. * 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.
  81313. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81314. * Test :
  81315. * Is the cullable object bounding sphere center in the frustum ?
  81316. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81317. */
  81318. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81319. /**
  81320. * No logging while loading
  81321. */
  81322. static readonly SCENELOADER_NO_LOGGING: number;
  81323. /**
  81324. * Minimal logging while loading
  81325. */
  81326. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81327. /**
  81328. * Summary logging while loading
  81329. */
  81330. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81331. /**
  81332. * Detailled logging while loading
  81333. */
  81334. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81335. /**
  81336. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81337. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81338. */
  81339. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81340. /**
  81341. * Constant used to retrieve the position texture index in the textures array in the prepass
  81342. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81343. */
  81344. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81345. /**
  81346. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81347. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81348. */
  81349. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81350. /**
  81351. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81352. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81353. */
  81354. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81355. /**
  81356. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81357. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81358. */
  81359. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81360. /**
  81361. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81362. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81363. */
  81364. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81365. /**
  81366. * Constant used to retrieve albedo index in the textures array in the prepass
  81367. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81368. */
  81369. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81370. }
  81371. }
  81372. declare module BABYLON {
  81373. /**
  81374. * This represents the required contract to create a new type of texture loader.
  81375. */
  81376. export interface IInternalTextureLoader {
  81377. /**
  81378. * Defines wether the loader supports cascade loading the different faces.
  81379. */
  81380. supportCascades: boolean;
  81381. /**
  81382. * This returns if the loader support the current file information.
  81383. * @param extension defines the file extension of the file being loaded
  81384. * @param mimeType defines the optional mime type of the file being loaded
  81385. * @returns true if the loader can load the specified file
  81386. */
  81387. canLoad(extension: string, mimeType?: string): boolean;
  81388. /**
  81389. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81390. * @param data contains the texture data
  81391. * @param texture defines the BabylonJS internal texture
  81392. * @param createPolynomials will be true if polynomials have been requested
  81393. * @param onLoad defines the callback to trigger once the texture is ready
  81394. * @param onError defines the callback to trigger in case of error
  81395. */
  81396. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81397. /**
  81398. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81399. * @param data contains the texture data
  81400. * @param texture defines the BabylonJS internal texture
  81401. * @param callback defines the method to call once ready to upload
  81402. */
  81403. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81404. }
  81405. }
  81406. declare module BABYLON {
  81407. /**
  81408. * Class used to store and describe the pipeline context associated with an effect
  81409. */
  81410. export interface IPipelineContext {
  81411. /**
  81412. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81413. */
  81414. isAsync: boolean;
  81415. /**
  81416. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81417. */
  81418. isReady: boolean;
  81419. /** @hidden */
  81420. _getVertexShaderCode(): string | null;
  81421. /** @hidden */
  81422. _getFragmentShaderCode(): string | null;
  81423. /** @hidden */
  81424. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81425. }
  81426. }
  81427. declare module BABYLON {
  81428. /**
  81429. * Class used to store gfx data (like WebGLBuffer)
  81430. */
  81431. export class DataBuffer {
  81432. /**
  81433. * Gets or sets the number of objects referencing this buffer
  81434. */
  81435. references: number;
  81436. /** Gets or sets the size of the underlying buffer */
  81437. capacity: number;
  81438. /**
  81439. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81440. */
  81441. is32Bits: boolean;
  81442. /**
  81443. * Gets the underlying buffer
  81444. */
  81445. get underlyingResource(): any;
  81446. }
  81447. }
  81448. declare module BABYLON {
  81449. /** @hidden */
  81450. export interface IShaderProcessor {
  81451. attributeProcessor?: (attribute: string) => string;
  81452. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81453. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81454. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81455. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81456. lineProcessor?: (line: string, isFragment: boolean) => string;
  81457. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81458. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81459. }
  81460. }
  81461. declare module BABYLON {
  81462. /** @hidden */
  81463. export interface ProcessingOptions {
  81464. defines: string[];
  81465. indexParameters: any;
  81466. isFragment: boolean;
  81467. shouldUseHighPrecisionShader: boolean;
  81468. supportsUniformBuffers: boolean;
  81469. shadersRepository: string;
  81470. includesShadersStore: {
  81471. [key: string]: string;
  81472. };
  81473. processor?: IShaderProcessor;
  81474. version: string;
  81475. platformName: string;
  81476. lookForClosingBracketForUniformBuffer?: boolean;
  81477. }
  81478. }
  81479. declare module BABYLON {
  81480. /** @hidden */
  81481. export class ShaderCodeNode {
  81482. line: string;
  81483. children: ShaderCodeNode[];
  81484. additionalDefineKey?: string;
  81485. additionalDefineValue?: string;
  81486. isValid(preprocessors: {
  81487. [key: string]: string;
  81488. }): boolean;
  81489. process(preprocessors: {
  81490. [key: string]: string;
  81491. }, options: ProcessingOptions): string;
  81492. }
  81493. }
  81494. declare module BABYLON {
  81495. /** @hidden */
  81496. export class ShaderCodeCursor {
  81497. private _lines;
  81498. lineIndex: number;
  81499. get currentLine(): string;
  81500. get canRead(): boolean;
  81501. set lines(value: string[]);
  81502. }
  81503. }
  81504. declare module BABYLON {
  81505. /** @hidden */
  81506. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81507. process(preprocessors: {
  81508. [key: string]: string;
  81509. }, options: ProcessingOptions): string;
  81510. }
  81511. }
  81512. declare module BABYLON {
  81513. /** @hidden */
  81514. export class ShaderDefineExpression {
  81515. isTrue(preprocessors: {
  81516. [key: string]: string;
  81517. }): boolean;
  81518. private static _OperatorPriority;
  81519. private static _Stack;
  81520. static postfixToInfix(postfix: string[]): string;
  81521. static infixToPostfix(infix: string): string[];
  81522. }
  81523. }
  81524. declare module BABYLON {
  81525. /** @hidden */
  81526. export class ShaderCodeTestNode extends ShaderCodeNode {
  81527. testExpression: ShaderDefineExpression;
  81528. isValid(preprocessors: {
  81529. [key: string]: string;
  81530. }): boolean;
  81531. }
  81532. }
  81533. declare module BABYLON {
  81534. /** @hidden */
  81535. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81536. define: string;
  81537. not: boolean;
  81538. constructor(define: string, not?: boolean);
  81539. isTrue(preprocessors: {
  81540. [key: string]: string;
  81541. }): boolean;
  81542. }
  81543. }
  81544. declare module BABYLON {
  81545. /** @hidden */
  81546. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81547. leftOperand: ShaderDefineExpression;
  81548. rightOperand: ShaderDefineExpression;
  81549. isTrue(preprocessors: {
  81550. [key: string]: string;
  81551. }): boolean;
  81552. }
  81553. }
  81554. declare module BABYLON {
  81555. /** @hidden */
  81556. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81557. leftOperand: ShaderDefineExpression;
  81558. rightOperand: ShaderDefineExpression;
  81559. isTrue(preprocessors: {
  81560. [key: string]: string;
  81561. }): boolean;
  81562. }
  81563. }
  81564. declare module BABYLON {
  81565. /** @hidden */
  81566. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81567. define: string;
  81568. operand: string;
  81569. testValue: string;
  81570. constructor(define: string, operand: string, testValue: string);
  81571. isTrue(preprocessors: {
  81572. [key: string]: string;
  81573. }): boolean;
  81574. }
  81575. }
  81576. declare module BABYLON {
  81577. /**
  81578. * Class used to enable access to offline support
  81579. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81580. */
  81581. export interface IOfflineProvider {
  81582. /**
  81583. * Gets a boolean indicating if scene must be saved in the database
  81584. */
  81585. enableSceneOffline: boolean;
  81586. /**
  81587. * Gets a boolean indicating if textures must be saved in the database
  81588. */
  81589. enableTexturesOffline: boolean;
  81590. /**
  81591. * Open the offline support and make it available
  81592. * @param successCallback defines the callback to call on success
  81593. * @param errorCallback defines the callback to call on error
  81594. */
  81595. open(successCallback: () => void, errorCallback: () => void): void;
  81596. /**
  81597. * Loads an image from the offline support
  81598. * @param url defines the url to load from
  81599. * @param image defines the target DOM image
  81600. */
  81601. loadImage(url: string, image: HTMLImageElement): void;
  81602. /**
  81603. * Loads a file from offline support
  81604. * @param url defines the URL to load from
  81605. * @param sceneLoaded defines a callback to call on success
  81606. * @param progressCallBack defines a callback to call when progress changed
  81607. * @param errorCallback defines a callback to call on error
  81608. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81609. */
  81610. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81611. }
  81612. }
  81613. declare module BABYLON {
  81614. /**
  81615. * Class used to help managing file picking and drag'n'drop
  81616. * File Storage
  81617. */
  81618. export class FilesInputStore {
  81619. /**
  81620. * List of files ready to be loaded
  81621. */
  81622. static FilesToLoad: {
  81623. [key: string]: File;
  81624. };
  81625. }
  81626. }
  81627. declare module BABYLON {
  81628. /**
  81629. * Class used to define a retry strategy when error happens while loading assets
  81630. */
  81631. export class RetryStrategy {
  81632. /**
  81633. * Function used to defines an exponential back off strategy
  81634. * @param maxRetries defines the maximum number of retries (3 by default)
  81635. * @param baseInterval defines the interval between retries
  81636. * @returns the strategy function to use
  81637. */
  81638. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81639. }
  81640. }
  81641. declare module BABYLON {
  81642. /**
  81643. * @ignore
  81644. * Application error to support additional information when loading a file
  81645. */
  81646. export abstract class BaseError extends Error {
  81647. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81648. }
  81649. }
  81650. declare module BABYLON {
  81651. /** @ignore */
  81652. export class LoadFileError extends BaseError {
  81653. request?: WebRequest;
  81654. file?: File;
  81655. /**
  81656. * Creates a new LoadFileError
  81657. * @param message defines the message of the error
  81658. * @param request defines the optional web request
  81659. * @param file defines the optional file
  81660. */
  81661. constructor(message: string, object?: WebRequest | File);
  81662. }
  81663. /** @ignore */
  81664. export class RequestFileError extends BaseError {
  81665. request: WebRequest;
  81666. /**
  81667. * Creates a new LoadFileError
  81668. * @param message defines the message of the error
  81669. * @param request defines the optional web request
  81670. */
  81671. constructor(message: string, request: WebRequest);
  81672. }
  81673. /** @ignore */
  81674. export class ReadFileError extends BaseError {
  81675. file: File;
  81676. /**
  81677. * Creates a new ReadFileError
  81678. * @param message defines the message of the error
  81679. * @param file defines the optional file
  81680. */
  81681. constructor(message: string, file: File);
  81682. }
  81683. /**
  81684. * @hidden
  81685. */
  81686. export class FileTools {
  81687. /**
  81688. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81689. */
  81690. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81691. /**
  81692. * Gets or sets the base URL to use to load assets
  81693. */
  81694. static BaseUrl: string;
  81695. /**
  81696. * Default behaviour for cors in the application.
  81697. * It can be a string if the expected behavior is identical in the entire app.
  81698. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81699. */
  81700. static CorsBehavior: string | ((url: string | string[]) => string);
  81701. /**
  81702. * Gets or sets a function used to pre-process url before using them to load assets
  81703. */
  81704. static PreprocessUrl: (url: string) => string;
  81705. /**
  81706. * Removes unwanted characters from an url
  81707. * @param url defines the url to clean
  81708. * @returns the cleaned url
  81709. */
  81710. private static _CleanUrl;
  81711. /**
  81712. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81713. * @param url define the url we are trying
  81714. * @param element define the dom element where to configure the cors policy
  81715. */
  81716. static SetCorsBehavior(url: string | string[], element: {
  81717. crossOrigin: string | null;
  81718. }): void;
  81719. /**
  81720. * Loads an image as an HTMLImageElement.
  81721. * @param input url string, ArrayBuffer, or Blob to load
  81722. * @param onLoad callback called when the image successfully loads
  81723. * @param onError callback called when the image fails to load
  81724. * @param offlineProvider offline provider for caching
  81725. * @param mimeType optional mime type
  81726. * @returns the HTMLImageElement of the loaded image
  81727. */
  81728. 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>;
  81729. /**
  81730. * Reads a file from a File object
  81731. * @param file defines the file to load
  81732. * @param onSuccess defines the callback to call when data is loaded
  81733. * @param onProgress defines the callback to call during loading process
  81734. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81735. * @param onError defines the callback to call when an error occurs
  81736. * @returns a file request object
  81737. */
  81738. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81739. /**
  81740. * Loads a file from a url
  81741. * @param url url to load
  81742. * @param onSuccess callback called when the file successfully loads
  81743. * @param onProgress callback called while file is loading (if the server supports this mode)
  81744. * @param offlineProvider defines the offline provider for caching
  81745. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81746. * @param onError callback called when the file fails to load
  81747. * @returns a file request object
  81748. */
  81749. 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;
  81750. /**
  81751. * Loads a file
  81752. * @param url url to load
  81753. * @param onSuccess callback called when the file successfully loads
  81754. * @param onProgress callback called while file is loading (if the server supports this mode)
  81755. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81756. * @param onError callback called when the file fails to load
  81757. * @param onOpened callback called when the web request is opened
  81758. * @returns a file request object
  81759. */
  81760. 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;
  81761. /**
  81762. * Checks if the loaded document was accessed via `file:`-Protocol.
  81763. * @returns boolean
  81764. */
  81765. static IsFileURL(): boolean;
  81766. }
  81767. }
  81768. declare module BABYLON {
  81769. /** @hidden */
  81770. export class ShaderProcessor {
  81771. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81772. private static _ProcessPrecision;
  81773. private static _ExtractOperation;
  81774. private static _BuildSubExpression;
  81775. private static _BuildExpression;
  81776. private static _MoveCursorWithinIf;
  81777. private static _MoveCursor;
  81778. private static _EvaluatePreProcessors;
  81779. private static _PreparePreProcessors;
  81780. private static _ProcessShaderConversion;
  81781. private static _ProcessIncludes;
  81782. /**
  81783. * Loads a file from a url
  81784. * @param url url to load
  81785. * @param onSuccess callback called when the file successfully loads
  81786. * @param onProgress callback called while file is loading (if the server supports this mode)
  81787. * @param offlineProvider defines the offline provider for caching
  81788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81789. * @param onError callback called when the file fails to load
  81790. * @returns a file request object
  81791. * @hidden
  81792. */
  81793. 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;
  81794. }
  81795. }
  81796. declare module BABYLON {
  81797. /**
  81798. * @hidden
  81799. */
  81800. export interface IColor4Like {
  81801. r: float;
  81802. g: float;
  81803. b: float;
  81804. a: float;
  81805. }
  81806. /**
  81807. * @hidden
  81808. */
  81809. export interface IColor3Like {
  81810. r: float;
  81811. g: float;
  81812. b: float;
  81813. }
  81814. /**
  81815. * @hidden
  81816. */
  81817. export interface IVector4Like {
  81818. x: float;
  81819. y: float;
  81820. z: float;
  81821. w: float;
  81822. }
  81823. /**
  81824. * @hidden
  81825. */
  81826. export interface IVector3Like {
  81827. x: float;
  81828. y: float;
  81829. z: float;
  81830. }
  81831. /**
  81832. * @hidden
  81833. */
  81834. export interface IVector2Like {
  81835. x: float;
  81836. y: float;
  81837. }
  81838. /**
  81839. * @hidden
  81840. */
  81841. export interface IMatrixLike {
  81842. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81843. updateFlag: int;
  81844. }
  81845. /**
  81846. * @hidden
  81847. */
  81848. export interface IViewportLike {
  81849. x: float;
  81850. y: float;
  81851. width: float;
  81852. height: float;
  81853. }
  81854. /**
  81855. * @hidden
  81856. */
  81857. export interface IPlaneLike {
  81858. normal: IVector3Like;
  81859. d: float;
  81860. normalize(): void;
  81861. }
  81862. }
  81863. declare module BABYLON {
  81864. /**
  81865. * Interface used to define common properties for effect fallbacks
  81866. */
  81867. export interface IEffectFallbacks {
  81868. /**
  81869. * Removes the defines that should be removed when falling back.
  81870. * @param currentDefines defines the current define statements for the shader.
  81871. * @param effect defines the current effect we try to compile
  81872. * @returns The resulting defines with defines of the current rank removed.
  81873. */
  81874. reduce(currentDefines: string, effect: Effect): string;
  81875. /**
  81876. * Removes the fallback from the bound mesh.
  81877. */
  81878. unBindMesh(): void;
  81879. /**
  81880. * Checks to see if more fallbacks are still availible.
  81881. */
  81882. hasMoreFallbacks: boolean;
  81883. }
  81884. }
  81885. declare module BABYLON {
  81886. /**
  81887. * Class used to evalaute queries containing `and` and `or` operators
  81888. */
  81889. export class AndOrNotEvaluator {
  81890. /**
  81891. * Evaluate a query
  81892. * @param query defines the query to evaluate
  81893. * @param evaluateCallback defines the callback used to filter result
  81894. * @returns true if the query matches
  81895. */
  81896. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81897. private static _HandleParenthesisContent;
  81898. private static _SimplifyNegation;
  81899. }
  81900. }
  81901. declare module BABYLON {
  81902. /**
  81903. * Class used to store custom tags
  81904. */
  81905. export class Tags {
  81906. /**
  81907. * Adds support for tags on the given object
  81908. * @param obj defines the object to use
  81909. */
  81910. static EnableFor(obj: any): void;
  81911. /**
  81912. * Removes tags support
  81913. * @param obj defines the object to use
  81914. */
  81915. static DisableFor(obj: any): void;
  81916. /**
  81917. * Gets a boolean indicating if the given object has tags
  81918. * @param obj defines the object to use
  81919. * @returns a boolean
  81920. */
  81921. static HasTags(obj: any): boolean;
  81922. /**
  81923. * Gets the tags available on a given object
  81924. * @param obj defines the object to use
  81925. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81926. * @returns the tags
  81927. */
  81928. static GetTags(obj: any, asString?: boolean): any;
  81929. /**
  81930. * Adds tags to an object
  81931. * @param obj defines the object to use
  81932. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81933. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81934. */
  81935. static AddTagsTo(obj: any, tagsString: string): void;
  81936. /**
  81937. * @hidden
  81938. */
  81939. static _AddTagTo(obj: any, tag: string): void;
  81940. /**
  81941. * Removes specific tags from a specific object
  81942. * @param obj defines the object to use
  81943. * @param tagsString defines the tags to remove
  81944. */
  81945. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81946. /**
  81947. * @hidden
  81948. */
  81949. static _RemoveTagFrom(obj: any, tag: string): void;
  81950. /**
  81951. * Defines if tags hosted on an object match a given query
  81952. * @param obj defines the object to use
  81953. * @param tagsQuery defines the tag query
  81954. * @returns a boolean
  81955. */
  81956. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81957. }
  81958. }
  81959. declare module BABYLON {
  81960. /**
  81961. * Scalar computation library
  81962. */
  81963. export class Scalar {
  81964. /**
  81965. * Two pi constants convenient for computation.
  81966. */
  81967. static TwoPi: number;
  81968. /**
  81969. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81970. * @param a number
  81971. * @param b number
  81972. * @param epsilon (default = 1.401298E-45)
  81973. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81974. */
  81975. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81976. /**
  81977. * Returns a string : the upper case translation of the number i to hexadecimal.
  81978. * @param i number
  81979. * @returns the upper case translation of the number i to hexadecimal.
  81980. */
  81981. static ToHex(i: number): string;
  81982. /**
  81983. * Returns -1 if value is negative and +1 is value is positive.
  81984. * @param value the value
  81985. * @returns the value itself if it's equal to zero.
  81986. */
  81987. static Sign(value: number): number;
  81988. /**
  81989. * Returns the value itself if it's between min and max.
  81990. * Returns min if the value is lower than min.
  81991. * Returns max if the value is greater than max.
  81992. * @param value the value to clmap
  81993. * @param min the min value to clamp to (default: 0)
  81994. * @param max the max value to clamp to (default: 1)
  81995. * @returns the clamped value
  81996. */
  81997. static Clamp(value: number, min?: number, max?: number): number;
  81998. /**
  81999. * the log2 of value.
  82000. * @param value the value to compute log2 of
  82001. * @returns the log2 of value.
  82002. */
  82003. static Log2(value: number): number;
  82004. /**
  82005. * Loops the value, so that it is never larger than length and never smaller than 0.
  82006. *
  82007. * This is similar to the modulo operator but it works with floating point numbers.
  82008. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82009. * With t = 5 and length = 2.5, the result would be 0.0.
  82010. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82011. * @param value the value
  82012. * @param length the length
  82013. * @returns the looped value
  82014. */
  82015. static Repeat(value: number, length: number): number;
  82016. /**
  82017. * Normalize the value between 0.0 and 1.0 using min and max values
  82018. * @param value value to normalize
  82019. * @param min max to normalize between
  82020. * @param max min to normalize between
  82021. * @returns the normalized value
  82022. */
  82023. static Normalize(value: number, min: number, max: number): number;
  82024. /**
  82025. * Denormalize the value from 0.0 and 1.0 using min and max values
  82026. * @param normalized value to denormalize
  82027. * @param min max to denormalize between
  82028. * @param max min to denormalize between
  82029. * @returns the denormalized value
  82030. */
  82031. static Denormalize(normalized: number, min: number, max: number): number;
  82032. /**
  82033. * Calculates the shortest difference between two given angles given in degrees.
  82034. * @param current current angle in degrees
  82035. * @param target target angle in degrees
  82036. * @returns the delta
  82037. */
  82038. static DeltaAngle(current: number, target: number): number;
  82039. /**
  82040. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82041. * @param tx value
  82042. * @param length length
  82043. * @returns The returned value will move back and forth between 0 and length
  82044. */
  82045. static PingPong(tx: number, length: number): number;
  82046. /**
  82047. * Interpolates between min and max with smoothing at the limits.
  82048. *
  82049. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82050. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82051. * @param from from
  82052. * @param to to
  82053. * @param tx value
  82054. * @returns the smooth stepped value
  82055. */
  82056. static SmoothStep(from: number, to: number, tx: number): number;
  82057. /**
  82058. * Moves a value current towards target.
  82059. *
  82060. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82061. * Negative values of maxDelta pushes the value away from target.
  82062. * @param current current value
  82063. * @param target target value
  82064. * @param maxDelta max distance to move
  82065. * @returns resulting value
  82066. */
  82067. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82068. /**
  82069. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82070. *
  82071. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82072. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82073. * @param current current value
  82074. * @param target target value
  82075. * @param maxDelta max distance to move
  82076. * @returns resulting angle
  82077. */
  82078. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82079. /**
  82080. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82081. * @param start start value
  82082. * @param end target value
  82083. * @param amount amount to lerp between
  82084. * @returns the lerped value
  82085. */
  82086. static Lerp(start: number, end: number, amount: number): number;
  82087. /**
  82088. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82089. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82090. * @param start start value
  82091. * @param end target value
  82092. * @param amount amount to lerp between
  82093. * @returns the lerped value
  82094. */
  82095. static LerpAngle(start: number, end: number, amount: number): number;
  82096. /**
  82097. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82098. * @param a start value
  82099. * @param b target value
  82100. * @param value value between a and b
  82101. * @returns the inverseLerp value
  82102. */
  82103. static InverseLerp(a: number, b: number, value: number): number;
  82104. /**
  82105. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82106. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82107. * @param value1 spline value
  82108. * @param tangent1 spline value
  82109. * @param value2 spline value
  82110. * @param tangent2 spline value
  82111. * @param amount input value
  82112. * @returns hermite result
  82113. */
  82114. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82115. /**
  82116. * Returns a random float number between and min and max values
  82117. * @param min min value of random
  82118. * @param max max value of random
  82119. * @returns random value
  82120. */
  82121. static RandomRange(min: number, max: number): number;
  82122. /**
  82123. * This function returns percentage of a number in a given range.
  82124. *
  82125. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82126. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82127. * @param number to convert to percentage
  82128. * @param min min range
  82129. * @param max max range
  82130. * @returns the percentage
  82131. */
  82132. static RangeToPercent(number: number, min: number, max: number): number;
  82133. /**
  82134. * This function returns number that corresponds to the percentage in a given range.
  82135. *
  82136. * PercentToRange(0.34,0,100) will return 34.
  82137. * @param percent to convert to number
  82138. * @param min min range
  82139. * @param max max range
  82140. * @returns the number
  82141. */
  82142. static PercentToRange(percent: number, min: number, max: number): number;
  82143. /**
  82144. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82145. * @param angle The angle to normalize in radian.
  82146. * @return The converted angle.
  82147. */
  82148. static NormalizeRadians(angle: number): number;
  82149. }
  82150. }
  82151. declare module BABYLON {
  82152. /**
  82153. * Constant used to convert a value to gamma space
  82154. * @ignorenaming
  82155. */
  82156. export const ToGammaSpace: number;
  82157. /**
  82158. * Constant used to convert a value to linear space
  82159. * @ignorenaming
  82160. */
  82161. export const ToLinearSpace = 2.2;
  82162. /**
  82163. * Constant used to define the minimal number value in Babylon.js
  82164. * @ignorenaming
  82165. */
  82166. let Epsilon: number;
  82167. }
  82168. declare module BABYLON {
  82169. /**
  82170. * Class used to represent a viewport on screen
  82171. */
  82172. export class Viewport {
  82173. /** viewport left coordinate */
  82174. x: number;
  82175. /** viewport top coordinate */
  82176. y: number;
  82177. /**viewport width */
  82178. width: number;
  82179. /** viewport height */
  82180. height: number;
  82181. /**
  82182. * Creates a Viewport object located at (x, y) and sized (width, height)
  82183. * @param x defines viewport left coordinate
  82184. * @param y defines viewport top coordinate
  82185. * @param width defines the viewport width
  82186. * @param height defines the viewport height
  82187. */
  82188. constructor(
  82189. /** viewport left coordinate */
  82190. x: number,
  82191. /** viewport top coordinate */
  82192. y: number,
  82193. /**viewport width */
  82194. width: number,
  82195. /** viewport height */
  82196. height: number);
  82197. /**
  82198. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82199. * @param renderWidth defines the rendering width
  82200. * @param renderHeight defines the rendering height
  82201. * @returns a new Viewport
  82202. */
  82203. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82204. /**
  82205. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82206. * @param renderWidth defines the rendering width
  82207. * @param renderHeight defines the rendering height
  82208. * @param ref defines the target viewport
  82209. * @returns the current viewport
  82210. */
  82211. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82212. /**
  82213. * Returns a new Viewport copied from the current one
  82214. * @returns a new Viewport
  82215. */
  82216. clone(): Viewport;
  82217. }
  82218. }
  82219. declare module BABYLON {
  82220. /**
  82221. * Class containing a set of static utilities functions for arrays.
  82222. */
  82223. export class ArrayTools {
  82224. /**
  82225. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82226. * @param size the number of element to construct and put in the array
  82227. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82228. * @returns a new array filled with new objects
  82229. */
  82230. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82231. }
  82232. }
  82233. declare module BABYLON {
  82234. /**
  82235. * Represents a plane by the equation ax + by + cz + d = 0
  82236. */
  82237. export class Plane {
  82238. private static _TmpMatrix;
  82239. /**
  82240. * Normal of the plane (a,b,c)
  82241. */
  82242. normal: Vector3;
  82243. /**
  82244. * d component of the plane
  82245. */
  82246. d: number;
  82247. /**
  82248. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82249. * @param a a component of the plane
  82250. * @param b b component of the plane
  82251. * @param c c component of the plane
  82252. * @param d d component of the plane
  82253. */
  82254. constructor(a: number, b: number, c: number, d: number);
  82255. /**
  82256. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82257. */
  82258. asArray(): number[];
  82259. /**
  82260. * @returns a new plane copied from the current Plane.
  82261. */
  82262. clone(): Plane;
  82263. /**
  82264. * @returns the string "Plane".
  82265. */
  82266. getClassName(): string;
  82267. /**
  82268. * @returns the Plane hash code.
  82269. */
  82270. getHashCode(): number;
  82271. /**
  82272. * Normalize the current Plane in place.
  82273. * @returns the updated Plane.
  82274. */
  82275. normalize(): Plane;
  82276. /**
  82277. * Applies a transformation the plane and returns the result
  82278. * @param transformation the transformation matrix to be applied to the plane
  82279. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82280. */
  82281. transform(transformation: DeepImmutable<Matrix>): Plane;
  82282. /**
  82283. * Compute the dot product between the point and the plane normal
  82284. * @param point point to calculate the dot product with
  82285. * @returns the dot product (float) of the point coordinates and the plane normal.
  82286. */
  82287. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82288. /**
  82289. * Updates the current Plane from the plane defined by the three given points.
  82290. * @param point1 one of the points used to contruct the plane
  82291. * @param point2 one of the points used to contruct the plane
  82292. * @param point3 one of the points used to contruct the plane
  82293. * @returns the updated Plane.
  82294. */
  82295. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82296. /**
  82297. * Checks if the plane is facing a given direction
  82298. * @param direction the direction to check if the plane is facing
  82299. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82300. * @returns True is the vector "direction" is the same side than the plane normal.
  82301. */
  82302. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82303. /**
  82304. * Calculates the distance to a point
  82305. * @param point point to calculate distance to
  82306. * @returns the signed distance (float) from the given point to the Plane.
  82307. */
  82308. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82309. /**
  82310. * Creates a plane from an array
  82311. * @param array the array to create a plane from
  82312. * @returns a new Plane from the given array.
  82313. */
  82314. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82315. /**
  82316. * Creates a plane from three points
  82317. * @param point1 point used to create the plane
  82318. * @param point2 point used to create the plane
  82319. * @param point3 point used to create the plane
  82320. * @returns a new Plane defined by the three given points.
  82321. */
  82322. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82323. /**
  82324. * Creates a plane from an origin point and a normal
  82325. * @param origin origin of the plane to be constructed
  82326. * @param normal normal of the plane to be constructed
  82327. * @returns a new Plane the normal vector to this plane at the given origin point.
  82328. * Note : the vector "normal" is updated because normalized.
  82329. */
  82330. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82331. /**
  82332. * Calculates the distance from a plane and a point
  82333. * @param origin origin of the plane to be constructed
  82334. * @param normal normal of the plane to be constructed
  82335. * @param point point to calculate distance to
  82336. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82337. */
  82338. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82339. }
  82340. }
  82341. declare module BABYLON {
  82342. /** @hidden */
  82343. export class PerformanceConfigurator {
  82344. /** @hidden */
  82345. static MatrixUse64Bits: boolean;
  82346. /** @hidden */
  82347. static MatrixTrackPrecisionChange: boolean;
  82348. /** @hidden */
  82349. static MatrixCurrentType: any;
  82350. /** @hidden */
  82351. static MatrixTrackedMatrices: Array<any> | null;
  82352. /** @hidden */
  82353. static SetMatrixPrecision(use64bits: boolean): void;
  82354. }
  82355. }
  82356. declare module BABYLON {
  82357. /**
  82358. * Class representing a vector containing 2 coordinates
  82359. */
  82360. export class Vector2 {
  82361. /** defines the first coordinate */
  82362. x: number;
  82363. /** defines the second coordinate */
  82364. y: number;
  82365. /**
  82366. * Creates a new Vector2 from the given x and y coordinates
  82367. * @param x defines the first coordinate
  82368. * @param y defines the second coordinate
  82369. */
  82370. constructor(
  82371. /** defines the first coordinate */
  82372. x?: number,
  82373. /** defines the second coordinate */
  82374. y?: number);
  82375. /**
  82376. * Gets a string with the Vector2 coordinates
  82377. * @returns a string with the Vector2 coordinates
  82378. */
  82379. toString(): string;
  82380. /**
  82381. * Gets class name
  82382. * @returns the string "Vector2"
  82383. */
  82384. getClassName(): string;
  82385. /**
  82386. * Gets current vector hash code
  82387. * @returns the Vector2 hash code as a number
  82388. */
  82389. getHashCode(): number;
  82390. /**
  82391. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82392. * @param array defines the source array
  82393. * @param index defines the offset in source array
  82394. * @returns the current Vector2
  82395. */
  82396. toArray(array: FloatArray, index?: number): Vector2;
  82397. /**
  82398. * Update the current vector from an array
  82399. * @param array defines the destination array
  82400. * @param index defines the offset in the destination array
  82401. * @returns the current Vector3
  82402. */
  82403. fromArray(array: FloatArray, index?: number): Vector2;
  82404. /**
  82405. * Copy the current vector to an array
  82406. * @returns a new array with 2 elements: the Vector2 coordinates.
  82407. */
  82408. asArray(): number[];
  82409. /**
  82410. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82411. * @param source defines the source Vector2
  82412. * @returns the current updated Vector2
  82413. */
  82414. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82415. /**
  82416. * Sets the Vector2 coordinates with the given floats
  82417. * @param x defines the first coordinate
  82418. * @param y defines the second coordinate
  82419. * @returns the current updated Vector2
  82420. */
  82421. copyFromFloats(x: number, y: number): Vector2;
  82422. /**
  82423. * Sets the Vector2 coordinates with the given floats
  82424. * @param x defines the first coordinate
  82425. * @param y defines the second coordinate
  82426. * @returns the current updated Vector2
  82427. */
  82428. set(x: number, y: number): Vector2;
  82429. /**
  82430. * Add another vector with the current one
  82431. * @param otherVector defines the other vector
  82432. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82433. */
  82434. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82435. /**
  82436. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82437. * @param otherVector defines the other vector
  82438. * @param result defines the target vector
  82439. * @returns the unmodified current Vector2
  82440. */
  82441. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82442. /**
  82443. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82444. * @param otherVector defines the other vector
  82445. * @returns the current updated Vector2
  82446. */
  82447. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82448. /**
  82449. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82450. * @param otherVector defines the other vector
  82451. * @returns a new Vector2
  82452. */
  82453. addVector3(otherVector: Vector3): Vector2;
  82454. /**
  82455. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82456. * @param otherVector defines the other vector
  82457. * @returns a new Vector2
  82458. */
  82459. subtract(otherVector: Vector2): Vector2;
  82460. /**
  82461. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82462. * @param otherVector defines the other vector
  82463. * @param result defines the target vector
  82464. * @returns the unmodified current Vector2
  82465. */
  82466. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82467. /**
  82468. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82469. * @param otherVector defines the other vector
  82470. * @returns the current updated Vector2
  82471. */
  82472. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82473. /**
  82474. * Multiplies in place the current Vector2 coordinates by the given ones
  82475. * @param otherVector defines the other vector
  82476. * @returns the current updated Vector2
  82477. */
  82478. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82479. /**
  82480. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82481. * @param otherVector defines the other vector
  82482. * @returns a new Vector2
  82483. */
  82484. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82485. /**
  82486. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82487. * @param otherVector defines the other vector
  82488. * @param result defines the target vector
  82489. * @returns the unmodified current Vector2
  82490. */
  82491. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82492. /**
  82493. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82494. * @param x defines the first coordinate
  82495. * @param y defines the second coordinate
  82496. * @returns a new Vector2
  82497. */
  82498. multiplyByFloats(x: number, y: number): Vector2;
  82499. /**
  82500. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82501. * @param otherVector defines the other vector
  82502. * @returns a new Vector2
  82503. */
  82504. divide(otherVector: Vector2): Vector2;
  82505. /**
  82506. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82507. * @param otherVector defines the other vector
  82508. * @param result defines the target vector
  82509. * @returns the unmodified current Vector2
  82510. */
  82511. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82512. /**
  82513. * Divides the current Vector2 coordinates by the given ones
  82514. * @param otherVector defines the other vector
  82515. * @returns the current updated Vector2
  82516. */
  82517. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82518. /**
  82519. * Gets a new Vector2 with current Vector2 negated coordinates
  82520. * @returns a new Vector2
  82521. */
  82522. negate(): Vector2;
  82523. /**
  82524. * Negate this vector in place
  82525. * @returns this
  82526. */
  82527. negateInPlace(): Vector2;
  82528. /**
  82529. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82530. * @param result defines the Vector3 object where to store the result
  82531. * @returns the current Vector2
  82532. */
  82533. negateToRef(result: Vector2): Vector2;
  82534. /**
  82535. * Multiply the Vector2 coordinates by scale
  82536. * @param scale defines the scaling factor
  82537. * @returns the current updated Vector2
  82538. */
  82539. scaleInPlace(scale: number): Vector2;
  82540. /**
  82541. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82542. * @param scale defines the scaling factor
  82543. * @returns a new Vector2
  82544. */
  82545. scale(scale: number): Vector2;
  82546. /**
  82547. * Scale the current Vector2 values by a factor to a given Vector2
  82548. * @param scale defines the scale factor
  82549. * @param result defines the Vector2 object where to store the result
  82550. * @returns the unmodified current Vector2
  82551. */
  82552. scaleToRef(scale: number, result: Vector2): Vector2;
  82553. /**
  82554. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82555. * @param scale defines the scale factor
  82556. * @param result defines the Vector2 object where to store the result
  82557. * @returns the unmodified current Vector2
  82558. */
  82559. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82560. /**
  82561. * Gets a boolean if two vectors are equals
  82562. * @param otherVector defines the other vector
  82563. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82564. */
  82565. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82566. /**
  82567. * Gets a boolean if two vectors are equals (using an epsilon value)
  82568. * @param otherVector defines the other vector
  82569. * @param epsilon defines the minimal distance to consider equality
  82570. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82571. */
  82572. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82573. /**
  82574. * Gets a new Vector2 from current Vector2 floored values
  82575. * @returns a new Vector2
  82576. */
  82577. floor(): Vector2;
  82578. /**
  82579. * Gets a new Vector2 from current Vector2 floored values
  82580. * @returns a new Vector2
  82581. */
  82582. fract(): Vector2;
  82583. /**
  82584. * Gets the length of the vector
  82585. * @returns the vector length (float)
  82586. */
  82587. length(): number;
  82588. /**
  82589. * Gets the vector squared length
  82590. * @returns the vector squared length (float)
  82591. */
  82592. lengthSquared(): number;
  82593. /**
  82594. * Normalize the vector
  82595. * @returns the current updated Vector2
  82596. */
  82597. normalize(): Vector2;
  82598. /**
  82599. * Gets a new Vector2 copied from the Vector2
  82600. * @returns a new Vector2
  82601. */
  82602. clone(): Vector2;
  82603. /**
  82604. * Gets a new Vector2(0, 0)
  82605. * @returns a new Vector2
  82606. */
  82607. static Zero(): Vector2;
  82608. /**
  82609. * Gets a new Vector2(1, 1)
  82610. * @returns a new Vector2
  82611. */
  82612. static One(): Vector2;
  82613. /**
  82614. * Gets a new Vector2 set from the given index element of the given array
  82615. * @param array defines the data source
  82616. * @param offset defines the offset in the data source
  82617. * @returns a new Vector2
  82618. */
  82619. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82620. /**
  82621. * Sets "result" from the given index element of the given array
  82622. * @param array defines the data source
  82623. * @param offset defines the offset in the data source
  82624. * @param result defines the target vector
  82625. */
  82626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82627. /**
  82628. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82629. * @param value1 defines 1st point of control
  82630. * @param value2 defines 2nd point of control
  82631. * @param value3 defines 3rd point of control
  82632. * @param value4 defines 4th point of control
  82633. * @param amount defines the interpolation factor
  82634. * @returns a new Vector2
  82635. */
  82636. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82637. /**
  82638. * 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".
  82639. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82640. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82641. * @param value defines the value to clamp
  82642. * @param min defines the lower limit
  82643. * @param max defines the upper limit
  82644. * @returns a new Vector2
  82645. */
  82646. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82647. /**
  82648. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82649. * @param value1 defines the 1st control point
  82650. * @param tangent1 defines the outgoing tangent
  82651. * @param value2 defines the 2nd control point
  82652. * @param tangent2 defines the incoming tangent
  82653. * @param amount defines the interpolation factor
  82654. * @returns a new Vector2
  82655. */
  82656. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82657. /**
  82658. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82659. * @param start defines the start vector
  82660. * @param end defines the end vector
  82661. * @param amount defines the interpolation factor
  82662. * @returns a new Vector2
  82663. */
  82664. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82665. /**
  82666. * Gets the dot product of the vector "left" and the vector "right"
  82667. * @param left defines first vector
  82668. * @param right defines second vector
  82669. * @returns the dot product (float)
  82670. */
  82671. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82672. /**
  82673. * Returns a new Vector2 equal to the normalized given vector
  82674. * @param vector defines the vector to normalize
  82675. * @returns a new Vector2
  82676. */
  82677. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82678. /**
  82679. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82680. * @param left defines 1st vector
  82681. * @param right defines 2nd vector
  82682. * @returns a new Vector2
  82683. */
  82684. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82685. /**
  82686. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82687. * @param left defines 1st vector
  82688. * @param right defines 2nd vector
  82689. * @returns a new Vector2
  82690. */
  82691. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82692. /**
  82693. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82694. * @param vector defines the vector to transform
  82695. * @param transformation defines the matrix to apply
  82696. * @returns a new Vector2
  82697. */
  82698. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82699. /**
  82700. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82701. * @param vector defines the vector to transform
  82702. * @param transformation defines the matrix to apply
  82703. * @param result defines the target vector
  82704. */
  82705. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82706. /**
  82707. * Determines if a given vector is included in a triangle
  82708. * @param p defines the vector to test
  82709. * @param p0 defines 1st triangle point
  82710. * @param p1 defines 2nd triangle point
  82711. * @param p2 defines 3rd triangle point
  82712. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82713. */
  82714. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82715. /**
  82716. * Gets the distance between the vectors "value1" and "value2"
  82717. * @param value1 defines first vector
  82718. * @param value2 defines second vector
  82719. * @returns the distance between vectors
  82720. */
  82721. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82722. /**
  82723. * Returns the squared distance between the vectors "value1" and "value2"
  82724. * @param value1 defines first vector
  82725. * @param value2 defines second vector
  82726. * @returns the squared distance between vectors
  82727. */
  82728. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82729. /**
  82730. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82731. * @param value1 defines first vector
  82732. * @param value2 defines second vector
  82733. * @returns a new Vector2
  82734. */
  82735. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82736. /**
  82737. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82738. * @param p defines the middle point
  82739. * @param segA defines one point of the segment
  82740. * @param segB defines the other point of the segment
  82741. * @returns the shortest distance
  82742. */
  82743. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82744. }
  82745. /**
  82746. * Class used to store (x,y,z) vector representation
  82747. * A Vector3 is the main object used in 3D geometry
  82748. * It can represent etiher the coordinates of a point the space, either a direction
  82749. * Reminder: js uses a left handed forward facing system
  82750. */
  82751. export class Vector3 {
  82752. private static _UpReadOnly;
  82753. private static _ZeroReadOnly;
  82754. /** @hidden */
  82755. _x: number;
  82756. /** @hidden */
  82757. _y: number;
  82758. /** @hidden */
  82759. _z: number;
  82760. /** @hidden */
  82761. _isDirty: boolean;
  82762. /** Gets or sets the x coordinate */
  82763. get x(): number;
  82764. set x(value: number);
  82765. /** Gets or sets the y coordinate */
  82766. get y(): number;
  82767. set y(value: number);
  82768. /** Gets or sets the z coordinate */
  82769. get z(): number;
  82770. set z(value: number);
  82771. /**
  82772. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82773. * @param x defines the first coordinates (on X axis)
  82774. * @param y defines the second coordinates (on Y axis)
  82775. * @param z defines the third coordinates (on Z axis)
  82776. */
  82777. constructor(x?: number, y?: number, z?: number);
  82778. /**
  82779. * Creates a string representation of the Vector3
  82780. * @returns a string with the Vector3 coordinates.
  82781. */
  82782. toString(): string;
  82783. /**
  82784. * Gets the class name
  82785. * @returns the string "Vector3"
  82786. */
  82787. getClassName(): string;
  82788. /**
  82789. * Creates the Vector3 hash code
  82790. * @returns a number which tends to be unique between Vector3 instances
  82791. */
  82792. getHashCode(): number;
  82793. /**
  82794. * Creates an array containing three elements : the coordinates of the Vector3
  82795. * @returns a new array of numbers
  82796. */
  82797. asArray(): number[];
  82798. /**
  82799. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82800. * @param array defines the destination array
  82801. * @param index defines the offset in the destination array
  82802. * @returns the current Vector3
  82803. */
  82804. toArray(array: FloatArray, index?: number): Vector3;
  82805. /**
  82806. * Update the current vector from an array
  82807. * @param array defines the destination array
  82808. * @param index defines the offset in the destination array
  82809. * @returns the current Vector3
  82810. */
  82811. fromArray(array: FloatArray, index?: number): Vector3;
  82812. /**
  82813. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82814. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82815. */
  82816. toQuaternion(): Quaternion;
  82817. /**
  82818. * Adds the given vector to the current Vector3
  82819. * @param otherVector defines the second operand
  82820. * @returns the current updated Vector3
  82821. */
  82822. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82823. /**
  82824. * Adds the given coordinates to the current Vector3
  82825. * @param x defines the x coordinate of the operand
  82826. * @param y defines the y coordinate of the operand
  82827. * @param z defines the z coordinate of the operand
  82828. * @returns the current updated Vector3
  82829. */
  82830. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82831. /**
  82832. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82833. * @param otherVector defines the second operand
  82834. * @returns the resulting Vector3
  82835. */
  82836. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82837. /**
  82838. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82839. * @param otherVector defines the second operand
  82840. * @param result defines the Vector3 object where to store the result
  82841. * @returns the current Vector3
  82842. */
  82843. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82844. /**
  82845. * Subtract the given vector from the current Vector3
  82846. * @param otherVector defines the second operand
  82847. * @returns the current updated Vector3
  82848. */
  82849. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82850. /**
  82851. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82852. * @param otherVector defines the second operand
  82853. * @returns the resulting Vector3
  82854. */
  82855. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82856. /**
  82857. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82858. * @param otherVector defines the second operand
  82859. * @param result defines the Vector3 object where to store the result
  82860. * @returns the current Vector3
  82861. */
  82862. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82863. /**
  82864. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82865. * @param x defines the x coordinate of the operand
  82866. * @param y defines the y coordinate of the operand
  82867. * @param z defines the z coordinate of the operand
  82868. * @returns the resulting Vector3
  82869. */
  82870. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82871. /**
  82872. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82873. * @param x defines the x coordinate of the operand
  82874. * @param y defines the y coordinate of the operand
  82875. * @param z defines the z coordinate of the operand
  82876. * @param result defines the Vector3 object where to store the result
  82877. * @returns the current Vector3
  82878. */
  82879. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82880. /**
  82881. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82882. * @returns a new Vector3
  82883. */
  82884. negate(): Vector3;
  82885. /**
  82886. * Negate this vector in place
  82887. * @returns this
  82888. */
  82889. negateInPlace(): Vector3;
  82890. /**
  82891. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82892. * @param result defines the Vector3 object where to store the result
  82893. * @returns the current Vector3
  82894. */
  82895. negateToRef(result: Vector3): Vector3;
  82896. /**
  82897. * Multiplies the Vector3 coordinates by the float "scale"
  82898. * @param scale defines the multiplier factor
  82899. * @returns the current updated Vector3
  82900. */
  82901. scaleInPlace(scale: number): Vector3;
  82902. /**
  82903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82904. * @param scale defines the multiplier factor
  82905. * @returns a new Vector3
  82906. */
  82907. scale(scale: number): Vector3;
  82908. /**
  82909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82910. * @param scale defines the multiplier factor
  82911. * @param result defines the Vector3 object where to store the result
  82912. * @returns the current Vector3
  82913. */
  82914. scaleToRef(scale: number, result: Vector3): Vector3;
  82915. /**
  82916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82917. * @param scale defines the scale factor
  82918. * @param result defines the Vector3 object where to store the result
  82919. * @returns the unmodified current Vector3
  82920. */
  82921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82922. /**
  82923. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82924. * @param origin defines the origin of the projection ray
  82925. * @param plane defines the plane to project to
  82926. * @returns the projected vector3
  82927. */
  82928. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82929. /**
  82930. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82931. * @param origin defines the origin of the projection ray
  82932. * @param plane defines the plane to project to
  82933. * @param result defines the Vector3 where to store the result
  82934. */
  82935. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82936. /**
  82937. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82938. * @param otherVector defines the second operand
  82939. * @returns true if both vectors are equals
  82940. */
  82941. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82942. /**
  82943. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82944. * @param otherVector defines the second operand
  82945. * @param epsilon defines the minimal distance to define values as equals
  82946. * @returns true if both vectors are distant less than epsilon
  82947. */
  82948. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82949. /**
  82950. * Returns true if the current Vector3 coordinates equals the given floats
  82951. * @param x defines the x coordinate of the operand
  82952. * @param y defines the y coordinate of the operand
  82953. * @param z defines the z coordinate of the operand
  82954. * @returns true if both vectors are equals
  82955. */
  82956. equalsToFloats(x: number, y: number, z: number): boolean;
  82957. /**
  82958. * Multiplies the current Vector3 coordinates by the given ones
  82959. * @param otherVector defines the second operand
  82960. * @returns the current updated Vector3
  82961. */
  82962. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82963. /**
  82964. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82965. * @param otherVector defines the second operand
  82966. * @returns the new Vector3
  82967. */
  82968. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82969. /**
  82970. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82971. * @param otherVector defines the second operand
  82972. * @param result defines the Vector3 object where to store the result
  82973. * @returns the current Vector3
  82974. */
  82975. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82976. /**
  82977. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82978. * @param x defines the x coordinate of the operand
  82979. * @param y defines the y coordinate of the operand
  82980. * @param z defines the z coordinate of the operand
  82981. * @returns the new Vector3
  82982. */
  82983. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82984. /**
  82985. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82986. * @param otherVector defines the second operand
  82987. * @returns the new Vector3
  82988. */
  82989. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82990. /**
  82991. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82992. * @param otherVector defines the second operand
  82993. * @param result defines the Vector3 object where to store the result
  82994. * @returns the current Vector3
  82995. */
  82996. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82997. /**
  82998. * Divides the current Vector3 coordinates by the given ones.
  82999. * @param otherVector defines the second operand
  83000. * @returns the current updated Vector3
  83001. */
  83002. divideInPlace(otherVector: Vector3): Vector3;
  83003. /**
  83004. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83005. * @param other defines the second operand
  83006. * @returns the current updated Vector3
  83007. */
  83008. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83009. /**
  83010. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83011. * @param other defines the second operand
  83012. * @returns the current updated Vector3
  83013. */
  83014. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83015. /**
  83016. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83017. * @param x defines the x coordinate of the operand
  83018. * @param y defines the y coordinate of the operand
  83019. * @param z defines the z coordinate of the operand
  83020. * @returns the current updated Vector3
  83021. */
  83022. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83023. /**
  83024. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83025. * @param x defines the x coordinate of the operand
  83026. * @param y defines the y coordinate of the operand
  83027. * @param z defines the z coordinate of the operand
  83028. * @returns the current updated Vector3
  83029. */
  83030. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83031. /**
  83032. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83033. * Check if is non uniform within a certain amount of decimal places to account for this
  83034. * @param epsilon the amount the values can differ
  83035. * @returns if the the vector is non uniform to a certain number of decimal places
  83036. */
  83037. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83038. /**
  83039. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83040. */
  83041. get isNonUniform(): boolean;
  83042. /**
  83043. * Gets a new Vector3 from current Vector3 floored values
  83044. * @returns a new Vector3
  83045. */
  83046. floor(): Vector3;
  83047. /**
  83048. * Gets a new Vector3 from current Vector3 floored values
  83049. * @returns a new Vector3
  83050. */
  83051. fract(): Vector3;
  83052. /**
  83053. * Gets the length of the Vector3
  83054. * @returns the length of the Vector3
  83055. */
  83056. length(): number;
  83057. /**
  83058. * Gets the squared length of the Vector3
  83059. * @returns squared length of the Vector3
  83060. */
  83061. lengthSquared(): number;
  83062. /**
  83063. * Normalize the current Vector3.
  83064. * Please note that this is an in place operation.
  83065. * @returns the current updated Vector3
  83066. */
  83067. normalize(): Vector3;
  83068. /**
  83069. * Reorders the x y z properties of the vector in place
  83070. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83071. * @returns the current updated vector
  83072. */
  83073. reorderInPlace(order: string): this;
  83074. /**
  83075. * Rotates the vector around 0,0,0 by a quaternion
  83076. * @param quaternion the rotation quaternion
  83077. * @param result vector to store the result
  83078. * @returns the resulting vector
  83079. */
  83080. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83081. /**
  83082. * Rotates a vector around a given point
  83083. * @param quaternion the rotation quaternion
  83084. * @param point the point to rotate around
  83085. * @param result vector to store the result
  83086. * @returns the resulting vector
  83087. */
  83088. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83089. /**
  83090. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83091. * The cross product is then orthogonal to both current and "other"
  83092. * @param other defines the right operand
  83093. * @returns the cross product
  83094. */
  83095. cross(other: Vector3): Vector3;
  83096. /**
  83097. * Normalize the current Vector3 with the given input length.
  83098. * Please note that this is an in place operation.
  83099. * @param len the length of the vector
  83100. * @returns the current updated Vector3
  83101. */
  83102. normalizeFromLength(len: number): Vector3;
  83103. /**
  83104. * Normalize the current Vector3 to a new vector
  83105. * @returns the new Vector3
  83106. */
  83107. normalizeToNew(): Vector3;
  83108. /**
  83109. * Normalize the current Vector3 to the reference
  83110. * @param reference define the Vector3 to update
  83111. * @returns the updated Vector3
  83112. */
  83113. normalizeToRef(reference: Vector3): Vector3;
  83114. /**
  83115. * Creates a new Vector3 copied from the current Vector3
  83116. * @returns the new Vector3
  83117. */
  83118. clone(): Vector3;
  83119. /**
  83120. * Copies the given vector coordinates to the current Vector3 ones
  83121. * @param source defines the source Vector3
  83122. * @returns the current updated Vector3
  83123. */
  83124. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83125. /**
  83126. * Copies the given floats to the current Vector3 coordinates
  83127. * @param x defines the x coordinate of the operand
  83128. * @param y defines the y coordinate of the operand
  83129. * @param z defines the z coordinate of the operand
  83130. * @returns the current updated Vector3
  83131. */
  83132. copyFromFloats(x: number, y: number, z: number): Vector3;
  83133. /**
  83134. * Copies the given floats to the current Vector3 coordinates
  83135. * @param x defines the x coordinate of the operand
  83136. * @param y defines the y coordinate of the operand
  83137. * @param z defines the z coordinate of the operand
  83138. * @returns the current updated Vector3
  83139. */
  83140. set(x: number, y: number, z: number): Vector3;
  83141. /**
  83142. * Copies the given float to the current Vector3 coordinates
  83143. * @param v defines the x, y and z coordinates of the operand
  83144. * @returns the current updated Vector3
  83145. */
  83146. setAll(v: number): Vector3;
  83147. /**
  83148. * Get the clip factor between two vectors
  83149. * @param vector0 defines the first operand
  83150. * @param vector1 defines the second operand
  83151. * @param axis defines the axis to use
  83152. * @param size defines the size along the axis
  83153. * @returns the clip factor
  83154. */
  83155. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83156. /**
  83157. * Get angle between two vectors
  83158. * @param vector0 angle between vector0 and vector1
  83159. * @param vector1 angle between vector0 and vector1
  83160. * @param normal direction of the normal
  83161. * @return the angle between vector0 and vector1
  83162. */
  83163. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83164. /**
  83165. * Returns a new Vector3 set from the index "offset" of the given array
  83166. * @param array defines the source array
  83167. * @param offset defines the offset in the source array
  83168. * @returns the new Vector3
  83169. */
  83170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83171. /**
  83172. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83173. * @param array defines the source array
  83174. * @param offset defines the offset in the source array
  83175. * @returns the new Vector3
  83176. * @deprecated Please use FromArray instead.
  83177. */
  83178. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83179. /**
  83180. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83181. * @param array defines the source array
  83182. * @param offset defines the offset in the source array
  83183. * @param result defines the Vector3 where to store the result
  83184. */
  83185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83186. /**
  83187. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83188. * @param array defines the source array
  83189. * @param offset defines the offset in the source array
  83190. * @param result defines the Vector3 where to store the result
  83191. * @deprecated Please use FromArrayToRef instead.
  83192. */
  83193. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83194. /**
  83195. * Sets the given vector "result" with the given floats.
  83196. * @param x defines the x coordinate of the source
  83197. * @param y defines the y coordinate of the source
  83198. * @param z defines the z coordinate of the source
  83199. * @param result defines the Vector3 where to store the result
  83200. */
  83201. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83202. /**
  83203. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83204. * @returns a new empty Vector3
  83205. */
  83206. static Zero(): Vector3;
  83207. /**
  83208. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83209. * @returns a new unit Vector3
  83210. */
  83211. static One(): Vector3;
  83212. /**
  83213. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83214. * @returns a new up Vector3
  83215. */
  83216. static Up(): Vector3;
  83217. /**
  83218. * Gets a up Vector3 that must not be updated
  83219. */
  83220. static get UpReadOnly(): DeepImmutable<Vector3>;
  83221. /**
  83222. * Gets a zero Vector3 that must not be updated
  83223. */
  83224. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83225. /**
  83226. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83227. * @returns a new down Vector3
  83228. */
  83229. static Down(): Vector3;
  83230. /**
  83231. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83232. * @param rightHandedSystem is the scene right-handed (negative z)
  83233. * @returns a new forward Vector3
  83234. */
  83235. static Forward(rightHandedSystem?: boolean): Vector3;
  83236. /**
  83237. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83238. * @param rightHandedSystem is the scene right-handed (negative-z)
  83239. * @returns a new forward Vector3
  83240. */
  83241. static Backward(rightHandedSystem?: boolean): Vector3;
  83242. /**
  83243. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83244. * @returns a new right Vector3
  83245. */
  83246. static Right(): Vector3;
  83247. /**
  83248. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83249. * @returns a new left Vector3
  83250. */
  83251. static Left(): Vector3;
  83252. /**
  83253. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83254. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83255. * @param vector defines the Vector3 to transform
  83256. * @param transformation defines the transformation matrix
  83257. * @returns the transformed Vector3
  83258. */
  83259. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83260. /**
  83261. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83262. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83263. * @param vector defines the Vector3 to transform
  83264. * @param transformation defines the transformation matrix
  83265. * @param result defines the Vector3 where to store the result
  83266. */
  83267. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83268. /**
  83269. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83270. * This method computes tranformed coordinates only, not transformed direction vectors
  83271. * @param x define the x coordinate of the source vector
  83272. * @param y define the y coordinate of the source vector
  83273. * @param z define the z coordinate of the source vector
  83274. * @param transformation defines the transformation matrix
  83275. * @param result defines the Vector3 where to store the result
  83276. */
  83277. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83278. /**
  83279. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83280. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83281. * @param vector defines the Vector3 to transform
  83282. * @param transformation defines the transformation matrix
  83283. * @returns the new Vector3
  83284. */
  83285. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83286. /**
  83287. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83288. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83289. * @param vector defines the Vector3 to transform
  83290. * @param transformation defines the transformation matrix
  83291. * @param result defines the Vector3 where to store the result
  83292. */
  83293. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83294. /**
  83295. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83296. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83297. * @param x define the x coordinate of the source vector
  83298. * @param y define the y coordinate of the source vector
  83299. * @param z define the z coordinate of the source vector
  83300. * @param transformation defines the transformation matrix
  83301. * @param result defines the Vector3 where to store the result
  83302. */
  83303. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83304. /**
  83305. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83306. * @param value1 defines the first control point
  83307. * @param value2 defines the second control point
  83308. * @param value3 defines the third control point
  83309. * @param value4 defines the fourth control point
  83310. * @param amount defines the amount on the spline to use
  83311. * @returns the new Vector3
  83312. */
  83313. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83314. /**
  83315. * 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"
  83316. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83317. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83318. * @param value defines the current value
  83319. * @param min defines the lower range value
  83320. * @param max defines the upper range value
  83321. * @returns the new Vector3
  83322. */
  83323. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83324. /**
  83325. * 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"
  83326. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83327. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83328. * @param value defines the current value
  83329. * @param min defines the lower range value
  83330. * @param max defines the upper range value
  83331. * @param result defines the Vector3 where to store the result
  83332. */
  83333. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83334. /**
  83335. * Checks if a given vector is inside a specific range
  83336. * @param v defines the vector to test
  83337. * @param min defines the minimum range
  83338. * @param max defines the maximum range
  83339. */
  83340. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83341. /**
  83342. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83343. * @param value1 defines the first control point
  83344. * @param tangent1 defines the first tangent vector
  83345. * @param value2 defines the second control point
  83346. * @param tangent2 defines the second tangent vector
  83347. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83348. * @returns the new Vector3
  83349. */
  83350. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83351. /**
  83352. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83353. * @param start defines the start value
  83354. * @param end defines the end value
  83355. * @param amount max defines amount between both (between 0 and 1)
  83356. * @returns the new Vector3
  83357. */
  83358. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83359. /**
  83360. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83361. * @param start defines the start value
  83362. * @param end defines the end value
  83363. * @param amount max defines amount between both (between 0 and 1)
  83364. * @param result defines the Vector3 where to store the result
  83365. */
  83366. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83367. /**
  83368. * Returns the dot product (float) between the vectors "left" and "right"
  83369. * @param left defines the left operand
  83370. * @param right defines the right operand
  83371. * @returns the dot product
  83372. */
  83373. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83374. /**
  83375. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83376. * The cross product is then orthogonal to both "left" and "right"
  83377. * @param left defines the left operand
  83378. * @param right defines the right operand
  83379. * @returns the cross product
  83380. */
  83381. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83382. /**
  83383. * Sets the given vector "result" with the cross product of "left" and "right"
  83384. * The cross product is then orthogonal to both "left" and "right"
  83385. * @param left defines the left operand
  83386. * @param right defines the right operand
  83387. * @param result defines the Vector3 where to store the result
  83388. */
  83389. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83390. /**
  83391. * Returns a new Vector3 as the normalization of the given vector
  83392. * @param vector defines the Vector3 to normalize
  83393. * @returns the new Vector3
  83394. */
  83395. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83396. /**
  83397. * Sets the given vector "result" with the normalization of the given first vector
  83398. * @param vector defines the Vector3 to normalize
  83399. * @param result defines the Vector3 where to store the result
  83400. */
  83401. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83402. /**
  83403. * Project a Vector3 onto screen space
  83404. * @param vector defines the Vector3 to project
  83405. * @param world defines the world matrix to use
  83406. * @param transform defines the transform (view x projection) matrix to use
  83407. * @param viewport defines the screen viewport to use
  83408. * @returns the new Vector3
  83409. */
  83410. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83411. /** @hidden */
  83412. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83413. /**
  83414. * Unproject from screen space to object space
  83415. * @param source defines the screen space Vector3 to use
  83416. * @param viewportWidth defines the current width of the viewport
  83417. * @param viewportHeight defines the current height of the viewport
  83418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83419. * @param transform defines the transform (view x projection) matrix to use
  83420. * @returns the new Vector3
  83421. */
  83422. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83423. /**
  83424. * Unproject from screen space to object space
  83425. * @param source defines the screen space Vector3 to use
  83426. * @param viewportWidth defines the current width of the viewport
  83427. * @param viewportHeight defines the current height of the viewport
  83428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83429. * @param view defines the view matrix to use
  83430. * @param projection defines the projection matrix to use
  83431. * @returns the new Vector3
  83432. */
  83433. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83434. /**
  83435. * Unproject from screen space to object space
  83436. * @param source defines the screen space Vector3 to use
  83437. * @param viewportWidth defines the current width of the viewport
  83438. * @param viewportHeight defines the current height of the viewport
  83439. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83440. * @param view defines the view matrix to use
  83441. * @param projection defines the projection matrix to use
  83442. * @param result defines the Vector3 where to store the result
  83443. */
  83444. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83445. /**
  83446. * Unproject from screen space to object space
  83447. * @param sourceX defines the screen space x coordinate to use
  83448. * @param sourceY defines the screen space y coordinate to use
  83449. * @param sourceZ defines the screen space z coordinate to use
  83450. * @param viewportWidth defines the current width of the viewport
  83451. * @param viewportHeight defines the current height of the viewport
  83452. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83453. * @param view defines the view matrix to use
  83454. * @param projection defines the projection matrix to use
  83455. * @param result defines the Vector3 where to store the result
  83456. */
  83457. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83458. /**
  83459. * Gets the minimal coordinate values between two Vector3
  83460. * @param left defines the first operand
  83461. * @param right defines the second operand
  83462. * @returns the new Vector3
  83463. */
  83464. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83465. /**
  83466. * Gets the maximal coordinate values between two Vector3
  83467. * @param left defines the first operand
  83468. * @param right defines the second operand
  83469. * @returns the new Vector3
  83470. */
  83471. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83472. /**
  83473. * Returns the distance between the vectors "value1" and "value2"
  83474. * @param value1 defines the first operand
  83475. * @param value2 defines the second operand
  83476. * @returns the distance
  83477. */
  83478. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83479. /**
  83480. * Returns the squared distance between the vectors "value1" and "value2"
  83481. * @param value1 defines the first operand
  83482. * @param value2 defines the second operand
  83483. * @returns the squared distance
  83484. */
  83485. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83486. /**
  83487. * Returns a new Vector3 located at the center between "value1" and "value2"
  83488. * @param value1 defines the first operand
  83489. * @param value2 defines the second operand
  83490. * @returns the new Vector3
  83491. */
  83492. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83493. /**
  83494. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83495. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83496. * to something in order to rotate it from its local system to the given target system
  83497. * Note: axis1, axis2 and axis3 are normalized during this operation
  83498. * @param axis1 defines the first axis
  83499. * @param axis2 defines the second axis
  83500. * @param axis3 defines the third axis
  83501. * @returns a new Vector3
  83502. */
  83503. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83504. /**
  83505. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83506. * @param axis1 defines the first axis
  83507. * @param axis2 defines the second axis
  83508. * @param axis3 defines the third axis
  83509. * @param ref defines the Vector3 where to store the result
  83510. */
  83511. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83512. }
  83513. /**
  83514. * Vector4 class created for EulerAngle class conversion to Quaternion
  83515. */
  83516. export class Vector4 {
  83517. /** x value of the vector */
  83518. x: number;
  83519. /** y value of the vector */
  83520. y: number;
  83521. /** z value of the vector */
  83522. z: number;
  83523. /** w value of the vector */
  83524. w: number;
  83525. /**
  83526. * Creates a Vector4 object from the given floats.
  83527. * @param x x value of the vector
  83528. * @param y y value of the vector
  83529. * @param z z value of the vector
  83530. * @param w w value of the vector
  83531. */
  83532. constructor(
  83533. /** x value of the vector */
  83534. x: number,
  83535. /** y value of the vector */
  83536. y: number,
  83537. /** z value of the vector */
  83538. z: number,
  83539. /** w value of the vector */
  83540. w: number);
  83541. /**
  83542. * Returns the string with the Vector4 coordinates.
  83543. * @returns a string containing all the vector values
  83544. */
  83545. toString(): string;
  83546. /**
  83547. * Returns the string "Vector4".
  83548. * @returns "Vector4"
  83549. */
  83550. getClassName(): string;
  83551. /**
  83552. * Returns the Vector4 hash code.
  83553. * @returns a unique hash code
  83554. */
  83555. getHashCode(): number;
  83556. /**
  83557. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83558. * @returns the resulting array
  83559. */
  83560. asArray(): number[];
  83561. /**
  83562. * Populates the given array from the given index with the Vector4 coordinates.
  83563. * @param array array to populate
  83564. * @param index index of the array to start at (default: 0)
  83565. * @returns the Vector4.
  83566. */
  83567. toArray(array: FloatArray, index?: number): Vector4;
  83568. /**
  83569. * Update the current vector from an array
  83570. * @param array defines the destination array
  83571. * @param index defines the offset in the destination array
  83572. * @returns the current Vector3
  83573. */
  83574. fromArray(array: FloatArray, index?: number): Vector4;
  83575. /**
  83576. * Adds the given vector to the current Vector4.
  83577. * @param otherVector the vector to add
  83578. * @returns the updated Vector4.
  83579. */
  83580. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83581. /**
  83582. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83583. * @param otherVector the vector to add
  83584. * @returns the resulting vector
  83585. */
  83586. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83587. /**
  83588. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83589. * @param otherVector the vector to add
  83590. * @param result the vector to store the result
  83591. * @returns the current Vector4.
  83592. */
  83593. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83594. /**
  83595. * Subtract in place the given vector from the current Vector4.
  83596. * @param otherVector the vector to subtract
  83597. * @returns the updated Vector4.
  83598. */
  83599. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83600. /**
  83601. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83602. * @param otherVector the vector to add
  83603. * @returns the new vector with the result
  83604. */
  83605. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83606. /**
  83607. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83608. * @param otherVector the vector to subtract
  83609. * @param result the vector to store the result
  83610. * @returns the current Vector4.
  83611. */
  83612. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83613. /**
  83614. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83615. */
  83616. /**
  83617. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83618. * @param x value to subtract
  83619. * @param y value to subtract
  83620. * @param z value to subtract
  83621. * @param w value to subtract
  83622. * @returns new vector containing the result
  83623. */
  83624. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83625. /**
  83626. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83627. * @param x value to subtract
  83628. * @param y value to subtract
  83629. * @param z value to subtract
  83630. * @param w value to subtract
  83631. * @param result the vector to store the result in
  83632. * @returns the current Vector4.
  83633. */
  83634. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83635. /**
  83636. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83637. * @returns a new vector with the negated values
  83638. */
  83639. negate(): Vector4;
  83640. /**
  83641. * Negate this vector in place
  83642. * @returns this
  83643. */
  83644. negateInPlace(): Vector4;
  83645. /**
  83646. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83647. * @param result defines the Vector3 object where to store the result
  83648. * @returns the current Vector4
  83649. */
  83650. negateToRef(result: Vector4): Vector4;
  83651. /**
  83652. * Multiplies the current Vector4 coordinates by scale (float).
  83653. * @param scale the number to scale with
  83654. * @returns the updated Vector4.
  83655. */
  83656. scaleInPlace(scale: number): Vector4;
  83657. /**
  83658. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83659. * @param scale the number to scale with
  83660. * @returns a new vector with the result
  83661. */
  83662. scale(scale: number): Vector4;
  83663. /**
  83664. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83665. * @param scale the number to scale with
  83666. * @param result a vector to store the result in
  83667. * @returns the current Vector4.
  83668. */
  83669. scaleToRef(scale: number, result: Vector4): Vector4;
  83670. /**
  83671. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83672. * @param scale defines the scale factor
  83673. * @param result defines the Vector4 object where to store the result
  83674. * @returns the unmodified current Vector4
  83675. */
  83676. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83677. /**
  83678. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83679. * @param otherVector the vector to compare against
  83680. * @returns true if they are equal
  83681. */
  83682. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83683. /**
  83684. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83685. * @param otherVector vector to compare against
  83686. * @param epsilon (Default: very small number)
  83687. * @returns true if they are equal
  83688. */
  83689. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83690. /**
  83691. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83692. * @param x x value to compare against
  83693. * @param y y value to compare against
  83694. * @param z z value to compare against
  83695. * @param w w value to compare against
  83696. * @returns true if equal
  83697. */
  83698. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83699. /**
  83700. * Multiplies in place the current Vector4 by the given one.
  83701. * @param otherVector vector to multiple with
  83702. * @returns the updated Vector4.
  83703. */
  83704. multiplyInPlace(otherVector: Vector4): Vector4;
  83705. /**
  83706. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83707. * @param otherVector vector to multiple with
  83708. * @returns resulting new vector
  83709. */
  83710. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83711. /**
  83712. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83713. * @param otherVector vector to multiple with
  83714. * @param result vector to store the result
  83715. * @returns the current Vector4.
  83716. */
  83717. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83718. /**
  83719. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83720. * @param x x value multiply with
  83721. * @param y y value multiply with
  83722. * @param z z value multiply with
  83723. * @param w w value multiply with
  83724. * @returns resulting new vector
  83725. */
  83726. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83727. /**
  83728. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83729. * @param otherVector vector to devide with
  83730. * @returns resulting new vector
  83731. */
  83732. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83733. /**
  83734. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83735. * @param otherVector vector to devide with
  83736. * @param result vector to store the result
  83737. * @returns the current Vector4.
  83738. */
  83739. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83740. /**
  83741. * Divides the current Vector3 coordinates by the given ones.
  83742. * @param otherVector vector to devide with
  83743. * @returns the updated Vector3.
  83744. */
  83745. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83746. /**
  83747. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83748. * @param other defines the second operand
  83749. * @returns the current updated Vector4
  83750. */
  83751. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83752. /**
  83753. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83754. * @param other defines the second operand
  83755. * @returns the current updated Vector4
  83756. */
  83757. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83758. /**
  83759. * Gets a new Vector4 from current Vector4 floored values
  83760. * @returns a new Vector4
  83761. */
  83762. floor(): Vector4;
  83763. /**
  83764. * Gets a new Vector4 from current Vector3 floored values
  83765. * @returns a new Vector4
  83766. */
  83767. fract(): Vector4;
  83768. /**
  83769. * Returns the Vector4 length (float).
  83770. * @returns the length
  83771. */
  83772. length(): number;
  83773. /**
  83774. * Returns the Vector4 squared length (float).
  83775. * @returns the length squared
  83776. */
  83777. lengthSquared(): number;
  83778. /**
  83779. * Normalizes in place the Vector4.
  83780. * @returns the updated Vector4.
  83781. */
  83782. normalize(): Vector4;
  83783. /**
  83784. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83785. * @returns this converted to a new vector3
  83786. */
  83787. toVector3(): Vector3;
  83788. /**
  83789. * Returns a new Vector4 copied from the current one.
  83790. * @returns the new cloned vector
  83791. */
  83792. clone(): Vector4;
  83793. /**
  83794. * Updates the current Vector4 with the given one coordinates.
  83795. * @param source the source vector to copy from
  83796. * @returns the updated Vector4.
  83797. */
  83798. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83799. /**
  83800. * Updates the current Vector4 coordinates with the given floats.
  83801. * @param x float to copy from
  83802. * @param y float to copy from
  83803. * @param z float to copy from
  83804. * @param w float to copy from
  83805. * @returns the updated Vector4.
  83806. */
  83807. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83808. /**
  83809. * Updates the current Vector4 coordinates with the given floats.
  83810. * @param x float to set from
  83811. * @param y float to set from
  83812. * @param z float to set from
  83813. * @param w float to set from
  83814. * @returns the updated Vector4.
  83815. */
  83816. set(x: number, y: number, z: number, w: number): Vector4;
  83817. /**
  83818. * Copies the given float to the current Vector3 coordinates
  83819. * @param v defines the x, y, z and w coordinates of the operand
  83820. * @returns the current updated Vector3
  83821. */
  83822. setAll(v: number): Vector4;
  83823. /**
  83824. * Returns a new Vector4 set from the starting index of the given array.
  83825. * @param array the array to pull values from
  83826. * @param offset the offset into the array to start at
  83827. * @returns the new vector
  83828. */
  83829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83830. /**
  83831. * Updates the given vector "result" from the starting index of the given array.
  83832. * @param array the array to pull values from
  83833. * @param offset the offset into the array to start at
  83834. * @param result the vector to store the result in
  83835. */
  83836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83837. /**
  83838. * Updates the given vector "result" from the starting index of the given Float32Array.
  83839. * @param array the array to pull values from
  83840. * @param offset the offset into the array to start at
  83841. * @param result the vector to store the result in
  83842. */
  83843. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83844. /**
  83845. * Updates the given vector "result" coordinates from the given floats.
  83846. * @param x float to set from
  83847. * @param y float to set from
  83848. * @param z float to set from
  83849. * @param w float to set from
  83850. * @param result the vector to the floats in
  83851. */
  83852. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83853. /**
  83854. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83855. * @returns the new vector
  83856. */
  83857. static Zero(): Vector4;
  83858. /**
  83859. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83860. * @returns the new vector
  83861. */
  83862. static One(): Vector4;
  83863. /**
  83864. * Returns a new normalized Vector4 from the given one.
  83865. * @param vector the vector to normalize
  83866. * @returns the vector
  83867. */
  83868. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83869. /**
  83870. * Updates the given vector "result" from the normalization of the given one.
  83871. * @param vector the vector to normalize
  83872. * @param result the vector to store the result in
  83873. */
  83874. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83875. /**
  83876. * Returns a vector with the minimum values from the left and right vectors
  83877. * @param left left vector to minimize
  83878. * @param right right vector to minimize
  83879. * @returns a new vector with the minimum of the left and right vector values
  83880. */
  83881. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83882. /**
  83883. * Returns a vector with the maximum values from the left and right vectors
  83884. * @param left left vector to maximize
  83885. * @param right right vector to maximize
  83886. * @returns a new vector with the maximum of the left and right vector values
  83887. */
  83888. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83889. /**
  83890. * Returns the distance (float) between the vectors "value1" and "value2".
  83891. * @param value1 value to calulate the distance between
  83892. * @param value2 value to calulate the distance between
  83893. * @return the distance between the two vectors
  83894. */
  83895. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83896. /**
  83897. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83898. * @param value1 value to calulate the distance between
  83899. * @param value2 value to calulate the distance between
  83900. * @return the distance between the two vectors squared
  83901. */
  83902. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83903. /**
  83904. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83905. * @param value1 value to calulate the center between
  83906. * @param value2 value to calulate the center between
  83907. * @return the center between the two vectors
  83908. */
  83909. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83910. /**
  83911. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83912. * This methods computes transformed normalized direction vectors only.
  83913. * @param vector the vector to transform
  83914. * @param transformation the transformation matrix to apply
  83915. * @returns the new vector
  83916. */
  83917. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83918. /**
  83919. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83920. * This methods computes transformed normalized direction vectors only.
  83921. * @param vector the vector to transform
  83922. * @param transformation the transformation matrix to apply
  83923. * @param result the vector to store the result in
  83924. */
  83925. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83926. /**
  83927. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83928. * This methods computes transformed normalized direction vectors only.
  83929. * @param x value to transform
  83930. * @param y value to transform
  83931. * @param z value to transform
  83932. * @param w value to transform
  83933. * @param transformation the transformation matrix to apply
  83934. * @param result the vector to store the results in
  83935. */
  83936. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83937. /**
  83938. * Creates a new Vector4 from a Vector3
  83939. * @param source defines the source data
  83940. * @param w defines the 4th component (default is 0)
  83941. * @returns a new Vector4
  83942. */
  83943. static FromVector3(source: Vector3, w?: number): Vector4;
  83944. }
  83945. /**
  83946. * Class used to store quaternion data
  83947. * @see https://en.wikipedia.org/wiki/Quaternion
  83948. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83949. */
  83950. export class Quaternion {
  83951. /** @hidden */
  83952. _x: number;
  83953. /** @hidden */
  83954. _y: number;
  83955. /** @hidden */
  83956. _z: number;
  83957. /** @hidden */
  83958. _w: number;
  83959. /** @hidden */
  83960. _isDirty: boolean;
  83961. /** Gets or sets the x coordinate */
  83962. get x(): number;
  83963. set x(value: number);
  83964. /** Gets or sets the y coordinate */
  83965. get y(): number;
  83966. set y(value: number);
  83967. /** Gets or sets the z coordinate */
  83968. get z(): number;
  83969. set z(value: number);
  83970. /** Gets or sets the w coordinate */
  83971. get w(): number;
  83972. set w(value: number);
  83973. /**
  83974. * Creates a new Quaternion from the given floats
  83975. * @param x defines the first component (0 by default)
  83976. * @param y defines the second component (0 by default)
  83977. * @param z defines the third component (0 by default)
  83978. * @param w defines the fourth component (1.0 by default)
  83979. */
  83980. constructor(x?: number, y?: number, z?: number, w?: number);
  83981. /**
  83982. * Gets a string representation for the current quaternion
  83983. * @returns a string with the Quaternion coordinates
  83984. */
  83985. toString(): string;
  83986. /**
  83987. * Gets the class name of the quaternion
  83988. * @returns the string "Quaternion"
  83989. */
  83990. getClassName(): string;
  83991. /**
  83992. * Gets a hash code for this quaternion
  83993. * @returns the quaternion hash code
  83994. */
  83995. getHashCode(): number;
  83996. /**
  83997. * Copy the quaternion to an array
  83998. * @returns a new array populated with 4 elements from the quaternion coordinates
  83999. */
  84000. asArray(): number[];
  84001. /**
  84002. * Check if two quaternions are equals
  84003. * @param otherQuaternion defines the second operand
  84004. * @return true if the current quaternion and the given one coordinates are strictly equals
  84005. */
  84006. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84007. /**
  84008. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84009. * @param otherQuaternion defines the other quaternion
  84010. * @param epsilon defines the minimal distance to consider equality
  84011. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84012. */
  84013. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84014. /**
  84015. * Clone the current quaternion
  84016. * @returns a new quaternion copied from the current one
  84017. */
  84018. clone(): Quaternion;
  84019. /**
  84020. * Copy a quaternion to the current one
  84021. * @param other defines the other quaternion
  84022. * @returns the updated current quaternion
  84023. */
  84024. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84025. /**
  84026. * Updates the current quaternion with the given float coordinates
  84027. * @param x defines the x coordinate
  84028. * @param y defines the y coordinate
  84029. * @param z defines the z coordinate
  84030. * @param w defines the w coordinate
  84031. * @returns the updated current quaternion
  84032. */
  84033. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84034. /**
  84035. * Updates the current quaternion from the given float coordinates
  84036. * @param x defines the x coordinate
  84037. * @param y defines the y coordinate
  84038. * @param z defines the z coordinate
  84039. * @param w defines the w coordinate
  84040. * @returns the updated current quaternion
  84041. */
  84042. set(x: number, y: number, z: number, w: number): Quaternion;
  84043. /**
  84044. * Adds two quaternions
  84045. * @param other defines the second operand
  84046. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84047. */
  84048. add(other: DeepImmutable<Quaternion>): Quaternion;
  84049. /**
  84050. * Add a quaternion to the current one
  84051. * @param other defines the quaternion to add
  84052. * @returns the current quaternion
  84053. */
  84054. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84055. /**
  84056. * Subtract two quaternions
  84057. * @param other defines the second operand
  84058. * @returns a new quaternion as the subtraction result of the given one from the current one
  84059. */
  84060. subtract(other: Quaternion): Quaternion;
  84061. /**
  84062. * Multiplies the current quaternion by a scale factor
  84063. * @param value defines the scale factor
  84064. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84065. */
  84066. scale(value: number): Quaternion;
  84067. /**
  84068. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84069. * @param scale defines the scale factor
  84070. * @param result defines the Quaternion object where to store the result
  84071. * @returns the unmodified current quaternion
  84072. */
  84073. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84074. /**
  84075. * Multiplies in place the current quaternion by a scale factor
  84076. * @param value defines the scale factor
  84077. * @returns the current modified quaternion
  84078. */
  84079. scaleInPlace(value: number): Quaternion;
  84080. /**
  84081. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84082. * @param scale defines the scale factor
  84083. * @param result defines the Quaternion object where to store the result
  84084. * @returns the unmodified current quaternion
  84085. */
  84086. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84087. /**
  84088. * Multiplies two quaternions
  84089. * @param q1 defines the second operand
  84090. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84091. */
  84092. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84093. /**
  84094. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84095. * @param q1 defines the second operand
  84096. * @param result defines the target quaternion
  84097. * @returns the current quaternion
  84098. */
  84099. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84100. /**
  84101. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84102. * @param q1 defines the second operand
  84103. * @returns the currentupdated quaternion
  84104. */
  84105. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84106. /**
  84107. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84108. * @param ref defines the target quaternion
  84109. * @returns the current quaternion
  84110. */
  84111. conjugateToRef(ref: Quaternion): Quaternion;
  84112. /**
  84113. * Conjugates in place (1-q) the current quaternion
  84114. * @returns the current updated quaternion
  84115. */
  84116. conjugateInPlace(): Quaternion;
  84117. /**
  84118. * Conjugates in place (1-q) the current quaternion
  84119. * @returns a new quaternion
  84120. */
  84121. conjugate(): Quaternion;
  84122. /**
  84123. * Gets length of current quaternion
  84124. * @returns the quaternion length (float)
  84125. */
  84126. length(): number;
  84127. /**
  84128. * Normalize in place the current quaternion
  84129. * @returns the current updated quaternion
  84130. */
  84131. normalize(): Quaternion;
  84132. /**
  84133. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84134. * @param order is a reserved parameter and is ignored for now
  84135. * @returns a new Vector3 containing the Euler angles
  84136. */
  84137. toEulerAngles(order?: string): Vector3;
  84138. /**
  84139. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84140. * @param result defines the vector which will be filled with the Euler angles
  84141. * @returns the current unchanged quaternion
  84142. */
  84143. toEulerAnglesToRef(result: Vector3): Quaternion;
  84144. /**
  84145. * Updates the given rotation matrix with the current quaternion values
  84146. * @param result defines the target matrix
  84147. * @returns the current unchanged quaternion
  84148. */
  84149. toRotationMatrix(result: Matrix): Quaternion;
  84150. /**
  84151. * Updates the current quaternion from the given rotation matrix values
  84152. * @param matrix defines the source matrix
  84153. * @returns the current updated quaternion
  84154. */
  84155. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84156. /**
  84157. * Creates a new quaternion from a rotation matrix
  84158. * @param matrix defines the source matrix
  84159. * @returns a new quaternion created from the given rotation matrix values
  84160. */
  84161. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84162. /**
  84163. * Updates the given quaternion with the given rotation matrix values
  84164. * @param matrix defines the source matrix
  84165. * @param result defines the target quaternion
  84166. */
  84167. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84168. /**
  84169. * Returns the dot product (float) between the quaternions "left" and "right"
  84170. * @param left defines the left operand
  84171. * @param right defines the right operand
  84172. * @returns the dot product
  84173. */
  84174. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84175. /**
  84176. * Checks if the two quaternions are close to each other
  84177. * @param quat0 defines the first quaternion to check
  84178. * @param quat1 defines the second quaternion to check
  84179. * @returns true if the two quaternions are close to each other
  84180. */
  84181. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84182. /**
  84183. * Creates an empty quaternion
  84184. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84185. */
  84186. static Zero(): Quaternion;
  84187. /**
  84188. * Inverse a given quaternion
  84189. * @param q defines the source quaternion
  84190. * @returns a new quaternion as the inverted current quaternion
  84191. */
  84192. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84193. /**
  84194. * Inverse a given quaternion
  84195. * @param q defines the source quaternion
  84196. * @param result the quaternion the result will be stored in
  84197. * @returns the result quaternion
  84198. */
  84199. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84200. /**
  84201. * Creates an identity quaternion
  84202. * @returns the identity quaternion
  84203. */
  84204. static Identity(): Quaternion;
  84205. /**
  84206. * Gets a boolean indicating if the given quaternion is identity
  84207. * @param quaternion defines the quaternion to check
  84208. * @returns true if the quaternion is identity
  84209. */
  84210. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84211. /**
  84212. * Creates a quaternion from a rotation around an axis
  84213. * @param axis defines the axis to use
  84214. * @param angle defines the angle to use
  84215. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84216. */
  84217. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84218. /**
  84219. * Creates a rotation around an axis and stores it into the given quaternion
  84220. * @param axis defines the axis to use
  84221. * @param angle defines the angle to use
  84222. * @param result defines the target quaternion
  84223. * @returns the target quaternion
  84224. */
  84225. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84226. /**
  84227. * Creates a new quaternion from data stored into an array
  84228. * @param array defines the data source
  84229. * @param offset defines the offset in the source array where the data starts
  84230. * @returns a new quaternion
  84231. */
  84232. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84233. /**
  84234. * Updates the given quaternion "result" from the starting index of the given array.
  84235. * @param array the array to pull values from
  84236. * @param offset the offset into the array to start at
  84237. * @param result the quaternion to store the result in
  84238. */
  84239. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84240. /**
  84241. * Create a quaternion from Euler rotation angles
  84242. * @param x Pitch
  84243. * @param y Yaw
  84244. * @param z Roll
  84245. * @returns the new Quaternion
  84246. */
  84247. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84248. /**
  84249. * Updates a quaternion from Euler rotation angles
  84250. * @param x Pitch
  84251. * @param y Yaw
  84252. * @param z Roll
  84253. * @param result the quaternion to store the result
  84254. * @returns the updated quaternion
  84255. */
  84256. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84257. /**
  84258. * Create a quaternion from Euler rotation vector
  84259. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84260. * @returns the new Quaternion
  84261. */
  84262. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84263. /**
  84264. * Updates a quaternion from Euler rotation vector
  84265. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84266. * @param result the quaternion to store the result
  84267. * @returns the updated quaternion
  84268. */
  84269. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84270. /**
  84271. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84272. * @param yaw defines the rotation around Y axis
  84273. * @param pitch defines the rotation around X axis
  84274. * @param roll defines the rotation around Z axis
  84275. * @returns the new quaternion
  84276. */
  84277. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84278. /**
  84279. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84280. * @param yaw defines the rotation around Y axis
  84281. * @param pitch defines the rotation around X axis
  84282. * @param roll defines the rotation around Z axis
  84283. * @param result defines the target quaternion
  84284. */
  84285. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84286. /**
  84287. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84288. * @param alpha defines the rotation around first axis
  84289. * @param beta defines the rotation around second axis
  84290. * @param gamma defines the rotation around third axis
  84291. * @returns the new quaternion
  84292. */
  84293. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84294. /**
  84295. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84296. * @param alpha defines the rotation around first axis
  84297. * @param beta defines the rotation around second axis
  84298. * @param gamma defines the rotation around third axis
  84299. * @param result defines the target quaternion
  84300. */
  84301. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84302. /**
  84303. * 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)
  84304. * @param axis1 defines the first axis
  84305. * @param axis2 defines the second axis
  84306. * @param axis3 defines the third axis
  84307. * @returns the new quaternion
  84308. */
  84309. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84310. /**
  84311. * 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
  84312. * @param axis1 defines the first axis
  84313. * @param axis2 defines the second axis
  84314. * @param axis3 defines the third axis
  84315. * @param ref defines the target quaternion
  84316. */
  84317. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84318. /**
  84319. * Interpolates between two quaternions
  84320. * @param left defines first quaternion
  84321. * @param right defines second quaternion
  84322. * @param amount defines the gradient to use
  84323. * @returns the new interpolated quaternion
  84324. */
  84325. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84326. /**
  84327. * Interpolates between two quaternions and stores it into a target quaternion
  84328. * @param left defines first quaternion
  84329. * @param right defines second quaternion
  84330. * @param amount defines the gradient to use
  84331. * @param result defines the target quaternion
  84332. */
  84333. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84334. /**
  84335. * Interpolate between two quaternions using Hermite interpolation
  84336. * @param value1 defines first quaternion
  84337. * @param tangent1 defines the incoming tangent
  84338. * @param value2 defines second quaternion
  84339. * @param tangent2 defines the outgoing tangent
  84340. * @param amount defines the target quaternion
  84341. * @returns the new interpolated quaternion
  84342. */
  84343. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84344. }
  84345. /**
  84346. * Class used to store matrix data (4x4)
  84347. */
  84348. export class Matrix {
  84349. /**
  84350. * Gets the precision of matrix computations
  84351. */
  84352. static get Use64Bits(): boolean;
  84353. private static _updateFlagSeed;
  84354. private static _identityReadOnly;
  84355. private _isIdentity;
  84356. private _isIdentityDirty;
  84357. private _isIdentity3x2;
  84358. private _isIdentity3x2Dirty;
  84359. /**
  84360. * Gets the update flag of the matrix which is an unique number for the matrix.
  84361. * It will be incremented every time the matrix data change.
  84362. * You can use it to speed the comparison between two versions of the same matrix.
  84363. */
  84364. updateFlag: number;
  84365. private readonly _m;
  84366. /**
  84367. * Gets the internal data of the matrix
  84368. */
  84369. get m(): DeepImmutable<Float32Array | Array<number>>;
  84370. /** @hidden */
  84371. _markAsUpdated(): void;
  84372. /** @hidden */
  84373. private _updateIdentityStatus;
  84374. /**
  84375. * Creates an empty matrix (filled with zeros)
  84376. */
  84377. constructor();
  84378. /**
  84379. * Check if the current matrix is identity
  84380. * @returns true is the matrix is the identity matrix
  84381. */
  84382. isIdentity(): boolean;
  84383. /**
  84384. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84385. * @returns true is the matrix is the identity matrix
  84386. */
  84387. isIdentityAs3x2(): boolean;
  84388. /**
  84389. * Gets the determinant of the matrix
  84390. * @returns the matrix determinant
  84391. */
  84392. determinant(): number;
  84393. /**
  84394. * Returns the matrix as a Float32Array or Array<number>
  84395. * @returns the matrix underlying array
  84396. */
  84397. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84398. /**
  84399. * Returns the matrix as a Float32Array or Array<number>
  84400. * @returns the matrix underlying array.
  84401. */
  84402. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84403. /**
  84404. * Inverts the current matrix in place
  84405. * @returns the current inverted matrix
  84406. */
  84407. invert(): Matrix;
  84408. /**
  84409. * Sets all the matrix elements to zero
  84410. * @returns the current matrix
  84411. */
  84412. reset(): Matrix;
  84413. /**
  84414. * Adds the current matrix with a second one
  84415. * @param other defines the matrix to add
  84416. * @returns a new matrix as the addition of the current matrix and the given one
  84417. */
  84418. add(other: DeepImmutable<Matrix>): Matrix;
  84419. /**
  84420. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84421. * @param other defines the matrix to add
  84422. * @param result defines the target matrix
  84423. * @returns the current matrix
  84424. */
  84425. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84426. /**
  84427. * Adds in place the given matrix to the current matrix
  84428. * @param other defines the second operand
  84429. * @returns the current updated matrix
  84430. */
  84431. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84432. /**
  84433. * Sets the given matrix to the current inverted Matrix
  84434. * @param other defines the target matrix
  84435. * @returns the unmodified current matrix
  84436. */
  84437. invertToRef(other: Matrix): Matrix;
  84438. /**
  84439. * add a value at the specified position in the current Matrix
  84440. * @param index the index of the value within the matrix. between 0 and 15.
  84441. * @param value the value to be added
  84442. * @returns the current updated matrix
  84443. */
  84444. addAtIndex(index: number, value: number): Matrix;
  84445. /**
  84446. * mutiply the specified position in the current Matrix by a value
  84447. * @param index the index of the value within the matrix. between 0 and 15.
  84448. * @param value the value to be added
  84449. * @returns the current updated matrix
  84450. */
  84451. multiplyAtIndex(index: number, value: number): Matrix;
  84452. /**
  84453. * Inserts the translation vector (using 3 floats) in the current matrix
  84454. * @param x defines the 1st component of the translation
  84455. * @param y defines the 2nd component of the translation
  84456. * @param z defines the 3rd component of the translation
  84457. * @returns the current updated matrix
  84458. */
  84459. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84460. /**
  84461. * Adds the translation vector (using 3 floats) in the current matrix
  84462. * @param x defines the 1st component of the translation
  84463. * @param y defines the 2nd component of the translation
  84464. * @param z defines the 3rd component of the translation
  84465. * @returns the current updated matrix
  84466. */
  84467. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84468. /**
  84469. * Inserts the translation vector in the current matrix
  84470. * @param vector3 defines the translation to insert
  84471. * @returns the current updated matrix
  84472. */
  84473. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84474. /**
  84475. * Gets the translation value of the current matrix
  84476. * @returns a new Vector3 as the extracted translation from the matrix
  84477. */
  84478. getTranslation(): Vector3;
  84479. /**
  84480. * Fill a Vector3 with the extracted translation from the matrix
  84481. * @param result defines the Vector3 where to store the translation
  84482. * @returns the current matrix
  84483. */
  84484. getTranslationToRef(result: Vector3): Matrix;
  84485. /**
  84486. * Remove rotation and scaling part from the matrix
  84487. * @returns the updated matrix
  84488. */
  84489. removeRotationAndScaling(): Matrix;
  84490. /**
  84491. * Multiply two matrices
  84492. * @param other defines the second operand
  84493. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84494. */
  84495. multiply(other: DeepImmutable<Matrix>): Matrix;
  84496. /**
  84497. * Copy the current matrix from the given one
  84498. * @param other defines the source matrix
  84499. * @returns the current updated matrix
  84500. */
  84501. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84502. /**
  84503. * Populates the given array from the starting index with the current matrix values
  84504. * @param array defines the target array
  84505. * @param offset defines the offset in the target array where to start storing values
  84506. * @returns the current matrix
  84507. */
  84508. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84509. /**
  84510. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84511. * @param other defines the second operand
  84512. * @param result defines the matrix where to store the multiplication
  84513. * @returns the current matrix
  84514. */
  84515. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84516. /**
  84517. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84518. * @param other defines the second operand
  84519. * @param result defines the array where to store the multiplication
  84520. * @param offset defines the offset in the target array where to start storing values
  84521. * @returns the current matrix
  84522. */
  84523. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84524. /**
  84525. * Check equality between this matrix and a second one
  84526. * @param value defines the second matrix to compare
  84527. * @returns true is the current matrix and the given one values are strictly equal
  84528. */
  84529. equals(value: DeepImmutable<Matrix>): boolean;
  84530. /**
  84531. * Clone the current matrix
  84532. * @returns a new matrix from the current matrix
  84533. */
  84534. clone(): Matrix;
  84535. /**
  84536. * Returns the name of the current matrix class
  84537. * @returns the string "Matrix"
  84538. */
  84539. getClassName(): string;
  84540. /**
  84541. * Gets the hash code of the current matrix
  84542. * @returns the hash code
  84543. */
  84544. getHashCode(): number;
  84545. /**
  84546. * Decomposes the current Matrix into a translation, rotation and scaling components
  84547. * @param scale defines the scale vector3 given as a reference to update
  84548. * @param rotation defines the rotation quaternion given as a reference to update
  84549. * @param translation defines the translation vector3 given as a reference to update
  84550. * @returns true if operation was successful
  84551. */
  84552. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84553. /**
  84554. * Gets specific row of the matrix
  84555. * @param index defines the number of the row to get
  84556. * @returns the index-th row of the current matrix as a new Vector4
  84557. */
  84558. getRow(index: number): Nullable<Vector4>;
  84559. /**
  84560. * Sets the index-th row of the current matrix to the vector4 values
  84561. * @param index defines the number of the row to set
  84562. * @param row defines the target vector4
  84563. * @returns the updated current matrix
  84564. */
  84565. setRow(index: number, row: Vector4): Matrix;
  84566. /**
  84567. * Compute the transpose of the matrix
  84568. * @returns the new transposed matrix
  84569. */
  84570. transpose(): Matrix;
  84571. /**
  84572. * Compute the transpose of the matrix and store it in a given matrix
  84573. * @param result defines the target matrix
  84574. * @returns the current matrix
  84575. */
  84576. transposeToRef(result: Matrix): Matrix;
  84577. /**
  84578. * Sets the index-th row of the current matrix with the given 4 x float values
  84579. * @param index defines the row index
  84580. * @param x defines the x component to set
  84581. * @param y defines the y component to set
  84582. * @param z defines the z component to set
  84583. * @param w defines the w component to set
  84584. * @returns the updated current matrix
  84585. */
  84586. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84587. /**
  84588. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84589. * @param scale defines the scale factor
  84590. * @returns a new matrix
  84591. */
  84592. scale(scale: number): Matrix;
  84593. /**
  84594. * Scale the current matrix values by a factor to a given result matrix
  84595. * @param scale defines the scale factor
  84596. * @param result defines the matrix to store the result
  84597. * @returns the current matrix
  84598. */
  84599. scaleToRef(scale: number, result: Matrix): Matrix;
  84600. /**
  84601. * Scale the current matrix values by a factor and add the result to a given matrix
  84602. * @param scale defines the scale factor
  84603. * @param result defines the Matrix to store the result
  84604. * @returns the current matrix
  84605. */
  84606. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84607. /**
  84608. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84609. * @param ref matrix to store the result
  84610. */
  84611. toNormalMatrix(ref: Matrix): void;
  84612. /**
  84613. * Gets only rotation part of the current matrix
  84614. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84615. */
  84616. getRotationMatrix(): Matrix;
  84617. /**
  84618. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84619. * @param result defines the target matrix to store data to
  84620. * @returns the current matrix
  84621. */
  84622. getRotationMatrixToRef(result: Matrix): Matrix;
  84623. /**
  84624. * Toggles model matrix from being right handed to left handed in place and vice versa
  84625. */
  84626. toggleModelMatrixHandInPlace(): void;
  84627. /**
  84628. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84629. */
  84630. toggleProjectionMatrixHandInPlace(): void;
  84631. /**
  84632. * Creates a matrix from an array
  84633. * @param array defines the source array
  84634. * @param offset defines an offset in the source array
  84635. * @returns a new Matrix set from the starting index of the given array
  84636. */
  84637. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84638. /**
  84639. * Copy the content of an array into a given matrix
  84640. * @param array defines the source array
  84641. * @param offset defines an offset in the source array
  84642. * @param result defines the target matrix
  84643. */
  84644. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84645. /**
  84646. * Stores an array into a matrix after having multiplied each component by a given factor
  84647. * @param array defines the source array
  84648. * @param offset defines the offset in the source array
  84649. * @param scale defines the scaling factor
  84650. * @param result defines the target matrix
  84651. */
  84652. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84653. /**
  84654. * Gets an identity matrix that must not be updated
  84655. */
  84656. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84657. /**
  84658. * Stores a list of values (16) inside a given matrix
  84659. * @param initialM11 defines 1st value of 1st row
  84660. * @param initialM12 defines 2nd value of 1st row
  84661. * @param initialM13 defines 3rd value of 1st row
  84662. * @param initialM14 defines 4th value of 1st row
  84663. * @param initialM21 defines 1st value of 2nd row
  84664. * @param initialM22 defines 2nd value of 2nd row
  84665. * @param initialM23 defines 3rd value of 2nd row
  84666. * @param initialM24 defines 4th value of 2nd row
  84667. * @param initialM31 defines 1st value of 3rd row
  84668. * @param initialM32 defines 2nd value of 3rd row
  84669. * @param initialM33 defines 3rd value of 3rd row
  84670. * @param initialM34 defines 4th value of 3rd row
  84671. * @param initialM41 defines 1st value of 4th row
  84672. * @param initialM42 defines 2nd value of 4th row
  84673. * @param initialM43 defines 3rd value of 4th row
  84674. * @param initialM44 defines 4th value of 4th row
  84675. * @param result defines the target matrix
  84676. */
  84677. 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;
  84678. /**
  84679. * Creates new matrix from a list of values (16)
  84680. * @param initialM11 defines 1st value of 1st row
  84681. * @param initialM12 defines 2nd value of 1st row
  84682. * @param initialM13 defines 3rd value of 1st row
  84683. * @param initialM14 defines 4th value of 1st row
  84684. * @param initialM21 defines 1st value of 2nd row
  84685. * @param initialM22 defines 2nd value of 2nd row
  84686. * @param initialM23 defines 3rd value of 2nd row
  84687. * @param initialM24 defines 4th value of 2nd row
  84688. * @param initialM31 defines 1st value of 3rd row
  84689. * @param initialM32 defines 2nd value of 3rd row
  84690. * @param initialM33 defines 3rd value of 3rd row
  84691. * @param initialM34 defines 4th value of 3rd row
  84692. * @param initialM41 defines 1st value of 4th row
  84693. * @param initialM42 defines 2nd value of 4th row
  84694. * @param initialM43 defines 3rd value of 4th row
  84695. * @param initialM44 defines 4th value of 4th row
  84696. * @returns the new matrix
  84697. */
  84698. 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;
  84699. /**
  84700. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84701. * @param scale defines the scale vector3
  84702. * @param rotation defines the rotation quaternion
  84703. * @param translation defines the translation vector3
  84704. * @returns a new matrix
  84705. */
  84706. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84707. /**
  84708. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84709. * @param scale defines the scale vector3
  84710. * @param rotation defines the rotation quaternion
  84711. * @param translation defines the translation vector3
  84712. * @param result defines the target matrix
  84713. */
  84714. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84715. /**
  84716. * Creates a new identity matrix
  84717. * @returns a new identity matrix
  84718. */
  84719. static Identity(): Matrix;
  84720. /**
  84721. * Creates a new identity matrix and stores the result in a given matrix
  84722. * @param result defines the target matrix
  84723. */
  84724. static IdentityToRef(result: Matrix): void;
  84725. /**
  84726. * Creates a new zero matrix
  84727. * @returns a new zero matrix
  84728. */
  84729. static Zero(): Matrix;
  84730. /**
  84731. * Creates a new rotation matrix for "angle" radians around the X axis
  84732. * @param angle defines the angle (in radians) to use
  84733. * @return the new matrix
  84734. */
  84735. static RotationX(angle: number): Matrix;
  84736. /**
  84737. * Creates a new matrix as the invert of a given matrix
  84738. * @param source defines the source matrix
  84739. * @returns the new matrix
  84740. */
  84741. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84742. /**
  84743. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84744. * @param angle defines the angle (in radians) to use
  84745. * @param result defines the target matrix
  84746. */
  84747. static RotationXToRef(angle: number, result: Matrix): void;
  84748. /**
  84749. * Creates a new rotation matrix for "angle" radians around the Y axis
  84750. * @param angle defines the angle (in radians) to use
  84751. * @return the new matrix
  84752. */
  84753. static RotationY(angle: number): Matrix;
  84754. /**
  84755. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84756. * @param angle defines the angle (in radians) to use
  84757. * @param result defines the target matrix
  84758. */
  84759. static RotationYToRef(angle: number, result: Matrix): void;
  84760. /**
  84761. * Creates a new rotation matrix for "angle" radians around the Z axis
  84762. * @param angle defines the angle (in radians) to use
  84763. * @return the new matrix
  84764. */
  84765. static RotationZ(angle: number): Matrix;
  84766. /**
  84767. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84768. * @param angle defines the angle (in radians) to use
  84769. * @param result defines the target matrix
  84770. */
  84771. static RotationZToRef(angle: number, result: Matrix): void;
  84772. /**
  84773. * Creates a new rotation matrix for "angle" radians around the given axis
  84774. * @param axis defines the axis to use
  84775. * @param angle defines the angle (in radians) to use
  84776. * @return the new matrix
  84777. */
  84778. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84779. /**
  84780. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84781. * @param axis defines the axis to use
  84782. * @param angle defines the angle (in radians) to use
  84783. * @param result defines the target matrix
  84784. */
  84785. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84786. /**
  84787. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84788. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84789. * @param from defines the vector to align
  84790. * @param to defines the vector to align to
  84791. * @param result defines the target matrix
  84792. */
  84793. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84794. /**
  84795. * Creates a rotation matrix
  84796. * @param yaw defines the yaw angle in radians (Y axis)
  84797. * @param pitch defines the pitch angle in radians (X axis)
  84798. * @param roll defines the roll angle in radians (Z axis)
  84799. * @returns the new rotation matrix
  84800. */
  84801. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84802. /**
  84803. * Creates a rotation matrix and stores it in a given matrix
  84804. * @param yaw defines the yaw angle in radians (Y axis)
  84805. * @param pitch defines the pitch angle in radians (X axis)
  84806. * @param roll defines the roll angle in radians (Z axis)
  84807. * @param result defines the target matrix
  84808. */
  84809. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84810. /**
  84811. * Creates a scaling matrix
  84812. * @param x defines the scale factor on X axis
  84813. * @param y defines the scale factor on Y axis
  84814. * @param z defines the scale factor on Z axis
  84815. * @returns the new matrix
  84816. */
  84817. static Scaling(x: number, y: number, z: number): Matrix;
  84818. /**
  84819. * Creates a scaling matrix and stores it in a given matrix
  84820. * @param x defines the scale factor on X axis
  84821. * @param y defines the scale factor on Y axis
  84822. * @param z defines the scale factor on Z axis
  84823. * @param result defines the target matrix
  84824. */
  84825. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84826. /**
  84827. * Creates a translation matrix
  84828. * @param x defines the translation on X axis
  84829. * @param y defines the translation on Y axis
  84830. * @param z defines the translationon Z axis
  84831. * @returns the new matrix
  84832. */
  84833. static Translation(x: number, y: number, z: number): Matrix;
  84834. /**
  84835. * Creates a translation matrix and stores it in a given matrix
  84836. * @param x defines the translation on X axis
  84837. * @param y defines the translation on Y axis
  84838. * @param z defines the translationon Z axis
  84839. * @param result defines the target matrix
  84840. */
  84841. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84842. /**
  84843. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84844. * @param startValue defines the start value
  84845. * @param endValue defines the end value
  84846. * @param gradient defines the gradient factor
  84847. * @returns the new matrix
  84848. */
  84849. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84850. /**
  84851. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84852. * @param startValue defines the start value
  84853. * @param endValue defines the end value
  84854. * @param gradient defines the gradient factor
  84855. * @param result defines the Matrix object where to store data
  84856. */
  84857. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84858. /**
  84859. * Builds a new matrix whose values are computed by:
  84860. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84861. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84862. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84863. * @param startValue defines the first matrix
  84864. * @param endValue defines the second matrix
  84865. * @param gradient defines the gradient between the two matrices
  84866. * @returns the new matrix
  84867. */
  84868. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84869. /**
  84870. * Update a matrix to values which are computed by:
  84871. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84872. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84873. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84874. * @param startValue defines the first matrix
  84875. * @param endValue defines the second matrix
  84876. * @param gradient defines the gradient between the two matrices
  84877. * @param result defines the target matrix
  84878. */
  84879. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84880. /**
  84881. * 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"
  84882. * This function works in left handed mode
  84883. * @param eye defines the final position of the entity
  84884. * @param target defines where the entity should look at
  84885. * @param up defines the up vector for the entity
  84886. * @returns the new matrix
  84887. */
  84888. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84889. /**
  84890. * 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".
  84891. * This function works in left handed mode
  84892. * @param eye defines the final position of the entity
  84893. * @param target defines where the entity should look at
  84894. * @param up defines the up vector for the entity
  84895. * @param result defines the target matrix
  84896. */
  84897. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84898. /**
  84899. * 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"
  84900. * This function works in right handed mode
  84901. * @param eye defines the final position of the entity
  84902. * @param target defines where the entity should look at
  84903. * @param up defines the up vector for the entity
  84904. * @returns the new matrix
  84905. */
  84906. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84907. /**
  84908. * 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".
  84909. * This function works in right handed mode
  84910. * @param eye defines the final position of the entity
  84911. * @param target defines where the entity should look at
  84912. * @param up defines the up vector for the entity
  84913. * @param result defines the target matrix
  84914. */
  84915. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84916. /**
  84917. * Create a left-handed orthographic projection matrix
  84918. * @param width defines the viewport width
  84919. * @param height defines the viewport height
  84920. * @param znear defines the near clip plane
  84921. * @param zfar defines the far clip plane
  84922. * @returns a new matrix as a left-handed orthographic projection matrix
  84923. */
  84924. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84925. /**
  84926. * Store a left-handed orthographic projection to a given matrix
  84927. * @param width defines the viewport width
  84928. * @param height defines the viewport height
  84929. * @param znear defines the near clip plane
  84930. * @param zfar defines the far clip plane
  84931. * @param result defines the target matrix
  84932. */
  84933. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84934. /**
  84935. * Create a left-handed orthographic projection matrix
  84936. * @param left defines the viewport left coordinate
  84937. * @param right defines the viewport right coordinate
  84938. * @param bottom defines the viewport bottom coordinate
  84939. * @param top defines the viewport top coordinate
  84940. * @param znear defines the near clip plane
  84941. * @param zfar defines the far clip plane
  84942. * @returns a new matrix as a left-handed orthographic projection matrix
  84943. */
  84944. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84945. /**
  84946. * Stores a left-handed orthographic projection into a given matrix
  84947. * @param left defines the viewport left coordinate
  84948. * @param right defines the viewport right coordinate
  84949. * @param bottom defines the viewport bottom coordinate
  84950. * @param top defines the viewport top coordinate
  84951. * @param znear defines the near clip plane
  84952. * @param zfar defines the far clip plane
  84953. * @param result defines the target matrix
  84954. */
  84955. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84956. /**
  84957. * Creates a right-handed orthographic projection matrix
  84958. * @param left defines the viewport left coordinate
  84959. * @param right defines the viewport right coordinate
  84960. * @param bottom defines the viewport bottom coordinate
  84961. * @param top defines the viewport top coordinate
  84962. * @param znear defines the near clip plane
  84963. * @param zfar defines the far clip plane
  84964. * @returns a new matrix as a right-handed orthographic projection matrix
  84965. */
  84966. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84967. /**
  84968. * Stores a right-handed orthographic projection into a given matrix
  84969. * @param left defines the viewport left coordinate
  84970. * @param right defines the viewport right coordinate
  84971. * @param bottom defines the viewport bottom coordinate
  84972. * @param top defines the viewport top coordinate
  84973. * @param znear defines the near clip plane
  84974. * @param zfar defines the far clip plane
  84975. * @param result defines the target matrix
  84976. */
  84977. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84978. /**
  84979. * Creates a left-handed perspective projection matrix
  84980. * @param width defines the viewport width
  84981. * @param height defines the viewport height
  84982. * @param znear defines the near clip plane
  84983. * @param zfar defines the far clip plane
  84984. * @returns a new matrix as a left-handed perspective projection matrix
  84985. */
  84986. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84987. /**
  84988. * Creates a left-handed perspective projection matrix
  84989. * @param fov defines the horizontal field of view
  84990. * @param aspect defines the aspect ratio
  84991. * @param znear defines the near clip plane
  84992. * @param zfar defines the far clip plane
  84993. * @returns a new matrix as a left-handed perspective projection matrix
  84994. */
  84995. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84996. /**
  84997. * Stores a left-handed perspective projection into a given matrix
  84998. * @param fov defines the horizontal field of view
  84999. * @param aspect defines the aspect ratio
  85000. * @param znear defines the near clip plane
  85001. * @param zfar defines the far clip plane
  85002. * @param result defines the target matrix
  85003. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85004. */
  85005. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85006. /**
  85007. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85008. * @param fov defines the horizontal field of view
  85009. * @param aspect defines the aspect ratio
  85010. * @param znear defines the near clip plane
  85011. * @param zfar not used as infinity is used as far clip
  85012. * @param result defines the target matrix
  85013. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85014. */
  85015. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85016. /**
  85017. * Creates a right-handed perspective projection matrix
  85018. * @param fov defines the horizontal field of view
  85019. * @param aspect defines the aspect ratio
  85020. * @param znear defines the near clip plane
  85021. * @param zfar defines the far clip plane
  85022. * @returns a new matrix as a right-handed perspective projection matrix
  85023. */
  85024. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85025. /**
  85026. * Stores a right-handed perspective projection into a given matrix
  85027. * @param fov defines the horizontal field of view
  85028. * @param aspect defines the aspect ratio
  85029. * @param znear defines the near clip plane
  85030. * @param zfar defines the far clip plane
  85031. * @param result defines the target matrix
  85032. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85033. */
  85034. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85035. /**
  85036. * Stores a right-handed perspective projection into a given matrix
  85037. * @param fov defines the horizontal field of view
  85038. * @param aspect defines the aspect ratio
  85039. * @param znear defines the near clip plane
  85040. * @param zfar not used as infinity is used as far clip
  85041. * @param result defines the target matrix
  85042. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85043. */
  85044. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85045. /**
  85046. * Stores a perspective projection for WebVR info a given matrix
  85047. * @param fov defines the field of view
  85048. * @param znear defines the near clip plane
  85049. * @param zfar defines the far clip plane
  85050. * @param result defines the target matrix
  85051. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85052. */
  85053. static PerspectiveFovWebVRToRef(fov: {
  85054. upDegrees: number;
  85055. downDegrees: number;
  85056. leftDegrees: number;
  85057. rightDegrees: number;
  85058. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85059. /**
  85060. * Computes a complete transformation matrix
  85061. * @param viewport defines the viewport to use
  85062. * @param world defines the world matrix
  85063. * @param view defines the view matrix
  85064. * @param projection defines the projection matrix
  85065. * @param zmin defines the near clip plane
  85066. * @param zmax defines the far clip plane
  85067. * @returns the transformation matrix
  85068. */
  85069. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85070. /**
  85071. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85072. * @param matrix defines the matrix to use
  85073. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85074. */
  85075. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85076. /**
  85077. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85078. * @param matrix defines the matrix to use
  85079. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85080. */
  85081. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85082. /**
  85083. * Compute the transpose of a given matrix
  85084. * @param matrix defines the matrix to transpose
  85085. * @returns the new matrix
  85086. */
  85087. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85088. /**
  85089. * Compute the transpose of a matrix and store it in a target matrix
  85090. * @param matrix defines the matrix to transpose
  85091. * @param result defines the target matrix
  85092. */
  85093. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85094. /**
  85095. * Computes a reflection matrix from a plane
  85096. * @param plane defines the reflection plane
  85097. * @returns a new matrix
  85098. */
  85099. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85100. /**
  85101. * Computes a reflection matrix from a plane
  85102. * @param plane defines the reflection plane
  85103. * @param result defines the target matrix
  85104. */
  85105. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85106. /**
  85107. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85108. * @param xaxis defines the value of the 1st axis
  85109. * @param yaxis defines the value of the 2nd axis
  85110. * @param zaxis defines the value of the 3rd axis
  85111. * @param result defines the target matrix
  85112. */
  85113. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85114. /**
  85115. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85116. * @param quat defines the quaternion to use
  85117. * @param result defines the target matrix
  85118. */
  85119. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85120. }
  85121. /**
  85122. * @hidden
  85123. */
  85124. export class TmpVectors {
  85125. static Vector2: Vector2[];
  85126. static Vector3: Vector3[];
  85127. static Vector4: Vector4[];
  85128. static Quaternion: Quaternion[];
  85129. static Matrix: Matrix[];
  85130. }
  85131. }
  85132. declare module BABYLON {
  85133. /**
  85134. * Defines potential orientation for back face culling
  85135. */
  85136. export enum Orientation {
  85137. /**
  85138. * Clockwise
  85139. */
  85140. CW = 0,
  85141. /** Counter clockwise */
  85142. CCW = 1
  85143. }
  85144. /** Class used to represent a Bezier curve */
  85145. export class BezierCurve {
  85146. /**
  85147. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85148. * @param t defines the time
  85149. * @param x1 defines the left coordinate on X axis
  85150. * @param y1 defines the left coordinate on Y axis
  85151. * @param x2 defines the right coordinate on X axis
  85152. * @param y2 defines the right coordinate on Y axis
  85153. * @returns the interpolated value
  85154. */
  85155. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85156. }
  85157. /**
  85158. * Defines angle representation
  85159. */
  85160. export class Angle {
  85161. private _radians;
  85162. /**
  85163. * Creates an Angle object of "radians" radians (float).
  85164. * @param radians the angle in radians
  85165. */
  85166. constructor(radians: number);
  85167. /**
  85168. * Get value in degrees
  85169. * @returns the Angle value in degrees (float)
  85170. */
  85171. degrees(): number;
  85172. /**
  85173. * Get value in radians
  85174. * @returns the Angle value in radians (float)
  85175. */
  85176. radians(): number;
  85177. /**
  85178. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85179. * @param a defines first point as the origin
  85180. * @param b defines point
  85181. * @returns a new Angle
  85182. */
  85183. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85184. /**
  85185. * Gets a new Angle object from the given float in radians
  85186. * @param radians defines the angle value in radians
  85187. * @returns a new Angle
  85188. */
  85189. static FromRadians(radians: number): Angle;
  85190. /**
  85191. * Gets a new Angle object from the given float in degrees
  85192. * @param degrees defines the angle value in degrees
  85193. * @returns a new Angle
  85194. */
  85195. static FromDegrees(degrees: number): Angle;
  85196. }
  85197. /**
  85198. * This represents an arc in a 2d space.
  85199. */
  85200. export class Arc2 {
  85201. /** Defines the start point of the arc */
  85202. startPoint: Vector2;
  85203. /** Defines the mid point of the arc */
  85204. midPoint: Vector2;
  85205. /** Defines the end point of the arc */
  85206. endPoint: Vector2;
  85207. /**
  85208. * Defines the center point of the arc.
  85209. */
  85210. centerPoint: Vector2;
  85211. /**
  85212. * Defines the radius of the arc.
  85213. */
  85214. radius: number;
  85215. /**
  85216. * Defines the angle of the arc (from mid point to end point).
  85217. */
  85218. angle: Angle;
  85219. /**
  85220. * Defines the start angle of the arc (from start point to middle point).
  85221. */
  85222. startAngle: Angle;
  85223. /**
  85224. * Defines the orientation of the arc (clock wise/counter clock wise).
  85225. */
  85226. orientation: Orientation;
  85227. /**
  85228. * Creates an Arc object from the three given points : start, middle and end.
  85229. * @param startPoint Defines the start point of the arc
  85230. * @param midPoint Defines the midlle point of the arc
  85231. * @param endPoint Defines the end point of the arc
  85232. */
  85233. constructor(
  85234. /** Defines the start point of the arc */
  85235. startPoint: Vector2,
  85236. /** Defines the mid point of the arc */
  85237. midPoint: Vector2,
  85238. /** Defines the end point of the arc */
  85239. endPoint: Vector2);
  85240. }
  85241. /**
  85242. * Represents a 2D path made up of multiple 2D points
  85243. */
  85244. export class Path2 {
  85245. private _points;
  85246. private _length;
  85247. /**
  85248. * If the path start and end point are the same
  85249. */
  85250. closed: boolean;
  85251. /**
  85252. * Creates a Path2 object from the starting 2D coordinates x and y.
  85253. * @param x the starting points x value
  85254. * @param y the starting points y value
  85255. */
  85256. constructor(x: number, y: number);
  85257. /**
  85258. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85259. * @param x the added points x value
  85260. * @param y the added points y value
  85261. * @returns the updated Path2.
  85262. */
  85263. addLineTo(x: number, y: number): Path2;
  85264. /**
  85265. * 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.
  85266. * @param midX middle point x value
  85267. * @param midY middle point y value
  85268. * @param endX end point x value
  85269. * @param endY end point y value
  85270. * @param numberOfSegments (default: 36)
  85271. * @returns the updated Path2.
  85272. */
  85273. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85274. /**
  85275. * Closes the Path2.
  85276. * @returns the Path2.
  85277. */
  85278. close(): Path2;
  85279. /**
  85280. * Gets the sum of the distance between each sequential point in the path
  85281. * @returns the Path2 total length (float).
  85282. */
  85283. length(): number;
  85284. /**
  85285. * Gets the points which construct the path
  85286. * @returns the Path2 internal array of points.
  85287. */
  85288. getPoints(): Vector2[];
  85289. /**
  85290. * Retreives the point at the distance aways from the starting point
  85291. * @param normalizedLengthPosition the length along the path to retreive the point from
  85292. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85293. */
  85294. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85295. /**
  85296. * Creates a new path starting from an x and y position
  85297. * @param x starting x value
  85298. * @param y starting y value
  85299. * @returns a new Path2 starting at the coordinates (x, y).
  85300. */
  85301. static StartingAt(x: number, y: number): Path2;
  85302. }
  85303. /**
  85304. * Represents a 3D path made up of multiple 3D points
  85305. */
  85306. export class Path3D {
  85307. /**
  85308. * an array of Vector3, the curve axis of the Path3D
  85309. */
  85310. path: Vector3[];
  85311. private _curve;
  85312. private _distances;
  85313. private _tangents;
  85314. private _normals;
  85315. private _binormals;
  85316. private _raw;
  85317. private _alignTangentsWithPath;
  85318. private readonly _pointAtData;
  85319. /**
  85320. * new Path3D(path, normal, raw)
  85321. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85322. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85323. * @param path an array of Vector3, the curve axis of the Path3D
  85324. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85325. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85326. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85327. */
  85328. constructor(
  85329. /**
  85330. * an array of Vector3, the curve axis of the Path3D
  85331. */
  85332. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85333. /**
  85334. * Returns the Path3D array of successive Vector3 designing its curve.
  85335. * @returns the Path3D array of successive Vector3 designing its curve.
  85336. */
  85337. getCurve(): Vector3[];
  85338. /**
  85339. * Returns the Path3D array of successive Vector3 designing its curve.
  85340. * @returns the Path3D array of successive Vector3 designing its curve.
  85341. */
  85342. getPoints(): Vector3[];
  85343. /**
  85344. * @returns the computed length (float) of the path.
  85345. */
  85346. length(): number;
  85347. /**
  85348. * Returns an array populated with tangent vectors on each Path3D curve point.
  85349. * @returns an array populated with tangent vectors on each Path3D curve point.
  85350. */
  85351. getTangents(): Vector3[];
  85352. /**
  85353. * Returns an array populated with normal vectors on each Path3D curve point.
  85354. * @returns an array populated with normal vectors on each Path3D curve point.
  85355. */
  85356. getNormals(): Vector3[];
  85357. /**
  85358. * Returns an array populated with binormal vectors on each Path3D curve point.
  85359. * @returns an array populated with binormal vectors on each Path3D curve point.
  85360. */
  85361. getBinormals(): Vector3[];
  85362. /**
  85363. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85364. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85365. */
  85366. getDistances(): number[];
  85367. /**
  85368. * Returns an interpolated point along this path
  85369. * @param position the position of the point along this path, from 0.0 to 1.0
  85370. * @returns a new Vector3 as the point
  85371. */
  85372. getPointAt(position: number): Vector3;
  85373. /**
  85374. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85375. * @param position the position of the point along this path, from 0.0 to 1.0
  85376. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85377. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85378. */
  85379. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85380. /**
  85381. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85382. * @param position the position of the point along this path, from 0.0 to 1.0
  85383. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85384. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85385. */
  85386. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85387. /**
  85388. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85389. * @param position the position of the point along this path, from 0.0 to 1.0
  85390. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85391. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85392. */
  85393. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85394. /**
  85395. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85396. * @param position the position of the point along this path, from 0.0 to 1.0
  85397. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85398. */
  85399. getDistanceAt(position: number): number;
  85400. /**
  85401. * Returns the array index of the previous point of an interpolated point along this path
  85402. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85403. * @returns the array index
  85404. */
  85405. getPreviousPointIndexAt(position: number): number;
  85406. /**
  85407. * 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)
  85408. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85409. * @returns the sub position
  85410. */
  85411. getSubPositionAt(position: number): number;
  85412. /**
  85413. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85414. * @param target the vector of which to get the closest position to
  85415. * @returns the position of the closest virtual point on this path to the target vector
  85416. */
  85417. getClosestPositionTo(target: Vector3): number;
  85418. /**
  85419. * Returns a sub path (slice) of this path
  85420. * @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
  85421. * @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
  85422. * @returns a sub path (slice) of this path
  85423. */
  85424. slice(start?: number, end?: number): Path3D;
  85425. /**
  85426. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85427. * @param path path which all values are copied into the curves points
  85428. * @param firstNormal which should be projected onto the curve
  85429. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85430. * @returns the same object updated.
  85431. */
  85432. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85433. private _compute;
  85434. private _getFirstNonNullVector;
  85435. private _getLastNonNullVector;
  85436. private _normalVector;
  85437. /**
  85438. * Updates the point at data for an interpolated point along this curve
  85439. * @param position the position of the point along this curve, from 0.0 to 1.0
  85440. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85441. * @returns the (updated) point at data
  85442. */
  85443. private _updatePointAtData;
  85444. /**
  85445. * Updates the point at data from the specified parameters
  85446. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85447. * @param point the interpolated point
  85448. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85449. */
  85450. private _setPointAtData;
  85451. /**
  85452. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85453. */
  85454. private _updateInterpolationMatrix;
  85455. }
  85456. /**
  85457. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85458. * A Curve3 is designed from a series of successive Vector3.
  85459. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85460. */
  85461. export class Curve3 {
  85462. private _points;
  85463. private _length;
  85464. /**
  85465. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85466. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85467. * @param v1 (Vector3) the control point
  85468. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85469. * @param nbPoints (integer) the wanted number of points in the curve
  85470. * @returns the created Curve3
  85471. */
  85472. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85473. /**
  85474. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85475. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85476. * @param v1 (Vector3) the first control point
  85477. * @param v2 (Vector3) the second control point
  85478. * @param v3 (Vector3) the end point of the Cubic Bezier
  85479. * @param nbPoints (integer) the wanted number of points in the curve
  85480. * @returns the created Curve3
  85481. */
  85482. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85483. /**
  85484. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85485. * @param p1 (Vector3) the origin point of the Hermite Spline
  85486. * @param t1 (Vector3) the tangent vector at the origin point
  85487. * @param p2 (Vector3) the end point of the Hermite Spline
  85488. * @param t2 (Vector3) the tangent vector at the end point
  85489. * @param nbPoints (integer) the wanted number of points in the curve
  85490. * @returns the created Curve3
  85491. */
  85492. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85493. /**
  85494. * Returns a Curve3 object along a CatmullRom Spline curve :
  85495. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85496. * @param nbPoints (integer) the wanted number of points between each curve control points
  85497. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85498. * @returns the created Curve3
  85499. */
  85500. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85501. /**
  85502. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85503. * A Curve3 is designed from a series of successive Vector3.
  85504. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85505. * @param points points which make up the curve
  85506. */
  85507. constructor(points: Vector3[]);
  85508. /**
  85509. * @returns the Curve3 stored array of successive Vector3
  85510. */
  85511. getPoints(): Vector3[];
  85512. /**
  85513. * @returns the computed length (float) of the curve.
  85514. */
  85515. length(): number;
  85516. /**
  85517. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85518. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85519. * curveA and curveB keep unchanged.
  85520. * @param curve the curve to continue from this curve
  85521. * @returns the newly constructed curve
  85522. */
  85523. continue(curve: DeepImmutable<Curve3>): Curve3;
  85524. private _computeLength;
  85525. }
  85526. }
  85527. declare module BABYLON {
  85528. /**
  85529. * This represents the main contract an easing function should follow.
  85530. * Easing functions are used throughout the animation system.
  85531. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85532. */
  85533. export interface IEasingFunction {
  85534. /**
  85535. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85536. * of the easing function.
  85537. * The link below provides some of the most common examples of easing functions.
  85538. * @see https://easings.net/
  85539. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85540. * @returns the corresponding value on the curve defined by the easing function
  85541. */
  85542. ease(gradient: number): number;
  85543. }
  85544. /**
  85545. * Base class used for every default easing function.
  85546. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85547. */
  85548. export class EasingFunction implements IEasingFunction {
  85549. /**
  85550. * Interpolation follows the mathematical formula associated with the easing function.
  85551. */
  85552. static readonly EASINGMODE_EASEIN: number;
  85553. /**
  85554. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85555. */
  85556. static readonly EASINGMODE_EASEOUT: number;
  85557. /**
  85558. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85559. */
  85560. static readonly EASINGMODE_EASEINOUT: number;
  85561. private _easingMode;
  85562. /**
  85563. * Sets the easing mode of the current function.
  85564. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85565. */
  85566. setEasingMode(easingMode: number): void;
  85567. /**
  85568. * Gets the current easing mode.
  85569. * @returns the easing mode
  85570. */
  85571. getEasingMode(): number;
  85572. /**
  85573. * @hidden
  85574. */
  85575. easeInCore(gradient: number): number;
  85576. /**
  85577. * Given an input gradient between 0 and 1, this returns the corresponding value
  85578. * of the easing function.
  85579. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85580. * @returns the corresponding value on the curve defined by the easing function
  85581. */
  85582. ease(gradient: number): number;
  85583. }
  85584. /**
  85585. * Easing function with a circle shape (see link below).
  85586. * @see https://easings.net/#easeInCirc
  85587. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85588. */
  85589. export class CircleEase extends EasingFunction implements IEasingFunction {
  85590. /** @hidden */
  85591. easeInCore(gradient: number): number;
  85592. }
  85593. /**
  85594. * Easing function with a ease back shape (see link below).
  85595. * @see https://easings.net/#easeInBack
  85596. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85597. */
  85598. export class BackEase extends EasingFunction implements IEasingFunction {
  85599. /** Defines the amplitude of the function */
  85600. amplitude: number;
  85601. /**
  85602. * Instantiates a back ease easing
  85603. * @see https://easings.net/#easeInBack
  85604. * @param amplitude Defines the amplitude of the function
  85605. */
  85606. constructor(
  85607. /** Defines the amplitude of the function */
  85608. amplitude?: number);
  85609. /** @hidden */
  85610. easeInCore(gradient: number): number;
  85611. }
  85612. /**
  85613. * Easing function with a bouncing shape (see link below).
  85614. * @see https://easings.net/#easeInBounce
  85615. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85616. */
  85617. export class BounceEase extends EasingFunction implements IEasingFunction {
  85618. /** Defines the number of bounces */
  85619. bounces: number;
  85620. /** Defines the amplitude of the bounce */
  85621. bounciness: number;
  85622. /**
  85623. * Instantiates a bounce easing
  85624. * @see https://easings.net/#easeInBounce
  85625. * @param bounces Defines the number of bounces
  85626. * @param bounciness Defines the amplitude of the bounce
  85627. */
  85628. constructor(
  85629. /** Defines the number of bounces */
  85630. bounces?: number,
  85631. /** Defines the amplitude of the bounce */
  85632. bounciness?: number);
  85633. /** @hidden */
  85634. easeInCore(gradient: number): number;
  85635. }
  85636. /**
  85637. * Easing function with a power of 3 shape (see link below).
  85638. * @see https://easings.net/#easeInCubic
  85639. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85640. */
  85641. export class CubicEase extends EasingFunction implements IEasingFunction {
  85642. /** @hidden */
  85643. easeInCore(gradient: number): number;
  85644. }
  85645. /**
  85646. * Easing function with an elastic shape (see link below).
  85647. * @see https://easings.net/#easeInElastic
  85648. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85649. */
  85650. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85651. /** Defines the number of oscillations*/
  85652. oscillations: number;
  85653. /** Defines the amplitude of the oscillations*/
  85654. springiness: number;
  85655. /**
  85656. * Instantiates an elastic easing function
  85657. * @see https://easings.net/#easeInElastic
  85658. * @param oscillations Defines the number of oscillations
  85659. * @param springiness Defines the amplitude of the oscillations
  85660. */
  85661. constructor(
  85662. /** Defines the number of oscillations*/
  85663. oscillations?: number,
  85664. /** Defines the amplitude of the oscillations*/
  85665. springiness?: number);
  85666. /** @hidden */
  85667. easeInCore(gradient: number): number;
  85668. }
  85669. /**
  85670. * Easing function with an exponential shape (see link below).
  85671. * @see https://easings.net/#easeInExpo
  85672. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85673. */
  85674. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85675. /** Defines the exponent of the function */
  85676. exponent: number;
  85677. /**
  85678. * Instantiates an exponential easing function
  85679. * @see https://easings.net/#easeInExpo
  85680. * @param exponent Defines the exponent of the function
  85681. */
  85682. constructor(
  85683. /** Defines the exponent of the function */
  85684. exponent?: number);
  85685. /** @hidden */
  85686. easeInCore(gradient: number): number;
  85687. }
  85688. /**
  85689. * Easing function with a power shape (see link below).
  85690. * @see https://easings.net/#easeInQuad
  85691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85692. */
  85693. export class PowerEase extends EasingFunction implements IEasingFunction {
  85694. /** Defines the power of the function */
  85695. power: number;
  85696. /**
  85697. * Instantiates an power base easing function
  85698. * @see https://easings.net/#easeInQuad
  85699. * @param power Defines the power of the function
  85700. */
  85701. constructor(
  85702. /** Defines the power of the function */
  85703. power?: number);
  85704. /** @hidden */
  85705. easeInCore(gradient: number): number;
  85706. }
  85707. /**
  85708. * Easing function with a power of 2 shape (see link below).
  85709. * @see https://easings.net/#easeInQuad
  85710. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85711. */
  85712. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85713. /** @hidden */
  85714. easeInCore(gradient: number): number;
  85715. }
  85716. /**
  85717. * Easing function with a power of 4 shape (see link below).
  85718. * @see https://easings.net/#easeInQuart
  85719. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85720. */
  85721. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85722. /** @hidden */
  85723. easeInCore(gradient: number): number;
  85724. }
  85725. /**
  85726. * Easing function with a power of 5 shape (see link below).
  85727. * @see https://easings.net/#easeInQuint
  85728. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85729. */
  85730. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85731. /** @hidden */
  85732. easeInCore(gradient: number): number;
  85733. }
  85734. /**
  85735. * Easing function with a sin shape (see link below).
  85736. * @see https://easings.net/#easeInSine
  85737. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85738. */
  85739. export class SineEase extends EasingFunction implements IEasingFunction {
  85740. /** @hidden */
  85741. easeInCore(gradient: number): number;
  85742. }
  85743. /**
  85744. * Easing function with a bezier shape (see link below).
  85745. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85746. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85747. */
  85748. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85749. /** Defines the x component of the start tangent in the bezier curve */
  85750. x1: number;
  85751. /** Defines the y component of the start tangent in the bezier curve */
  85752. y1: number;
  85753. /** Defines the x component of the end tangent in the bezier curve */
  85754. x2: number;
  85755. /** Defines the y component of the end tangent in the bezier curve */
  85756. y2: number;
  85757. /**
  85758. * Instantiates a bezier function
  85759. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85760. * @param x1 Defines the x component of the start tangent in the bezier curve
  85761. * @param y1 Defines the y component of the start tangent in the bezier curve
  85762. * @param x2 Defines the x component of the end tangent in the bezier curve
  85763. * @param y2 Defines the y component of the end tangent in the bezier curve
  85764. */
  85765. constructor(
  85766. /** Defines the x component of the start tangent in the bezier curve */
  85767. x1?: number,
  85768. /** Defines the y component of the start tangent in the bezier curve */
  85769. y1?: number,
  85770. /** Defines the x component of the end tangent in the bezier curve */
  85771. x2?: number,
  85772. /** Defines the y component of the end tangent in the bezier curve */
  85773. y2?: number);
  85774. /** @hidden */
  85775. easeInCore(gradient: number): number;
  85776. }
  85777. }
  85778. declare module BABYLON {
  85779. /**
  85780. * Class used to hold a RBG color
  85781. */
  85782. export class Color3 {
  85783. /**
  85784. * Defines the red component (between 0 and 1, default is 0)
  85785. */
  85786. r: number;
  85787. /**
  85788. * Defines the green component (between 0 and 1, default is 0)
  85789. */
  85790. g: number;
  85791. /**
  85792. * Defines the blue component (between 0 and 1, default is 0)
  85793. */
  85794. b: number;
  85795. /**
  85796. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85797. * @param r defines the red component (between 0 and 1, default is 0)
  85798. * @param g defines the green component (between 0 and 1, default is 0)
  85799. * @param b defines the blue component (between 0 and 1, default is 0)
  85800. */
  85801. constructor(
  85802. /**
  85803. * Defines the red component (between 0 and 1, default is 0)
  85804. */
  85805. r?: number,
  85806. /**
  85807. * Defines the green component (between 0 and 1, default is 0)
  85808. */
  85809. g?: number,
  85810. /**
  85811. * Defines the blue component (between 0 and 1, default is 0)
  85812. */
  85813. b?: number);
  85814. /**
  85815. * Creates a string with the Color3 current values
  85816. * @returns the string representation of the Color3 object
  85817. */
  85818. toString(): string;
  85819. /**
  85820. * Returns the string "Color3"
  85821. * @returns "Color3"
  85822. */
  85823. getClassName(): string;
  85824. /**
  85825. * Compute the Color3 hash code
  85826. * @returns an unique number that can be used to hash Color3 objects
  85827. */
  85828. getHashCode(): number;
  85829. /**
  85830. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85831. * @param array defines the array where to store the r,g,b components
  85832. * @param index defines an optional index in the target array to define where to start storing values
  85833. * @returns the current Color3 object
  85834. */
  85835. toArray(array: FloatArray, index?: number): Color3;
  85836. /**
  85837. * Update the current color with values stored in an array from the starting index of the given array
  85838. * @param array defines the source array
  85839. * @param offset defines an offset in the source array
  85840. * @returns the current Color3 object
  85841. */
  85842. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85843. /**
  85844. * Returns a new Color4 object from the current Color3 and the given alpha
  85845. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85846. * @returns a new Color4 object
  85847. */
  85848. toColor4(alpha?: number): Color4;
  85849. /**
  85850. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85851. * @returns the new array
  85852. */
  85853. asArray(): number[];
  85854. /**
  85855. * Returns the luminance value
  85856. * @returns a float value
  85857. */
  85858. toLuminance(): number;
  85859. /**
  85860. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85861. * @param otherColor defines the second operand
  85862. * @returns the new Color3 object
  85863. */
  85864. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85865. /**
  85866. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85867. * @param otherColor defines the second operand
  85868. * @param result defines the Color3 object where to store the result
  85869. * @returns the current Color3
  85870. */
  85871. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85872. /**
  85873. * Determines equality between Color3 objects
  85874. * @param otherColor defines the second operand
  85875. * @returns true if the rgb values are equal to the given ones
  85876. */
  85877. equals(otherColor: DeepImmutable<Color3>): boolean;
  85878. /**
  85879. * Determines equality between the current Color3 object and a set of r,b,g values
  85880. * @param r defines the red component to check
  85881. * @param g defines the green component to check
  85882. * @param b defines the blue component to check
  85883. * @returns true if the rgb values are equal to the given ones
  85884. */
  85885. equalsFloats(r: number, g: number, b: number): boolean;
  85886. /**
  85887. * Multiplies in place each rgb value by scale
  85888. * @param scale defines the scaling factor
  85889. * @returns the updated Color3
  85890. */
  85891. scale(scale: number): Color3;
  85892. /**
  85893. * Multiplies the rgb values by scale and stores the result into "result"
  85894. * @param scale defines the scaling factor
  85895. * @param result defines the Color3 object where to store the result
  85896. * @returns the unmodified current Color3
  85897. */
  85898. scaleToRef(scale: number, result: Color3): Color3;
  85899. /**
  85900. * Scale the current Color3 values by a factor and add the result to a given Color3
  85901. * @param scale defines the scale factor
  85902. * @param result defines color to store the result into
  85903. * @returns the unmodified current Color3
  85904. */
  85905. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85906. /**
  85907. * Clamps the rgb values by the min and max values and stores the result into "result"
  85908. * @param min defines minimum clamping value (default is 0)
  85909. * @param max defines maximum clamping value (default is 1)
  85910. * @param result defines color to store the result into
  85911. * @returns the original Color3
  85912. */
  85913. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85914. /**
  85915. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85916. * @param otherColor defines the second operand
  85917. * @returns the new Color3
  85918. */
  85919. add(otherColor: DeepImmutable<Color3>): Color3;
  85920. /**
  85921. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85922. * @param otherColor defines the second operand
  85923. * @param result defines Color3 object to store the result into
  85924. * @returns the unmodified current Color3
  85925. */
  85926. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85927. /**
  85928. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85929. * @param otherColor defines the second operand
  85930. * @returns the new Color3
  85931. */
  85932. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85933. /**
  85934. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85935. * @param otherColor defines the second operand
  85936. * @param result defines Color3 object to store the result into
  85937. * @returns the unmodified current Color3
  85938. */
  85939. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85940. /**
  85941. * Copy the current object
  85942. * @returns a new Color3 copied the current one
  85943. */
  85944. clone(): Color3;
  85945. /**
  85946. * Copies the rgb values from the source in the current Color3
  85947. * @param source defines the source Color3 object
  85948. * @returns the updated Color3 object
  85949. */
  85950. copyFrom(source: DeepImmutable<Color3>): Color3;
  85951. /**
  85952. * Updates the Color3 rgb values from the given floats
  85953. * @param r defines the red component to read from
  85954. * @param g defines the green component to read from
  85955. * @param b defines the blue component to read from
  85956. * @returns the current Color3 object
  85957. */
  85958. copyFromFloats(r: number, g: number, b: number): Color3;
  85959. /**
  85960. * Updates the Color3 rgb values from the given floats
  85961. * @param r defines the red component to read from
  85962. * @param g defines the green component to read from
  85963. * @param b defines the blue component to read from
  85964. * @returns the current Color3 object
  85965. */
  85966. set(r: number, g: number, b: number): Color3;
  85967. /**
  85968. * Compute the Color3 hexadecimal code as a string
  85969. * @returns a string containing the hexadecimal representation of the Color3 object
  85970. */
  85971. toHexString(): string;
  85972. /**
  85973. * Computes a new Color3 converted from the current one to linear space
  85974. * @returns a new Color3 object
  85975. */
  85976. toLinearSpace(): Color3;
  85977. /**
  85978. * Converts current color in rgb space to HSV values
  85979. * @returns a new color3 representing the HSV values
  85980. */
  85981. toHSV(): Color3;
  85982. /**
  85983. * Converts current color in rgb space to HSV values
  85984. * @param result defines the Color3 where to store the HSV values
  85985. */
  85986. toHSVToRef(result: Color3): void;
  85987. /**
  85988. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85989. * @param convertedColor defines the Color3 object where to store the linear space version
  85990. * @returns the unmodified Color3
  85991. */
  85992. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85993. /**
  85994. * Computes a new Color3 converted from the current one to gamma space
  85995. * @returns a new Color3 object
  85996. */
  85997. toGammaSpace(): Color3;
  85998. /**
  85999. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86000. * @param convertedColor defines the Color3 object where to store the gamma space version
  86001. * @returns the unmodified Color3
  86002. */
  86003. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86004. private static _BlackReadOnly;
  86005. /**
  86006. * Convert Hue, saturation and value to a Color3 (RGB)
  86007. * @param hue defines the hue
  86008. * @param saturation defines the saturation
  86009. * @param value defines the value
  86010. * @param result defines the Color3 where to store the RGB values
  86011. */
  86012. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86013. /**
  86014. * Creates a new Color3 from the string containing valid hexadecimal values
  86015. * @param hex defines a string containing valid hexadecimal values
  86016. * @returns a new Color3 object
  86017. */
  86018. static FromHexString(hex: string): Color3;
  86019. /**
  86020. * Creates a new Color3 from the starting index of the given array
  86021. * @param array defines the source array
  86022. * @param offset defines an offset in the source array
  86023. * @returns a new Color3 object
  86024. */
  86025. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86026. /**
  86027. * Creates a new Color3 from the starting index element of the given array
  86028. * @param array defines the source array to read from
  86029. * @param offset defines the offset in the source array
  86030. * @param result defines the target Color3 object
  86031. */
  86032. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86033. /**
  86034. * Creates a new Color3 from integer values (< 256)
  86035. * @param r defines the red component to read from (value between 0 and 255)
  86036. * @param g defines the green component to read from (value between 0 and 255)
  86037. * @param b defines the blue component to read from (value between 0 and 255)
  86038. * @returns a new Color3 object
  86039. */
  86040. static FromInts(r: number, g: number, b: number): Color3;
  86041. /**
  86042. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86043. * @param start defines the start Color3 value
  86044. * @param end defines the end Color3 value
  86045. * @param amount defines the gradient value between start and end
  86046. * @returns a new Color3 object
  86047. */
  86048. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86049. /**
  86050. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86051. * @param left defines the start value
  86052. * @param right defines the end value
  86053. * @param amount defines the gradient factor
  86054. * @param result defines the Color3 object where to store the result
  86055. */
  86056. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86057. /**
  86058. * Returns a Color3 value containing a red color
  86059. * @returns a new Color3 object
  86060. */
  86061. static Red(): Color3;
  86062. /**
  86063. * Returns a Color3 value containing a green color
  86064. * @returns a new Color3 object
  86065. */
  86066. static Green(): Color3;
  86067. /**
  86068. * Returns a Color3 value containing a blue color
  86069. * @returns a new Color3 object
  86070. */
  86071. static Blue(): Color3;
  86072. /**
  86073. * Returns a Color3 value containing a black color
  86074. * @returns a new Color3 object
  86075. */
  86076. static Black(): Color3;
  86077. /**
  86078. * Gets a Color3 value containing a black color that must not be updated
  86079. */
  86080. static get BlackReadOnly(): DeepImmutable<Color3>;
  86081. /**
  86082. * Returns a Color3 value containing a white color
  86083. * @returns a new Color3 object
  86084. */
  86085. static White(): Color3;
  86086. /**
  86087. * Returns a Color3 value containing a purple color
  86088. * @returns a new Color3 object
  86089. */
  86090. static Purple(): Color3;
  86091. /**
  86092. * Returns a Color3 value containing a magenta color
  86093. * @returns a new Color3 object
  86094. */
  86095. static Magenta(): Color3;
  86096. /**
  86097. * Returns a Color3 value containing a yellow color
  86098. * @returns a new Color3 object
  86099. */
  86100. static Yellow(): Color3;
  86101. /**
  86102. * Returns a Color3 value containing a gray color
  86103. * @returns a new Color3 object
  86104. */
  86105. static Gray(): Color3;
  86106. /**
  86107. * Returns a Color3 value containing a teal color
  86108. * @returns a new Color3 object
  86109. */
  86110. static Teal(): Color3;
  86111. /**
  86112. * Returns a Color3 value containing a random color
  86113. * @returns a new Color3 object
  86114. */
  86115. static Random(): Color3;
  86116. }
  86117. /**
  86118. * Class used to hold a RBGA color
  86119. */
  86120. export class Color4 {
  86121. /**
  86122. * Defines the red component (between 0 and 1, default is 0)
  86123. */
  86124. r: number;
  86125. /**
  86126. * Defines the green component (between 0 and 1, default is 0)
  86127. */
  86128. g: number;
  86129. /**
  86130. * Defines the blue component (between 0 and 1, default is 0)
  86131. */
  86132. b: number;
  86133. /**
  86134. * Defines the alpha component (between 0 and 1, default is 1)
  86135. */
  86136. a: number;
  86137. /**
  86138. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86139. * @param r defines the red component (between 0 and 1, default is 0)
  86140. * @param g defines the green component (between 0 and 1, default is 0)
  86141. * @param b defines the blue component (between 0 and 1, default is 0)
  86142. * @param a defines the alpha component (between 0 and 1, default is 1)
  86143. */
  86144. constructor(
  86145. /**
  86146. * Defines the red component (between 0 and 1, default is 0)
  86147. */
  86148. r?: number,
  86149. /**
  86150. * Defines the green component (between 0 and 1, default is 0)
  86151. */
  86152. g?: number,
  86153. /**
  86154. * Defines the blue component (between 0 and 1, default is 0)
  86155. */
  86156. b?: number,
  86157. /**
  86158. * Defines the alpha component (between 0 and 1, default is 1)
  86159. */
  86160. a?: number);
  86161. /**
  86162. * Adds in place the given Color4 values to the current Color4 object
  86163. * @param right defines the second operand
  86164. * @returns the current updated Color4 object
  86165. */
  86166. addInPlace(right: DeepImmutable<Color4>): Color4;
  86167. /**
  86168. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86169. * @returns the new array
  86170. */
  86171. asArray(): number[];
  86172. /**
  86173. * Stores from the starting index in the given array the Color4 successive values
  86174. * @param array defines the array where to store the r,g,b components
  86175. * @param index defines an optional index in the target array to define where to start storing values
  86176. * @returns the current Color4 object
  86177. */
  86178. toArray(array: number[], index?: number): Color4;
  86179. /**
  86180. * Update the current color with values stored in an array from the starting index of the given array
  86181. * @param array defines the source array
  86182. * @param offset defines an offset in the source array
  86183. * @returns the current Color4 object
  86184. */
  86185. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86186. /**
  86187. * Determines equality between Color4 objects
  86188. * @param otherColor defines the second operand
  86189. * @returns true if the rgba values are equal to the given ones
  86190. */
  86191. equals(otherColor: DeepImmutable<Color4>): boolean;
  86192. /**
  86193. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86194. * @param right defines the second operand
  86195. * @returns a new Color4 object
  86196. */
  86197. add(right: DeepImmutable<Color4>): Color4;
  86198. /**
  86199. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86200. * @param right defines the second operand
  86201. * @returns a new Color4 object
  86202. */
  86203. subtract(right: DeepImmutable<Color4>): Color4;
  86204. /**
  86205. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86206. * @param right defines the second operand
  86207. * @param result defines the Color4 object where to store the result
  86208. * @returns the current Color4 object
  86209. */
  86210. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86211. /**
  86212. * Creates a new Color4 with the current Color4 values multiplied by scale
  86213. * @param scale defines the scaling factor to apply
  86214. * @returns a new Color4 object
  86215. */
  86216. scale(scale: number): Color4;
  86217. /**
  86218. * Multiplies the current Color4 values by scale and stores the result in "result"
  86219. * @param scale defines the scaling factor to apply
  86220. * @param result defines the Color4 object where to store the result
  86221. * @returns the current unmodified Color4
  86222. */
  86223. scaleToRef(scale: number, result: Color4): Color4;
  86224. /**
  86225. * Scale the current Color4 values by a factor and add the result to a given Color4
  86226. * @param scale defines the scale factor
  86227. * @param result defines the Color4 object where to store the result
  86228. * @returns the unmodified current Color4
  86229. */
  86230. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86231. /**
  86232. * Clamps the rgb values by the min and max values and stores the result into "result"
  86233. * @param min defines minimum clamping value (default is 0)
  86234. * @param max defines maximum clamping value (default is 1)
  86235. * @param result defines color to store the result into.
  86236. * @returns the cuurent Color4
  86237. */
  86238. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86239. /**
  86240. * Multipy an Color4 value by another and return a new Color4 object
  86241. * @param color defines the Color4 value to multiply by
  86242. * @returns a new Color4 object
  86243. */
  86244. multiply(color: Color4): Color4;
  86245. /**
  86246. * Multipy a Color4 value by another and push the result in a reference value
  86247. * @param color defines the Color4 value to multiply by
  86248. * @param result defines the Color4 to fill the result in
  86249. * @returns the result Color4
  86250. */
  86251. multiplyToRef(color: Color4, result: Color4): Color4;
  86252. /**
  86253. * Creates a string with the Color4 current values
  86254. * @returns the string representation of the Color4 object
  86255. */
  86256. toString(): string;
  86257. /**
  86258. * Returns the string "Color4"
  86259. * @returns "Color4"
  86260. */
  86261. getClassName(): string;
  86262. /**
  86263. * Compute the Color4 hash code
  86264. * @returns an unique number that can be used to hash Color4 objects
  86265. */
  86266. getHashCode(): number;
  86267. /**
  86268. * Creates a new Color4 copied from the current one
  86269. * @returns a new Color4 object
  86270. */
  86271. clone(): Color4;
  86272. /**
  86273. * Copies the given Color4 values into the current one
  86274. * @param source defines the source Color4 object
  86275. * @returns the current updated Color4 object
  86276. */
  86277. copyFrom(source: Color4): Color4;
  86278. /**
  86279. * Copies the given float values into the current one
  86280. * @param r defines the red component to read from
  86281. * @param g defines the green component to read from
  86282. * @param b defines the blue component to read from
  86283. * @param a defines the alpha component to read from
  86284. * @returns the current updated Color4 object
  86285. */
  86286. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86287. /**
  86288. * Copies the given float values into the current one
  86289. * @param r defines the red component to read from
  86290. * @param g defines the green component to read from
  86291. * @param b defines the blue component to read from
  86292. * @param a defines the alpha component to read from
  86293. * @returns the current updated Color4 object
  86294. */
  86295. set(r: number, g: number, b: number, a: number): Color4;
  86296. /**
  86297. * Compute the Color4 hexadecimal code as a string
  86298. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86299. * @returns a string containing the hexadecimal representation of the Color4 object
  86300. */
  86301. toHexString(returnAsColor3?: boolean): string;
  86302. /**
  86303. * Computes a new Color4 converted from the current one to linear space
  86304. * @returns a new Color4 object
  86305. */
  86306. toLinearSpace(): Color4;
  86307. /**
  86308. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86309. * @param convertedColor defines the Color4 object where to store the linear space version
  86310. * @returns the unmodified Color4
  86311. */
  86312. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86313. /**
  86314. * Computes a new Color4 converted from the current one to gamma space
  86315. * @returns a new Color4 object
  86316. */
  86317. toGammaSpace(): Color4;
  86318. /**
  86319. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86320. * @param convertedColor defines the Color4 object where to store the gamma space version
  86321. * @returns the unmodified Color4
  86322. */
  86323. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86324. /**
  86325. * Creates a new Color4 from the string containing valid hexadecimal values
  86326. * @param hex defines a string containing valid hexadecimal values
  86327. * @returns a new Color4 object
  86328. */
  86329. static FromHexString(hex: string): Color4;
  86330. /**
  86331. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86332. * @param left defines the start value
  86333. * @param right defines the end value
  86334. * @param amount defines the gradient factor
  86335. * @returns a new Color4 object
  86336. */
  86337. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86338. /**
  86339. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86340. * @param left defines the start value
  86341. * @param right defines the end value
  86342. * @param amount defines the gradient factor
  86343. * @param result defines the Color4 object where to store data
  86344. */
  86345. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86346. /**
  86347. * Creates a new Color4 from a Color3 and an alpha value
  86348. * @param color3 defines the source Color3 to read from
  86349. * @param alpha defines the alpha component (1.0 by default)
  86350. * @returns a new Color4 object
  86351. */
  86352. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86353. /**
  86354. * Creates a new Color4 from the starting index element of the given array
  86355. * @param array defines the source array to read from
  86356. * @param offset defines the offset in the source array
  86357. * @returns a new Color4 object
  86358. */
  86359. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86360. /**
  86361. * Creates a new Color4 from the starting index element of the given array
  86362. * @param array defines the source array to read from
  86363. * @param offset defines the offset in the source array
  86364. * @param result defines the target Color4 object
  86365. */
  86366. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86367. /**
  86368. * Creates a new Color3 from integer values (< 256)
  86369. * @param r defines the red component to read from (value between 0 and 255)
  86370. * @param g defines the green component to read from (value between 0 and 255)
  86371. * @param b defines the blue component to read from (value between 0 and 255)
  86372. * @param a defines the alpha component to read from (value between 0 and 255)
  86373. * @returns a new Color3 object
  86374. */
  86375. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86376. /**
  86377. * Check the content of a given array and convert it to an array containing RGBA data
  86378. * If the original array was already containing count * 4 values then it is returned directly
  86379. * @param colors defines the array to check
  86380. * @param count defines the number of RGBA data to expect
  86381. * @returns an array containing count * 4 values (RGBA)
  86382. */
  86383. static CheckColors4(colors: number[], count: number): number[];
  86384. }
  86385. /**
  86386. * @hidden
  86387. */
  86388. export class TmpColors {
  86389. static Color3: Color3[];
  86390. static Color4: Color4[];
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /**
  86395. * Defines an interface which represents an animation key frame
  86396. */
  86397. export interface IAnimationKey {
  86398. /**
  86399. * Frame of the key frame
  86400. */
  86401. frame: number;
  86402. /**
  86403. * Value at the specifies key frame
  86404. */
  86405. value: any;
  86406. /**
  86407. * The input tangent for the cubic hermite spline
  86408. */
  86409. inTangent?: any;
  86410. /**
  86411. * The output tangent for the cubic hermite spline
  86412. */
  86413. outTangent?: any;
  86414. /**
  86415. * The animation interpolation type
  86416. */
  86417. interpolation?: AnimationKeyInterpolation;
  86418. }
  86419. /**
  86420. * Enum for the animation key frame interpolation type
  86421. */
  86422. export enum AnimationKeyInterpolation {
  86423. /**
  86424. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86425. */
  86426. STEP = 1
  86427. }
  86428. }
  86429. declare module BABYLON {
  86430. /**
  86431. * Represents the range of an animation
  86432. */
  86433. export class AnimationRange {
  86434. /**The name of the animation range**/
  86435. name: string;
  86436. /**The starting frame of the animation */
  86437. from: number;
  86438. /**The ending frame of the animation*/
  86439. to: number;
  86440. /**
  86441. * Initializes the range of an animation
  86442. * @param name The name of the animation range
  86443. * @param from The starting frame of the animation
  86444. * @param to The ending frame of the animation
  86445. */
  86446. constructor(
  86447. /**The name of the animation range**/
  86448. name: string,
  86449. /**The starting frame of the animation */
  86450. from: number,
  86451. /**The ending frame of the animation*/
  86452. to: number);
  86453. /**
  86454. * Makes a copy of the animation range
  86455. * @returns A copy of the animation range
  86456. */
  86457. clone(): AnimationRange;
  86458. }
  86459. }
  86460. declare module BABYLON {
  86461. /**
  86462. * Composed of a frame, and an action function
  86463. */
  86464. export class AnimationEvent {
  86465. /** The frame for which the event is triggered **/
  86466. frame: number;
  86467. /** The event to perform when triggered **/
  86468. action: (currentFrame: number) => void;
  86469. /** Specifies if the event should be triggered only once**/
  86470. onlyOnce?: boolean | undefined;
  86471. /**
  86472. * Specifies if the animation event is done
  86473. */
  86474. isDone: boolean;
  86475. /**
  86476. * Initializes the animation event
  86477. * @param frame The frame for which the event is triggered
  86478. * @param action The event to perform when triggered
  86479. * @param onlyOnce Specifies if the event should be triggered only once
  86480. */
  86481. constructor(
  86482. /** The frame for which the event is triggered **/
  86483. frame: number,
  86484. /** The event to perform when triggered **/
  86485. action: (currentFrame: number) => void,
  86486. /** Specifies if the event should be triggered only once**/
  86487. onlyOnce?: boolean | undefined);
  86488. /** @hidden */
  86489. _clone(): AnimationEvent;
  86490. }
  86491. }
  86492. declare module BABYLON {
  86493. /**
  86494. * Interface used to define a behavior
  86495. */
  86496. export interface Behavior<T> {
  86497. /** gets or sets behavior's name */
  86498. name: string;
  86499. /**
  86500. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86501. */
  86502. init(): void;
  86503. /**
  86504. * Called when the behavior is attached to a target
  86505. * @param target defines the target where the behavior is attached to
  86506. */
  86507. attach(target: T): void;
  86508. /**
  86509. * Called when the behavior is detached from its target
  86510. */
  86511. detach(): void;
  86512. }
  86513. /**
  86514. * Interface implemented by classes supporting behaviors
  86515. */
  86516. export interface IBehaviorAware<T> {
  86517. /**
  86518. * Attach a behavior
  86519. * @param behavior defines the behavior to attach
  86520. * @returns the current host
  86521. */
  86522. addBehavior(behavior: Behavior<T>): T;
  86523. /**
  86524. * Remove a behavior from the current object
  86525. * @param behavior defines the behavior to detach
  86526. * @returns the current host
  86527. */
  86528. removeBehavior(behavior: Behavior<T>): T;
  86529. /**
  86530. * Gets a behavior using its name to search
  86531. * @param name defines the name to search
  86532. * @returns the behavior or null if not found
  86533. */
  86534. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86535. }
  86536. }
  86537. declare module BABYLON {
  86538. /**
  86539. * Defines an array and its length.
  86540. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86541. */
  86542. export interface ISmartArrayLike<T> {
  86543. /**
  86544. * The data of the array.
  86545. */
  86546. data: Array<T>;
  86547. /**
  86548. * The active length of the array.
  86549. */
  86550. length: number;
  86551. }
  86552. /**
  86553. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86554. */
  86555. export class SmartArray<T> implements ISmartArrayLike<T> {
  86556. /**
  86557. * The full set of data from the array.
  86558. */
  86559. data: Array<T>;
  86560. /**
  86561. * The active length of the array.
  86562. */
  86563. length: number;
  86564. protected _id: number;
  86565. /**
  86566. * Instantiates a Smart Array.
  86567. * @param capacity defines the default capacity of the array.
  86568. */
  86569. constructor(capacity: number);
  86570. /**
  86571. * Pushes a value at the end of the active data.
  86572. * @param value defines the object to push in the array.
  86573. */
  86574. push(value: T): void;
  86575. /**
  86576. * Iterates over the active data and apply the lambda to them.
  86577. * @param func defines the action to apply on each value.
  86578. */
  86579. forEach(func: (content: T) => void): void;
  86580. /**
  86581. * Sorts the full sets of data.
  86582. * @param compareFn defines the comparison function to apply.
  86583. */
  86584. sort(compareFn: (a: T, b: T) => number): void;
  86585. /**
  86586. * Resets the active data to an empty array.
  86587. */
  86588. reset(): void;
  86589. /**
  86590. * Releases all the data from the array as well as the array.
  86591. */
  86592. dispose(): void;
  86593. /**
  86594. * Concats the active data with a given array.
  86595. * @param array defines the data to concatenate with.
  86596. */
  86597. concat(array: any): void;
  86598. /**
  86599. * Returns the position of a value in the active data.
  86600. * @param value defines the value to find the index for
  86601. * @returns the index if found in the active data otherwise -1
  86602. */
  86603. indexOf(value: T): number;
  86604. /**
  86605. * Returns whether an element is part of the active data.
  86606. * @param value defines the value to look for
  86607. * @returns true if found in the active data otherwise false
  86608. */
  86609. contains(value: T): boolean;
  86610. private static _GlobalId;
  86611. }
  86612. /**
  86613. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86614. * The data in this array can only be present once
  86615. */
  86616. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86617. private _duplicateId;
  86618. /**
  86619. * Pushes a value at the end of the active data.
  86620. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86621. * @param value defines the object to push in the array.
  86622. */
  86623. push(value: T): void;
  86624. /**
  86625. * Pushes a value at the end of the active data.
  86626. * If the data is already present, it won t be added again
  86627. * @param value defines the object to push in the array.
  86628. * @returns true if added false if it was already present
  86629. */
  86630. pushNoDuplicate(value: T): boolean;
  86631. /**
  86632. * Resets the active data to an empty array.
  86633. */
  86634. reset(): void;
  86635. /**
  86636. * Concats the active data with a given array.
  86637. * This ensures no dupplicate will be present in the result.
  86638. * @param array defines the data to concatenate with.
  86639. */
  86640. concatWithNoDuplicate(array: any): void;
  86641. }
  86642. }
  86643. declare module BABYLON {
  86644. /**
  86645. * @ignore
  86646. * This is a list of all the different input types that are available in the application.
  86647. * Fo instance: ArcRotateCameraGamepadInput...
  86648. */
  86649. export var CameraInputTypes: {};
  86650. /**
  86651. * This is the contract to implement in order to create a new input class.
  86652. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86653. */
  86654. export interface ICameraInput<TCamera extends Camera> {
  86655. /**
  86656. * Defines the camera the input is attached to.
  86657. */
  86658. camera: Nullable<TCamera>;
  86659. /**
  86660. * Gets the class name of the current intput.
  86661. * @returns the class name
  86662. */
  86663. getClassName(): string;
  86664. /**
  86665. * Get the friendly name associated with the input class.
  86666. * @returns the input friendly name
  86667. */
  86668. getSimpleName(): string;
  86669. /**
  86670. * Attach the input controls to a specific dom element to get the input from.
  86671. * @param element Defines the element the controls should be listened from
  86672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86673. */
  86674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86675. /**
  86676. * Detach the current controls from the specified dom element.
  86677. * @param element Defines the element to stop listening the inputs from
  86678. */
  86679. detachControl(element: Nullable<HTMLElement>): void;
  86680. /**
  86681. * Update the current camera state depending on the inputs that have been used this frame.
  86682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86683. */
  86684. checkInputs?: () => void;
  86685. }
  86686. /**
  86687. * Represents a map of input types to input instance or input index to input instance.
  86688. */
  86689. export interface CameraInputsMap<TCamera extends Camera> {
  86690. /**
  86691. * Accessor to the input by input type.
  86692. */
  86693. [name: string]: ICameraInput<TCamera>;
  86694. /**
  86695. * Accessor to the input by input index.
  86696. */
  86697. [idx: number]: ICameraInput<TCamera>;
  86698. }
  86699. /**
  86700. * This represents the input manager used within a camera.
  86701. * It helps dealing with all the different kind of input attached to a camera.
  86702. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86703. */
  86704. export class CameraInputsManager<TCamera extends Camera> {
  86705. /**
  86706. * Defines the list of inputs attahed to the camera.
  86707. */
  86708. attached: CameraInputsMap<TCamera>;
  86709. /**
  86710. * Defines the dom element the camera is collecting inputs from.
  86711. * This is null if the controls have not been attached.
  86712. */
  86713. attachedElement: Nullable<HTMLElement>;
  86714. /**
  86715. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86716. */
  86717. noPreventDefault: boolean;
  86718. /**
  86719. * Defined the camera the input manager belongs to.
  86720. */
  86721. camera: TCamera;
  86722. /**
  86723. * Update the current camera state depending on the inputs that have been used this frame.
  86724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86725. */
  86726. checkInputs: () => void;
  86727. /**
  86728. * Instantiate a new Camera Input Manager.
  86729. * @param camera Defines the camera the input manager blongs to
  86730. */
  86731. constructor(camera: TCamera);
  86732. /**
  86733. * Add an input method to a camera
  86734. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86735. * @param input camera input method
  86736. */
  86737. add(input: ICameraInput<TCamera>): void;
  86738. /**
  86739. * Remove a specific input method from a camera
  86740. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86741. * @param inputToRemove camera input method
  86742. */
  86743. remove(inputToRemove: ICameraInput<TCamera>): void;
  86744. /**
  86745. * Remove a specific input type from a camera
  86746. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86747. * @param inputType the type of the input to remove
  86748. */
  86749. removeByType(inputType: string): void;
  86750. private _addCheckInputs;
  86751. /**
  86752. * Attach the input controls to the currently attached dom element to listen the events from.
  86753. * @param input Defines the input to attach
  86754. */
  86755. attachInput(input: ICameraInput<TCamera>): void;
  86756. /**
  86757. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86758. * @param element Defines the dom element to collect the events from
  86759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86760. */
  86761. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86762. /**
  86763. * Detach the current manager inputs controls from a specific dom element.
  86764. * @param element Defines the dom element to collect the events from
  86765. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86766. */
  86767. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86768. /**
  86769. * Rebuild the dynamic inputCheck function from the current list of
  86770. * defined inputs in the manager.
  86771. */
  86772. rebuildInputCheck(): void;
  86773. /**
  86774. * Remove all attached input methods from a camera
  86775. */
  86776. clear(): void;
  86777. /**
  86778. * Serialize the current input manager attached to a camera.
  86779. * This ensures than once parsed,
  86780. * the input associated to the camera will be identical to the current ones
  86781. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86782. */
  86783. serialize(serializedCamera: any): void;
  86784. /**
  86785. * Parses an input manager serialized JSON to restore the previous list of inputs
  86786. * and states associated to a camera.
  86787. * @param parsedCamera Defines the JSON to parse
  86788. */
  86789. parse(parsedCamera: any): void;
  86790. }
  86791. }
  86792. declare module BABYLON {
  86793. /**
  86794. * Class used to store data that will be store in GPU memory
  86795. */
  86796. export class Buffer {
  86797. private _engine;
  86798. private _buffer;
  86799. /** @hidden */
  86800. _data: Nullable<DataArray>;
  86801. private _updatable;
  86802. private _instanced;
  86803. private _divisor;
  86804. /**
  86805. * Gets the byte stride.
  86806. */
  86807. readonly byteStride: number;
  86808. /**
  86809. * Constructor
  86810. * @param engine the engine
  86811. * @param data the data to use for this buffer
  86812. * @param updatable whether the data is updatable
  86813. * @param stride the stride (optional)
  86814. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86815. * @param instanced whether the buffer is instanced (optional)
  86816. * @param useBytes set to true if the stride in in bytes (optional)
  86817. * @param divisor sets an optional divisor for instances (1 by default)
  86818. */
  86819. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86820. /**
  86821. * Create a new VertexBuffer based on the current buffer
  86822. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86823. * @param offset defines offset in the buffer (0 by default)
  86824. * @param size defines the size in floats of attributes (position is 3 for instance)
  86825. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86826. * @param instanced defines if the vertex buffer contains indexed data
  86827. * @param useBytes defines if the offset and stride are in bytes *
  86828. * @param divisor sets an optional divisor for instances (1 by default)
  86829. * @returns the new vertex buffer
  86830. */
  86831. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86832. /**
  86833. * Gets a boolean indicating if the Buffer is updatable?
  86834. * @returns true if the buffer is updatable
  86835. */
  86836. isUpdatable(): boolean;
  86837. /**
  86838. * Gets current buffer's data
  86839. * @returns a DataArray or null
  86840. */
  86841. getData(): Nullable<DataArray>;
  86842. /**
  86843. * Gets underlying native buffer
  86844. * @returns underlying native buffer
  86845. */
  86846. getBuffer(): Nullable<DataBuffer>;
  86847. /**
  86848. * Gets the stride in float32 units (i.e. byte stride / 4).
  86849. * May not be an integer if the byte stride is not divisible by 4.
  86850. * @returns the stride in float32 units
  86851. * @deprecated Please use byteStride instead.
  86852. */
  86853. getStrideSize(): number;
  86854. /**
  86855. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86856. * @param data defines the data to store
  86857. */
  86858. create(data?: Nullable<DataArray>): void;
  86859. /** @hidden */
  86860. _rebuild(): void;
  86861. /**
  86862. * Update current buffer data
  86863. * @param data defines the data to store
  86864. */
  86865. update(data: DataArray): void;
  86866. /**
  86867. * Updates the data directly.
  86868. * @param data the new data
  86869. * @param offset the new offset
  86870. * @param vertexCount the vertex count (optional)
  86871. * @param useBytes set to true if the offset is in bytes
  86872. */
  86873. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86874. /**
  86875. * Release all resources
  86876. */
  86877. dispose(): void;
  86878. }
  86879. /**
  86880. * Specialized buffer used to store vertex data
  86881. */
  86882. export class VertexBuffer {
  86883. /** @hidden */
  86884. _buffer: Buffer;
  86885. private _kind;
  86886. private _size;
  86887. private _ownsBuffer;
  86888. private _instanced;
  86889. private _instanceDivisor;
  86890. /**
  86891. * The byte type.
  86892. */
  86893. static readonly BYTE: number;
  86894. /**
  86895. * The unsigned byte type.
  86896. */
  86897. static readonly UNSIGNED_BYTE: number;
  86898. /**
  86899. * The short type.
  86900. */
  86901. static readonly SHORT: number;
  86902. /**
  86903. * The unsigned short type.
  86904. */
  86905. static readonly UNSIGNED_SHORT: number;
  86906. /**
  86907. * The integer type.
  86908. */
  86909. static readonly INT: number;
  86910. /**
  86911. * The unsigned integer type.
  86912. */
  86913. static readonly UNSIGNED_INT: number;
  86914. /**
  86915. * The float type.
  86916. */
  86917. static readonly FLOAT: number;
  86918. /**
  86919. * Gets or sets the instance divisor when in instanced mode
  86920. */
  86921. get instanceDivisor(): number;
  86922. set instanceDivisor(value: number);
  86923. /**
  86924. * Gets the byte stride.
  86925. */
  86926. readonly byteStride: number;
  86927. /**
  86928. * Gets the byte offset.
  86929. */
  86930. readonly byteOffset: number;
  86931. /**
  86932. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86933. */
  86934. readonly normalized: boolean;
  86935. /**
  86936. * Gets the data type of each component in the array.
  86937. */
  86938. readonly type: number;
  86939. /**
  86940. * Constructor
  86941. * @param engine the engine
  86942. * @param data the data to use for this vertex buffer
  86943. * @param kind the vertex buffer kind
  86944. * @param updatable whether the data is updatable
  86945. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86946. * @param stride the stride (optional)
  86947. * @param instanced whether the buffer is instanced (optional)
  86948. * @param offset the offset of the data (optional)
  86949. * @param size the number of components (optional)
  86950. * @param type the type of the component (optional)
  86951. * @param normalized whether the data contains normalized data (optional)
  86952. * @param useBytes set to true if stride and offset are in bytes (optional)
  86953. * @param divisor defines the instance divisor to use (1 by default)
  86954. */
  86955. 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);
  86956. /** @hidden */
  86957. _rebuild(): void;
  86958. /**
  86959. * Returns the kind of the VertexBuffer (string)
  86960. * @returns a string
  86961. */
  86962. getKind(): string;
  86963. /**
  86964. * Gets a boolean indicating if the VertexBuffer is updatable?
  86965. * @returns true if the buffer is updatable
  86966. */
  86967. isUpdatable(): boolean;
  86968. /**
  86969. * Gets current buffer's data
  86970. * @returns a DataArray or null
  86971. */
  86972. getData(): Nullable<DataArray>;
  86973. /**
  86974. * Gets underlying native buffer
  86975. * @returns underlying native buffer
  86976. */
  86977. getBuffer(): Nullable<DataBuffer>;
  86978. /**
  86979. * Gets the stride in float32 units (i.e. byte stride / 4).
  86980. * May not be an integer if the byte stride is not divisible by 4.
  86981. * @returns the stride in float32 units
  86982. * @deprecated Please use byteStride instead.
  86983. */
  86984. getStrideSize(): number;
  86985. /**
  86986. * Returns the offset as a multiple of the type byte length.
  86987. * @returns the offset in bytes
  86988. * @deprecated Please use byteOffset instead.
  86989. */
  86990. getOffset(): number;
  86991. /**
  86992. * Returns the number of components per vertex attribute (integer)
  86993. * @returns the size in float
  86994. */
  86995. getSize(): number;
  86996. /**
  86997. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86998. * @returns true if this buffer is instanced
  86999. */
  87000. getIsInstanced(): boolean;
  87001. /**
  87002. * Returns the instancing divisor, zero for non-instanced (integer).
  87003. * @returns a number
  87004. */
  87005. getInstanceDivisor(): number;
  87006. /**
  87007. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87008. * @param data defines the data to store
  87009. */
  87010. create(data?: DataArray): void;
  87011. /**
  87012. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87013. * This function will create a new buffer if the current one is not updatable
  87014. * @param data defines the data to store
  87015. */
  87016. update(data: DataArray): void;
  87017. /**
  87018. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87019. * Returns the directly updated WebGLBuffer.
  87020. * @param data the new data
  87021. * @param offset the new offset
  87022. * @param useBytes set to true if the offset is in bytes
  87023. */
  87024. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87025. /**
  87026. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87027. */
  87028. dispose(): void;
  87029. /**
  87030. * Enumerates each value of this vertex buffer as numbers.
  87031. * @param count the number of values to enumerate
  87032. * @param callback the callback function called for each value
  87033. */
  87034. forEach(count: number, callback: (value: number, index: number) => void): void;
  87035. /**
  87036. * Positions
  87037. */
  87038. static readonly PositionKind: string;
  87039. /**
  87040. * Normals
  87041. */
  87042. static readonly NormalKind: string;
  87043. /**
  87044. * Tangents
  87045. */
  87046. static readonly TangentKind: string;
  87047. /**
  87048. * Texture coordinates
  87049. */
  87050. static readonly UVKind: string;
  87051. /**
  87052. * Texture coordinates 2
  87053. */
  87054. static readonly UV2Kind: string;
  87055. /**
  87056. * Texture coordinates 3
  87057. */
  87058. static readonly UV3Kind: string;
  87059. /**
  87060. * Texture coordinates 4
  87061. */
  87062. static readonly UV4Kind: string;
  87063. /**
  87064. * Texture coordinates 5
  87065. */
  87066. static readonly UV5Kind: string;
  87067. /**
  87068. * Texture coordinates 6
  87069. */
  87070. static readonly UV6Kind: string;
  87071. /**
  87072. * Colors
  87073. */
  87074. static readonly ColorKind: string;
  87075. /**
  87076. * Matrix indices (for bones)
  87077. */
  87078. static readonly MatricesIndicesKind: string;
  87079. /**
  87080. * Matrix weights (for bones)
  87081. */
  87082. static readonly MatricesWeightsKind: string;
  87083. /**
  87084. * Additional matrix indices (for bones)
  87085. */
  87086. static readonly MatricesIndicesExtraKind: string;
  87087. /**
  87088. * Additional matrix weights (for bones)
  87089. */
  87090. static readonly MatricesWeightsExtraKind: string;
  87091. /**
  87092. * Deduces the stride given a kind.
  87093. * @param kind The kind string to deduce
  87094. * @returns The deduced stride
  87095. */
  87096. static DeduceStride(kind: string): number;
  87097. /**
  87098. * Gets the byte length of the given type.
  87099. * @param type the type
  87100. * @returns the number of bytes
  87101. */
  87102. static GetTypeByteLength(type: number): number;
  87103. /**
  87104. * Enumerates each value of the given parameters as numbers.
  87105. * @param data the data to enumerate
  87106. * @param byteOffset the byte offset of the data
  87107. * @param byteStride the byte stride of the data
  87108. * @param componentCount the number of components per element
  87109. * @param componentType the type of the component
  87110. * @param count the number of values to enumerate
  87111. * @param normalized whether the data is normalized
  87112. * @param callback the callback function called for each value
  87113. */
  87114. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87115. private static _GetFloatValue;
  87116. }
  87117. }
  87118. declare module BABYLON {
  87119. /**
  87120. * The options Interface for creating a Capsule Mesh
  87121. */
  87122. export interface ICreateCapsuleOptions {
  87123. /** The Orientation of the capsule. Default : Vector3.Up() */
  87124. orientation?: Vector3;
  87125. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87126. subdivisions: number;
  87127. /** Number of cylindrical segments on the capsule. */
  87128. tessellation: number;
  87129. /** Height or Length of the capsule. */
  87130. height: number;
  87131. /** Radius of the capsule. */
  87132. radius: number;
  87133. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87134. capSubdivisions: number;
  87135. /** Overwrite for the top radius. */
  87136. radiusTop?: number;
  87137. /** Overwrite for the bottom radius. */
  87138. radiusBottom?: number;
  87139. /** Overwrite for the top capSubdivisions. */
  87140. topCapSubdivisions?: number;
  87141. /** Overwrite for the bottom capSubdivisions. */
  87142. bottomCapSubdivisions?: number;
  87143. }
  87144. /**
  87145. * Class containing static functions to help procedurally build meshes
  87146. */
  87147. export class CapsuleBuilder {
  87148. /**
  87149. * Creates a capsule or a pill mesh
  87150. * @param name defines the name of the mesh
  87151. * @param options The constructors options.
  87152. * @param scene The scene the mesh is scoped to.
  87153. * @returns Capsule Mesh
  87154. */
  87155. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87156. }
  87157. }
  87158. declare module BABYLON {
  87159. /**
  87160. * @hidden
  87161. */
  87162. export class IntersectionInfo {
  87163. bu: Nullable<number>;
  87164. bv: Nullable<number>;
  87165. distance: number;
  87166. faceId: number;
  87167. subMeshId: number;
  87168. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87169. }
  87170. }
  87171. declare module BABYLON {
  87172. /**
  87173. * Class used to store bounding sphere information
  87174. */
  87175. export class BoundingSphere {
  87176. /**
  87177. * Gets the center of the bounding sphere in local space
  87178. */
  87179. readonly center: Vector3;
  87180. /**
  87181. * Radius of the bounding sphere in local space
  87182. */
  87183. radius: number;
  87184. /**
  87185. * Gets the center of the bounding sphere in world space
  87186. */
  87187. readonly centerWorld: Vector3;
  87188. /**
  87189. * Radius of the bounding sphere in world space
  87190. */
  87191. radiusWorld: number;
  87192. /**
  87193. * Gets the minimum vector in local space
  87194. */
  87195. readonly minimum: Vector3;
  87196. /**
  87197. * Gets the maximum vector in local space
  87198. */
  87199. readonly maximum: Vector3;
  87200. private _worldMatrix;
  87201. private static readonly TmpVector3;
  87202. /**
  87203. * Creates a new bounding sphere
  87204. * @param min defines the minimum vector (in local space)
  87205. * @param max defines the maximum vector (in local space)
  87206. * @param worldMatrix defines the new world matrix
  87207. */
  87208. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87209. /**
  87210. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87211. * @param min defines the new minimum vector (in local space)
  87212. * @param max defines the new maximum vector (in local space)
  87213. * @param worldMatrix defines the new world matrix
  87214. */
  87215. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87216. /**
  87217. * Scale the current bounding sphere by applying a scale factor
  87218. * @param factor defines the scale factor to apply
  87219. * @returns the current bounding box
  87220. */
  87221. scale(factor: number): BoundingSphere;
  87222. /**
  87223. * Gets the world matrix of the bounding box
  87224. * @returns a matrix
  87225. */
  87226. getWorldMatrix(): DeepImmutable<Matrix>;
  87227. /** @hidden */
  87228. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87229. /**
  87230. * Tests if the bounding sphere is intersecting the frustum planes
  87231. * @param frustumPlanes defines the frustum planes to test
  87232. * @returns true if there is an intersection
  87233. */
  87234. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87235. /**
  87236. * Tests if the bounding sphere center is in between the frustum planes.
  87237. * Used for optimistic fast inclusion.
  87238. * @param frustumPlanes defines the frustum planes to test
  87239. * @returns true if the sphere center is in between the frustum planes
  87240. */
  87241. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87242. /**
  87243. * Tests if a point is inside the bounding sphere
  87244. * @param point defines the point to test
  87245. * @returns true if the point is inside the bounding sphere
  87246. */
  87247. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87248. /**
  87249. * Checks if two sphere intersct
  87250. * @param sphere0 sphere 0
  87251. * @param sphere1 sphere 1
  87252. * @returns true if the speres intersect
  87253. */
  87254. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87255. }
  87256. }
  87257. declare module BABYLON {
  87258. /**
  87259. * Class used to store bounding box information
  87260. */
  87261. export class BoundingBox implements ICullable {
  87262. /**
  87263. * Gets the 8 vectors representing the bounding box in local space
  87264. */
  87265. readonly vectors: Vector3[];
  87266. /**
  87267. * Gets the center of the bounding box in local space
  87268. */
  87269. readonly center: Vector3;
  87270. /**
  87271. * Gets the center of the bounding box in world space
  87272. */
  87273. readonly centerWorld: Vector3;
  87274. /**
  87275. * Gets the extend size in local space
  87276. */
  87277. readonly extendSize: Vector3;
  87278. /**
  87279. * Gets the extend size in world space
  87280. */
  87281. readonly extendSizeWorld: Vector3;
  87282. /**
  87283. * Gets the OBB (object bounding box) directions
  87284. */
  87285. readonly directions: Vector3[];
  87286. /**
  87287. * Gets the 8 vectors representing the bounding box in world space
  87288. */
  87289. readonly vectorsWorld: Vector3[];
  87290. /**
  87291. * Gets the minimum vector in world space
  87292. */
  87293. readonly minimumWorld: Vector3;
  87294. /**
  87295. * Gets the maximum vector in world space
  87296. */
  87297. readonly maximumWorld: Vector3;
  87298. /**
  87299. * Gets the minimum vector in local space
  87300. */
  87301. readonly minimum: Vector3;
  87302. /**
  87303. * Gets the maximum vector in local space
  87304. */
  87305. readonly maximum: Vector3;
  87306. private _worldMatrix;
  87307. private static readonly TmpVector3;
  87308. /**
  87309. * @hidden
  87310. */
  87311. _tag: number;
  87312. /**
  87313. * Creates a new bounding box
  87314. * @param min defines the minimum vector (in local space)
  87315. * @param max defines the maximum vector (in local space)
  87316. * @param worldMatrix defines the new world matrix
  87317. */
  87318. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87319. /**
  87320. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87321. * @param min defines the new minimum vector (in local space)
  87322. * @param max defines the new maximum vector (in local space)
  87323. * @param worldMatrix defines the new world matrix
  87324. */
  87325. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87326. /**
  87327. * Scale the current bounding box by applying a scale factor
  87328. * @param factor defines the scale factor to apply
  87329. * @returns the current bounding box
  87330. */
  87331. scale(factor: number): BoundingBox;
  87332. /**
  87333. * Gets the world matrix of the bounding box
  87334. * @returns a matrix
  87335. */
  87336. getWorldMatrix(): DeepImmutable<Matrix>;
  87337. /** @hidden */
  87338. _update(world: DeepImmutable<Matrix>): void;
  87339. /**
  87340. * Tests if the bounding box is intersecting the frustum planes
  87341. * @param frustumPlanes defines the frustum planes to test
  87342. * @returns true if there is an intersection
  87343. */
  87344. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87345. /**
  87346. * Tests if the bounding box is entirely inside the frustum planes
  87347. * @param frustumPlanes defines the frustum planes to test
  87348. * @returns true if there is an inclusion
  87349. */
  87350. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87351. /**
  87352. * Tests if a point is inside the bounding box
  87353. * @param point defines the point to test
  87354. * @returns true if the point is inside the bounding box
  87355. */
  87356. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87357. /**
  87358. * Tests if the bounding box intersects with a bounding sphere
  87359. * @param sphere defines the sphere to test
  87360. * @returns true if there is an intersection
  87361. */
  87362. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87363. /**
  87364. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87365. * @param min defines the min vector to use
  87366. * @param max defines the max vector to use
  87367. * @returns true if there is an intersection
  87368. */
  87369. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87370. /**
  87371. * Tests if two bounding boxes are intersections
  87372. * @param box0 defines the first box to test
  87373. * @param box1 defines the second box to test
  87374. * @returns true if there is an intersection
  87375. */
  87376. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87377. /**
  87378. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87379. * @param minPoint defines the minimum vector of the bounding box
  87380. * @param maxPoint defines the maximum vector of the bounding box
  87381. * @param sphereCenter defines the sphere center
  87382. * @param sphereRadius defines the sphere radius
  87383. * @returns true if there is an intersection
  87384. */
  87385. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87386. /**
  87387. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87388. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87389. * @param frustumPlanes defines the frustum planes to test
  87390. * @return true if there is an inclusion
  87391. */
  87392. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87393. /**
  87394. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87395. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87396. * @param frustumPlanes defines the frustum planes to test
  87397. * @return true if there is an intersection
  87398. */
  87399. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87400. }
  87401. }
  87402. declare module BABYLON {
  87403. /** @hidden */
  87404. export class Collider {
  87405. /** Define if a collision was found */
  87406. collisionFound: boolean;
  87407. /**
  87408. * Define last intersection point in local space
  87409. */
  87410. intersectionPoint: Vector3;
  87411. /**
  87412. * Define last collided mesh
  87413. */
  87414. collidedMesh: Nullable<AbstractMesh>;
  87415. private _collisionPoint;
  87416. private _planeIntersectionPoint;
  87417. private _tempVector;
  87418. private _tempVector2;
  87419. private _tempVector3;
  87420. private _tempVector4;
  87421. private _edge;
  87422. private _baseToVertex;
  87423. private _destinationPoint;
  87424. private _slidePlaneNormal;
  87425. private _displacementVector;
  87426. /** @hidden */
  87427. _radius: Vector3;
  87428. /** @hidden */
  87429. _retry: number;
  87430. private _velocity;
  87431. private _basePoint;
  87432. private _epsilon;
  87433. /** @hidden */
  87434. _velocityWorldLength: number;
  87435. /** @hidden */
  87436. _basePointWorld: Vector3;
  87437. private _velocityWorld;
  87438. private _normalizedVelocity;
  87439. /** @hidden */
  87440. _initialVelocity: Vector3;
  87441. /** @hidden */
  87442. _initialPosition: Vector3;
  87443. private _nearestDistance;
  87444. private _collisionMask;
  87445. get collisionMask(): number;
  87446. set collisionMask(mask: number);
  87447. /**
  87448. * Gets the plane normal used to compute the sliding response (in local space)
  87449. */
  87450. get slidePlaneNormal(): Vector3;
  87451. /** @hidden */
  87452. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87453. /** @hidden */
  87454. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87455. /** @hidden */
  87456. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87457. /** @hidden */
  87458. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87459. /** @hidden */
  87460. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87461. /** @hidden */
  87462. _getResponse(pos: Vector3, vel: Vector3): void;
  87463. }
  87464. }
  87465. declare module BABYLON {
  87466. /**
  87467. * Interface for cullable objects
  87468. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87469. */
  87470. export interface ICullable {
  87471. /**
  87472. * Checks if the object or part of the object is in the frustum
  87473. * @param frustumPlanes Camera near/planes
  87474. * @returns true if the object is in frustum otherwise false
  87475. */
  87476. isInFrustum(frustumPlanes: Plane[]): boolean;
  87477. /**
  87478. * Checks if a cullable object (mesh...) is in the camera frustum
  87479. * Unlike isInFrustum this cheks the full bounding box
  87480. * @param frustumPlanes Camera near/planes
  87481. * @returns true if the object is in frustum otherwise false
  87482. */
  87483. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87484. }
  87485. /**
  87486. * Info for a bounding data of a mesh
  87487. */
  87488. export class BoundingInfo implements ICullable {
  87489. /**
  87490. * Bounding box for the mesh
  87491. */
  87492. readonly boundingBox: BoundingBox;
  87493. /**
  87494. * Bounding sphere for the mesh
  87495. */
  87496. readonly boundingSphere: BoundingSphere;
  87497. private _isLocked;
  87498. private static readonly TmpVector3;
  87499. /**
  87500. * Constructs bounding info
  87501. * @param minimum min vector of the bounding box/sphere
  87502. * @param maximum max vector of the bounding box/sphere
  87503. * @param worldMatrix defines the new world matrix
  87504. */
  87505. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87506. /**
  87507. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87508. * @param min defines the new minimum vector (in local space)
  87509. * @param max defines the new maximum vector (in local space)
  87510. * @param worldMatrix defines the new world matrix
  87511. */
  87512. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87513. /**
  87514. * min vector of the bounding box/sphere
  87515. */
  87516. get minimum(): Vector3;
  87517. /**
  87518. * max vector of the bounding box/sphere
  87519. */
  87520. get maximum(): Vector3;
  87521. /**
  87522. * If the info is locked and won't be updated to avoid perf overhead
  87523. */
  87524. get isLocked(): boolean;
  87525. set isLocked(value: boolean);
  87526. /**
  87527. * Updates the bounding sphere and box
  87528. * @param world world matrix to be used to update
  87529. */
  87530. update(world: DeepImmutable<Matrix>): void;
  87531. /**
  87532. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87533. * @param center New center of the bounding info
  87534. * @param extend New extend of the bounding info
  87535. * @returns the current bounding info
  87536. */
  87537. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87538. /**
  87539. * Scale the current bounding info by applying a scale factor
  87540. * @param factor defines the scale factor to apply
  87541. * @returns the current bounding info
  87542. */
  87543. scale(factor: number): BoundingInfo;
  87544. /**
  87545. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87546. * @param frustumPlanes defines the frustum to test
  87547. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87548. * @returns true if the bounding info is in the frustum planes
  87549. */
  87550. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87551. /**
  87552. * Gets the world distance between the min and max points of the bounding box
  87553. */
  87554. get diagonalLength(): number;
  87555. /**
  87556. * Checks if a cullable object (mesh...) is in the camera frustum
  87557. * Unlike isInFrustum this cheks the full bounding box
  87558. * @param frustumPlanes Camera near/planes
  87559. * @returns true if the object is in frustum otherwise false
  87560. */
  87561. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87562. /** @hidden */
  87563. _checkCollision(collider: Collider): boolean;
  87564. /**
  87565. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87566. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87567. * @param point the point to check intersection with
  87568. * @returns if the point intersects
  87569. */
  87570. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87571. /**
  87572. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87573. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87574. * @param boundingInfo the bounding info to check intersection with
  87575. * @param precise if the intersection should be done using OBB
  87576. * @returns if the bounding info intersects
  87577. */
  87578. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87579. }
  87580. }
  87581. declare module BABYLON {
  87582. /**
  87583. * Extracts minimum and maximum values from a list of indexed positions
  87584. * @param positions defines the positions to use
  87585. * @param indices defines the indices to the positions
  87586. * @param indexStart defines the start index
  87587. * @param indexCount defines the end index
  87588. * @param bias defines bias value to add to the result
  87589. * @return minimum and maximum values
  87590. */
  87591. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87592. minimum: Vector3;
  87593. maximum: Vector3;
  87594. };
  87595. /**
  87596. * Extracts minimum and maximum values from a list of positions
  87597. * @param positions defines the positions to use
  87598. * @param start defines the start index in the positions array
  87599. * @param count defines the number of positions to handle
  87600. * @param bias defines bias value to add to the result
  87601. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87602. * @return minimum and maximum values
  87603. */
  87604. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87605. minimum: Vector3;
  87606. maximum: Vector3;
  87607. };
  87608. }
  87609. declare module BABYLON {
  87610. /** @hidden */
  87611. export class WebGLDataBuffer extends DataBuffer {
  87612. private _buffer;
  87613. constructor(resource: WebGLBuffer);
  87614. get underlyingResource(): any;
  87615. }
  87616. }
  87617. declare module BABYLON {
  87618. /** @hidden */
  87619. export class WebGLPipelineContext implements IPipelineContext {
  87620. engine: ThinEngine;
  87621. program: Nullable<WebGLProgram>;
  87622. context?: WebGLRenderingContext;
  87623. vertexShader?: WebGLShader;
  87624. fragmentShader?: WebGLShader;
  87625. isParallelCompiled: boolean;
  87626. onCompiled?: () => void;
  87627. transformFeedback?: WebGLTransformFeedback | null;
  87628. vertexCompilationError: Nullable<string>;
  87629. fragmentCompilationError: Nullable<string>;
  87630. programLinkError: Nullable<string>;
  87631. programValidationError: Nullable<string>;
  87632. get isAsync(): boolean;
  87633. get isReady(): boolean;
  87634. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87635. _getVertexShaderCode(): string | null;
  87636. _getFragmentShaderCode(): string | null;
  87637. }
  87638. }
  87639. declare module BABYLON {
  87640. interface ThinEngine {
  87641. /**
  87642. * Create an uniform buffer
  87643. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87644. * @param elements defines the content of the uniform buffer
  87645. * @returns the webGL uniform buffer
  87646. */
  87647. createUniformBuffer(elements: FloatArray): DataBuffer;
  87648. /**
  87649. * Create a dynamic uniform buffer
  87650. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87651. * @param elements defines the content of the uniform buffer
  87652. * @returns the webGL uniform buffer
  87653. */
  87654. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87655. /**
  87656. * Update an existing uniform buffer
  87657. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87658. * @param uniformBuffer defines the target uniform buffer
  87659. * @param elements defines the content to update
  87660. * @param offset defines the offset in the uniform buffer where update should start
  87661. * @param count defines the size of the data to update
  87662. */
  87663. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87664. /**
  87665. * Bind an uniform buffer to the current webGL context
  87666. * @param buffer defines the buffer to bind
  87667. */
  87668. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87669. /**
  87670. * Bind a buffer to the current webGL context at a given location
  87671. * @param buffer defines the buffer to bind
  87672. * @param location defines the index where to bind the buffer
  87673. */
  87674. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87675. /**
  87676. * Bind a specific block at a given index in a specific shader program
  87677. * @param pipelineContext defines the pipeline context to use
  87678. * @param blockName defines the block name
  87679. * @param index defines the index where to bind the block
  87680. */
  87681. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87682. }
  87683. }
  87684. declare module BABYLON {
  87685. /**
  87686. * Uniform buffer objects.
  87687. *
  87688. * Handles blocks of uniform on the GPU.
  87689. *
  87690. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87691. *
  87692. * For more information, please refer to :
  87693. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87694. */
  87695. export class UniformBuffer {
  87696. private _engine;
  87697. private _buffer;
  87698. private _data;
  87699. private _bufferData;
  87700. private _dynamic?;
  87701. private _uniformLocations;
  87702. private _uniformSizes;
  87703. private _uniformLocationPointer;
  87704. private _needSync;
  87705. private _noUBO;
  87706. private _currentEffect;
  87707. /** @hidden */
  87708. _alreadyBound: boolean;
  87709. private static _MAX_UNIFORM_SIZE;
  87710. private static _tempBuffer;
  87711. /**
  87712. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87713. * This is dynamic to allow compat with webgl 1 and 2.
  87714. * You will need to pass the name of the uniform as well as the value.
  87715. */
  87716. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87717. /**
  87718. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87719. * This is dynamic to allow compat with webgl 1 and 2.
  87720. * You will need to pass the name of the uniform as well as the value.
  87721. */
  87722. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87723. /**
  87724. * Lambda to Update a single float in a uniform buffer.
  87725. * This is dynamic to allow compat with webgl 1 and 2.
  87726. * You will need to pass the name of the uniform as well as the value.
  87727. */
  87728. updateFloat: (name: string, x: number) => void;
  87729. /**
  87730. * Lambda to Update a vec2 of float in a uniform buffer.
  87731. * This is dynamic to allow compat with webgl 1 and 2.
  87732. * You will need to pass the name of the uniform as well as the value.
  87733. */
  87734. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87735. /**
  87736. * Lambda to Update a vec3 of float in a uniform buffer.
  87737. * This is dynamic to allow compat with webgl 1 and 2.
  87738. * You will need to pass the name of the uniform as well as the value.
  87739. */
  87740. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87741. /**
  87742. * Lambda to Update a vec4 of float in a uniform buffer.
  87743. * This is dynamic to allow compat with webgl 1 and 2.
  87744. * You will need to pass the name of the uniform as well as the value.
  87745. */
  87746. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87747. /**
  87748. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87749. * This is dynamic to allow compat with webgl 1 and 2.
  87750. * You will need to pass the name of the uniform as well as the value.
  87751. */
  87752. updateMatrix: (name: string, mat: Matrix) => void;
  87753. /**
  87754. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87755. * This is dynamic to allow compat with webgl 1 and 2.
  87756. * You will need to pass the name of the uniform as well as the value.
  87757. */
  87758. updateVector3: (name: string, vector: Vector3) => void;
  87759. /**
  87760. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87761. * This is dynamic to allow compat with webgl 1 and 2.
  87762. * You will need to pass the name of the uniform as well as the value.
  87763. */
  87764. updateVector4: (name: string, vector: Vector4) => void;
  87765. /**
  87766. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87767. * This is dynamic to allow compat with webgl 1 and 2.
  87768. * You will need to pass the name of the uniform as well as the value.
  87769. */
  87770. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87771. /**
  87772. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87773. * This is dynamic to allow compat with webgl 1 and 2.
  87774. * You will need to pass the name of the uniform as well as the value.
  87775. */
  87776. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87777. /**
  87778. * Instantiates a new Uniform buffer objects.
  87779. *
  87780. * Handles blocks of uniform on the GPU.
  87781. *
  87782. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87783. *
  87784. * For more information, please refer to :
  87785. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87786. * @param engine Define the engine the buffer is associated with
  87787. * @param data Define the data contained in the buffer
  87788. * @param dynamic Define if the buffer is updatable
  87789. */
  87790. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87791. /**
  87792. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87793. * or just falling back on setUniformXXX calls.
  87794. */
  87795. get useUbo(): boolean;
  87796. /**
  87797. * Indicates if the WebGL underlying uniform buffer is in sync
  87798. * with the javascript cache data.
  87799. */
  87800. get isSync(): boolean;
  87801. /**
  87802. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87803. * Also, a dynamic UniformBuffer will disable cache verification and always
  87804. * update the underlying WebGL uniform buffer to the GPU.
  87805. * @returns if Dynamic, otherwise false
  87806. */
  87807. isDynamic(): boolean;
  87808. /**
  87809. * The data cache on JS side.
  87810. * @returns the underlying data as a float array
  87811. */
  87812. getData(): Float32Array;
  87813. /**
  87814. * The underlying WebGL Uniform buffer.
  87815. * @returns the webgl buffer
  87816. */
  87817. getBuffer(): Nullable<DataBuffer>;
  87818. /**
  87819. * std140 layout specifies how to align data within an UBO structure.
  87820. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87821. * for specs.
  87822. */
  87823. private _fillAlignment;
  87824. /**
  87825. * Adds an uniform in the buffer.
  87826. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87827. * for the layout to be correct !
  87828. * @param name Name of the uniform, as used in the uniform block in the shader.
  87829. * @param size Data size, or data directly.
  87830. */
  87831. addUniform(name: string, size: number | number[]): void;
  87832. /**
  87833. * Adds a Matrix 4x4 to the uniform buffer.
  87834. * @param name Name of the uniform, as used in the uniform block in the shader.
  87835. * @param mat A 4x4 matrix.
  87836. */
  87837. addMatrix(name: string, mat: Matrix): void;
  87838. /**
  87839. * Adds a vec2 to the uniform buffer.
  87840. * @param name Name of the uniform, as used in the uniform block in the shader.
  87841. * @param x Define the x component value of the vec2
  87842. * @param y Define the y component value of the vec2
  87843. */
  87844. addFloat2(name: string, x: number, y: number): void;
  87845. /**
  87846. * Adds a vec3 to the uniform buffer.
  87847. * @param name Name of the uniform, as used in the uniform block in the shader.
  87848. * @param x Define the x component value of the vec3
  87849. * @param y Define the y component value of the vec3
  87850. * @param z Define the z component value of the vec3
  87851. */
  87852. addFloat3(name: string, x: number, y: number, z: number): void;
  87853. /**
  87854. * Adds a vec3 to the uniform buffer.
  87855. * @param name Name of the uniform, as used in the uniform block in the shader.
  87856. * @param color Define the vec3 from a Color
  87857. */
  87858. addColor3(name: string, color: Color3): void;
  87859. /**
  87860. * Adds a vec4 to the uniform buffer.
  87861. * @param name Name of the uniform, as used in the uniform block in the shader.
  87862. * @param color Define the rgb components from a Color
  87863. * @param alpha Define the a component of the vec4
  87864. */
  87865. addColor4(name: string, color: Color3, alpha: number): void;
  87866. /**
  87867. * Adds a vec3 to the uniform buffer.
  87868. * @param name Name of the uniform, as used in the uniform block in the shader.
  87869. * @param vector Define the vec3 components from a Vector
  87870. */
  87871. addVector3(name: string, vector: Vector3): void;
  87872. /**
  87873. * Adds a Matrix 3x3 to the uniform buffer.
  87874. * @param name Name of the uniform, as used in the uniform block in the shader.
  87875. */
  87876. addMatrix3x3(name: string): void;
  87877. /**
  87878. * Adds a Matrix 2x2 to the uniform buffer.
  87879. * @param name Name of the uniform, as used in the uniform block in the shader.
  87880. */
  87881. addMatrix2x2(name: string): void;
  87882. /**
  87883. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87884. */
  87885. create(): void;
  87886. /** @hidden */
  87887. _rebuild(): void;
  87888. /**
  87889. * Updates the WebGL Uniform Buffer on the GPU.
  87890. * If the `dynamic` flag is set to true, no cache comparison is done.
  87891. * Otherwise, the buffer will be updated only if the cache differs.
  87892. */
  87893. update(): void;
  87894. /**
  87895. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87896. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87897. * @param data Define the flattened data
  87898. * @param size Define the size of the data.
  87899. */
  87900. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87901. private _valueCache;
  87902. private _cacheMatrix;
  87903. private _updateMatrix3x3ForUniform;
  87904. private _updateMatrix3x3ForEffect;
  87905. private _updateMatrix2x2ForEffect;
  87906. private _updateMatrix2x2ForUniform;
  87907. private _updateFloatForEffect;
  87908. private _updateFloatForUniform;
  87909. private _updateFloat2ForEffect;
  87910. private _updateFloat2ForUniform;
  87911. private _updateFloat3ForEffect;
  87912. private _updateFloat3ForUniform;
  87913. private _updateFloat4ForEffect;
  87914. private _updateFloat4ForUniform;
  87915. private _updateMatrixForEffect;
  87916. private _updateMatrixForUniform;
  87917. private _updateVector3ForEffect;
  87918. private _updateVector3ForUniform;
  87919. private _updateVector4ForEffect;
  87920. private _updateVector4ForUniform;
  87921. private _updateColor3ForEffect;
  87922. private _updateColor3ForUniform;
  87923. private _updateColor4ForEffect;
  87924. private _updateColor4ForUniform;
  87925. /**
  87926. * Sets a sampler uniform on the effect.
  87927. * @param name Define the name of the sampler.
  87928. * @param texture Define the texture to set in the sampler
  87929. */
  87930. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87931. /**
  87932. * Directly updates the value of the uniform in the cache AND on the GPU.
  87933. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87934. * @param data Define the flattened data
  87935. */
  87936. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87937. /**
  87938. * Binds this uniform buffer to an effect.
  87939. * @param effect Define the effect to bind the buffer to
  87940. * @param name Name of the uniform block in the shader.
  87941. */
  87942. bindToEffect(effect: Effect, name: string): void;
  87943. /**
  87944. * Disposes the uniform buffer.
  87945. */
  87946. dispose(): void;
  87947. }
  87948. }
  87949. declare module BABYLON {
  87950. /**
  87951. * Enum that determines the text-wrapping mode to use.
  87952. */
  87953. export enum InspectableType {
  87954. /**
  87955. * Checkbox for booleans
  87956. */
  87957. Checkbox = 0,
  87958. /**
  87959. * Sliders for numbers
  87960. */
  87961. Slider = 1,
  87962. /**
  87963. * Vector3
  87964. */
  87965. Vector3 = 2,
  87966. /**
  87967. * Quaternions
  87968. */
  87969. Quaternion = 3,
  87970. /**
  87971. * Color3
  87972. */
  87973. Color3 = 4,
  87974. /**
  87975. * String
  87976. */
  87977. String = 5
  87978. }
  87979. /**
  87980. * Interface used to define custom inspectable properties.
  87981. * This interface is used by the inspector to display custom property grids
  87982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87983. */
  87984. export interface IInspectable {
  87985. /**
  87986. * Gets the label to display
  87987. */
  87988. label: string;
  87989. /**
  87990. * Gets the name of the property to edit
  87991. */
  87992. propertyName: string;
  87993. /**
  87994. * Gets the type of the editor to use
  87995. */
  87996. type: InspectableType;
  87997. /**
  87998. * Gets the minimum value of the property when using in "slider" mode
  87999. */
  88000. min?: number;
  88001. /**
  88002. * Gets the maximum value of the property when using in "slider" mode
  88003. */
  88004. max?: number;
  88005. /**
  88006. * Gets the setp to use when using in "slider" mode
  88007. */
  88008. step?: number;
  88009. }
  88010. }
  88011. declare module BABYLON {
  88012. /**
  88013. * Class used to provide helper for timing
  88014. */
  88015. export class TimingTools {
  88016. /**
  88017. * Polyfill for setImmediate
  88018. * @param action defines the action to execute after the current execution block
  88019. */
  88020. static SetImmediate(action: () => void): void;
  88021. }
  88022. }
  88023. declare module BABYLON {
  88024. /**
  88025. * Class used to enable instatition of objects by class name
  88026. */
  88027. export class InstantiationTools {
  88028. /**
  88029. * Use this object to register external classes like custom textures or material
  88030. * to allow the laoders to instantiate them
  88031. */
  88032. static RegisteredExternalClasses: {
  88033. [key: string]: Object;
  88034. };
  88035. /**
  88036. * Tries to instantiate a new object from a given class name
  88037. * @param className defines the class name to instantiate
  88038. * @returns the new object or null if the system was not able to do the instantiation
  88039. */
  88040. static Instantiate(className: string): any;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * Define options used to create a depth texture
  88046. */
  88047. export class DepthTextureCreationOptions {
  88048. /** Specifies whether or not a stencil should be allocated in the texture */
  88049. generateStencil?: boolean;
  88050. /** Specifies whether or not bilinear filtering is enable on the texture */
  88051. bilinearFiltering?: boolean;
  88052. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88053. comparisonFunction?: number;
  88054. /** Specifies if the created texture is a cube texture */
  88055. isCube?: boolean;
  88056. }
  88057. }
  88058. declare module BABYLON {
  88059. interface ThinEngine {
  88060. /**
  88061. * Creates a depth stencil cube texture.
  88062. * This is only available in WebGL 2.
  88063. * @param size The size of face edge in the cube texture.
  88064. * @param options The options defining the cube texture.
  88065. * @returns The cube texture
  88066. */
  88067. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88068. /**
  88069. * Creates a cube texture
  88070. * @param rootUrl defines the url where the files to load is located
  88071. * @param scene defines the current scene
  88072. * @param files defines the list of files to load (1 per face)
  88073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88074. * @param onLoad defines an optional callback raised when the texture is loaded
  88075. * @param onError defines an optional callback raised if there is an issue to load the texture
  88076. * @param format defines the format of the data
  88077. * @param forcedExtension defines the extension to use to pick the right loader
  88078. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88081. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88082. * @returns the cube texture as an InternalTexture
  88083. */
  88084. 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;
  88085. /**
  88086. * Creates a cube texture
  88087. * @param rootUrl defines the url where the files to load is located
  88088. * @param scene defines the current scene
  88089. * @param files defines the list of files to load (1 per face)
  88090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88091. * @param onLoad defines an optional callback raised when the texture is loaded
  88092. * @param onError defines an optional callback raised if there is an issue to load the texture
  88093. * @param format defines the format of the data
  88094. * @param forcedExtension defines the extension to use to pick the right loader
  88095. * @returns the cube texture as an InternalTexture
  88096. */
  88097. 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;
  88098. /**
  88099. * Creates a cube texture
  88100. * @param rootUrl defines the url where the files to load is located
  88101. * @param scene defines the current scene
  88102. * @param files defines the list of files to load (1 per face)
  88103. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88104. * @param onLoad defines an optional callback raised when the texture is loaded
  88105. * @param onError defines an optional callback raised if there is an issue to load the texture
  88106. * @param format defines the format of the data
  88107. * @param forcedExtension defines the extension to use to pick the right loader
  88108. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88109. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88110. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88111. * @returns the cube texture as an InternalTexture
  88112. */
  88113. 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;
  88114. /** @hidden */
  88115. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88116. /** @hidden */
  88117. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88118. /** @hidden */
  88119. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88120. /** @hidden */
  88121. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88122. /**
  88123. * @hidden
  88124. */
  88125. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88126. }
  88127. }
  88128. declare module BABYLON {
  88129. /**
  88130. * Class for creating a cube texture
  88131. */
  88132. export class CubeTexture extends BaseTexture {
  88133. private _delayedOnLoad;
  88134. /**
  88135. * Observable triggered once the texture has been loaded.
  88136. */
  88137. onLoadObservable: Observable<CubeTexture>;
  88138. /**
  88139. * The url of the texture
  88140. */
  88141. url: string;
  88142. /**
  88143. * Gets or sets the center of the bounding box associated with the cube texture.
  88144. * It must define where the camera used to render the texture was set
  88145. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88146. */
  88147. boundingBoxPosition: Vector3;
  88148. private _boundingBoxSize;
  88149. /**
  88150. * Gets or sets the size of the bounding box associated with the cube texture
  88151. * When defined, the cubemap will switch to local mode
  88152. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88153. * @example https://www.babylonjs-playground.com/#RNASML
  88154. */
  88155. set boundingBoxSize(value: Vector3);
  88156. /**
  88157. * Returns the bounding box size
  88158. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88159. */
  88160. get boundingBoxSize(): Vector3;
  88161. protected _rotationY: number;
  88162. /**
  88163. * Sets texture matrix rotation angle around Y axis in radians.
  88164. */
  88165. set rotationY(value: number);
  88166. /**
  88167. * Gets texture matrix rotation angle around Y axis radians.
  88168. */
  88169. get rotationY(): number;
  88170. /**
  88171. * Are mip maps generated for this texture or not.
  88172. */
  88173. get noMipmap(): boolean;
  88174. private _noMipmap;
  88175. private _files;
  88176. protected _forcedExtension: Nullable<string>;
  88177. private _extensions;
  88178. private _textureMatrix;
  88179. private _format;
  88180. private _createPolynomials;
  88181. /**
  88182. * Creates a cube texture from an array of image urls
  88183. * @param files defines an array of image urls
  88184. * @param scene defines the hosting scene
  88185. * @param noMipmap specifies if mip maps are not used
  88186. * @returns a cube texture
  88187. */
  88188. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88189. /**
  88190. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88191. * @param url defines the url of the prefiltered texture
  88192. * @param scene defines the scene the texture is attached to
  88193. * @param forcedExtension defines the extension of the file if different from the url
  88194. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88195. * @return the prefiltered texture
  88196. */
  88197. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88198. /**
  88199. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88200. * as prefiltered data.
  88201. * @param rootUrl defines the url of the texture or the root name of the six images
  88202. * @param null defines the scene or engine the texture is attached to
  88203. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88204. * @param noMipmap defines if mipmaps should be created or not
  88205. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88206. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88207. * @param onError defines a callback triggered in case of error during load
  88208. * @param format defines the internal format to use for the texture once loaded
  88209. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88210. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88211. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88212. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88213. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88214. * @return the cube texture
  88215. */
  88216. 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);
  88217. /**
  88218. * Get the current class name of the texture useful for serialization or dynamic coding.
  88219. * @returns "CubeTexture"
  88220. */
  88221. getClassName(): string;
  88222. /**
  88223. * Update the url (and optional buffer) of this texture if url was null during construction.
  88224. * @param url the url of the texture
  88225. * @param forcedExtension defines the extension to use
  88226. * @param onLoad callback called when the texture is loaded (defaults to null)
  88227. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88228. */
  88229. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88230. /**
  88231. * Delays loading of the cube texture
  88232. * @param forcedExtension defines the extension to use
  88233. */
  88234. delayLoad(forcedExtension?: string): void;
  88235. /**
  88236. * Returns the reflection texture matrix
  88237. * @returns the reflection texture matrix
  88238. */
  88239. getReflectionTextureMatrix(): Matrix;
  88240. /**
  88241. * Sets the reflection texture matrix
  88242. * @param value Reflection texture matrix
  88243. */
  88244. setReflectionTextureMatrix(value: Matrix): void;
  88245. /**
  88246. * Parses text to create a cube texture
  88247. * @param parsedTexture define the serialized text to read from
  88248. * @param scene defines the hosting scene
  88249. * @param rootUrl defines the root url of the cube texture
  88250. * @returns a cube texture
  88251. */
  88252. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88253. /**
  88254. * Makes a clone, or deep copy, of the cube texture
  88255. * @returns a new cube texture
  88256. */
  88257. clone(): CubeTexture;
  88258. }
  88259. }
  88260. declare module BABYLON {
  88261. /**
  88262. * Manages the defines for the Material
  88263. */
  88264. export class MaterialDefines {
  88265. /** @hidden */
  88266. protected _keys: string[];
  88267. private _isDirty;
  88268. /** @hidden */
  88269. _renderId: number;
  88270. /** @hidden */
  88271. _areLightsDirty: boolean;
  88272. /** @hidden */
  88273. _areLightsDisposed: boolean;
  88274. /** @hidden */
  88275. _areAttributesDirty: boolean;
  88276. /** @hidden */
  88277. _areTexturesDirty: boolean;
  88278. /** @hidden */
  88279. _areFresnelDirty: boolean;
  88280. /** @hidden */
  88281. _areMiscDirty: boolean;
  88282. /** @hidden */
  88283. _areImageProcessingDirty: boolean;
  88284. /** @hidden */
  88285. _normals: boolean;
  88286. /** @hidden */
  88287. _uvs: boolean;
  88288. /** @hidden */
  88289. _needNormals: boolean;
  88290. /** @hidden */
  88291. _needUVs: boolean;
  88292. [id: string]: any;
  88293. /**
  88294. * Specifies if the material needs to be re-calculated
  88295. */
  88296. get isDirty(): boolean;
  88297. /**
  88298. * Marks the material to indicate that it has been re-calculated
  88299. */
  88300. markAsProcessed(): void;
  88301. /**
  88302. * Marks the material to indicate that it needs to be re-calculated
  88303. */
  88304. markAsUnprocessed(): void;
  88305. /**
  88306. * Marks the material to indicate all of its defines need to be re-calculated
  88307. */
  88308. markAllAsDirty(): void;
  88309. /**
  88310. * Marks the material to indicate that image processing needs to be re-calculated
  88311. */
  88312. markAsImageProcessingDirty(): void;
  88313. /**
  88314. * Marks the material to indicate the lights need to be re-calculated
  88315. * @param disposed Defines whether the light is dirty due to dispose or not
  88316. */
  88317. markAsLightDirty(disposed?: boolean): void;
  88318. /**
  88319. * Marks the attribute state as changed
  88320. */
  88321. markAsAttributesDirty(): void;
  88322. /**
  88323. * Marks the texture state as changed
  88324. */
  88325. markAsTexturesDirty(): void;
  88326. /**
  88327. * Marks the fresnel state as changed
  88328. */
  88329. markAsFresnelDirty(): void;
  88330. /**
  88331. * Marks the misc state as changed
  88332. */
  88333. markAsMiscDirty(): void;
  88334. /**
  88335. * Rebuilds the material defines
  88336. */
  88337. rebuild(): void;
  88338. /**
  88339. * Specifies if two material defines are equal
  88340. * @param other - A material define instance to compare to
  88341. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88342. */
  88343. isEqual(other: MaterialDefines): boolean;
  88344. /**
  88345. * Clones this instance's defines to another instance
  88346. * @param other - material defines to clone values to
  88347. */
  88348. cloneTo(other: MaterialDefines): void;
  88349. /**
  88350. * Resets the material define values
  88351. */
  88352. reset(): void;
  88353. /**
  88354. * Converts the material define values to a string
  88355. * @returns - String of material define information
  88356. */
  88357. toString(): string;
  88358. }
  88359. }
  88360. declare module BABYLON {
  88361. /**
  88362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88364. * 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;
  88365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88366. */
  88367. export class ColorCurves {
  88368. private _dirty;
  88369. private _tempColor;
  88370. private _globalCurve;
  88371. private _highlightsCurve;
  88372. private _midtonesCurve;
  88373. private _shadowsCurve;
  88374. private _positiveCurve;
  88375. private _negativeCurve;
  88376. private _globalHue;
  88377. private _globalDensity;
  88378. private _globalSaturation;
  88379. private _globalExposure;
  88380. /**
  88381. * Gets the global Hue value.
  88382. * 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).
  88383. */
  88384. get globalHue(): number;
  88385. /**
  88386. * Sets the global Hue value.
  88387. * 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).
  88388. */
  88389. set globalHue(value: number);
  88390. /**
  88391. * Gets the global Density value.
  88392. * 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.
  88393. * Values less than zero provide a filter of opposite hue.
  88394. */
  88395. get globalDensity(): number;
  88396. /**
  88397. * Sets the global Density value.
  88398. * 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.
  88399. * Values less than zero provide a filter of opposite hue.
  88400. */
  88401. set globalDensity(value: number);
  88402. /**
  88403. * Gets the global Saturation value.
  88404. * 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.
  88405. */
  88406. get globalSaturation(): number;
  88407. /**
  88408. * Sets the global Saturation value.
  88409. * 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.
  88410. */
  88411. set globalSaturation(value: number);
  88412. /**
  88413. * Gets the global Exposure value.
  88414. * 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.
  88415. */
  88416. get globalExposure(): number;
  88417. /**
  88418. * Sets the global Exposure value.
  88419. * 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.
  88420. */
  88421. set globalExposure(value: number);
  88422. private _highlightsHue;
  88423. private _highlightsDensity;
  88424. private _highlightsSaturation;
  88425. private _highlightsExposure;
  88426. /**
  88427. * Gets the highlights Hue value.
  88428. * 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).
  88429. */
  88430. get highlightsHue(): number;
  88431. /**
  88432. * Sets the highlights Hue value.
  88433. * 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).
  88434. */
  88435. set highlightsHue(value: number);
  88436. /**
  88437. * Gets the highlights Density value.
  88438. * 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.
  88439. * Values less than zero provide a filter of opposite hue.
  88440. */
  88441. get highlightsDensity(): number;
  88442. /**
  88443. * Sets the highlights Density value.
  88444. * 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.
  88445. * Values less than zero provide a filter of opposite hue.
  88446. */
  88447. set highlightsDensity(value: number);
  88448. /**
  88449. * Gets the highlights Saturation value.
  88450. * 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.
  88451. */
  88452. get highlightsSaturation(): number;
  88453. /**
  88454. * Sets the highlights Saturation value.
  88455. * 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.
  88456. */
  88457. set highlightsSaturation(value: number);
  88458. /**
  88459. * Gets the highlights Exposure value.
  88460. * 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.
  88461. */
  88462. get highlightsExposure(): number;
  88463. /**
  88464. * Sets the highlights Exposure value.
  88465. * 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.
  88466. */
  88467. set highlightsExposure(value: number);
  88468. private _midtonesHue;
  88469. private _midtonesDensity;
  88470. private _midtonesSaturation;
  88471. private _midtonesExposure;
  88472. /**
  88473. * Gets the midtones Hue value.
  88474. * 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).
  88475. */
  88476. get midtonesHue(): number;
  88477. /**
  88478. * Sets the midtones Hue value.
  88479. * 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).
  88480. */
  88481. set midtonesHue(value: number);
  88482. /**
  88483. * Gets the midtones Density value.
  88484. * 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.
  88485. * Values less than zero provide a filter of opposite hue.
  88486. */
  88487. get midtonesDensity(): number;
  88488. /**
  88489. * Sets the midtones Density value.
  88490. * 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.
  88491. * Values less than zero provide a filter of opposite hue.
  88492. */
  88493. set midtonesDensity(value: number);
  88494. /**
  88495. * Gets the midtones Saturation value.
  88496. * 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.
  88497. */
  88498. get midtonesSaturation(): number;
  88499. /**
  88500. * Sets the midtones Saturation value.
  88501. * 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.
  88502. */
  88503. set midtonesSaturation(value: number);
  88504. /**
  88505. * Gets the midtones Exposure value.
  88506. * 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.
  88507. */
  88508. get midtonesExposure(): number;
  88509. /**
  88510. * Sets the midtones Exposure value.
  88511. * 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.
  88512. */
  88513. set midtonesExposure(value: number);
  88514. private _shadowsHue;
  88515. private _shadowsDensity;
  88516. private _shadowsSaturation;
  88517. private _shadowsExposure;
  88518. /**
  88519. * Gets the shadows Hue value.
  88520. * 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).
  88521. */
  88522. get shadowsHue(): number;
  88523. /**
  88524. * Sets the shadows Hue value.
  88525. * 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).
  88526. */
  88527. set shadowsHue(value: number);
  88528. /**
  88529. * Gets the shadows Density value.
  88530. * 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.
  88531. * Values less than zero provide a filter of opposite hue.
  88532. */
  88533. get shadowsDensity(): number;
  88534. /**
  88535. * Sets the shadows Density value.
  88536. * 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.
  88537. * Values less than zero provide a filter of opposite hue.
  88538. */
  88539. set shadowsDensity(value: number);
  88540. /**
  88541. * Gets the shadows Saturation value.
  88542. * 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.
  88543. */
  88544. get shadowsSaturation(): number;
  88545. /**
  88546. * Sets the shadows Saturation value.
  88547. * 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.
  88548. */
  88549. set shadowsSaturation(value: number);
  88550. /**
  88551. * Gets the shadows Exposure value.
  88552. * 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.
  88553. */
  88554. get shadowsExposure(): number;
  88555. /**
  88556. * Sets the shadows Exposure value.
  88557. * 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.
  88558. */
  88559. set shadowsExposure(value: number);
  88560. /**
  88561. * Returns the class name
  88562. * @returns The class name
  88563. */
  88564. getClassName(): string;
  88565. /**
  88566. * Binds the color curves to the shader.
  88567. * @param colorCurves The color curve to bind
  88568. * @param effect The effect to bind to
  88569. * @param positiveUniform The positive uniform shader parameter
  88570. * @param neutralUniform The neutral uniform shader parameter
  88571. * @param negativeUniform The negative uniform shader parameter
  88572. */
  88573. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88574. /**
  88575. * Prepare the list of uniforms associated with the ColorCurves effects.
  88576. * @param uniformsList The list of uniforms used in the effect
  88577. */
  88578. static PrepareUniforms(uniformsList: string[]): void;
  88579. /**
  88580. * Returns color grading data based on a hue, density, saturation and exposure value.
  88581. * @param filterHue The hue of the color filter.
  88582. * @param filterDensity The density of the color filter.
  88583. * @param saturation The saturation.
  88584. * @param exposure The exposure.
  88585. * @param result The result data container.
  88586. */
  88587. private getColorGradingDataToRef;
  88588. /**
  88589. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88590. * @param value The input slider value in range [-100,100].
  88591. * @returns Adjusted value.
  88592. */
  88593. private static applyColorGradingSliderNonlinear;
  88594. /**
  88595. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88596. * @param hue The hue (H) input.
  88597. * @param saturation The saturation (S) input.
  88598. * @param brightness The brightness (B) input.
  88599. * @result An RGBA color represented as Vector4.
  88600. */
  88601. private static fromHSBToRef;
  88602. /**
  88603. * Returns a value clamped between min and max
  88604. * @param value The value to clamp
  88605. * @param min The minimum of value
  88606. * @param max The maximum of value
  88607. * @returns The clamped value.
  88608. */
  88609. private static clamp;
  88610. /**
  88611. * Clones the current color curve instance.
  88612. * @return The cloned curves
  88613. */
  88614. clone(): ColorCurves;
  88615. /**
  88616. * Serializes the current color curve instance to a json representation.
  88617. * @return a JSON representation
  88618. */
  88619. serialize(): any;
  88620. /**
  88621. * Parses the color curve from a json representation.
  88622. * @param source the JSON source to parse
  88623. * @return The parsed curves
  88624. */
  88625. static Parse(source: any): ColorCurves;
  88626. }
  88627. }
  88628. declare module BABYLON {
  88629. /**
  88630. * Interface to follow in your material defines to integrate easily the
  88631. * Image proccessing functions.
  88632. * @hidden
  88633. */
  88634. export interface IImageProcessingConfigurationDefines {
  88635. IMAGEPROCESSING: boolean;
  88636. VIGNETTE: boolean;
  88637. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88638. VIGNETTEBLENDMODEOPAQUE: boolean;
  88639. TONEMAPPING: boolean;
  88640. TONEMAPPING_ACES: boolean;
  88641. CONTRAST: boolean;
  88642. EXPOSURE: boolean;
  88643. COLORCURVES: boolean;
  88644. COLORGRADING: boolean;
  88645. COLORGRADING3D: boolean;
  88646. SAMPLER3DGREENDEPTH: boolean;
  88647. SAMPLER3DBGRMAP: boolean;
  88648. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88649. }
  88650. /**
  88651. * @hidden
  88652. */
  88653. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88654. IMAGEPROCESSING: boolean;
  88655. VIGNETTE: boolean;
  88656. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88657. VIGNETTEBLENDMODEOPAQUE: boolean;
  88658. TONEMAPPING: boolean;
  88659. TONEMAPPING_ACES: boolean;
  88660. CONTRAST: boolean;
  88661. COLORCURVES: boolean;
  88662. COLORGRADING: boolean;
  88663. COLORGRADING3D: boolean;
  88664. SAMPLER3DGREENDEPTH: boolean;
  88665. SAMPLER3DBGRMAP: boolean;
  88666. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88667. EXPOSURE: boolean;
  88668. constructor();
  88669. }
  88670. /**
  88671. * This groups together the common properties used for image processing either in direct forward pass
  88672. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88673. * or not.
  88674. */
  88675. export class ImageProcessingConfiguration {
  88676. /**
  88677. * Default tone mapping applied in BabylonJS.
  88678. */
  88679. static readonly TONEMAPPING_STANDARD: number;
  88680. /**
  88681. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88682. * to other engines rendering to increase portability.
  88683. */
  88684. static readonly TONEMAPPING_ACES: number;
  88685. /**
  88686. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88687. */
  88688. colorCurves: Nullable<ColorCurves>;
  88689. private _colorCurvesEnabled;
  88690. /**
  88691. * Gets wether the color curves effect is enabled.
  88692. */
  88693. get colorCurvesEnabled(): boolean;
  88694. /**
  88695. * Sets wether the color curves effect is enabled.
  88696. */
  88697. set colorCurvesEnabled(value: boolean);
  88698. private _colorGradingTexture;
  88699. /**
  88700. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88701. */
  88702. get colorGradingTexture(): Nullable<BaseTexture>;
  88703. /**
  88704. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88705. */
  88706. set colorGradingTexture(value: Nullable<BaseTexture>);
  88707. private _colorGradingEnabled;
  88708. /**
  88709. * Gets wether the color grading effect is enabled.
  88710. */
  88711. get colorGradingEnabled(): boolean;
  88712. /**
  88713. * Sets wether the color grading effect is enabled.
  88714. */
  88715. set colorGradingEnabled(value: boolean);
  88716. private _colorGradingWithGreenDepth;
  88717. /**
  88718. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88719. */
  88720. get colorGradingWithGreenDepth(): boolean;
  88721. /**
  88722. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88723. */
  88724. set colorGradingWithGreenDepth(value: boolean);
  88725. private _colorGradingBGR;
  88726. /**
  88727. * Gets wether the color grading texture contains BGR values.
  88728. */
  88729. get colorGradingBGR(): boolean;
  88730. /**
  88731. * Sets wether the color grading texture contains BGR values.
  88732. */
  88733. set colorGradingBGR(value: boolean);
  88734. /** @hidden */
  88735. _exposure: number;
  88736. /**
  88737. * Gets the Exposure used in the effect.
  88738. */
  88739. get exposure(): number;
  88740. /**
  88741. * Sets the Exposure used in the effect.
  88742. */
  88743. set exposure(value: number);
  88744. private _toneMappingEnabled;
  88745. /**
  88746. * Gets wether the tone mapping effect is enabled.
  88747. */
  88748. get toneMappingEnabled(): boolean;
  88749. /**
  88750. * Sets wether the tone mapping effect is enabled.
  88751. */
  88752. set toneMappingEnabled(value: boolean);
  88753. private _toneMappingType;
  88754. /**
  88755. * Gets the type of tone mapping effect.
  88756. */
  88757. get toneMappingType(): number;
  88758. /**
  88759. * Sets the type of tone mapping effect used in BabylonJS.
  88760. */
  88761. set toneMappingType(value: number);
  88762. protected _contrast: number;
  88763. /**
  88764. * Gets the contrast used in the effect.
  88765. */
  88766. get contrast(): number;
  88767. /**
  88768. * Sets the contrast used in the effect.
  88769. */
  88770. set contrast(value: number);
  88771. /**
  88772. * Vignette stretch size.
  88773. */
  88774. vignetteStretch: number;
  88775. /**
  88776. * Vignette centre X Offset.
  88777. */
  88778. vignetteCentreX: number;
  88779. /**
  88780. * Vignette centre Y Offset.
  88781. */
  88782. vignetteCentreY: number;
  88783. /**
  88784. * Vignette weight or intensity of the vignette effect.
  88785. */
  88786. vignetteWeight: number;
  88787. /**
  88788. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88789. * if vignetteEnabled is set to true.
  88790. */
  88791. vignetteColor: Color4;
  88792. /**
  88793. * Camera field of view used by the Vignette effect.
  88794. */
  88795. vignetteCameraFov: number;
  88796. private _vignetteBlendMode;
  88797. /**
  88798. * Gets the vignette blend mode allowing different kind of effect.
  88799. */
  88800. get vignetteBlendMode(): number;
  88801. /**
  88802. * Sets the vignette blend mode allowing different kind of effect.
  88803. */
  88804. set vignetteBlendMode(value: number);
  88805. private _vignetteEnabled;
  88806. /**
  88807. * Gets wether the vignette effect is enabled.
  88808. */
  88809. get vignetteEnabled(): boolean;
  88810. /**
  88811. * Sets wether the vignette effect is enabled.
  88812. */
  88813. set vignetteEnabled(value: boolean);
  88814. private _applyByPostProcess;
  88815. /**
  88816. * Gets wether the image processing is applied through a post process or not.
  88817. */
  88818. get applyByPostProcess(): boolean;
  88819. /**
  88820. * Sets wether the image processing is applied through a post process or not.
  88821. */
  88822. set applyByPostProcess(value: boolean);
  88823. private _isEnabled;
  88824. /**
  88825. * Gets wether the image processing is enabled or not.
  88826. */
  88827. get isEnabled(): boolean;
  88828. /**
  88829. * Sets wether the image processing is enabled or not.
  88830. */
  88831. set isEnabled(value: boolean);
  88832. /**
  88833. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88834. */
  88835. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88836. /**
  88837. * Method called each time the image processing information changes requires to recompile the effect.
  88838. */
  88839. protected _updateParameters(): void;
  88840. /**
  88841. * Gets the current class name.
  88842. * @return "ImageProcessingConfiguration"
  88843. */
  88844. getClassName(): string;
  88845. /**
  88846. * Prepare the list of uniforms associated with the Image Processing effects.
  88847. * @param uniforms The list of uniforms used in the effect
  88848. * @param defines the list of defines currently in use
  88849. */
  88850. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88851. /**
  88852. * Prepare the list of samplers associated with the Image Processing effects.
  88853. * @param samplersList The list of uniforms used in the effect
  88854. * @param defines the list of defines currently in use
  88855. */
  88856. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88857. /**
  88858. * Prepare the list of defines associated to the shader.
  88859. * @param defines the list of defines to complete
  88860. * @param forPostProcess Define if we are currently in post process mode or not
  88861. */
  88862. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88863. /**
  88864. * Returns true if all the image processing information are ready.
  88865. * @returns True if ready, otherwise, false
  88866. */
  88867. isReady(): boolean;
  88868. /**
  88869. * Binds the image processing to the shader.
  88870. * @param effect The effect to bind to
  88871. * @param overrideAspectRatio Override the aspect ratio of the effect
  88872. */
  88873. bind(effect: Effect, overrideAspectRatio?: number): void;
  88874. /**
  88875. * Clones the current image processing instance.
  88876. * @return The cloned image processing
  88877. */
  88878. clone(): ImageProcessingConfiguration;
  88879. /**
  88880. * Serializes the current image processing instance to a json representation.
  88881. * @return a JSON representation
  88882. */
  88883. serialize(): any;
  88884. /**
  88885. * Parses the image processing from a json representation.
  88886. * @param source the JSON source to parse
  88887. * @return The parsed image processing
  88888. */
  88889. static Parse(source: any): ImageProcessingConfiguration;
  88890. private static _VIGNETTEMODE_MULTIPLY;
  88891. private static _VIGNETTEMODE_OPAQUE;
  88892. /**
  88893. * Used to apply the vignette as a mix with the pixel color.
  88894. */
  88895. static get VIGNETTEMODE_MULTIPLY(): number;
  88896. /**
  88897. * Used to apply the vignette as a replacement of the pixel color.
  88898. */
  88899. static get VIGNETTEMODE_OPAQUE(): number;
  88900. }
  88901. }
  88902. declare module BABYLON {
  88903. /** @hidden */
  88904. export var postprocessVertexShader: {
  88905. name: string;
  88906. shader: string;
  88907. };
  88908. }
  88909. declare module BABYLON {
  88910. /**
  88911. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88912. */
  88913. export type RenderTargetTextureSize = number | {
  88914. width: number;
  88915. height: number;
  88916. layers?: number;
  88917. };
  88918. interface ThinEngine {
  88919. /**
  88920. * Creates a new render target texture
  88921. * @param size defines the size of the texture
  88922. * @param options defines the options used to create the texture
  88923. * @returns a new render target texture stored in an InternalTexture
  88924. */
  88925. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88926. /**
  88927. * Creates a depth stencil texture.
  88928. * This is only available in WebGL 2 or with the depth texture extension available.
  88929. * @param size The size of face edge in the texture.
  88930. * @param options The options defining the texture.
  88931. * @returns The texture
  88932. */
  88933. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88934. /** @hidden */
  88935. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88936. }
  88937. }
  88938. declare module BABYLON {
  88939. /**
  88940. * Defines the kind of connection point for node based material
  88941. */
  88942. export enum NodeMaterialBlockConnectionPointTypes {
  88943. /** Float */
  88944. Float = 1,
  88945. /** Int */
  88946. Int = 2,
  88947. /** Vector2 */
  88948. Vector2 = 4,
  88949. /** Vector3 */
  88950. Vector3 = 8,
  88951. /** Vector4 */
  88952. Vector4 = 16,
  88953. /** Color3 */
  88954. Color3 = 32,
  88955. /** Color4 */
  88956. Color4 = 64,
  88957. /** Matrix */
  88958. Matrix = 128,
  88959. /** Custom object */
  88960. Object = 256,
  88961. /** Detect type based on connection */
  88962. AutoDetect = 1024,
  88963. /** Output type that will be defined by input type */
  88964. BasedOnInput = 2048
  88965. }
  88966. }
  88967. declare module BABYLON {
  88968. /**
  88969. * Enum used to define the target of a block
  88970. */
  88971. export enum NodeMaterialBlockTargets {
  88972. /** Vertex shader */
  88973. Vertex = 1,
  88974. /** Fragment shader */
  88975. Fragment = 2,
  88976. /** Neutral */
  88977. Neutral = 4,
  88978. /** Vertex and Fragment */
  88979. VertexAndFragment = 3
  88980. }
  88981. }
  88982. declare module BABYLON {
  88983. /**
  88984. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88985. */
  88986. export enum NodeMaterialBlockConnectionPointMode {
  88987. /** Value is an uniform */
  88988. Uniform = 0,
  88989. /** Value is a mesh attribute */
  88990. Attribute = 1,
  88991. /** Value is a varying between vertex and fragment shaders */
  88992. Varying = 2,
  88993. /** Mode is undefined */
  88994. Undefined = 3
  88995. }
  88996. }
  88997. declare module BABYLON {
  88998. /**
  88999. * Enum used to define system values e.g. values automatically provided by the system
  89000. */
  89001. export enum NodeMaterialSystemValues {
  89002. /** World */
  89003. World = 1,
  89004. /** View */
  89005. View = 2,
  89006. /** Projection */
  89007. Projection = 3,
  89008. /** ViewProjection */
  89009. ViewProjection = 4,
  89010. /** WorldView */
  89011. WorldView = 5,
  89012. /** WorldViewProjection */
  89013. WorldViewProjection = 6,
  89014. /** CameraPosition */
  89015. CameraPosition = 7,
  89016. /** Fog Color */
  89017. FogColor = 8,
  89018. /** Delta time */
  89019. DeltaTime = 9
  89020. }
  89021. }
  89022. declare module BABYLON {
  89023. /** Defines supported spaces */
  89024. export enum Space {
  89025. /** Local (object) space */
  89026. LOCAL = 0,
  89027. /** World space */
  89028. WORLD = 1,
  89029. /** Bone space */
  89030. BONE = 2
  89031. }
  89032. /** Defines the 3 main axes */
  89033. export class Axis {
  89034. /** X axis */
  89035. static X: Vector3;
  89036. /** Y axis */
  89037. static Y: Vector3;
  89038. /** Z axis */
  89039. static Z: Vector3;
  89040. }
  89041. }
  89042. declare module BABYLON {
  89043. /**
  89044. * Represents a camera frustum
  89045. */
  89046. export class Frustum {
  89047. /**
  89048. * Gets the planes representing the frustum
  89049. * @param transform matrix to be applied to the returned planes
  89050. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89051. */
  89052. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89053. /**
  89054. * Gets the near frustum plane transformed by the transform matrix
  89055. * @param transform transformation matrix to be applied to the resulting frustum plane
  89056. * @param frustumPlane the resuling frustum plane
  89057. */
  89058. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89059. /**
  89060. * Gets the far frustum plane transformed by the transform matrix
  89061. * @param transform transformation matrix to be applied to the resulting frustum plane
  89062. * @param frustumPlane the resuling frustum plane
  89063. */
  89064. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89065. /**
  89066. * Gets the left frustum plane transformed by the transform matrix
  89067. * @param transform transformation matrix to be applied to the resulting frustum plane
  89068. * @param frustumPlane the resuling frustum plane
  89069. */
  89070. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89071. /**
  89072. * Gets the right frustum plane transformed by the transform matrix
  89073. * @param transform transformation matrix to be applied to the resulting frustum plane
  89074. * @param frustumPlane the resuling frustum plane
  89075. */
  89076. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89077. /**
  89078. * Gets the top frustum plane transformed by the transform matrix
  89079. * @param transform transformation matrix to be applied to the resulting frustum plane
  89080. * @param frustumPlane the resuling frustum plane
  89081. */
  89082. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89083. /**
  89084. * Gets the bottom frustum plane transformed by the transform matrix
  89085. * @param transform transformation matrix to be applied to the resulting frustum plane
  89086. * @param frustumPlane the resuling frustum plane
  89087. */
  89088. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89089. /**
  89090. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89091. * @param transform transformation matrix to be applied to the resulting frustum planes
  89092. * @param frustumPlanes the resuling frustum planes
  89093. */
  89094. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89095. }
  89096. }
  89097. declare module BABYLON {
  89098. /**
  89099. * Interface for the size containing width and height
  89100. */
  89101. export interface ISize {
  89102. /**
  89103. * Width
  89104. */
  89105. width: number;
  89106. /**
  89107. * Heighht
  89108. */
  89109. height: number;
  89110. }
  89111. /**
  89112. * Size containing widht and height
  89113. */
  89114. export class Size implements ISize {
  89115. /**
  89116. * Width
  89117. */
  89118. width: number;
  89119. /**
  89120. * Height
  89121. */
  89122. height: number;
  89123. /**
  89124. * Creates a Size object from the given width and height (floats).
  89125. * @param width width of the new size
  89126. * @param height height of the new size
  89127. */
  89128. constructor(width: number, height: number);
  89129. /**
  89130. * Returns a string with the Size width and height
  89131. * @returns a string with the Size width and height
  89132. */
  89133. toString(): string;
  89134. /**
  89135. * "Size"
  89136. * @returns the string "Size"
  89137. */
  89138. getClassName(): string;
  89139. /**
  89140. * Returns the Size hash code.
  89141. * @returns a hash code for a unique width and height
  89142. */
  89143. getHashCode(): number;
  89144. /**
  89145. * Updates the current size from the given one.
  89146. * @param src the given size
  89147. */
  89148. copyFrom(src: Size): void;
  89149. /**
  89150. * Updates in place the current Size from the given floats.
  89151. * @param width width of the new size
  89152. * @param height height of the new size
  89153. * @returns the updated Size.
  89154. */
  89155. copyFromFloats(width: number, height: number): Size;
  89156. /**
  89157. * Updates in place the current Size from the given floats.
  89158. * @param width width to set
  89159. * @param height height to set
  89160. * @returns the updated Size.
  89161. */
  89162. set(width: number, height: number): Size;
  89163. /**
  89164. * Multiplies the width and height by numbers
  89165. * @param w factor to multiple the width by
  89166. * @param h factor to multiple the height by
  89167. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89168. */
  89169. multiplyByFloats(w: number, h: number): Size;
  89170. /**
  89171. * Clones the size
  89172. * @returns a new Size copied from the given one.
  89173. */
  89174. clone(): Size;
  89175. /**
  89176. * True if the current Size and the given one width and height are strictly equal.
  89177. * @param other the other size to compare against
  89178. * @returns True if the current Size and the given one width and height are strictly equal.
  89179. */
  89180. equals(other: Size): boolean;
  89181. /**
  89182. * The surface of the Size : width * height (float).
  89183. */
  89184. get surface(): number;
  89185. /**
  89186. * Create a new size of zero
  89187. * @returns a new Size set to (0.0, 0.0)
  89188. */
  89189. static Zero(): Size;
  89190. /**
  89191. * Sums the width and height of two sizes
  89192. * @param otherSize size to add to this size
  89193. * @returns a new Size set as the addition result of the current Size and the given one.
  89194. */
  89195. add(otherSize: Size): Size;
  89196. /**
  89197. * Subtracts the width and height of two
  89198. * @param otherSize size to subtract to this size
  89199. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89200. */
  89201. subtract(otherSize: Size): Size;
  89202. /**
  89203. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89204. * @param start starting size to lerp between
  89205. * @param end end size to lerp between
  89206. * @param amount amount to lerp between the start and end values
  89207. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89208. */
  89209. static Lerp(start: Size, end: Size, amount: number): Size;
  89210. }
  89211. }
  89212. declare module BABYLON {
  89213. /**
  89214. * Contains position and normal vectors for a vertex
  89215. */
  89216. export class PositionNormalVertex {
  89217. /** the position of the vertex (defaut: 0,0,0) */
  89218. position: Vector3;
  89219. /** the normal of the vertex (defaut: 0,1,0) */
  89220. normal: Vector3;
  89221. /**
  89222. * Creates a PositionNormalVertex
  89223. * @param position the position of the vertex (defaut: 0,0,0)
  89224. * @param normal the normal of the vertex (defaut: 0,1,0)
  89225. */
  89226. constructor(
  89227. /** the position of the vertex (defaut: 0,0,0) */
  89228. position?: Vector3,
  89229. /** the normal of the vertex (defaut: 0,1,0) */
  89230. normal?: Vector3);
  89231. /**
  89232. * Clones the PositionNormalVertex
  89233. * @returns the cloned PositionNormalVertex
  89234. */
  89235. clone(): PositionNormalVertex;
  89236. }
  89237. /**
  89238. * Contains position, normal and uv vectors for a vertex
  89239. */
  89240. export class PositionNormalTextureVertex {
  89241. /** the position of the vertex (defaut: 0,0,0) */
  89242. position: Vector3;
  89243. /** the normal of the vertex (defaut: 0,1,0) */
  89244. normal: Vector3;
  89245. /** the uv of the vertex (default: 0,0) */
  89246. uv: Vector2;
  89247. /**
  89248. * Creates a PositionNormalTextureVertex
  89249. * @param position the position of the vertex (defaut: 0,0,0)
  89250. * @param normal the normal of the vertex (defaut: 0,1,0)
  89251. * @param uv the uv of the vertex (default: 0,0)
  89252. */
  89253. constructor(
  89254. /** the position of the vertex (defaut: 0,0,0) */
  89255. position?: Vector3,
  89256. /** the normal of the vertex (defaut: 0,1,0) */
  89257. normal?: Vector3,
  89258. /** the uv of the vertex (default: 0,0) */
  89259. uv?: Vector2);
  89260. /**
  89261. * Clones the PositionNormalTextureVertex
  89262. * @returns the cloned PositionNormalTextureVertex
  89263. */
  89264. clone(): PositionNormalTextureVertex;
  89265. }
  89266. }
  89267. declare module BABYLON {
  89268. /**
  89269. * Enum defining the type of animations supported by InputBlock
  89270. */
  89271. export enum AnimatedInputBlockTypes {
  89272. /** No animation */
  89273. None = 0,
  89274. /** Time based animation. Will only work for floats */
  89275. Time = 1
  89276. }
  89277. }
  89278. declare module BABYLON {
  89279. /**
  89280. * Interface describing all the common properties and methods a shadow light needs to implement.
  89281. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89282. * as well as binding the different shadow properties to the effects.
  89283. */
  89284. export interface IShadowLight extends Light {
  89285. /**
  89286. * The light id in the scene (used in scene.findLighById for instance)
  89287. */
  89288. id: string;
  89289. /**
  89290. * The position the shdow will be casted from.
  89291. */
  89292. position: Vector3;
  89293. /**
  89294. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89295. */
  89296. direction: Vector3;
  89297. /**
  89298. * The transformed position. Position of the light in world space taking parenting in account.
  89299. */
  89300. transformedPosition: Vector3;
  89301. /**
  89302. * The transformed direction. Direction of the light in world space taking parenting in account.
  89303. */
  89304. transformedDirection: Vector3;
  89305. /**
  89306. * The friendly name of the light in the scene.
  89307. */
  89308. name: string;
  89309. /**
  89310. * Defines the shadow projection clipping minimum z value.
  89311. */
  89312. shadowMinZ: number;
  89313. /**
  89314. * Defines the shadow projection clipping maximum z value.
  89315. */
  89316. shadowMaxZ: number;
  89317. /**
  89318. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89319. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89320. */
  89321. computeTransformedInformation(): boolean;
  89322. /**
  89323. * Gets the scene the light belongs to.
  89324. * @returns The scene
  89325. */
  89326. getScene(): Scene;
  89327. /**
  89328. * Callback defining a custom Projection Matrix Builder.
  89329. * This can be used to override the default projection matrix computation.
  89330. */
  89331. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89332. /**
  89333. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89334. * @param matrix The materix to updated with the projection information
  89335. * @param viewMatrix The transform matrix of the light
  89336. * @param renderList The list of mesh to render in the map
  89337. * @returns The current light
  89338. */
  89339. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89340. /**
  89341. * Gets the current depth scale used in ESM.
  89342. * @returns The scale
  89343. */
  89344. getDepthScale(): number;
  89345. /**
  89346. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89347. * @returns true if a cube texture needs to be use
  89348. */
  89349. needCube(): boolean;
  89350. /**
  89351. * Detects if the projection matrix requires to be recomputed this frame.
  89352. * @returns true if it requires to be recomputed otherwise, false.
  89353. */
  89354. needProjectionMatrixCompute(): boolean;
  89355. /**
  89356. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89357. */
  89358. forceProjectionMatrixCompute(): void;
  89359. /**
  89360. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89361. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89362. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89363. */
  89364. getShadowDirection(faceIndex?: number): Vector3;
  89365. /**
  89366. * Gets the minZ used for shadow according to both the scene and the light.
  89367. * @param activeCamera The camera we are returning the min for
  89368. * @returns the depth min z
  89369. */
  89370. getDepthMinZ(activeCamera: Camera): number;
  89371. /**
  89372. * Gets the maxZ used for shadow according to both the scene and the light.
  89373. * @param activeCamera The camera we are returning the max for
  89374. * @returns the depth max z
  89375. */
  89376. getDepthMaxZ(activeCamera: Camera): number;
  89377. }
  89378. /**
  89379. * Base implementation IShadowLight
  89380. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89381. */
  89382. export abstract class ShadowLight extends Light implements IShadowLight {
  89383. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89384. protected _position: Vector3;
  89385. protected _setPosition(value: Vector3): void;
  89386. /**
  89387. * Sets the position the shadow will be casted from. Also use as the light position for both
  89388. * point and spot lights.
  89389. */
  89390. get position(): Vector3;
  89391. /**
  89392. * Sets the position the shadow will be casted from. Also use as the light position for both
  89393. * point and spot lights.
  89394. */
  89395. set position(value: Vector3);
  89396. protected _direction: Vector3;
  89397. protected _setDirection(value: Vector3): void;
  89398. /**
  89399. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89400. * Also use as the light direction on spot and directional lights.
  89401. */
  89402. get direction(): Vector3;
  89403. /**
  89404. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89405. * Also use as the light direction on spot and directional lights.
  89406. */
  89407. set direction(value: Vector3);
  89408. protected _shadowMinZ: number;
  89409. /**
  89410. * Gets the shadow projection clipping minimum z value.
  89411. */
  89412. get shadowMinZ(): number;
  89413. /**
  89414. * Sets the shadow projection clipping minimum z value.
  89415. */
  89416. set shadowMinZ(value: number);
  89417. protected _shadowMaxZ: number;
  89418. /**
  89419. * Sets the shadow projection clipping maximum z value.
  89420. */
  89421. get shadowMaxZ(): number;
  89422. /**
  89423. * Gets the shadow projection clipping maximum z value.
  89424. */
  89425. set shadowMaxZ(value: number);
  89426. /**
  89427. * Callback defining a custom Projection Matrix Builder.
  89428. * This can be used to override the default projection matrix computation.
  89429. */
  89430. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89431. /**
  89432. * The transformed position. Position of the light in world space taking parenting in account.
  89433. */
  89434. transformedPosition: Vector3;
  89435. /**
  89436. * The transformed direction. Direction of the light in world space taking parenting in account.
  89437. */
  89438. transformedDirection: Vector3;
  89439. private _needProjectionMatrixCompute;
  89440. /**
  89441. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89442. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89443. */
  89444. computeTransformedInformation(): boolean;
  89445. /**
  89446. * Return the depth scale used for the shadow map.
  89447. * @returns the depth scale.
  89448. */
  89449. getDepthScale(): number;
  89450. /**
  89451. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89452. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89453. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89454. */
  89455. getShadowDirection(faceIndex?: number): Vector3;
  89456. /**
  89457. * Returns the ShadowLight absolute position in the World.
  89458. * @returns the position vector in world space
  89459. */
  89460. getAbsolutePosition(): Vector3;
  89461. /**
  89462. * Sets the ShadowLight direction toward the passed target.
  89463. * @param target The point to target in local space
  89464. * @returns the updated ShadowLight direction
  89465. */
  89466. setDirectionToTarget(target: Vector3): Vector3;
  89467. /**
  89468. * Returns the light rotation in euler definition.
  89469. * @returns the x y z rotation in local space.
  89470. */
  89471. getRotation(): Vector3;
  89472. /**
  89473. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89474. * @returns true if a cube texture needs to be use
  89475. */
  89476. needCube(): boolean;
  89477. /**
  89478. * Detects if the projection matrix requires to be recomputed this frame.
  89479. * @returns true if it requires to be recomputed otherwise, false.
  89480. */
  89481. needProjectionMatrixCompute(): boolean;
  89482. /**
  89483. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89484. */
  89485. forceProjectionMatrixCompute(): void;
  89486. /** @hidden */
  89487. _initCache(): void;
  89488. /** @hidden */
  89489. _isSynchronized(): boolean;
  89490. /**
  89491. * Computes the world matrix of the node
  89492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89493. * @returns the world matrix
  89494. */
  89495. computeWorldMatrix(force?: boolean): Matrix;
  89496. /**
  89497. * Gets the minZ used for shadow according to both the scene and the light.
  89498. * @param activeCamera The camera we are returning the min for
  89499. * @returns the depth min z
  89500. */
  89501. getDepthMinZ(activeCamera: Camera): number;
  89502. /**
  89503. * Gets the maxZ used for shadow according to both the scene and the light.
  89504. * @param activeCamera The camera we are returning the max for
  89505. * @returns the depth max z
  89506. */
  89507. getDepthMaxZ(activeCamera: Camera): number;
  89508. /**
  89509. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89510. * @param matrix The materix to updated with the projection information
  89511. * @param viewMatrix The transform matrix of the light
  89512. * @param renderList The list of mesh to render in the map
  89513. * @returns The current light
  89514. */
  89515. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89516. }
  89517. }
  89518. declare module BABYLON {
  89519. /** @hidden */
  89520. export var packingFunctions: {
  89521. name: string;
  89522. shader: string;
  89523. };
  89524. }
  89525. declare module BABYLON {
  89526. /** @hidden */
  89527. export var bayerDitherFunctions: {
  89528. name: string;
  89529. shader: string;
  89530. };
  89531. }
  89532. declare module BABYLON {
  89533. /** @hidden */
  89534. export var shadowMapFragmentDeclaration: {
  89535. name: string;
  89536. shader: string;
  89537. };
  89538. }
  89539. declare module BABYLON {
  89540. /** @hidden */
  89541. export var clipPlaneFragmentDeclaration: {
  89542. name: string;
  89543. shader: string;
  89544. };
  89545. }
  89546. declare module BABYLON {
  89547. /** @hidden */
  89548. export var clipPlaneFragment: {
  89549. name: string;
  89550. shader: string;
  89551. };
  89552. }
  89553. declare module BABYLON {
  89554. /** @hidden */
  89555. export var shadowMapFragment: {
  89556. name: string;
  89557. shader: string;
  89558. };
  89559. }
  89560. declare module BABYLON {
  89561. /** @hidden */
  89562. export var shadowMapPixelShader: {
  89563. name: string;
  89564. shader: string;
  89565. };
  89566. }
  89567. declare module BABYLON {
  89568. /** @hidden */
  89569. export var bonesDeclaration: {
  89570. name: string;
  89571. shader: string;
  89572. };
  89573. }
  89574. declare module BABYLON {
  89575. /** @hidden */
  89576. export var morphTargetsVertexGlobalDeclaration: {
  89577. name: string;
  89578. shader: string;
  89579. };
  89580. }
  89581. declare module BABYLON {
  89582. /** @hidden */
  89583. export var morphTargetsVertexDeclaration: {
  89584. name: string;
  89585. shader: string;
  89586. };
  89587. }
  89588. declare module BABYLON {
  89589. /** @hidden */
  89590. export var instancesDeclaration: {
  89591. name: string;
  89592. shader: string;
  89593. };
  89594. }
  89595. declare module BABYLON {
  89596. /** @hidden */
  89597. export var helperFunctions: {
  89598. name: string;
  89599. shader: string;
  89600. };
  89601. }
  89602. declare module BABYLON {
  89603. /** @hidden */
  89604. export var shadowMapVertexDeclaration: {
  89605. name: string;
  89606. shader: string;
  89607. };
  89608. }
  89609. declare module BABYLON {
  89610. /** @hidden */
  89611. export var clipPlaneVertexDeclaration: {
  89612. name: string;
  89613. shader: string;
  89614. };
  89615. }
  89616. declare module BABYLON {
  89617. /** @hidden */
  89618. export var morphTargetsVertex: {
  89619. name: string;
  89620. shader: string;
  89621. };
  89622. }
  89623. declare module BABYLON {
  89624. /** @hidden */
  89625. export var instancesVertex: {
  89626. name: string;
  89627. shader: string;
  89628. };
  89629. }
  89630. declare module BABYLON {
  89631. /** @hidden */
  89632. export var bonesVertex: {
  89633. name: string;
  89634. shader: string;
  89635. };
  89636. }
  89637. declare module BABYLON {
  89638. /** @hidden */
  89639. export var shadowMapVertexNormalBias: {
  89640. name: string;
  89641. shader: string;
  89642. };
  89643. }
  89644. declare module BABYLON {
  89645. /** @hidden */
  89646. export var shadowMapVertexMetric: {
  89647. name: string;
  89648. shader: string;
  89649. };
  89650. }
  89651. declare module BABYLON {
  89652. /** @hidden */
  89653. export var clipPlaneVertex: {
  89654. name: string;
  89655. shader: string;
  89656. };
  89657. }
  89658. declare module BABYLON {
  89659. /** @hidden */
  89660. export var shadowMapVertexShader: {
  89661. name: string;
  89662. shader: string;
  89663. };
  89664. }
  89665. declare module BABYLON {
  89666. /** @hidden */
  89667. export var depthBoxBlurPixelShader: {
  89668. name: string;
  89669. shader: string;
  89670. };
  89671. }
  89672. declare module BABYLON {
  89673. /** @hidden */
  89674. export var shadowMapFragmentSoftTransparentShadow: {
  89675. name: string;
  89676. shader: string;
  89677. };
  89678. }
  89679. declare module BABYLON {
  89680. /**
  89681. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89682. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89683. */
  89684. export class EffectFallbacks implements IEffectFallbacks {
  89685. private _defines;
  89686. private _currentRank;
  89687. private _maxRank;
  89688. private _mesh;
  89689. /**
  89690. * Removes the fallback from the bound mesh.
  89691. */
  89692. unBindMesh(): void;
  89693. /**
  89694. * Adds a fallback on the specified property.
  89695. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89696. * @param define The name of the define in the shader
  89697. */
  89698. addFallback(rank: number, define: string): void;
  89699. /**
  89700. * Sets the mesh to use CPU skinning when needing to fallback.
  89701. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89702. * @param mesh The mesh to use the fallbacks.
  89703. */
  89704. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89705. /**
  89706. * Checks to see if more fallbacks are still availible.
  89707. */
  89708. get hasMoreFallbacks(): boolean;
  89709. /**
  89710. * Removes the defines that should be removed when falling back.
  89711. * @param currentDefines defines the current define statements for the shader.
  89712. * @param effect defines the current effect we try to compile
  89713. * @returns The resulting defines with defines of the current rank removed.
  89714. */
  89715. reduce(currentDefines: string, effect: Effect): string;
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /**
  89720. * Interface used to define Action
  89721. */
  89722. export interface IAction {
  89723. /**
  89724. * Trigger for the action
  89725. */
  89726. trigger: number;
  89727. /** Options of the trigger */
  89728. triggerOptions: any;
  89729. /**
  89730. * Gets the trigger parameters
  89731. * @returns the trigger parameters
  89732. */
  89733. getTriggerParameter(): any;
  89734. /**
  89735. * Internal only - executes current action event
  89736. * @hidden
  89737. */
  89738. _executeCurrent(evt?: ActionEvent): void;
  89739. /**
  89740. * Serialize placeholder for child classes
  89741. * @param parent of child
  89742. * @returns the serialized object
  89743. */
  89744. serialize(parent: any): any;
  89745. /**
  89746. * Internal only
  89747. * @hidden
  89748. */
  89749. _prepare(): void;
  89750. /**
  89751. * Internal only - manager for action
  89752. * @hidden
  89753. */
  89754. _actionManager: Nullable<AbstractActionManager>;
  89755. /**
  89756. * Adds action to chain of actions, may be a DoNothingAction
  89757. * @param action defines the next action to execute
  89758. * @returns The action passed in
  89759. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89760. */
  89761. then(action: IAction): IAction;
  89762. }
  89763. /**
  89764. * The action to be carried out following a trigger
  89765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89766. */
  89767. export class Action implements IAction {
  89768. /** the trigger, with or without parameters, for the action */
  89769. triggerOptions: any;
  89770. /**
  89771. * Trigger for the action
  89772. */
  89773. trigger: number;
  89774. /**
  89775. * Internal only - manager for action
  89776. * @hidden
  89777. */
  89778. _actionManager: ActionManager;
  89779. private _nextActiveAction;
  89780. private _child;
  89781. private _condition?;
  89782. private _triggerParameter;
  89783. /**
  89784. * An event triggered prior to action being executed.
  89785. */
  89786. onBeforeExecuteObservable: Observable<Action>;
  89787. /**
  89788. * Creates a new Action
  89789. * @param triggerOptions the trigger, with or without parameters, for the action
  89790. * @param condition an optional determinant of action
  89791. */
  89792. constructor(
  89793. /** the trigger, with or without parameters, for the action */
  89794. triggerOptions: any, condition?: Condition);
  89795. /**
  89796. * Internal only
  89797. * @hidden
  89798. */
  89799. _prepare(): void;
  89800. /**
  89801. * Gets the trigger parameters
  89802. * @returns the trigger parameters
  89803. */
  89804. getTriggerParameter(): any;
  89805. /**
  89806. * Internal only - executes current action event
  89807. * @hidden
  89808. */
  89809. _executeCurrent(evt?: ActionEvent): void;
  89810. /**
  89811. * Execute placeholder for child classes
  89812. * @param evt optional action event
  89813. */
  89814. execute(evt?: ActionEvent): void;
  89815. /**
  89816. * Skips to next active action
  89817. */
  89818. skipToNextActiveAction(): void;
  89819. /**
  89820. * Adds action to chain of actions, may be a DoNothingAction
  89821. * @param action defines the next action to execute
  89822. * @returns The action passed in
  89823. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89824. */
  89825. then(action: Action): Action;
  89826. /**
  89827. * Internal only
  89828. * @hidden
  89829. */
  89830. _getProperty(propertyPath: string): string;
  89831. /**
  89832. * Internal only
  89833. * @hidden
  89834. */
  89835. _getEffectiveTarget(target: any, propertyPath: string): any;
  89836. /**
  89837. * Serialize placeholder for child classes
  89838. * @param parent of child
  89839. * @returns the serialized object
  89840. */
  89841. serialize(parent: any): any;
  89842. /**
  89843. * Internal only called by serialize
  89844. * @hidden
  89845. */
  89846. protected _serialize(serializedAction: any, parent?: any): any;
  89847. /**
  89848. * Internal only
  89849. * @hidden
  89850. */
  89851. static _SerializeValueAsString: (value: any) => string;
  89852. /**
  89853. * Internal only
  89854. * @hidden
  89855. */
  89856. static _GetTargetProperty: (target: Scene | Node) => {
  89857. name: string;
  89858. targetType: string;
  89859. value: string;
  89860. };
  89861. }
  89862. }
  89863. declare module BABYLON {
  89864. /**
  89865. * A Condition applied to an Action
  89866. */
  89867. export class Condition {
  89868. /**
  89869. * Internal only - manager for action
  89870. * @hidden
  89871. */
  89872. _actionManager: ActionManager;
  89873. /**
  89874. * Internal only
  89875. * @hidden
  89876. */
  89877. _evaluationId: number;
  89878. /**
  89879. * Internal only
  89880. * @hidden
  89881. */
  89882. _currentResult: boolean;
  89883. /**
  89884. * Creates a new Condition
  89885. * @param actionManager the manager of the action the condition is applied to
  89886. */
  89887. constructor(actionManager: ActionManager);
  89888. /**
  89889. * Check if the current condition is valid
  89890. * @returns a boolean
  89891. */
  89892. isValid(): boolean;
  89893. /**
  89894. * Internal only
  89895. * @hidden
  89896. */
  89897. _getProperty(propertyPath: string): string;
  89898. /**
  89899. * Internal only
  89900. * @hidden
  89901. */
  89902. _getEffectiveTarget(target: any, propertyPath: string): any;
  89903. /**
  89904. * Serialize placeholder for child classes
  89905. * @returns the serialized object
  89906. */
  89907. serialize(): any;
  89908. /**
  89909. * Internal only
  89910. * @hidden
  89911. */
  89912. protected _serialize(serializedCondition: any): any;
  89913. }
  89914. /**
  89915. * Defines specific conditional operators as extensions of Condition
  89916. */
  89917. export class ValueCondition extends Condition {
  89918. /** path to specify the property of the target the conditional operator uses */
  89919. propertyPath: string;
  89920. /** the value compared by the conditional operator against the current value of the property */
  89921. value: any;
  89922. /** the conditional operator, default ValueCondition.IsEqual */
  89923. operator: number;
  89924. /**
  89925. * Internal only
  89926. * @hidden
  89927. */
  89928. private static _IsEqual;
  89929. /**
  89930. * Internal only
  89931. * @hidden
  89932. */
  89933. private static _IsDifferent;
  89934. /**
  89935. * Internal only
  89936. * @hidden
  89937. */
  89938. private static _IsGreater;
  89939. /**
  89940. * Internal only
  89941. * @hidden
  89942. */
  89943. private static _IsLesser;
  89944. /**
  89945. * returns the number for IsEqual
  89946. */
  89947. static get IsEqual(): number;
  89948. /**
  89949. * Returns the number for IsDifferent
  89950. */
  89951. static get IsDifferent(): number;
  89952. /**
  89953. * Returns the number for IsGreater
  89954. */
  89955. static get IsGreater(): number;
  89956. /**
  89957. * Returns the number for IsLesser
  89958. */
  89959. static get IsLesser(): number;
  89960. /**
  89961. * Internal only The action manager for the condition
  89962. * @hidden
  89963. */
  89964. _actionManager: ActionManager;
  89965. /**
  89966. * Internal only
  89967. * @hidden
  89968. */
  89969. private _target;
  89970. /**
  89971. * Internal only
  89972. * @hidden
  89973. */
  89974. private _effectiveTarget;
  89975. /**
  89976. * Internal only
  89977. * @hidden
  89978. */
  89979. private _property;
  89980. /**
  89981. * Creates a new ValueCondition
  89982. * @param actionManager manager for the action the condition applies to
  89983. * @param target for the action
  89984. * @param propertyPath path to specify the property of the target the conditional operator uses
  89985. * @param value the value compared by the conditional operator against the current value of the property
  89986. * @param operator the conditional operator, default ValueCondition.IsEqual
  89987. */
  89988. constructor(actionManager: ActionManager, target: any,
  89989. /** path to specify the property of the target the conditional operator uses */
  89990. propertyPath: string,
  89991. /** the value compared by the conditional operator against the current value of the property */
  89992. value: any,
  89993. /** the conditional operator, default ValueCondition.IsEqual */
  89994. operator?: number);
  89995. /**
  89996. * Compares the given value with the property value for the specified conditional operator
  89997. * @returns the result of the comparison
  89998. */
  89999. isValid(): boolean;
  90000. /**
  90001. * Serialize the ValueCondition into a JSON compatible object
  90002. * @returns serialization object
  90003. */
  90004. serialize(): any;
  90005. /**
  90006. * Gets the name of the conditional operator for the ValueCondition
  90007. * @param operator the conditional operator
  90008. * @returns the name
  90009. */
  90010. static GetOperatorName(operator: number): string;
  90011. }
  90012. /**
  90013. * Defines a predicate condition as an extension of Condition
  90014. */
  90015. export class PredicateCondition extends Condition {
  90016. /** defines the predicate function used to validate the condition */
  90017. predicate: () => boolean;
  90018. /**
  90019. * Internal only - manager for action
  90020. * @hidden
  90021. */
  90022. _actionManager: ActionManager;
  90023. /**
  90024. * Creates a new PredicateCondition
  90025. * @param actionManager manager for the action the condition applies to
  90026. * @param predicate defines the predicate function used to validate the condition
  90027. */
  90028. constructor(actionManager: ActionManager,
  90029. /** defines the predicate function used to validate the condition */
  90030. predicate: () => boolean);
  90031. /**
  90032. * @returns the validity of the predicate condition
  90033. */
  90034. isValid(): boolean;
  90035. }
  90036. /**
  90037. * Defines a state condition as an extension of Condition
  90038. */
  90039. export class StateCondition extends Condition {
  90040. /** Value to compare with target state */
  90041. value: string;
  90042. /**
  90043. * Internal only - manager for action
  90044. * @hidden
  90045. */
  90046. _actionManager: ActionManager;
  90047. /**
  90048. * Internal only
  90049. * @hidden
  90050. */
  90051. private _target;
  90052. /**
  90053. * Creates a new StateCondition
  90054. * @param actionManager manager for the action the condition applies to
  90055. * @param target of the condition
  90056. * @param value to compare with target state
  90057. */
  90058. constructor(actionManager: ActionManager, target: any,
  90059. /** Value to compare with target state */
  90060. value: string);
  90061. /**
  90062. * Gets a boolean indicating if the current condition is met
  90063. * @returns the validity of the state
  90064. */
  90065. isValid(): boolean;
  90066. /**
  90067. * Serialize the StateCondition into a JSON compatible object
  90068. * @returns serialization object
  90069. */
  90070. serialize(): any;
  90071. }
  90072. }
  90073. declare module BABYLON {
  90074. /**
  90075. * This defines an action responsible to toggle a boolean once triggered.
  90076. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90077. */
  90078. export class SwitchBooleanAction extends Action {
  90079. /**
  90080. * The path to the boolean property in the target object
  90081. */
  90082. propertyPath: string;
  90083. private _target;
  90084. private _effectiveTarget;
  90085. private _property;
  90086. /**
  90087. * Instantiate the action
  90088. * @param triggerOptions defines the trigger options
  90089. * @param target defines the object containing the boolean
  90090. * @param propertyPath defines the path to the boolean property in the target object
  90091. * @param condition defines the trigger related conditions
  90092. */
  90093. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90094. /** @hidden */
  90095. _prepare(): void;
  90096. /**
  90097. * Execute the action toggle the boolean value.
  90098. */
  90099. execute(): void;
  90100. /**
  90101. * Serializes the actions and its related information.
  90102. * @param parent defines the object to serialize in
  90103. * @returns the serialized object
  90104. */
  90105. serialize(parent: any): any;
  90106. }
  90107. /**
  90108. * This defines an action responsible to set a the state field of the target
  90109. * to a desired value once triggered.
  90110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90111. */
  90112. export class SetStateAction extends Action {
  90113. /**
  90114. * The value to store in the state field.
  90115. */
  90116. value: string;
  90117. private _target;
  90118. /**
  90119. * Instantiate the action
  90120. * @param triggerOptions defines the trigger options
  90121. * @param target defines the object containing the state property
  90122. * @param value defines the value to store in the state field
  90123. * @param condition defines the trigger related conditions
  90124. */
  90125. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90126. /**
  90127. * Execute the action and store the value on the target state property.
  90128. */
  90129. execute(): void;
  90130. /**
  90131. * Serializes the actions and its related information.
  90132. * @param parent defines the object to serialize in
  90133. * @returns the serialized object
  90134. */
  90135. serialize(parent: any): any;
  90136. }
  90137. /**
  90138. * This defines an action responsible to set a property of the target
  90139. * to a desired value once triggered.
  90140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90141. */
  90142. export class SetValueAction extends Action {
  90143. /**
  90144. * The path of the property to set in the target.
  90145. */
  90146. propertyPath: string;
  90147. /**
  90148. * The value to set in the property
  90149. */
  90150. value: any;
  90151. private _target;
  90152. private _effectiveTarget;
  90153. private _property;
  90154. /**
  90155. * Instantiate the action
  90156. * @param triggerOptions defines the trigger options
  90157. * @param target defines the object containing the property
  90158. * @param propertyPath defines the path of the property to set in the target
  90159. * @param value defines the value to set in the property
  90160. * @param condition defines the trigger related conditions
  90161. */
  90162. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90163. /** @hidden */
  90164. _prepare(): void;
  90165. /**
  90166. * Execute the action and set the targetted property to the desired value.
  90167. */
  90168. execute(): void;
  90169. /**
  90170. * Serializes the actions and its related information.
  90171. * @param parent defines the object to serialize in
  90172. * @returns the serialized object
  90173. */
  90174. serialize(parent: any): any;
  90175. }
  90176. /**
  90177. * This defines an action responsible to increment the target value
  90178. * to a desired value once triggered.
  90179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90180. */
  90181. export class IncrementValueAction extends Action {
  90182. /**
  90183. * The path of the property to increment in the target.
  90184. */
  90185. propertyPath: string;
  90186. /**
  90187. * The value we should increment the property by.
  90188. */
  90189. value: any;
  90190. private _target;
  90191. private _effectiveTarget;
  90192. private _property;
  90193. /**
  90194. * Instantiate the action
  90195. * @param triggerOptions defines the trigger options
  90196. * @param target defines the object containing the property
  90197. * @param propertyPath defines the path of the property to increment in the target
  90198. * @param value defines the value value we should increment the property by
  90199. * @param condition defines the trigger related conditions
  90200. */
  90201. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90202. /** @hidden */
  90203. _prepare(): void;
  90204. /**
  90205. * Execute the action and increment the target of the value amount.
  90206. */
  90207. execute(): void;
  90208. /**
  90209. * Serializes the actions and its related information.
  90210. * @param parent defines the object to serialize in
  90211. * @returns the serialized object
  90212. */
  90213. serialize(parent: any): any;
  90214. }
  90215. /**
  90216. * This defines an action responsible to start an animation once triggered.
  90217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90218. */
  90219. export class PlayAnimationAction extends Action {
  90220. /**
  90221. * Where the animation should start (animation frame)
  90222. */
  90223. from: number;
  90224. /**
  90225. * Where the animation should stop (animation frame)
  90226. */
  90227. to: number;
  90228. /**
  90229. * Define if the animation should loop or stop after the first play.
  90230. */
  90231. loop?: boolean;
  90232. private _target;
  90233. /**
  90234. * Instantiate the action
  90235. * @param triggerOptions defines the trigger options
  90236. * @param target defines the target animation or animation name
  90237. * @param from defines from where the animation should start (animation frame)
  90238. * @param end defines where the animation should stop (animation frame)
  90239. * @param loop defines if the animation should loop or stop after the first play
  90240. * @param condition defines the trigger related conditions
  90241. */
  90242. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90243. /** @hidden */
  90244. _prepare(): void;
  90245. /**
  90246. * Execute the action and play the animation.
  90247. */
  90248. execute(): void;
  90249. /**
  90250. * Serializes the actions and its related information.
  90251. * @param parent defines the object to serialize in
  90252. * @returns the serialized object
  90253. */
  90254. serialize(parent: any): any;
  90255. }
  90256. /**
  90257. * This defines an action responsible to stop an animation once triggered.
  90258. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90259. */
  90260. export class StopAnimationAction extends Action {
  90261. private _target;
  90262. /**
  90263. * Instantiate the action
  90264. * @param triggerOptions defines the trigger options
  90265. * @param target defines the target animation or animation name
  90266. * @param condition defines the trigger related conditions
  90267. */
  90268. constructor(triggerOptions: any, target: any, condition?: Condition);
  90269. /** @hidden */
  90270. _prepare(): void;
  90271. /**
  90272. * Execute the action and stop the animation.
  90273. */
  90274. execute(): void;
  90275. /**
  90276. * Serializes the actions and its related information.
  90277. * @param parent defines the object to serialize in
  90278. * @returns the serialized object
  90279. */
  90280. serialize(parent: any): any;
  90281. }
  90282. /**
  90283. * This defines an action responsible that does nothing once triggered.
  90284. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90285. */
  90286. export class DoNothingAction extends Action {
  90287. /**
  90288. * Instantiate the action
  90289. * @param triggerOptions defines the trigger options
  90290. * @param condition defines the trigger related conditions
  90291. */
  90292. constructor(triggerOptions?: any, condition?: Condition);
  90293. /**
  90294. * Execute the action and do nothing.
  90295. */
  90296. execute(): void;
  90297. /**
  90298. * Serializes the actions and its related information.
  90299. * @param parent defines the object to serialize in
  90300. * @returns the serialized object
  90301. */
  90302. serialize(parent: any): any;
  90303. }
  90304. /**
  90305. * This defines an action responsible to trigger several actions once triggered.
  90306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90307. */
  90308. export class CombineAction extends Action {
  90309. /**
  90310. * The list of aggregated animations to run.
  90311. */
  90312. children: Action[];
  90313. /**
  90314. * Instantiate the action
  90315. * @param triggerOptions defines the trigger options
  90316. * @param children defines the list of aggregated animations to run
  90317. * @param condition defines the trigger related conditions
  90318. */
  90319. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90320. /** @hidden */
  90321. _prepare(): void;
  90322. /**
  90323. * Execute the action and executes all the aggregated actions.
  90324. */
  90325. execute(evt: ActionEvent): void;
  90326. /**
  90327. * Serializes the actions and its related information.
  90328. * @param parent defines the object to serialize in
  90329. * @returns the serialized object
  90330. */
  90331. serialize(parent: any): any;
  90332. }
  90333. /**
  90334. * This defines an action responsible to run code (external event) once triggered.
  90335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90336. */
  90337. export class ExecuteCodeAction extends Action {
  90338. /**
  90339. * The callback function to run.
  90340. */
  90341. func: (evt: ActionEvent) => void;
  90342. /**
  90343. * Instantiate the action
  90344. * @param triggerOptions defines the trigger options
  90345. * @param func defines the callback function to run
  90346. * @param condition defines the trigger related conditions
  90347. */
  90348. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90349. /**
  90350. * Execute the action and run the attached code.
  90351. */
  90352. execute(evt: ActionEvent): void;
  90353. }
  90354. /**
  90355. * This defines an action responsible to set the parent property of the target once triggered.
  90356. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90357. */
  90358. export class SetParentAction extends Action {
  90359. private _parent;
  90360. private _target;
  90361. /**
  90362. * Instantiate the action
  90363. * @param triggerOptions defines the trigger options
  90364. * @param target defines the target containing the parent property
  90365. * @param parent defines from where the animation should start (animation frame)
  90366. * @param condition defines the trigger related conditions
  90367. */
  90368. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90369. /** @hidden */
  90370. _prepare(): void;
  90371. /**
  90372. * Execute the action and set the parent property.
  90373. */
  90374. execute(): void;
  90375. /**
  90376. * Serializes the actions and its related information.
  90377. * @param parent defines the object to serialize in
  90378. * @returns the serialized object
  90379. */
  90380. serialize(parent: any): any;
  90381. }
  90382. }
  90383. declare module BABYLON {
  90384. /**
  90385. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90386. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90387. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90388. */
  90389. export class ActionManager extends AbstractActionManager {
  90390. /**
  90391. * Nothing
  90392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90393. */
  90394. static readonly NothingTrigger: number;
  90395. /**
  90396. * On pick
  90397. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90398. */
  90399. static readonly OnPickTrigger: number;
  90400. /**
  90401. * On left pick
  90402. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90403. */
  90404. static readonly OnLeftPickTrigger: number;
  90405. /**
  90406. * On right pick
  90407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90408. */
  90409. static readonly OnRightPickTrigger: number;
  90410. /**
  90411. * On center pick
  90412. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90413. */
  90414. static readonly OnCenterPickTrigger: number;
  90415. /**
  90416. * On pick down
  90417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90418. */
  90419. static readonly OnPickDownTrigger: number;
  90420. /**
  90421. * On double pick
  90422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90423. */
  90424. static readonly OnDoublePickTrigger: number;
  90425. /**
  90426. * On pick up
  90427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90428. */
  90429. static readonly OnPickUpTrigger: number;
  90430. /**
  90431. * On pick out.
  90432. * This trigger will only be raised if you also declared a OnPickDown
  90433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90434. */
  90435. static readonly OnPickOutTrigger: number;
  90436. /**
  90437. * On long press
  90438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90439. */
  90440. static readonly OnLongPressTrigger: number;
  90441. /**
  90442. * On pointer over
  90443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90444. */
  90445. static readonly OnPointerOverTrigger: number;
  90446. /**
  90447. * On pointer out
  90448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90449. */
  90450. static readonly OnPointerOutTrigger: number;
  90451. /**
  90452. * On every frame
  90453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90454. */
  90455. static readonly OnEveryFrameTrigger: number;
  90456. /**
  90457. * On intersection enter
  90458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90459. */
  90460. static readonly OnIntersectionEnterTrigger: number;
  90461. /**
  90462. * On intersection exit
  90463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90464. */
  90465. static readonly OnIntersectionExitTrigger: number;
  90466. /**
  90467. * On key down
  90468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90469. */
  90470. static readonly OnKeyDownTrigger: number;
  90471. /**
  90472. * On key up
  90473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90474. */
  90475. static readonly OnKeyUpTrigger: number;
  90476. private _scene;
  90477. /**
  90478. * Creates a new action manager
  90479. * @param scene defines the hosting scene
  90480. */
  90481. constructor(scene: Scene);
  90482. /**
  90483. * Releases all associated resources
  90484. */
  90485. dispose(): void;
  90486. /**
  90487. * Gets hosting scene
  90488. * @returns the hosting scene
  90489. */
  90490. getScene(): Scene;
  90491. /**
  90492. * Does this action manager handles actions of any of the given triggers
  90493. * @param triggers defines the triggers to be tested
  90494. * @return a boolean indicating whether one (or more) of the triggers is handled
  90495. */
  90496. hasSpecificTriggers(triggers: number[]): boolean;
  90497. /**
  90498. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90499. * speed.
  90500. * @param triggerA defines the trigger to be tested
  90501. * @param triggerB defines the trigger to be tested
  90502. * @return a boolean indicating whether one (or more) of the triggers is handled
  90503. */
  90504. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90505. /**
  90506. * Does this action manager handles actions of a given trigger
  90507. * @param trigger defines the trigger to be tested
  90508. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90509. * @return whether the trigger is handled
  90510. */
  90511. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90512. /**
  90513. * Does this action manager has pointer triggers
  90514. */
  90515. get hasPointerTriggers(): boolean;
  90516. /**
  90517. * Does this action manager has pick triggers
  90518. */
  90519. get hasPickTriggers(): boolean;
  90520. /**
  90521. * Registers an action to this action manager
  90522. * @param action defines the action to be registered
  90523. * @return the action amended (prepared) after registration
  90524. */
  90525. registerAction(action: IAction): Nullable<IAction>;
  90526. /**
  90527. * Unregisters an action to this action manager
  90528. * @param action defines the action to be unregistered
  90529. * @return a boolean indicating whether the action has been unregistered
  90530. */
  90531. unregisterAction(action: IAction): Boolean;
  90532. /**
  90533. * Process a specific trigger
  90534. * @param trigger defines the trigger to process
  90535. * @param evt defines the event details to be processed
  90536. */
  90537. processTrigger(trigger: number, evt?: IActionEvent): void;
  90538. /** @hidden */
  90539. _getEffectiveTarget(target: any, propertyPath: string): any;
  90540. /** @hidden */
  90541. _getProperty(propertyPath: string): string;
  90542. /**
  90543. * Serialize this manager to a JSON object
  90544. * @param name defines the property name to store this manager
  90545. * @returns a JSON representation of this manager
  90546. */
  90547. serialize(name: string): any;
  90548. /**
  90549. * Creates a new ActionManager from a JSON data
  90550. * @param parsedActions defines the JSON data to read from
  90551. * @param object defines the hosting mesh
  90552. * @param scene defines the hosting scene
  90553. */
  90554. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90555. /**
  90556. * Get a trigger name by index
  90557. * @param trigger defines the trigger index
  90558. * @returns a trigger name
  90559. */
  90560. static GetTriggerName(trigger: number): string;
  90561. }
  90562. }
  90563. declare module BABYLON {
  90564. /**
  90565. * Class used to represent a sprite
  90566. * @see https://doc.babylonjs.com/babylon101/sprites
  90567. */
  90568. export class Sprite implements IAnimatable {
  90569. /** defines the name */
  90570. name: string;
  90571. /** Gets or sets the current world position */
  90572. position: Vector3;
  90573. /** Gets or sets the main color */
  90574. color: Color4;
  90575. /** Gets or sets the width */
  90576. width: number;
  90577. /** Gets or sets the height */
  90578. height: number;
  90579. /** Gets or sets rotation angle */
  90580. angle: number;
  90581. /** Gets or sets the cell index in the sprite sheet */
  90582. cellIndex: number;
  90583. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90584. cellRef: string;
  90585. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90586. invertU: boolean;
  90587. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90588. invertV: boolean;
  90589. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90590. disposeWhenFinishedAnimating: boolean;
  90591. /** Gets the list of attached animations */
  90592. animations: Nullable<Array<Animation>>;
  90593. /** Gets or sets a boolean indicating if the sprite can be picked */
  90594. isPickable: boolean;
  90595. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90596. useAlphaForPicking: boolean;
  90597. /** @hidden */
  90598. _xOffset: number;
  90599. /** @hidden */
  90600. _yOffset: number;
  90601. /** @hidden */
  90602. _xSize: number;
  90603. /** @hidden */
  90604. _ySize: number;
  90605. /**
  90606. * Gets or sets the associated action manager
  90607. */
  90608. actionManager: Nullable<ActionManager>;
  90609. /**
  90610. * An event triggered when the control has been disposed
  90611. */
  90612. onDisposeObservable: Observable<Sprite>;
  90613. private _animationStarted;
  90614. private _loopAnimation;
  90615. private _fromIndex;
  90616. private _toIndex;
  90617. private _delay;
  90618. private _direction;
  90619. private _manager;
  90620. private _time;
  90621. private _onAnimationEnd;
  90622. /**
  90623. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90624. */
  90625. isVisible: boolean;
  90626. /**
  90627. * Gets or sets the sprite size
  90628. */
  90629. get size(): number;
  90630. set size(value: number);
  90631. /**
  90632. * Returns a boolean indicating if the animation is started
  90633. */
  90634. get animationStarted(): boolean;
  90635. /**
  90636. * Gets or sets the unique id of the sprite
  90637. */
  90638. uniqueId: number;
  90639. /**
  90640. * Gets the manager of this sprite
  90641. */
  90642. get manager(): ISpriteManager;
  90643. /**
  90644. * Creates a new Sprite
  90645. * @param name defines the name
  90646. * @param manager defines the manager
  90647. */
  90648. constructor(
  90649. /** defines the name */
  90650. name: string, manager: ISpriteManager);
  90651. /**
  90652. * Returns the string "Sprite"
  90653. * @returns "Sprite"
  90654. */
  90655. getClassName(): string;
  90656. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90657. get fromIndex(): number;
  90658. set fromIndex(value: number);
  90659. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90660. get toIndex(): number;
  90661. set toIndex(value: number);
  90662. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90663. get loopAnimation(): boolean;
  90664. set loopAnimation(value: boolean);
  90665. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90666. get delay(): number;
  90667. set delay(value: number);
  90668. /**
  90669. * Starts an animation
  90670. * @param from defines the initial key
  90671. * @param to defines the end key
  90672. * @param loop defines if the animation must loop
  90673. * @param delay defines the start delay (in ms)
  90674. * @param onAnimationEnd defines a callback to call when animation ends
  90675. */
  90676. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90677. /** Stops current animation (if any) */
  90678. stopAnimation(): void;
  90679. /** @hidden */
  90680. _animate(deltaTime: number): void;
  90681. /** Release associated resources */
  90682. dispose(): void;
  90683. /**
  90684. * Serializes the sprite to a JSON object
  90685. * @returns the JSON object
  90686. */
  90687. serialize(): any;
  90688. /**
  90689. * Parses a JSON object to create a new sprite
  90690. * @param parsedSprite The JSON object to parse
  90691. * @param manager defines the hosting manager
  90692. * @returns the new sprite
  90693. */
  90694. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90695. }
  90696. }
  90697. declare module BABYLON {
  90698. /**
  90699. * Information about the result of picking within a scene
  90700. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90701. */
  90702. export class PickingInfo {
  90703. /** @hidden */
  90704. _pickingUnavailable: boolean;
  90705. /**
  90706. * If the pick collided with an object
  90707. */
  90708. hit: boolean;
  90709. /**
  90710. * Distance away where the pick collided
  90711. */
  90712. distance: number;
  90713. /**
  90714. * The location of pick collision
  90715. */
  90716. pickedPoint: Nullable<Vector3>;
  90717. /**
  90718. * The mesh corresponding the the pick collision
  90719. */
  90720. pickedMesh: Nullable<AbstractMesh>;
  90721. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90722. bu: number;
  90723. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90724. bv: number;
  90725. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90726. faceId: number;
  90727. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90728. subMeshFaceId: number;
  90729. /** Id of the the submesh that was picked */
  90730. subMeshId: number;
  90731. /** If a sprite was picked, this will be the sprite the pick collided with */
  90732. pickedSprite: Nullable<Sprite>;
  90733. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90734. thinInstanceIndex: number;
  90735. /**
  90736. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90737. */
  90738. originMesh: Nullable<AbstractMesh>;
  90739. /**
  90740. * The ray that was used to perform the picking.
  90741. */
  90742. ray: Nullable<Ray>;
  90743. /**
  90744. * Gets the normal correspodning to the face the pick collided with
  90745. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90746. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90747. * @returns The normal correspodning to the face the pick collided with
  90748. */
  90749. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90750. /**
  90751. * Gets the texture coordinates of where the pick occured
  90752. * @returns the vector containing the coordnates of the texture
  90753. */
  90754. getTextureCoordinates(): Nullable<Vector2>;
  90755. }
  90756. }
  90757. declare module BABYLON {
  90758. /**
  90759. * Class representing a ray with position and direction
  90760. */
  90761. export class Ray {
  90762. /** origin point */
  90763. origin: Vector3;
  90764. /** direction */
  90765. direction: Vector3;
  90766. /** length of the ray */
  90767. length: number;
  90768. private static readonly _TmpVector3;
  90769. private _tmpRay;
  90770. /**
  90771. * Creates a new ray
  90772. * @param origin origin point
  90773. * @param direction direction
  90774. * @param length length of the ray
  90775. */
  90776. constructor(
  90777. /** origin point */
  90778. origin: Vector3,
  90779. /** direction */
  90780. direction: Vector3,
  90781. /** length of the ray */
  90782. length?: number);
  90783. /**
  90784. * Checks if the ray intersects a box
  90785. * This does not account for the ray lenght by design to improve perfs.
  90786. * @param minimum bound of the box
  90787. * @param maximum bound of the box
  90788. * @param intersectionTreshold extra extend to be added to the box in all direction
  90789. * @returns if the box was hit
  90790. */
  90791. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90792. /**
  90793. * Checks if the ray intersects a box
  90794. * This does not account for the ray lenght by design to improve perfs.
  90795. * @param box the bounding box to check
  90796. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90797. * @returns if the box was hit
  90798. */
  90799. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90800. /**
  90801. * If the ray hits a sphere
  90802. * @param sphere the bounding sphere to check
  90803. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90804. * @returns true if it hits the sphere
  90805. */
  90806. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90807. /**
  90808. * If the ray hits a triange
  90809. * @param vertex0 triangle vertex
  90810. * @param vertex1 triangle vertex
  90811. * @param vertex2 triangle vertex
  90812. * @returns intersection information if hit
  90813. */
  90814. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90815. /**
  90816. * Checks if ray intersects a plane
  90817. * @param plane the plane to check
  90818. * @returns the distance away it was hit
  90819. */
  90820. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90821. /**
  90822. * Calculate the intercept of a ray on a given axis
  90823. * @param axis to check 'x' | 'y' | 'z'
  90824. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90825. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90826. */
  90827. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90828. /**
  90829. * Checks if ray intersects a mesh
  90830. * @param mesh the mesh to check
  90831. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90832. * @returns picking info of the intersecton
  90833. */
  90834. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90835. /**
  90836. * Checks if ray intersects a mesh
  90837. * @param meshes the meshes to check
  90838. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90839. * @param results array to store result in
  90840. * @returns Array of picking infos
  90841. */
  90842. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90843. private _comparePickingInfo;
  90844. private static smallnum;
  90845. private static rayl;
  90846. /**
  90847. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90848. * @param sega the first point of the segment to test the intersection against
  90849. * @param segb the second point of the segment to test the intersection against
  90850. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90851. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90852. */
  90853. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90854. /**
  90855. * Update the ray from viewport position
  90856. * @param x position
  90857. * @param y y position
  90858. * @param viewportWidth viewport width
  90859. * @param viewportHeight viewport height
  90860. * @param world world matrix
  90861. * @param view view matrix
  90862. * @param projection projection matrix
  90863. * @returns this ray updated
  90864. */
  90865. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90866. /**
  90867. * Creates a ray with origin and direction of 0,0,0
  90868. * @returns the new ray
  90869. */
  90870. static Zero(): Ray;
  90871. /**
  90872. * Creates a new ray from screen space and viewport
  90873. * @param x position
  90874. * @param y y position
  90875. * @param viewportWidth viewport width
  90876. * @param viewportHeight viewport height
  90877. * @param world world matrix
  90878. * @param view view matrix
  90879. * @param projection projection matrix
  90880. * @returns new ray
  90881. */
  90882. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90883. /**
  90884. * 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
  90885. * transformed to the given world matrix.
  90886. * @param origin The origin point
  90887. * @param end The end point
  90888. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90889. * @returns the new ray
  90890. */
  90891. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90892. /**
  90893. * Transforms a ray by a matrix
  90894. * @param ray ray to transform
  90895. * @param matrix matrix to apply
  90896. * @returns the resulting new ray
  90897. */
  90898. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90899. /**
  90900. * Transforms a ray by a matrix
  90901. * @param ray ray to transform
  90902. * @param matrix matrix to apply
  90903. * @param result ray to store result in
  90904. */
  90905. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90906. /**
  90907. * Unproject a ray from screen space to object space
  90908. * @param sourceX defines the screen space x coordinate to use
  90909. * @param sourceY defines the screen space y coordinate to use
  90910. * @param viewportWidth defines the current width of the viewport
  90911. * @param viewportHeight defines the current height of the viewport
  90912. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90913. * @param view defines the view matrix to use
  90914. * @param projection defines the projection matrix to use
  90915. */
  90916. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90917. }
  90918. /**
  90919. * Type used to define predicate used to select faces when a mesh intersection is detected
  90920. */
  90921. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90922. interface Scene {
  90923. /** @hidden */
  90924. _tempPickingRay: Nullable<Ray>;
  90925. /** @hidden */
  90926. _cachedRayForTransform: Ray;
  90927. /** @hidden */
  90928. _pickWithRayInverseMatrix: Matrix;
  90929. /** @hidden */
  90930. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90931. /** @hidden */
  90932. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90933. /** @hidden */
  90934. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90935. }
  90936. }
  90937. declare module BABYLON {
  90938. /**
  90939. * Groups all the scene component constants in one place to ease maintenance.
  90940. * @hidden
  90941. */
  90942. export class SceneComponentConstants {
  90943. static readonly NAME_EFFECTLAYER: string;
  90944. static readonly NAME_LAYER: string;
  90945. static readonly NAME_LENSFLARESYSTEM: string;
  90946. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90947. static readonly NAME_PARTICLESYSTEM: string;
  90948. static readonly NAME_GAMEPAD: string;
  90949. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90950. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90951. static readonly NAME_PREPASSRENDERER: string;
  90952. static readonly NAME_DEPTHRENDERER: string;
  90953. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90954. static readonly NAME_SPRITE: string;
  90955. static readonly NAME_SUBSURFACE: string;
  90956. static readonly NAME_OUTLINERENDERER: string;
  90957. static readonly NAME_PROCEDURALTEXTURE: string;
  90958. static readonly NAME_SHADOWGENERATOR: string;
  90959. static readonly NAME_OCTREE: string;
  90960. static readonly NAME_PHYSICSENGINE: string;
  90961. static readonly NAME_AUDIO: string;
  90962. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90963. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90964. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90965. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90966. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90967. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90968. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90969. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90970. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90971. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90972. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90973. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90974. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90975. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90976. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90977. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90978. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90979. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90980. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90981. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90982. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90983. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90984. static readonly STEP_AFTERRENDER_AUDIO: number;
  90985. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90986. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90987. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90988. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90989. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90990. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90991. static readonly STEP_POINTERMOVE_SPRITE: number;
  90992. static readonly STEP_POINTERDOWN_SPRITE: number;
  90993. static readonly STEP_POINTERUP_SPRITE: number;
  90994. }
  90995. /**
  90996. * This represents a scene component.
  90997. *
  90998. * This is used to decouple the dependency the scene is having on the different workloads like
  90999. * layers, post processes...
  91000. */
  91001. export interface ISceneComponent {
  91002. /**
  91003. * The name of the component. Each component must have a unique name.
  91004. */
  91005. name: string;
  91006. /**
  91007. * The scene the component belongs to.
  91008. */
  91009. scene: Scene;
  91010. /**
  91011. * Register the component to one instance of a scene.
  91012. */
  91013. register(): void;
  91014. /**
  91015. * Rebuilds the elements related to this component in case of
  91016. * context lost for instance.
  91017. */
  91018. rebuild(): void;
  91019. /**
  91020. * Disposes the component and the associated ressources.
  91021. */
  91022. dispose(): void;
  91023. }
  91024. /**
  91025. * This represents a SERIALIZABLE scene component.
  91026. *
  91027. * This extends Scene Component to add Serialization methods on top.
  91028. */
  91029. export interface ISceneSerializableComponent extends ISceneComponent {
  91030. /**
  91031. * Adds all the elements from the container to the scene
  91032. * @param container the container holding the elements
  91033. */
  91034. addFromContainer(container: AbstractScene): void;
  91035. /**
  91036. * Removes all the elements in the container from the scene
  91037. * @param container contains the elements to remove
  91038. * @param dispose if the removed element should be disposed (default: false)
  91039. */
  91040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91041. /**
  91042. * Serializes the component data to the specified json object
  91043. * @param serializationObject The object to serialize to
  91044. */
  91045. serialize(serializationObject: any): void;
  91046. }
  91047. /**
  91048. * Strong typing of a Mesh related stage step action
  91049. */
  91050. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91051. /**
  91052. * Strong typing of a Evaluate Sub Mesh related stage step action
  91053. */
  91054. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91055. /**
  91056. * Strong typing of a Active Mesh related stage step action
  91057. */
  91058. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91059. /**
  91060. * Strong typing of a Camera related stage step action
  91061. */
  91062. export type CameraStageAction = (camera: Camera) => void;
  91063. /**
  91064. * Strong typing of a Camera Frame buffer related stage step action
  91065. */
  91066. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91067. /**
  91068. * Strong typing of a Render Target related stage step action
  91069. */
  91070. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91071. /**
  91072. * Strong typing of a RenderingGroup related stage step action
  91073. */
  91074. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91075. /**
  91076. * Strong typing of a Mesh Render related stage step action
  91077. */
  91078. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91079. /**
  91080. * Strong typing of a simple stage step action
  91081. */
  91082. export type SimpleStageAction = () => void;
  91083. /**
  91084. * Strong typing of a render target action.
  91085. */
  91086. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91087. /**
  91088. * Strong typing of a pointer move action.
  91089. */
  91090. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91091. /**
  91092. * Strong typing of a pointer up/down action.
  91093. */
  91094. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91095. /**
  91096. * Representation of a stage in the scene (Basically a list of ordered steps)
  91097. * @hidden
  91098. */
  91099. export class Stage<T extends Function> extends Array<{
  91100. index: number;
  91101. component: ISceneComponent;
  91102. action: T;
  91103. }> {
  91104. /**
  91105. * Hide ctor from the rest of the world.
  91106. * @param items The items to add.
  91107. */
  91108. private constructor();
  91109. /**
  91110. * Creates a new Stage.
  91111. * @returns A new instance of a Stage
  91112. */
  91113. static Create<T extends Function>(): Stage<T>;
  91114. /**
  91115. * Registers a step in an ordered way in the targeted stage.
  91116. * @param index Defines the position to register the step in
  91117. * @param component Defines the component attached to the step
  91118. * @param action Defines the action to launch during the step
  91119. */
  91120. registerStep(index: number, component: ISceneComponent, action: T): void;
  91121. /**
  91122. * Clears all the steps from the stage.
  91123. */
  91124. clear(): void;
  91125. }
  91126. }
  91127. declare module BABYLON {
  91128. interface Scene {
  91129. /** @hidden */
  91130. _pointerOverSprite: Nullable<Sprite>;
  91131. /** @hidden */
  91132. _pickedDownSprite: Nullable<Sprite>;
  91133. /** @hidden */
  91134. _tempSpritePickingRay: Nullable<Ray>;
  91135. /**
  91136. * All of the sprite managers added to this scene
  91137. * @see https://doc.babylonjs.com/babylon101/sprites
  91138. */
  91139. spriteManagers: Array<ISpriteManager>;
  91140. /**
  91141. * An event triggered when sprites rendering is about to start
  91142. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91143. */
  91144. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91145. /**
  91146. * An event triggered when sprites rendering is done
  91147. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91148. */
  91149. onAfterSpritesRenderingObservable: Observable<Scene>;
  91150. /** @hidden */
  91151. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91152. /** Launch a ray to try to pick a sprite in the scene
  91153. * @param x position on screen
  91154. * @param y position on screen
  91155. * @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
  91156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91157. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91158. * @returns a PickingInfo
  91159. */
  91160. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91161. /** Use the given ray to pick a sprite in the scene
  91162. * @param ray The ray (in world space) to use to pick meshes
  91163. * @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
  91164. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91165. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91166. * @returns a PickingInfo
  91167. */
  91168. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91169. /** @hidden */
  91170. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91171. /** Launch a ray to try to pick sprites in the scene
  91172. * @param x position on screen
  91173. * @param y position on screen
  91174. * @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
  91175. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91176. * @returns a PickingInfo array
  91177. */
  91178. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91179. /** Use the given ray to pick sprites in the scene
  91180. * @param ray The ray (in world space) to use to pick meshes
  91181. * @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
  91182. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91183. * @returns a PickingInfo array
  91184. */
  91185. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91186. /**
  91187. * Force the sprite under the pointer
  91188. * @param sprite defines the sprite to use
  91189. */
  91190. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91191. /**
  91192. * Gets the sprite under the pointer
  91193. * @returns a Sprite or null if no sprite is under the pointer
  91194. */
  91195. getPointerOverSprite(): Nullable<Sprite>;
  91196. }
  91197. /**
  91198. * Defines the sprite scene component responsible to manage sprites
  91199. * in a given scene.
  91200. */
  91201. export class SpriteSceneComponent implements ISceneComponent {
  91202. /**
  91203. * The component name helpfull to identify the component in the list of scene components.
  91204. */
  91205. readonly name: string;
  91206. /**
  91207. * The scene the component belongs to.
  91208. */
  91209. scene: Scene;
  91210. /** @hidden */
  91211. private _spritePredicate;
  91212. /**
  91213. * Creates a new instance of the component for the given scene
  91214. * @param scene Defines the scene to register the component in
  91215. */
  91216. constructor(scene: Scene);
  91217. /**
  91218. * Registers the component in a given scene
  91219. */
  91220. register(): void;
  91221. /**
  91222. * Rebuilds the elements related to this component in case of
  91223. * context lost for instance.
  91224. */
  91225. rebuild(): void;
  91226. /**
  91227. * Disposes the component and the associated ressources.
  91228. */
  91229. dispose(): void;
  91230. private _pickSpriteButKeepRay;
  91231. private _pointerMove;
  91232. private _pointerDown;
  91233. private _pointerUp;
  91234. }
  91235. }
  91236. declare module BABYLON {
  91237. /** @hidden */
  91238. export var fogFragmentDeclaration: {
  91239. name: string;
  91240. shader: string;
  91241. };
  91242. }
  91243. declare module BABYLON {
  91244. /** @hidden */
  91245. export var fogFragment: {
  91246. name: string;
  91247. shader: string;
  91248. };
  91249. }
  91250. declare module BABYLON {
  91251. /** @hidden */
  91252. export var spritesPixelShader: {
  91253. name: string;
  91254. shader: string;
  91255. };
  91256. }
  91257. declare module BABYLON {
  91258. /** @hidden */
  91259. export var fogVertexDeclaration: {
  91260. name: string;
  91261. shader: string;
  91262. };
  91263. }
  91264. declare module BABYLON {
  91265. /** @hidden */
  91266. export var spritesVertexShader: {
  91267. name: string;
  91268. shader: string;
  91269. };
  91270. }
  91271. declare module BABYLON {
  91272. /**
  91273. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91274. */
  91275. export interface ISpriteManager extends IDisposable {
  91276. /**
  91277. * Gets manager's name
  91278. */
  91279. name: string;
  91280. /**
  91281. * Restricts the camera to viewing objects with the same layerMask.
  91282. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91283. */
  91284. layerMask: number;
  91285. /**
  91286. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91287. */
  91288. isPickable: boolean;
  91289. /**
  91290. * Gets the hosting scene
  91291. */
  91292. scene: Scene;
  91293. /**
  91294. * Specifies the rendering group id for this mesh (0 by default)
  91295. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91296. */
  91297. renderingGroupId: number;
  91298. /**
  91299. * Defines the list of sprites managed by the manager.
  91300. */
  91301. sprites: Array<Sprite>;
  91302. /**
  91303. * Gets or sets the spritesheet texture
  91304. */
  91305. texture: Texture;
  91306. /** Defines the default width of a cell in the spritesheet */
  91307. cellWidth: number;
  91308. /** Defines the default height of a cell in the spritesheet */
  91309. cellHeight: number;
  91310. /**
  91311. * Tests the intersection of a sprite with a specific ray.
  91312. * @param ray The ray we are sending to test the collision
  91313. * @param camera The camera space we are sending rays in
  91314. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91315. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91316. * @returns picking info or null.
  91317. */
  91318. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91319. /**
  91320. * Intersects the sprites with a ray
  91321. * @param ray defines the ray to intersect with
  91322. * @param camera defines the current active camera
  91323. * @param predicate defines a predicate used to select candidate sprites
  91324. * @returns null if no hit or a PickingInfo array
  91325. */
  91326. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91327. /**
  91328. * Renders the list of sprites on screen.
  91329. */
  91330. render(): void;
  91331. }
  91332. /**
  91333. * Class used to manage multiple sprites on the same spritesheet
  91334. * @see https://doc.babylonjs.com/babylon101/sprites
  91335. */
  91336. export class SpriteManager implements ISpriteManager {
  91337. /** defines the manager's name */
  91338. name: string;
  91339. /** Define the Url to load snippets */
  91340. static SnippetUrl: string;
  91341. /** Snippet ID if the manager was created from the snippet server */
  91342. snippetId: string;
  91343. /** Gets the list of sprites */
  91344. sprites: Sprite[];
  91345. /** Gets or sets the rendering group id (0 by default) */
  91346. renderingGroupId: number;
  91347. /** Gets or sets camera layer mask */
  91348. layerMask: number;
  91349. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91350. fogEnabled: boolean;
  91351. /** Gets or sets a boolean indicating if the sprites are pickable */
  91352. isPickable: boolean;
  91353. /** Defines the default width of a cell in the spritesheet */
  91354. cellWidth: number;
  91355. /** Defines the default height of a cell in the spritesheet */
  91356. cellHeight: number;
  91357. /** Associative array from JSON sprite data file */
  91358. private _cellData;
  91359. /** Array of sprite names from JSON sprite data file */
  91360. private _spriteMap;
  91361. /** True when packed cell data from JSON file is ready*/
  91362. private _packedAndReady;
  91363. private _textureContent;
  91364. private _useInstancing;
  91365. /**
  91366. * An event triggered when the manager is disposed.
  91367. */
  91368. onDisposeObservable: Observable<SpriteManager>;
  91369. private _onDisposeObserver;
  91370. /**
  91371. * Callback called when the manager is disposed
  91372. */
  91373. set onDispose(callback: () => void);
  91374. private _capacity;
  91375. private _fromPacked;
  91376. private _spriteTexture;
  91377. private _epsilon;
  91378. private _scene;
  91379. private _vertexData;
  91380. private _buffer;
  91381. private _vertexBuffers;
  91382. private _spriteBuffer;
  91383. private _indexBuffer;
  91384. private _effectBase;
  91385. private _effectFog;
  91386. private _vertexBufferSize;
  91387. /**
  91388. * Gets or sets the unique id of the sprite
  91389. */
  91390. uniqueId: number;
  91391. /**
  91392. * Gets the array of sprites
  91393. */
  91394. get children(): Sprite[];
  91395. /**
  91396. * Gets the hosting scene
  91397. */
  91398. get scene(): Scene;
  91399. /**
  91400. * Gets the capacity of the manager
  91401. */
  91402. get capacity(): number;
  91403. /**
  91404. * Gets or sets the spritesheet texture
  91405. */
  91406. get texture(): Texture;
  91407. set texture(value: Texture);
  91408. private _blendMode;
  91409. /**
  91410. * Blend mode use to render the particle, it can be any of
  91411. * the static Constants.ALPHA_x properties provided in this class.
  91412. * Default value is Constants.ALPHA_COMBINE
  91413. */
  91414. get blendMode(): number;
  91415. set blendMode(blendMode: number);
  91416. /** Disables writing to the depth buffer when rendering the sprites.
  91417. * It can be handy to disable depth writing when using textures without alpha channel
  91418. * and setting some specific blend modes.
  91419. */
  91420. disableDepthWrite: boolean;
  91421. /**
  91422. * Creates a new sprite manager
  91423. * @param name defines the manager's name
  91424. * @param imgUrl defines the sprite sheet url
  91425. * @param capacity defines the maximum allowed number of sprites
  91426. * @param cellSize defines the size of a sprite cell
  91427. * @param scene defines the hosting scene
  91428. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91429. * @param samplingMode defines the smapling mode to use with spritesheet
  91430. * @param fromPacked set to false; do not alter
  91431. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91432. */
  91433. constructor(
  91434. /** defines the manager's name */
  91435. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91436. /**
  91437. * Returns the string "SpriteManager"
  91438. * @returns "SpriteManager"
  91439. */
  91440. getClassName(): string;
  91441. private _makePacked;
  91442. private _appendSpriteVertex;
  91443. private _checkTextureAlpha;
  91444. /**
  91445. * Intersects the sprites with a ray
  91446. * @param ray defines the ray to intersect with
  91447. * @param camera defines the current active camera
  91448. * @param predicate defines a predicate used to select candidate sprites
  91449. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91450. * @returns null if no hit or a PickingInfo
  91451. */
  91452. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91453. /**
  91454. * Intersects the sprites with a ray
  91455. * @param ray defines the ray to intersect with
  91456. * @param camera defines the current active camera
  91457. * @param predicate defines a predicate used to select candidate sprites
  91458. * @returns null if no hit or a PickingInfo array
  91459. */
  91460. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91461. /**
  91462. * Render all child sprites
  91463. */
  91464. render(): void;
  91465. /**
  91466. * Release associated resources
  91467. */
  91468. dispose(): void;
  91469. /**
  91470. * Serializes the sprite manager to a JSON object
  91471. * @param serializeTexture defines if the texture must be serialized as well
  91472. * @returns the JSON object
  91473. */
  91474. serialize(serializeTexture?: boolean): any;
  91475. /**
  91476. * Parses a JSON object to create a new sprite manager.
  91477. * @param parsedManager The JSON object to parse
  91478. * @param scene The scene to create the sprite managerin
  91479. * @param rootUrl The root url to use to load external dependencies like texture
  91480. * @returns the new sprite manager
  91481. */
  91482. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91483. /**
  91484. * Creates a sprite manager from a snippet saved in a remote file
  91485. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91486. * @param url defines the url to load from
  91487. * @param scene defines the hosting scene
  91488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91489. * @returns a promise that will resolve to the new sprite manager
  91490. */
  91491. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91492. /**
  91493. * Creates a sprite manager from a snippet saved by the sprite editor
  91494. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91495. * @param scene defines the hosting scene
  91496. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91497. * @returns a promise that will resolve to the new sprite manager
  91498. */
  91499. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91500. }
  91501. }
  91502. declare module BABYLON {
  91503. /** Interface used by value gradients (color, factor, ...) */
  91504. export interface IValueGradient {
  91505. /**
  91506. * Gets or sets the gradient value (between 0 and 1)
  91507. */
  91508. gradient: number;
  91509. }
  91510. /** Class used to store color4 gradient */
  91511. export class ColorGradient implements IValueGradient {
  91512. /**
  91513. * Gets or sets the gradient value (between 0 and 1)
  91514. */
  91515. gradient: number;
  91516. /**
  91517. * Gets or sets first associated color
  91518. */
  91519. color1: Color4;
  91520. /**
  91521. * Gets or sets second associated color
  91522. */
  91523. color2?: Color4 | undefined;
  91524. /**
  91525. * Creates a new color4 gradient
  91526. * @param gradient gets or sets the gradient value (between 0 and 1)
  91527. * @param color1 gets or sets first associated color
  91528. * @param color2 gets or sets first second color
  91529. */
  91530. constructor(
  91531. /**
  91532. * Gets or sets the gradient value (between 0 and 1)
  91533. */
  91534. gradient: number,
  91535. /**
  91536. * Gets or sets first associated color
  91537. */
  91538. color1: Color4,
  91539. /**
  91540. * Gets or sets second associated color
  91541. */
  91542. color2?: Color4 | undefined);
  91543. /**
  91544. * Will get a color picked randomly between color1 and color2.
  91545. * If color2 is undefined then color1 will be used
  91546. * @param result defines the target Color4 to store the result in
  91547. */
  91548. getColorToRef(result: Color4): void;
  91549. }
  91550. /** Class used to store color 3 gradient */
  91551. export class Color3Gradient implements IValueGradient {
  91552. /**
  91553. * Gets or sets the gradient value (between 0 and 1)
  91554. */
  91555. gradient: number;
  91556. /**
  91557. * Gets or sets the associated color
  91558. */
  91559. color: Color3;
  91560. /**
  91561. * Creates a new color3 gradient
  91562. * @param gradient gets or sets the gradient value (between 0 and 1)
  91563. * @param color gets or sets associated color
  91564. */
  91565. constructor(
  91566. /**
  91567. * Gets or sets the gradient value (between 0 and 1)
  91568. */
  91569. gradient: number,
  91570. /**
  91571. * Gets or sets the associated color
  91572. */
  91573. color: Color3);
  91574. }
  91575. /** Class used to store factor gradient */
  91576. export class FactorGradient implements IValueGradient {
  91577. /**
  91578. * Gets or sets the gradient value (between 0 and 1)
  91579. */
  91580. gradient: number;
  91581. /**
  91582. * Gets or sets first associated factor
  91583. */
  91584. factor1: number;
  91585. /**
  91586. * Gets or sets second associated factor
  91587. */
  91588. factor2?: number | undefined;
  91589. /**
  91590. * Creates a new factor gradient
  91591. * @param gradient gets or sets the gradient value (between 0 and 1)
  91592. * @param factor1 gets or sets first associated factor
  91593. * @param factor2 gets or sets second associated factor
  91594. */
  91595. constructor(
  91596. /**
  91597. * Gets or sets the gradient value (between 0 and 1)
  91598. */
  91599. gradient: number,
  91600. /**
  91601. * Gets or sets first associated factor
  91602. */
  91603. factor1: number,
  91604. /**
  91605. * Gets or sets second associated factor
  91606. */
  91607. factor2?: number | undefined);
  91608. /**
  91609. * Will get a number picked randomly between factor1 and factor2.
  91610. * If factor2 is undefined then factor1 will be used
  91611. * @returns the picked number
  91612. */
  91613. getFactor(): number;
  91614. }
  91615. /**
  91616. * Helper used to simplify some generic gradient tasks
  91617. */
  91618. export class GradientHelper {
  91619. /**
  91620. * Gets the current gradient from an array of IValueGradient
  91621. * @param ratio defines the current ratio to get
  91622. * @param gradients defines the array of IValueGradient
  91623. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91624. */
  91625. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91626. }
  91627. }
  91628. declare module BABYLON {
  91629. interface ThinEngine {
  91630. /**
  91631. * Creates a raw texture
  91632. * @param data defines the data to store in the texture
  91633. * @param width defines the width of the texture
  91634. * @param height defines the height of the texture
  91635. * @param format defines the format of the data
  91636. * @param generateMipMaps defines if the engine should generate the mip levels
  91637. * @param invertY defines if data must be stored with Y axis inverted
  91638. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91639. * @param compression defines the compression used (null by default)
  91640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91641. * @returns the raw texture inside an InternalTexture
  91642. */
  91643. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91644. /**
  91645. * Update a raw texture
  91646. * @param texture defines the texture to update
  91647. * @param data defines the data to store in the texture
  91648. * @param format defines the format of the data
  91649. * @param invertY defines if data must be stored with Y axis inverted
  91650. */
  91651. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91652. /**
  91653. * Update a raw texture
  91654. * @param texture defines the texture to update
  91655. * @param data defines the data to store in the texture
  91656. * @param format defines the format of the data
  91657. * @param invertY defines if data must be stored with Y axis inverted
  91658. * @param compression defines the compression used (null by default)
  91659. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91660. */
  91661. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91662. /**
  91663. * Creates a new raw cube texture
  91664. * @param data defines the array of data to use to create each face
  91665. * @param size defines the size of the textures
  91666. * @param format defines the format of the data
  91667. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91668. * @param generateMipMaps defines if the engine should generate the mip levels
  91669. * @param invertY defines if data must be stored with Y axis inverted
  91670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91671. * @param compression defines the compression used (null by default)
  91672. * @returns the cube texture as an InternalTexture
  91673. */
  91674. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91675. /**
  91676. * Update a raw cube texture
  91677. * @param texture defines the texture to udpdate
  91678. * @param data defines the data to store
  91679. * @param format defines the data format
  91680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91681. * @param invertY defines if data must be stored with Y axis inverted
  91682. */
  91683. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91684. /**
  91685. * Update a raw cube texture
  91686. * @param texture defines the texture to udpdate
  91687. * @param data defines the data to store
  91688. * @param format defines the data format
  91689. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91690. * @param invertY defines if data must be stored with Y axis inverted
  91691. * @param compression defines the compression used (null by default)
  91692. */
  91693. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91694. /**
  91695. * Update a raw cube texture
  91696. * @param texture defines the texture to udpdate
  91697. * @param data defines the data to store
  91698. * @param format defines the data format
  91699. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91700. * @param invertY defines if data must be stored with Y axis inverted
  91701. * @param compression defines the compression used (null by default)
  91702. * @param level defines which level of the texture to update
  91703. */
  91704. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91705. /**
  91706. * Creates a new raw cube texture from a specified url
  91707. * @param url defines the url where the data is located
  91708. * @param scene defines the current scene
  91709. * @param size defines the size of the textures
  91710. * @param format defines the format of the data
  91711. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91712. * @param noMipmap defines if the engine should avoid generating the mip levels
  91713. * @param callback defines a callback used to extract texture data from loaded data
  91714. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91715. * @param onLoad defines a callback called when texture is loaded
  91716. * @param onError defines a callback called if there is an error
  91717. * @returns the cube texture as an InternalTexture
  91718. */
  91719. 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;
  91720. /**
  91721. * Creates a new raw cube texture from a specified url
  91722. * @param url defines the url where the data is located
  91723. * @param scene defines the current scene
  91724. * @param size defines the size of the textures
  91725. * @param format defines the format of the data
  91726. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91727. * @param noMipmap defines if the engine should avoid generating the mip levels
  91728. * @param callback defines a callback used to extract texture data from loaded data
  91729. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91730. * @param onLoad defines a callback called when texture is loaded
  91731. * @param onError defines a callback called if there is an error
  91732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91733. * @param invertY defines if data must be stored with Y axis inverted
  91734. * @returns the cube texture as an InternalTexture
  91735. */
  91736. 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;
  91737. /**
  91738. * Creates a new raw 3D texture
  91739. * @param data defines the data used to create the texture
  91740. * @param width defines the width of the texture
  91741. * @param height defines the height of the texture
  91742. * @param depth defines the depth of the texture
  91743. * @param format defines the format of the texture
  91744. * @param generateMipMaps defines if the engine must generate mip levels
  91745. * @param invertY defines if data must be stored with Y axis inverted
  91746. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91747. * @param compression defines the compressed used (can be null)
  91748. * @param textureType defines the compressed used (can be null)
  91749. * @returns a new raw 3D texture (stored in an InternalTexture)
  91750. */
  91751. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91752. /**
  91753. * Update a raw 3D texture
  91754. * @param texture defines the texture to update
  91755. * @param data defines the data to store
  91756. * @param format defines the data format
  91757. * @param invertY defines if data must be stored with Y axis inverted
  91758. */
  91759. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91760. /**
  91761. * Update a raw 3D texture
  91762. * @param texture defines the texture to update
  91763. * @param data defines the data to store
  91764. * @param format defines the data format
  91765. * @param invertY defines if data must be stored with Y axis inverted
  91766. * @param compression defines the used compression (can be null)
  91767. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91768. */
  91769. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91770. /**
  91771. * Creates a new raw 2D array texture
  91772. * @param data defines the data used to create the texture
  91773. * @param width defines the width of the texture
  91774. * @param height defines the height of the texture
  91775. * @param depth defines the number of layers of the texture
  91776. * @param format defines the format of the texture
  91777. * @param generateMipMaps defines if the engine must generate mip levels
  91778. * @param invertY defines if data must be stored with Y axis inverted
  91779. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91780. * @param compression defines the compressed used (can be null)
  91781. * @param textureType defines the compressed used (can be null)
  91782. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91783. */
  91784. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91785. /**
  91786. * Update a raw 2D array texture
  91787. * @param texture defines the texture to update
  91788. * @param data defines the data to store
  91789. * @param format defines the data format
  91790. * @param invertY defines if data must be stored with Y axis inverted
  91791. */
  91792. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91793. /**
  91794. * Update a raw 2D array texture
  91795. * @param texture defines the texture to update
  91796. * @param data defines the data to store
  91797. * @param format defines the data format
  91798. * @param invertY defines if data must be stored with Y axis inverted
  91799. * @param compression defines the used compression (can be null)
  91800. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91801. */
  91802. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91803. }
  91804. }
  91805. declare module BABYLON {
  91806. /**
  91807. * Raw texture can help creating a texture directly from an array of data.
  91808. * This can be super useful if you either get the data from an uncompressed source or
  91809. * if you wish to create your texture pixel by pixel.
  91810. */
  91811. export class RawTexture extends Texture {
  91812. /**
  91813. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91814. */
  91815. format: number;
  91816. /**
  91817. * Instantiates a new RawTexture.
  91818. * Raw texture can help creating a texture directly from an array of data.
  91819. * This can be super useful if you either get the data from an uncompressed source or
  91820. * if you wish to create your texture pixel by pixel.
  91821. * @param data define the array of data to use to create the texture
  91822. * @param width define the width of the texture
  91823. * @param height define the height of the texture
  91824. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91825. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91826. * @param generateMipMaps define whether mip maps should be generated or not
  91827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91829. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91830. */
  91831. constructor(data: ArrayBufferView, width: number, height: number,
  91832. /**
  91833. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91834. */
  91835. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91836. /**
  91837. * Updates the texture underlying data.
  91838. * @param data Define the new data of the texture
  91839. */
  91840. update(data: ArrayBufferView): void;
  91841. /**
  91842. * Creates a luminance texture from some data.
  91843. * @param data Define the texture data
  91844. * @param width Define the width of the texture
  91845. * @param height Define the height of the texture
  91846. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91850. * @returns the luminance texture
  91851. */
  91852. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91853. /**
  91854. * Creates a luminance alpha texture from some data.
  91855. * @param data Define the texture data
  91856. * @param width Define the width of the texture
  91857. * @param height Define the height of the texture
  91858. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91862. * @returns the luminance alpha texture
  91863. */
  91864. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91865. /**
  91866. * Creates an alpha texture from some data.
  91867. * @param data Define the texture data
  91868. * @param width Define the width of the texture
  91869. * @param height Define the height of the texture
  91870. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91874. * @returns the alpha texture
  91875. */
  91876. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91877. /**
  91878. * Creates a RGB texture from some data.
  91879. * @param data Define the texture data
  91880. * @param width Define the width of the texture
  91881. * @param height Define the height of the texture
  91882. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91883. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91884. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91885. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91886. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91887. * @returns the RGB alpha texture
  91888. */
  91889. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91890. /**
  91891. * Creates a RGBA texture from some data.
  91892. * @param data Define the texture data
  91893. * @param width Define the width of the texture
  91894. * @param height Define the height of the texture
  91895. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91896. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91897. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91898. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91899. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91900. * @returns the RGBA texture
  91901. */
  91902. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91903. /**
  91904. * Creates a R texture from some data.
  91905. * @param data Define the texture data
  91906. * @param width Define the width of the texture
  91907. * @param height Define the height of the texture
  91908. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91912. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91913. * @returns the R texture
  91914. */
  91915. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91916. }
  91917. }
  91918. declare module BABYLON {
  91919. interface ThinEngine {
  91920. /**
  91921. * Update a dynamic index buffer
  91922. * @param indexBuffer defines the target index buffer
  91923. * @param indices defines the data to update
  91924. * @param offset defines the offset in the target index buffer where update should start
  91925. */
  91926. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91927. /**
  91928. * Updates a dynamic vertex buffer.
  91929. * @param vertexBuffer the vertex buffer to update
  91930. * @param data the data used to update the vertex buffer
  91931. * @param byteOffset the byte offset of the data
  91932. * @param byteLength the byte length of the data
  91933. */
  91934. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91935. }
  91936. }
  91937. declare module BABYLON {
  91938. interface AbstractScene {
  91939. /**
  91940. * The list of procedural textures added to the scene
  91941. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91942. */
  91943. proceduralTextures: Array<ProceduralTexture>;
  91944. }
  91945. /**
  91946. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91947. * in a given scene.
  91948. */
  91949. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91950. /**
  91951. * The component name helpfull to identify the component in the list of scene components.
  91952. */
  91953. readonly name: string;
  91954. /**
  91955. * The scene the component belongs to.
  91956. */
  91957. scene: Scene;
  91958. /**
  91959. * Creates a new instance of the component for the given scene
  91960. * @param scene Defines the scene to register the component in
  91961. */
  91962. constructor(scene: Scene);
  91963. /**
  91964. * Registers the component in a given scene
  91965. */
  91966. register(): void;
  91967. /**
  91968. * Rebuilds the elements related to this component in case of
  91969. * context lost for instance.
  91970. */
  91971. rebuild(): void;
  91972. /**
  91973. * Disposes the component and the associated ressources.
  91974. */
  91975. dispose(): void;
  91976. private _beforeClear;
  91977. }
  91978. }
  91979. declare module BABYLON {
  91980. interface ThinEngine {
  91981. /**
  91982. * Creates a new render target cube texture
  91983. * @param size defines the size of the texture
  91984. * @param options defines the options used to create the texture
  91985. * @returns a new render target cube texture stored in an InternalTexture
  91986. */
  91987. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91988. }
  91989. }
  91990. declare module BABYLON {
  91991. /** @hidden */
  91992. export var proceduralVertexShader: {
  91993. name: string;
  91994. shader: string;
  91995. };
  91996. }
  91997. declare module BABYLON {
  91998. /**
  91999. * 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.
  92000. * This is the base class of any Procedural texture and contains most of the shareable code.
  92001. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92002. */
  92003. export class ProceduralTexture extends Texture {
  92004. /**
  92005. * Define if the texture is enabled or not (disabled texture will not render)
  92006. */
  92007. isEnabled: boolean;
  92008. /**
  92009. * Define if the texture must be cleared before rendering (default is true)
  92010. */
  92011. autoClear: boolean;
  92012. /**
  92013. * Callback called when the texture is generated
  92014. */
  92015. onGenerated: () => void;
  92016. /**
  92017. * Event raised when the texture is generated
  92018. */
  92019. onGeneratedObservable: Observable<ProceduralTexture>;
  92020. /**
  92021. * Event raised before the texture is generated
  92022. */
  92023. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92024. /**
  92025. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92026. */
  92027. nodeMaterialSource: Nullable<NodeMaterial>;
  92028. /** @hidden */
  92029. _generateMipMaps: boolean;
  92030. /** @hidden **/
  92031. _effect: Effect;
  92032. /** @hidden */
  92033. _textures: {
  92034. [key: string]: Texture;
  92035. };
  92036. /** @hidden */
  92037. protected _fallbackTexture: Nullable<Texture>;
  92038. private _size;
  92039. private _currentRefreshId;
  92040. private _frameId;
  92041. private _refreshRate;
  92042. private _vertexBuffers;
  92043. private _indexBuffer;
  92044. private _uniforms;
  92045. private _samplers;
  92046. private _fragment;
  92047. private _floats;
  92048. private _ints;
  92049. private _floatsArrays;
  92050. private _colors3;
  92051. private _colors4;
  92052. private _vectors2;
  92053. private _vectors3;
  92054. private _matrices;
  92055. private _fallbackTextureUsed;
  92056. private _fullEngine;
  92057. private _cachedDefines;
  92058. private _contentUpdateId;
  92059. private _contentData;
  92060. /**
  92061. * Instantiates a new procedural texture.
  92062. * 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.
  92063. * This is the base class of any Procedural texture and contains most of the shareable code.
  92064. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92065. * @param name Define the name of the texture
  92066. * @param size Define the size of the texture to create
  92067. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92068. * @param scene Define the scene the texture belongs to
  92069. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92070. * @param generateMipMaps Define if the texture should creates mip maps or not
  92071. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92072. */
  92073. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92074. /**
  92075. * The effect that is created when initializing the post process.
  92076. * @returns The created effect corresponding the the postprocess.
  92077. */
  92078. getEffect(): Effect;
  92079. /**
  92080. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92081. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92082. */
  92083. getContent(): Nullable<ArrayBufferView>;
  92084. private _createIndexBuffer;
  92085. /** @hidden */
  92086. _rebuild(): void;
  92087. /**
  92088. * Resets the texture in order to recreate its associated resources.
  92089. * This can be called in case of context loss
  92090. */
  92091. reset(): void;
  92092. protected _getDefines(): string;
  92093. /**
  92094. * Is the texture ready to be used ? (rendered at least once)
  92095. * @returns true if ready, otherwise, false.
  92096. */
  92097. isReady(): boolean;
  92098. /**
  92099. * Resets the refresh counter of the texture and start bak from scratch.
  92100. * Could be useful to regenerate the texture if it is setup to render only once.
  92101. */
  92102. resetRefreshCounter(): void;
  92103. /**
  92104. * Set the fragment shader to use in order to render the texture.
  92105. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92106. */
  92107. setFragment(fragment: any): void;
  92108. /**
  92109. * Define the refresh rate of the texture or the rendering frequency.
  92110. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92111. */
  92112. get refreshRate(): number;
  92113. set refreshRate(value: number);
  92114. /** @hidden */
  92115. _shouldRender(): boolean;
  92116. /**
  92117. * Get the size the texture is rendering at.
  92118. * @returns the size (on cube texture it is always squared)
  92119. */
  92120. getRenderSize(): RenderTargetTextureSize;
  92121. /**
  92122. * Resize the texture to new value.
  92123. * @param size Define the new size the texture should have
  92124. * @param generateMipMaps Define whether the new texture should create mip maps
  92125. */
  92126. resize(size: number, generateMipMaps: boolean): void;
  92127. private _checkUniform;
  92128. /**
  92129. * Set a texture in the shader program used to render.
  92130. * @param name Define the name of the uniform samplers as defined in the shader
  92131. * @param texture Define the texture to bind to this sampler
  92132. * @return the texture itself allowing "fluent" like uniform updates
  92133. */
  92134. setTexture(name: string, texture: Texture): ProceduralTexture;
  92135. /**
  92136. * Set a float in the shader.
  92137. * @param name Define the name of the uniform as defined in the shader
  92138. * @param value Define the value to give to the uniform
  92139. * @return the texture itself allowing "fluent" like uniform updates
  92140. */
  92141. setFloat(name: string, value: number): ProceduralTexture;
  92142. /**
  92143. * Set a int in the shader.
  92144. * @param name Define the name of the uniform as defined in the shader
  92145. * @param value Define the value to give to the uniform
  92146. * @return the texture itself allowing "fluent" like uniform updates
  92147. */
  92148. setInt(name: string, value: number): ProceduralTexture;
  92149. /**
  92150. * Set an array of floats in the shader.
  92151. * @param name Define the name of the uniform as defined in the shader
  92152. * @param value Define the value to give to the uniform
  92153. * @return the texture itself allowing "fluent" like uniform updates
  92154. */
  92155. setFloats(name: string, value: number[]): ProceduralTexture;
  92156. /**
  92157. * Set a vec3 in the shader from a Color3.
  92158. * @param name Define the name of the uniform as defined in the shader
  92159. * @param value Define the value to give to the uniform
  92160. * @return the texture itself allowing "fluent" like uniform updates
  92161. */
  92162. setColor3(name: string, value: Color3): ProceduralTexture;
  92163. /**
  92164. * Set a vec4 in the shader from a Color4.
  92165. * @param name Define the name of the uniform as defined in the shader
  92166. * @param value Define the value to give to the uniform
  92167. * @return the texture itself allowing "fluent" like uniform updates
  92168. */
  92169. setColor4(name: string, value: Color4): ProceduralTexture;
  92170. /**
  92171. * Set a vec2 in the shader from a Vector2.
  92172. * @param name Define the name of the uniform as defined in the shader
  92173. * @param value Define the value to give to the uniform
  92174. * @return the texture itself allowing "fluent" like uniform updates
  92175. */
  92176. setVector2(name: string, value: Vector2): ProceduralTexture;
  92177. /**
  92178. * Set a vec3 in the shader from a Vector3.
  92179. * @param name Define the name of the uniform as defined in the shader
  92180. * @param value Define the value to give to the uniform
  92181. * @return the texture itself allowing "fluent" like uniform updates
  92182. */
  92183. setVector3(name: string, value: Vector3): ProceduralTexture;
  92184. /**
  92185. * Set a mat4 in the shader from a MAtrix.
  92186. * @param name Define the name of the uniform as defined in the shader
  92187. * @param value Define the value to give to the uniform
  92188. * @return the texture itself allowing "fluent" like uniform updates
  92189. */
  92190. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92191. /**
  92192. * Render the texture to its associated render target.
  92193. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92194. */
  92195. render(useCameraPostProcess?: boolean): void;
  92196. /**
  92197. * Clone the texture.
  92198. * @returns the cloned texture
  92199. */
  92200. clone(): ProceduralTexture;
  92201. /**
  92202. * Dispose the texture and release its asoociated resources.
  92203. */
  92204. dispose(): void;
  92205. }
  92206. }
  92207. declare module BABYLON {
  92208. /**
  92209. * This represents the base class for particle system in Babylon.
  92210. * 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.
  92211. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92212. * @example https://doc.babylonjs.com/babylon101/particles
  92213. */
  92214. export class BaseParticleSystem {
  92215. /**
  92216. * Source color is added to the destination color without alpha affecting the result
  92217. */
  92218. static BLENDMODE_ONEONE: number;
  92219. /**
  92220. * Blend current color and particle color using particle’s alpha
  92221. */
  92222. static BLENDMODE_STANDARD: number;
  92223. /**
  92224. * Add current color and particle color multiplied by particle’s alpha
  92225. */
  92226. static BLENDMODE_ADD: number;
  92227. /**
  92228. * Multiply current color with particle color
  92229. */
  92230. static BLENDMODE_MULTIPLY: number;
  92231. /**
  92232. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92233. */
  92234. static BLENDMODE_MULTIPLYADD: number;
  92235. /**
  92236. * List of animations used by the particle system.
  92237. */
  92238. animations: Animation[];
  92239. /**
  92240. * Gets or sets the unique id of the particle system
  92241. */
  92242. uniqueId: number;
  92243. /**
  92244. * The id of the Particle system.
  92245. */
  92246. id: string;
  92247. /**
  92248. * The friendly name of the Particle system.
  92249. */
  92250. name: string;
  92251. /**
  92252. * Snippet ID if the particle system was created from the snippet server
  92253. */
  92254. snippetId: string;
  92255. /**
  92256. * The rendering group used by the Particle system to chose when to render.
  92257. */
  92258. renderingGroupId: number;
  92259. /**
  92260. * The emitter represents the Mesh or position we are attaching the particle system to.
  92261. */
  92262. emitter: Nullable<AbstractMesh | Vector3>;
  92263. /**
  92264. * The maximum number of particles to emit per frame
  92265. */
  92266. emitRate: number;
  92267. /**
  92268. * If you want to launch only a few particles at once, that can be done, as well.
  92269. */
  92270. manualEmitCount: number;
  92271. /**
  92272. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92273. */
  92274. updateSpeed: number;
  92275. /**
  92276. * The amount of time the particle system is running (depends of the overall update speed).
  92277. */
  92278. targetStopDuration: number;
  92279. /**
  92280. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92281. */
  92282. disposeOnStop: boolean;
  92283. /**
  92284. * Minimum power of emitting particles.
  92285. */
  92286. minEmitPower: number;
  92287. /**
  92288. * Maximum power of emitting particles.
  92289. */
  92290. maxEmitPower: number;
  92291. /**
  92292. * Minimum life time of emitting particles.
  92293. */
  92294. minLifeTime: number;
  92295. /**
  92296. * Maximum life time of emitting particles.
  92297. */
  92298. maxLifeTime: number;
  92299. /**
  92300. * Minimum Size of emitting particles.
  92301. */
  92302. minSize: number;
  92303. /**
  92304. * Maximum Size of emitting particles.
  92305. */
  92306. maxSize: number;
  92307. /**
  92308. * Minimum scale of emitting particles on X axis.
  92309. */
  92310. minScaleX: number;
  92311. /**
  92312. * Maximum scale of emitting particles on X axis.
  92313. */
  92314. maxScaleX: number;
  92315. /**
  92316. * Minimum scale of emitting particles on Y axis.
  92317. */
  92318. minScaleY: number;
  92319. /**
  92320. * Maximum scale of emitting particles on Y axis.
  92321. */
  92322. maxScaleY: number;
  92323. /**
  92324. * Gets or sets the minimal initial rotation in radians.
  92325. */
  92326. minInitialRotation: number;
  92327. /**
  92328. * Gets or sets the maximal initial rotation in radians.
  92329. */
  92330. maxInitialRotation: number;
  92331. /**
  92332. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92333. */
  92334. minAngularSpeed: number;
  92335. /**
  92336. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92337. */
  92338. maxAngularSpeed: number;
  92339. /**
  92340. * The texture used to render each particle. (this can be a spritesheet)
  92341. */
  92342. particleTexture: Nullable<BaseTexture>;
  92343. /**
  92344. * The layer mask we are rendering the particles through.
  92345. */
  92346. layerMask: number;
  92347. /**
  92348. * This can help using your own shader to render the particle system.
  92349. * The according effect will be created
  92350. */
  92351. customShader: any;
  92352. /**
  92353. * By default particle system starts as soon as they are created. This prevents the
  92354. * automatic start to happen and let you decide when to start emitting particles.
  92355. */
  92356. preventAutoStart: boolean;
  92357. private _noiseTexture;
  92358. /**
  92359. * Gets or sets a texture used to add random noise to particle positions
  92360. */
  92361. get noiseTexture(): Nullable<ProceduralTexture>;
  92362. set noiseTexture(value: Nullable<ProceduralTexture>);
  92363. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92364. noiseStrength: Vector3;
  92365. /**
  92366. * Callback triggered when the particle animation is ending.
  92367. */
  92368. onAnimationEnd: Nullable<() => void>;
  92369. /**
  92370. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92371. */
  92372. blendMode: number;
  92373. /**
  92374. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92375. * to override the particles.
  92376. */
  92377. forceDepthWrite: boolean;
  92378. /** 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 */
  92379. preWarmCycles: number;
  92380. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92381. preWarmStepOffset: number;
  92382. /**
  92383. * 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)
  92384. */
  92385. spriteCellChangeSpeed: number;
  92386. /**
  92387. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92388. */
  92389. startSpriteCellID: number;
  92390. /**
  92391. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92392. */
  92393. endSpriteCellID: number;
  92394. /**
  92395. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92396. */
  92397. spriteCellWidth: number;
  92398. /**
  92399. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92400. */
  92401. spriteCellHeight: number;
  92402. /**
  92403. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92404. */
  92405. spriteRandomStartCell: boolean;
  92406. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92407. translationPivot: Vector2;
  92408. /** @hidden */
  92409. protected _isAnimationSheetEnabled: boolean;
  92410. /**
  92411. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92412. */
  92413. beginAnimationOnStart: boolean;
  92414. /**
  92415. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92416. */
  92417. beginAnimationFrom: number;
  92418. /**
  92419. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92420. */
  92421. beginAnimationTo: number;
  92422. /**
  92423. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92424. */
  92425. beginAnimationLoop: boolean;
  92426. /**
  92427. * Gets or sets a world offset applied to all particles
  92428. */
  92429. worldOffset: Vector3;
  92430. /**
  92431. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92432. */
  92433. get isAnimationSheetEnabled(): boolean;
  92434. set isAnimationSheetEnabled(value: boolean);
  92435. /**
  92436. * Get hosting scene
  92437. * @returns the scene
  92438. */
  92439. getScene(): Nullable<Scene>;
  92440. /**
  92441. * You can use gravity if you want to give an orientation to your particles.
  92442. */
  92443. gravity: Vector3;
  92444. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92445. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92446. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92447. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92448. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92449. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92450. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92451. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92452. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92453. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92454. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92455. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92456. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92457. /**
  92458. * Defines the delay in milliseconds before starting the system (0 by default)
  92459. */
  92460. startDelay: number;
  92461. /**
  92462. * Gets the current list of drag gradients.
  92463. * You must use addDragGradient and removeDragGradient to udpate this list
  92464. * @returns the list of drag gradients
  92465. */
  92466. getDragGradients(): Nullable<Array<FactorGradient>>;
  92467. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92468. limitVelocityDamping: number;
  92469. /**
  92470. * Gets the current list of limit velocity gradients.
  92471. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92472. * @returns the list of limit velocity gradients
  92473. */
  92474. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92475. /**
  92476. * Gets the current list of color gradients.
  92477. * You must use addColorGradient and removeColorGradient to udpate this list
  92478. * @returns the list of color gradients
  92479. */
  92480. getColorGradients(): Nullable<Array<ColorGradient>>;
  92481. /**
  92482. * Gets the current list of size gradients.
  92483. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92484. * @returns the list of size gradients
  92485. */
  92486. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92487. /**
  92488. * Gets the current list of color remap gradients.
  92489. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92490. * @returns the list of color remap gradients
  92491. */
  92492. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92493. /**
  92494. * Gets the current list of alpha remap gradients.
  92495. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92496. * @returns the list of alpha remap gradients
  92497. */
  92498. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92499. /**
  92500. * Gets the current list of life time gradients.
  92501. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92502. * @returns the list of life time gradients
  92503. */
  92504. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92505. /**
  92506. * Gets the current list of angular speed gradients.
  92507. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92508. * @returns the list of angular speed gradients
  92509. */
  92510. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92511. /**
  92512. * Gets the current list of velocity gradients.
  92513. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92514. * @returns the list of velocity gradients
  92515. */
  92516. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92517. /**
  92518. * Gets the current list of start size gradients.
  92519. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92520. * @returns the list of start size gradients
  92521. */
  92522. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92523. /**
  92524. * Gets the current list of emit rate gradients.
  92525. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92526. * @returns the list of emit rate gradients
  92527. */
  92528. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92529. /**
  92530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92532. */
  92533. get direction1(): Vector3;
  92534. set direction1(value: Vector3);
  92535. /**
  92536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92537. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92538. */
  92539. get direction2(): Vector3;
  92540. set direction2(value: Vector3);
  92541. /**
  92542. * 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.
  92543. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92544. */
  92545. get minEmitBox(): Vector3;
  92546. set minEmitBox(value: Vector3);
  92547. /**
  92548. * 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.
  92549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92550. */
  92551. get maxEmitBox(): Vector3;
  92552. set maxEmitBox(value: Vector3);
  92553. /**
  92554. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92555. */
  92556. color1: Color4;
  92557. /**
  92558. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92559. */
  92560. color2: Color4;
  92561. /**
  92562. * Color the particle will have at the end of its lifetime
  92563. */
  92564. colorDead: Color4;
  92565. /**
  92566. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92567. */
  92568. textureMask: Color4;
  92569. /**
  92570. * The particle emitter type defines the emitter used by the particle system.
  92571. * It can be for example box, sphere, or cone...
  92572. */
  92573. particleEmitterType: IParticleEmitterType;
  92574. /** @hidden */
  92575. _isSubEmitter: boolean;
  92576. /**
  92577. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92578. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92579. */
  92580. billboardMode: number;
  92581. protected _isBillboardBased: boolean;
  92582. /**
  92583. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92584. */
  92585. get isBillboardBased(): boolean;
  92586. set isBillboardBased(value: boolean);
  92587. /**
  92588. * The scene the particle system belongs to.
  92589. */
  92590. protected _scene: Nullable<Scene>;
  92591. /**
  92592. * The engine the particle system belongs to.
  92593. */
  92594. protected _engine: ThinEngine;
  92595. /**
  92596. * Local cache of defines for image processing.
  92597. */
  92598. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92599. /**
  92600. * Default configuration related to image processing available in the standard Material.
  92601. */
  92602. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92603. /**
  92604. * Gets the image processing configuration used either in this material.
  92605. */
  92606. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92607. /**
  92608. * Sets the Default image processing configuration used either in the this material.
  92609. *
  92610. * If sets to null, the scene one is in use.
  92611. */
  92612. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92613. /**
  92614. * Attaches a new image processing configuration to the Standard Material.
  92615. * @param configuration
  92616. */
  92617. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92618. /** @hidden */
  92619. protected _reset(): void;
  92620. /** @hidden */
  92621. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92622. /**
  92623. * Instantiates a particle system.
  92624. * 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.
  92625. * @param name The name of the particle system
  92626. */
  92627. constructor(name: string);
  92628. /**
  92629. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92632. * @returns the emitter
  92633. */
  92634. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92635. /**
  92636. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92637. * @param radius The radius of the hemisphere to emit from
  92638. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92639. * @returns the emitter
  92640. */
  92641. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92642. /**
  92643. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92644. * @param radius The radius of the sphere to emit from
  92645. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92646. * @returns the emitter
  92647. */
  92648. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92649. /**
  92650. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92651. * @param radius The radius of the sphere to emit from
  92652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92654. * @returns the emitter
  92655. */
  92656. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92657. /**
  92658. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92659. * @param radius The radius of the emission cylinder
  92660. * @param height The height of the emission cylinder
  92661. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92662. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92663. * @returns the emitter
  92664. */
  92665. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92666. /**
  92667. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92668. * @param radius The radius of the cylinder to emit from
  92669. * @param height The height of the emission cylinder
  92670. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92673. * @returns the emitter
  92674. */
  92675. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92676. /**
  92677. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92678. * @param radius The radius of the cone to emit from
  92679. * @param angle The base angle of the cone
  92680. * @returns the emitter
  92681. */
  92682. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92683. /**
  92684. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92687. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92688. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92689. * @returns the emitter
  92690. */
  92691. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92692. }
  92693. }
  92694. declare module BABYLON {
  92695. /**
  92696. * Type of sub emitter
  92697. */
  92698. export enum SubEmitterType {
  92699. /**
  92700. * Attached to the particle over it's lifetime
  92701. */
  92702. ATTACHED = 0,
  92703. /**
  92704. * Created when the particle dies
  92705. */
  92706. END = 1
  92707. }
  92708. /**
  92709. * Sub emitter class used to emit particles from an existing particle
  92710. */
  92711. export class SubEmitter {
  92712. /**
  92713. * the particle system to be used by the sub emitter
  92714. */
  92715. particleSystem: ParticleSystem;
  92716. /**
  92717. * Type of the submitter (Default: END)
  92718. */
  92719. type: SubEmitterType;
  92720. /**
  92721. * 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)
  92722. * Note: This only is supported when using an emitter of type Mesh
  92723. */
  92724. inheritDirection: boolean;
  92725. /**
  92726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92727. */
  92728. inheritedVelocityAmount: number;
  92729. /**
  92730. * Creates a sub emitter
  92731. * @param particleSystem the particle system to be used by the sub emitter
  92732. */
  92733. constructor(
  92734. /**
  92735. * the particle system to be used by the sub emitter
  92736. */
  92737. particleSystem: ParticleSystem);
  92738. /**
  92739. * Clones the sub emitter
  92740. * @returns the cloned sub emitter
  92741. */
  92742. clone(): SubEmitter;
  92743. /**
  92744. * Serialize current object to a JSON object
  92745. * @returns the serialized object
  92746. */
  92747. serialize(): any;
  92748. /** @hidden */
  92749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92750. /**
  92751. * Creates a new SubEmitter from a serialized JSON version
  92752. * @param serializationObject defines the JSON object to read from
  92753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92754. * @param rootUrl defines the rootUrl for data loading
  92755. * @returns a new SubEmitter
  92756. */
  92757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92758. /** Release associated resources */
  92759. dispose(): void;
  92760. }
  92761. }
  92762. declare module BABYLON {
  92763. /** @hidden */
  92764. export var imageProcessingDeclaration: {
  92765. name: string;
  92766. shader: string;
  92767. };
  92768. }
  92769. declare module BABYLON {
  92770. /** @hidden */
  92771. export var imageProcessingFunctions: {
  92772. name: string;
  92773. shader: string;
  92774. };
  92775. }
  92776. declare module BABYLON {
  92777. /** @hidden */
  92778. export var particlesPixelShader: {
  92779. name: string;
  92780. shader: string;
  92781. };
  92782. }
  92783. declare module BABYLON {
  92784. /** @hidden */
  92785. export var particlesVertexShader: {
  92786. name: string;
  92787. shader: string;
  92788. };
  92789. }
  92790. declare module BABYLON {
  92791. /**
  92792. * Interface used to define entities containing multiple clip planes
  92793. */
  92794. export interface IClipPlanesHolder {
  92795. /**
  92796. * Gets or sets the active clipplane 1
  92797. */
  92798. clipPlane: Nullable<Plane>;
  92799. /**
  92800. * Gets or sets the active clipplane 2
  92801. */
  92802. clipPlane2: Nullable<Plane>;
  92803. /**
  92804. * Gets or sets the active clipplane 3
  92805. */
  92806. clipPlane3: Nullable<Plane>;
  92807. /**
  92808. * Gets or sets the active clipplane 4
  92809. */
  92810. clipPlane4: Nullable<Plane>;
  92811. /**
  92812. * Gets or sets the active clipplane 5
  92813. */
  92814. clipPlane5: Nullable<Plane>;
  92815. /**
  92816. * Gets or sets the active clipplane 6
  92817. */
  92818. clipPlane6: Nullable<Plane>;
  92819. }
  92820. }
  92821. declare module BABYLON {
  92822. /**
  92823. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92824. *
  92825. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92826. *
  92827. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92828. */
  92829. export class ThinMaterialHelper {
  92830. /**
  92831. * Binds the clip plane information from the holder to the effect.
  92832. * @param effect The effect we are binding the data to
  92833. * @param holder The entity containing the clip plane information
  92834. */
  92835. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92836. }
  92837. }
  92838. declare module BABYLON {
  92839. interface ThinEngine {
  92840. /**
  92841. * Sets alpha constants used by some alpha blending modes
  92842. * @param r defines the red component
  92843. * @param g defines the green component
  92844. * @param b defines the blue component
  92845. * @param a defines the alpha component
  92846. */
  92847. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92848. /**
  92849. * Sets the current alpha mode
  92850. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92851. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92852. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92853. */
  92854. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92855. /**
  92856. * Gets the current alpha mode
  92857. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92858. * @returns the current alpha mode
  92859. */
  92860. getAlphaMode(): number;
  92861. /**
  92862. * Sets the current alpha equation
  92863. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92864. */
  92865. setAlphaEquation(equation: number): void;
  92866. /**
  92867. * Gets the current alpha equation.
  92868. * @returns the current alpha equation
  92869. */
  92870. getAlphaEquation(): number;
  92871. }
  92872. }
  92873. declare module BABYLON {
  92874. /**
  92875. * This represents a particle system in Babylon.
  92876. * 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.
  92877. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92878. * @example https://doc.babylonjs.com/babylon101/particles
  92879. */
  92880. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92881. /**
  92882. * Billboard mode will only apply to Y axis
  92883. */
  92884. static readonly BILLBOARDMODE_Y: number;
  92885. /**
  92886. * Billboard mode will apply to all axes
  92887. */
  92888. static readonly BILLBOARDMODE_ALL: number;
  92889. /**
  92890. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92891. */
  92892. static readonly BILLBOARDMODE_STRETCHED: number;
  92893. /**
  92894. * This function can be defined to provide custom update for active particles.
  92895. * This function will be called instead of regular update (age, position, color, etc.).
  92896. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92897. */
  92898. updateFunction: (particles: Particle[]) => void;
  92899. private _emitterWorldMatrix;
  92900. /**
  92901. * This function can be defined to specify initial direction for every new particle.
  92902. * It by default use the emitterType defined function
  92903. */
  92904. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92905. /**
  92906. * This function can be defined to specify initial position for every new particle.
  92907. * It by default use the emitterType defined function
  92908. */
  92909. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92910. /**
  92911. * @hidden
  92912. */
  92913. _inheritedVelocityOffset: Vector3;
  92914. /**
  92915. * An event triggered when the system is disposed
  92916. */
  92917. onDisposeObservable: Observable<IParticleSystem>;
  92918. private _onDisposeObserver;
  92919. /**
  92920. * Sets a callback that will be triggered when the system is disposed
  92921. */
  92922. set onDispose(callback: () => void);
  92923. private _particles;
  92924. private _epsilon;
  92925. private _capacity;
  92926. private _stockParticles;
  92927. private _newPartsExcess;
  92928. private _vertexData;
  92929. private _vertexBuffer;
  92930. private _vertexBuffers;
  92931. private _spriteBuffer;
  92932. private _indexBuffer;
  92933. private _effect;
  92934. private _customEffect;
  92935. private _cachedDefines;
  92936. private _scaledColorStep;
  92937. private _colorDiff;
  92938. private _scaledDirection;
  92939. private _scaledGravity;
  92940. private _currentRenderId;
  92941. private _alive;
  92942. private _useInstancing;
  92943. private _started;
  92944. private _stopped;
  92945. private _actualFrame;
  92946. private _scaledUpdateSpeed;
  92947. private _vertexBufferSize;
  92948. /** @hidden */
  92949. _currentEmitRateGradient: Nullable<FactorGradient>;
  92950. /** @hidden */
  92951. _currentEmitRate1: number;
  92952. /** @hidden */
  92953. _currentEmitRate2: number;
  92954. /** @hidden */
  92955. _currentStartSizeGradient: Nullable<FactorGradient>;
  92956. /** @hidden */
  92957. _currentStartSize1: number;
  92958. /** @hidden */
  92959. _currentStartSize2: number;
  92960. private readonly _rawTextureWidth;
  92961. private _rampGradientsTexture;
  92962. private _useRampGradients;
  92963. /** Gets or sets a matrix to use to compute projection */
  92964. defaultProjectionMatrix: Matrix;
  92965. /** Gets or sets a matrix to use to compute view */
  92966. defaultViewMatrix: Matrix;
  92967. /** Gets or sets a boolean indicating that ramp gradients must be used
  92968. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92969. */
  92970. get useRampGradients(): boolean;
  92971. set useRampGradients(value: boolean);
  92972. /**
  92973. * 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.
  92974. * 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: [])
  92975. */
  92976. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92977. private _subEmitters;
  92978. /**
  92979. * @hidden
  92980. * If the particle systems emitter should be disposed when the particle system is disposed
  92981. */
  92982. _disposeEmitterOnDispose: boolean;
  92983. /**
  92984. * The current active Sub-systems, this property is used by the root particle system only.
  92985. */
  92986. activeSubSystems: Array<ParticleSystem>;
  92987. /**
  92988. * Specifies if the particles are updated in emitter local space or world space
  92989. */
  92990. isLocal: boolean;
  92991. private _rootParticleSystem;
  92992. /**
  92993. * Gets the current list of active particles
  92994. */
  92995. get particles(): Particle[];
  92996. /**
  92997. * Gets the number of particles active at the same time.
  92998. * @returns The number of active particles.
  92999. */
  93000. getActiveCount(): number;
  93001. /**
  93002. * Returns the string "ParticleSystem"
  93003. * @returns a string containing the class name
  93004. */
  93005. getClassName(): string;
  93006. /**
  93007. * Gets a boolean indicating that the system is stopping
  93008. * @returns true if the system is currently stopping
  93009. */
  93010. isStopping(): boolean;
  93011. /**
  93012. * Gets the custom effect used to render the particles
  93013. * @param blendMode Blend mode for which the effect should be retrieved
  93014. * @returns The effect
  93015. */
  93016. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93017. /**
  93018. * Sets the custom effect used to render the particles
  93019. * @param effect The effect to set
  93020. * @param blendMode Blend mode for which the effect should be set
  93021. */
  93022. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93023. /** @hidden */
  93024. private _onBeforeDrawParticlesObservable;
  93025. /**
  93026. * Observable that will be called just before the particles are drawn
  93027. */
  93028. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93029. /**
  93030. * Gets the name of the particle vertex shader
  93031. */
  93032. get vertexShaderName(): string;
  93033. /**
  93034. * Instantiates a particle system.
  93035. * 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.
  93036. * @param name The name of the particle system
  93037. * @param capacity The max number of particles alive at the same time
  93038. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93039. * @param customEffect a custom effect used to change the way particles are rendered by default
  93040. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93041. * @param epsilon Offset used to render the particles
  93042. */
  93043. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93044. private _addFactorGradient;
  93045. private _removeFactorGradient;
  93046. /**
  93047. * Adds a new life time gradient
  93048. * @param gradient defines the gradient to use (between 0 and 1)
  93049. * @param factor defines the life time factor to affect to the specified gradient
  93050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93051. * @returns the current particle system
  93052. */
  93053. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93054. /**
  93055. * Remove a specific life time gradient
  93056. * @param gradient defines the gradient to remove
  93057. * @returns the current particle system
  93058. */
  93059. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93060. /**
  93061. * Adds a new size gradient
  93062. * @param gradient defines the gradient to use (between 0 and 1)
  93063. * @param factor defines the size factor to affect to the specified gradient
  93064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93065. * @returns the current particle system
  93066. */
  93067. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93068. /**
  93069. * Remove a specific size gradient
  93070. * @param gradient defines the gradient to remove
  93071. * @returns the current particle system
  93072. */
  93073. removeSizeGradient(gradient: number): IParticleSystem;
  93074. /**
  93075. * Adds a new color remap gradient
  93076. * @param gradient defines the gradient to use (between 0 and 1)
  93077. * @param min defines the color remap minimal range
  93078. * @param max defines the color remap maximal range
  93079. * @returns the current particle system
  93080. */
  93081. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93082. /**
  93083. * Remove a specific color remap gradient
  93084. * @param gradient defines the gradient to remove
  93085. * @returns the current particle system
  93086. */
  93087. removeColorRemapGradient(gradient: number): IParticleSystem;
  93088. /**
  93089. * Adds a new alpha remap gradient
  93090. * @param gradient defines the gradient to use (between 0 and 1)
  93091. * @param min defines the alpha remap minimal range
  93092. * @param max defines the alpha remap maximal range
  93093. * @returns the current particle system
  93094. */
  93095. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93096. /**
  93097. * Remove a specific alpha remap gradient
  93098. * @param gradient defines the gradient to remove
  93099. * @returns the current particle system
  93100. */
  93101. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93102. /**
  93103. * Adds a new angular speed gradient
  93104. * @param gradient defines the gradient to use (between 0 and 1)
  93105. * @param factor defines the angular speed to affect to the specified gradient
  93106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93107. * @returns the current particle system
  93108. */
  93109. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93110. /**
  93111. * Remove a specific angular speed gradient
  93112. * @param gradient defines the gradient to remove
  93113. * @returns the current particle system
  93114. */
  93115. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93116. /**
  93117. * Adds a new velocity gradient
  93118. * @param gradient defines the gradient to use (between 0 and 1)
  93119. * @param factor defines the velocity to affect to the specified gradient
  93120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93121. * @returns the current particle system
  93122. */
  93123. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93124. /**
  93125. * Remove a specific velocity gradient
  93126. * @param gradient defines the gradient to remove
  93127. * @returns the current particle system
  93128. */
  93129. removeVelocityGradient(gradient: number): IParticleSystem;
  93130. /**
  93131. * Adds a new limit velocity gradient
  93132. * @param gradient defines the gradient to use (between 0 and 1)
  93133. * @param factor defines the limit velocity value to affect to the specified gradient
  93134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93135. * @returns the current particle system
  93136. */
  93137. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93138. /**
  93139. * Remove a specific limit velocity gradient
  93140. * @param gradient defines the gradient to remove
  93141. * @returns the current particle system
  93142. */
  93143. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93144. /**
  93145. * Adds a new drag gradient
  93146. * @param gradient defines the gradient to use (between 0 and 1)
  93147. * @param factor defines the drag value to affect to the specified gradient
  93148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93149. * @returns the current particle system
  93150. */
  93151. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93152. /**
  93153. * Remove a specific drag gradient
  93154. * @param gradient defines the gradient to remove
  93155. * @returns the current particle system
  93156. */
  93157. removeDragGradient(gradient: number): IParticleSystem;
  93158. /**
  93159. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93160. * @param gradient defines the gradient to use (between 0 and 1)
  93161. * @param factor defines the emit rate value to affect to the specified gradient
  93162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93163. * @returns the current particle system
  93164. */
  93165. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93166. /**
  93167. * Remove a specific emit rate gradient
  93168. * @param gradient defines the gradient to remove
  93169. * @returns the current particle system
  93170. */
  93171. removeEmitRateGradient(gradient: number): IParticleSystem;
  93172. /**
  93173. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93174. * @param gradient defines the gradient to use (between 0 and 1)
  93175. * @param factor defines the start size value to affect to the specified gradient
  93176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93177. * @returns the current particle system
  93178. */
  93179. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93180. /**
  93181. * Remove a specific start size gradient
  93182. * @param gradient defines the gradient to remove
  93183. * @returns the current particle system
  93184. */
  93185. removeStartSizeGradient(gradient: number): IParticleSystem;
  93186. private _createRampGradientTexture;
  93187. /**
  93188. * Gets the current list of ramp gradients.
  93189. * You must use addRampGradient and removeRampGradient to udpate this list
  93190. * @returns the list of ramp gradients
  93191. */
  93192. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93193. /** Force the system to rebuild all gradients that need to be resync */
  93194. forceRefreshGradients(): void;
  93195. private _syncRampGradientTexture;
  93196. /**
  93197. * Adds a new ramp gradient used to remap particle colors
  93198. * @param gradient defines the gradient to use (between 0 and 1)
  93199. * @param color defines the color to affect to the specified gradient
  93200. * @returns the current particle system
  93201. */
  93202. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93203. /**
  93204. * Remove a specific ramp gradient
  93205. * @param gradient defines the gradient to remove
  93206. * @returns the current particle system
  93207. */
  93208. removeRampGradient(gradient: number): ParticleSystem;
  93209. /**
  93210. * Adds a new color gradient
  93211. * @param gradient defines the gradient to use (between 0 and 1)
  93212. * @param color1 defines the color to affect to the specified gradient
  93213. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93214. * @returns this particle system
  93215. */
  93216. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93217. /**
  93218. * Remove a specific color gradient
  93219. * @param gradient defines the gradient to remove
  93220. * @returns this particle system
  93221. */
  93222. removeColorGradient(gradient: number): IParticleSystem;
  93223. private _fetchR;
  93224. protected _reset(): void;
  93225. private _resetEffect;
  93226. private _createVertexBuffers;
  93227. private _createIndexBuffer;
  93228. /**
  93229. * Gets the maximum number of particles active at the same time.
  93230. * @returns The max number of active particles.
  93231. */
  93232. getCapacity(): number;
  93233. /**
  93234. * Gets whether there are still active particles in the system.
  93235. * @returns True if it is alive, otherwise false.
  93236. */
  93237. isAlive(): boolean;
  93238. /**
  93239. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93240. * @returns True if it has been started, otherwise false.
  93241. */
  93242. isStarted(): boolean;
  93243. private _prepareSubEmitterInternalArray;
  93244. /**
  93245. * Starts the particle system and begins to emit
  93246. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93247. */
  93248. start(delay?: number): void;
  93249. /**
  93250. * Stops the particle system.
  93251. * @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.
  93252. */
  93253. stop(stopSubEmitters?: boolean): void;
  93254. /**
  93255. * Remove all active particles
  93256. */
  93257. reset(): void;
  93258. /**
  93259. * @hidden (for internal use only)
  93260. */
  93261. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93262. /**
  93263. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93264. * Its lifetime will start back at 0.
  93265. */
  93266. recycleParticle: (particle: Particle) => void;
  93267. private _stopSubEmitters;
  93268. private _createParticle;
  93269. private _removeFromRoot;
  93270. private _emitFromParticle;
  93271. private _update;
  93272. /** @hidden */
  93273. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93274. /** @hidden */
  93275. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93276. /**
  93277. * Fill the defines array according to the current settings of the particle system
  93278. * @param defines Array to be updated
  93279. * @param blendMode blend mode to take into account when updating the array
  93280. */
  93281. fillDefines(defines: Array<string>, blendMode: number): void;
  93282. /**
  93283. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93284. * @param uniforms Uniforms array to fill
  93285. * @param attributes Attributes array to fill
  93286. * @param samplers Samplers array to fill
  93287. */
  93288. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93289. /** @hidden */
  93290. private _getEffect;
  93291. /**
  93292. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93293. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93294. */
  93295. animate(preWarmOnly?: boolean): void;
  93296. private _appendParticleVertices;
  93297. /**
  93298. * Rebuilds the particle system.
  93299. */
  93300. rebuild(): void;
  93301. /**
  93302. * Is this system ready to be used/rendered
  93303. * @return true if the system is ready
  93304. */
  93305. isReady(): boolean;
  93306. private _render;
  93307. /**
  93308. * Renders the particle system in its current state.
  93309. * @returns the current number of particles
  93310. */
  93311. render(): number;
  93312. /**
  93313. * Disposes the particle system and free the associated resources
  93314. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93315. */
  93316. dispose(disposeTexture?: boolean): void;
  93317. /**
  93318. * Clones the particle system.
  93319. * @param name The name of the cloned object
  93320. * @param newEmitter The new emitter to use
  93321. * @returns the cloned particle system
  93322. */
  93323. clone(name: string, newEmitter: any): ParticleSystem;
  93324. /**
  93325. * Serializes the particle system to a JSON object
  93326. * @param serializeTexture defines if the texture must be serialized as well
  93327. * @returns the JSON object
  93328. */
  93329. serialize(serializeTexture?: boolean): any;
  93330. /** @hidden */
  93331. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93332. /** @hidden */
  93333. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93334. /**
  93335. * Parses a JSON object to create a particle system.
  93336. * @param parsedParticleSystem The JSON object to parse
  93337. * @param sceneOrEngine The scene or the engine to create the particle system in
  93338. * @param rootUrl The root url to use to load external dependencies like texture
  93339. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93340. * @returns the Parsed particle system
  93341. */
  93342. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93343. }
  93344. }
  93345. declare module BABYLON {
  93346. /**
  93347. * A particle represents one of the element emitted by a particle system.
  93348. * This is mainly define by its coordinates, direction, velocity and age.
  93349. */
  93350. export class Particle {
  93351. /**
  93352. * The particle system the particle belongs to.
  93353. */
  93354. particleSystem: ParticleSystem;
  93355. private static _Count;
  93356. /**
  93357. * Unique ID of the particle
  93358. */
  93359. id: number;
  93360. /**
  93361. * The world position of the particle in the scene.
  93362. */
  93363. position: Vector3;
  93364. /**
  93365. * The world direction of the particle in the scene.
  93366. */
  93367. direction: Vector3;
  93368. /**
  93369. * The color of the particle.
  93370. */
  93371. color: Color4;
  93372. /**
  93373. * The color change of the particle per step.
  93374. */
  93375. colorStep: Color4;
  93376. /**
  93377. * Defines how long will the life of the particle be.
  93378. */
  93379. lifeTime: number;
  93380. /**
  93381. * The current age of the particle.
  93382. */
  93383. age: number;
  93384. /**
  93385. * The current size of the particle.
  93386. */
  93387. size: number;
  93388. /**
  93389. * The current scale of the particle.
  93390. */
  93391. scale: Vector2;
  93392. /**
  93393. * The current angle of the particle.
  93394. */
  93395. angle: number;
  93396. /**
  93397. * Defines how fast is the angle changing.
  93398. */
  93399. angularSpeed: number;
  93400. /**
  93401. * Defines the cell index used by the particle to be rendered from a sprite.
  93402. */
  93403. cellIndex: number;
  93404. /**
  93405. * The information required to support color remapping
  93406. */
  93407. remapData: Vector4;
  93408. /** @hidden */
  93409. _randomCellOffset?: number;
  93410. /** @hidden */
  93411. _initialDirection: Nullable<Vector3>;
  93412. /** @hidden */
  93413. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93414. /** @hidden */
  93415. _initialStartSpriteCellID: number;
  93416. /** @hidden */
  93417. _initialEndSpriteCellID: number;
  93418. /** @hidden */
  93419. _currentColorGradient: Nullable<ColorGradient>;
  93420. /** @hidden */
  93421. _currentColor1: Color4;
  93422. /** @hidden */
  93423. _currentColor2: Color4;
  93424. /** @hidden */
  93425. _currentSizeGradient: Nullable<FactorGradient>;
  93426. /** @hidden */
  93427. _currentSize1: number;
  93428. /** @hidden */
  93429. _currentSize2: number;
  93430. /** @hidden */
  93431. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93432. /** @hidden */
  93433. _currentAngularSpeed1: number;
  93434. /** @hidden */
  93435. _currentAngularSpeed2: number;
  93436. /** @hidden */
  93437. _currentVelocityGradient: Nullable<FactorGradient>;
  93438. /** @hidden */
  93439. _currentVelocity1: number;
  93440. /** @hidden */
  93441. _currentVelocity2: number;
  93442. /** @hidden */
  93443. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93444. /** @hidden */
  93445. _currentLimitVelocity1: number;
  93446. /** @hidden */
  93447. _currentLimitVelocity2: number;
  93448. /** @hidden */
  93449. _currentDragGradient: Nullable<FactorGradient>;
  93450. /** @hidden */
  93451. _currentDrag1: number;
  93452. /** @hidden */
  93453. _currentDrag2: number;
  93454. /** @hidden */
  93455. _randomNoiseCoordinates1: Vector3;
  93456. /** @hidden */
  93457. _randomNoiseCoordinates2: Vector3;
  93458. /** @hidden */
  93459. _localPosition?: Vector3;
  93460. /**
  93461. * Creates a new instance Particle
  93462. * @param particleSystem the particle system the particle belongs to
  93463. */
  93464. constructor(
  93465. /**
  93466. * The particle system the particle belongs to.
  93467. */
  93468. particleSystem: ParticleSystem);
  93469. private updateCellInfoFromSystem;
  93470. /**
  93471. * Defines how the sprite cell index is updated for the particle
  93472. */
  93473. updateCellIndex(): void;
  93474. /** @hidden */
  93475. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93476. /** @hidden */
  93477. _inheritParticleInfoToSubEmitters(): void;
  93478. /** @hidden */
  93479. _reset(): void;
  93480. /**
  93481. * Copy the properties of particle to another one.
  93482. * @param other the particle to copy the information to.
  93483. */
  93484. copyTo(other: Particle): void;
  93485. }
  93486. }
  93487. declare module BABYLON {
  93488. /**
  93489. * Particle emitter represents a volume emitting particles.
  93490. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93491. */
  93492. export interface IParticleEmitterType {
  93493. /**
  93494. * Called by the particle System when the direction is computed for the created particle.
  93495. * @param worldMatrix is the world matrix of the particle system
  93496. * @param directionToUpdate is the direction vector to update with the result
  93497. * @param particle is the particle we are computed the direction for
  93498. * @param isLocal defines if the direction should be set in local space
  93499. */
  93500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93501. /**
  93502. * Called by the particle System when the position is computed for the created particle.
  93503. * @param worldMatrix is the world matrix of the particle system
  93504. * @param positionToUpdate is the position vector to update with the result
  93505. * @param particle is the particle we are computed the position for
  93506. * @param isLocal defines if the position should be set in local space
  93507. */
  93508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93509. /**
  93510. * Clones the current emitter and returns a copy of it
  93511. * @returns the new emitter
  93512. */
  93513. clone(): IParticleEmitterType;
  93514. /**
  93515. * Called by the GPUParticleSystem to setup the update shader
  93516. * @param effect defines the update shader
  93517. */
  93518. applyToShader(effect: Effect): void;
  93519. /**
  93520. * Returns a string to use to update the GPU particles update shader
  93521. * @returns the effect defines string
  93522. */
  93523. getEffectDefines(): string;
  93524. /**
  93525. * Returns a string representing the class name
  93526. * @returns a string containing the class name
  93527. */
  93528. getClassName(): string;
  93529. /**
  93530. * Serializes the particle system to a JSON object.
  93531. * @returns the JSON object
  93532. */
  93533. serialize(): any;
  93534. /**
  93535. * Parse properties from a JSON object
  93536. * @param serializationObject defines the JSON object
  93537. * @param scene defines the hosting scene
  93538. */
  93539. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93540. }
  93541. }
  93542. declare module BABYLON {
  93543. /**
  93544. * Particle emitter emitting particles from the inside of a box.
  93545. * It emits the particles randomly between 2 given directions.
  93546. */
  93547. export class BoxParticleEmitter implements IParticleEmitterType {
  93548. /**
  93549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93550. */
  93551. direction1: Vector3;
  93552. /**
  93553. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93554. */
  93555. direction2: Vector3;
  93556. /**
  93557. * 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.
  93558. */
  93559. minEmitBox: Vector3;
  93560. /**
  93561. * 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.
  93562. */
  93563. maxEmitBox: Vector3;
  93564. /**
  93565. * Creates a new instance BoxParticleEmitter
  93566. */
  93567. constructor();
  93568. /**
  93569. * Called by the particle System when the direction is computed for the created particle.
  93570. * @param worldMatrix is the world matrix of the particle system
  93571. * @param directionToUpdate is the direction vector to update with the result
  93572. * @param particle is the particle we are computed the direction for
  93573. * @param isLocal defines if the direction should be set in local space
  93574. */
  93575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93576. /**
  93577. * Called by the particle System when the position is computed for the created particle.
  93578. * @param worldMatrix is the world matrix of the particle system
  93579. * @param positionToUpdate is the position vector to update with the result
  93580. * @param particle is the particle we are computed the position for
  93581. * @param isLocal defines if the position should be set in local space
  93582. */
  93583. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93584. /**
  93585. * Clones the current emitter and returns a copy of it
  93586. * @returns the new emitter
  93587. */
  93588. clone(): BoxParticleEmitter;
  93589. /**
  93590. * Called by the GPUParticleSystem to setup the update shader
  93591. * @param effect defines the update shader
  93592. */
  93593. applyToShader(effect: Effect): void;
  93594. /**
  93595. * Returns a string to use to update the GPU particles update shader
  93596. * @returns a string containng the defines string
  93597. */
  93598. getEffectDefines(): string;
  93599. /**
  93600. * Returns the string "BoxParticleEmitter"
  93601. * @returns a string containing the class name
  93602. */
  93603. getClassName(): string;
  93604. /**
  93605. * Serializes the particle system to a JSON object.
  93606. * @returns the JSON object
  93607. */
  93608. serialize(): any;
  93609. /**
  93610. * Parse properties from a JSON object
  93611. * @param serializationObject defines the JSON object
  93612. */
  93613. parse(serializationObject: any): void;
  93614. }
  93615. }
  93616. declare module BABYLON {
  93617. /**
  93618. * Particle emitter emitting particles from the inside of a cone.
  93619. * It emits the particles alongside the cone volume from the base to the particle.
  93620. * The emission direction might be randomized.
  93621. */
  93622. export class ConeParticleEmitter implements IParticleEmitterType {
  93623. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93624. directionRandomizer: number;
  93625. private _radius;
  93626. private _angle;
  93627. private _height;
  93628. /**
  93629. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93630. */
  93631. radiusRange: number;
  93632. /**
  93633. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93634. */
  93635. heightRange: number;
  93636. /**
  93637. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93638. */
  93639. emitFromSpawnPointOnly: boolean;
  93640. /**
  93641. * Gets or sets the radius of the emission cone
  93642. */
  93643. get radius(): number;
  93644. set radius(value: number);
  93645. /**
  93646. * Gets or sets the angle of the emission cone
  93647. */
  93648. get angle(): number;
  93649. set angle(value: number);
  93650. private _buildHeight;
  93651. /**
  93652. * Creates a new instance ConeParticleEmitter
  93653. * @param radius the radius of the emission cone (1 by default)
  93654. * @param angle the cone base angle (PI by default)
  93655. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93656. */
  93657. constructor(radius?: number, angle?: number,
  93658. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93659. directionRandomizer?: number);
  93660. /**
  93661. * Called by the particle System when the direction is computed for the created particle.
  93662. * @param worldMatrix is the world matrix of the particle system
  93663. * @param directionToUpdate is the direction vector to update with the result
  93664. * @param particle is the particle we are computed the direction for
  93665. * @param isLocal defines if the direction should be set in local space
  93666. */
  93667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93668. /**
  93669. * Called by the particle System when the position is computed for the created particle.
  93670. * @param worldMatrix is the world matrix of the particle system
  93671. * @param positionToUpdate is the position vector to update with the result
  93672. * @param particle is the particle we are computed the position for
  93673. * @param isLocal defines if the position should be set in local space
  93674. */
  93675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93676. /**
  93677. * Clones the current emitter and returns a copy of it
  93678. * @returns the new emitter
  93679. */
  93680. clone(): ConeParticleEmitter;
  93681. /**
  93682. * Called by the GPUParticleSystem to setup the update shader
  93683. * @param effect defines the update shader
  93684. */
  93685. applyToShader(effect: Effect): void;
  93686. /**
  93687. * Returns a string to use to update the GPU particles update shader
  93688. * @returns a string containng the defines string
  93689. */
  93690. getEffectDefines(): string;
  93691. /**
  93692. * Returns the string "ConeParticleEmitter"
  93693. * @returns a string containing the class name
  93694. */
  93695. getClassName(): string;
  93696. /**
  93697. * Serializes the particle system to a JSON object.
  93698. * @returns the JSON object
  93699. */
  93700. serialize(): any;
  93701. /**
  93702. * Parse properties from a JSON object
  93703. * @param serializationObject defines the JSON object
  93704. */
  93705. parse(serializationObject: any): void;
  93706. }
  93707. }
  93708. declare module BABYLON {
  93709. /**
  93710. * Particle emitter emitting particles from the inside of a cylinder.
  93711. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93712. */
  93713. export class CylinderParticleEmitter implements IParticleEmitterType {
  93714. /**
  93715. * The radius of the emission cylinder.
  93716. */
  93717. radius: number;
  93718. /**
  93719. * The height of the emission cylinder.
  93720. */
  93721. height: number;
  93722. /**
  93723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93724. */
  93725. radiusRange: number;
  93726. /**
  93727. * How much to randomize the particle direction [0-1].
  93728. */
  93729. directionRandomizer: number;
  93730. /**
  93731. * Creates a new instance CylinderParticleEmitter
  93732. * @param radius the radius of the emission cylinder (1 by default)
  93733. * @param height the height of the emission cylinder (1 by default)
  93734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93735. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93736. */
  93737. constructor(
  93738. /**
  93739. * The radius of the emission cylinder.
  93740. */
  93741. radius?: number,
  93742. /**
  93743. * The height of the emission cylinder.
  93744. */
  93745. height?: number,
  93746. /**
  93747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93748. */
  93749. radiusRange?: number,
  93750. /**
  93751. * How much to randomize the particle direction [0-1].
  93752. */
  93753. directionRandomizer?: number);
  93754. /**
  93755. * Called by the particle System when the direction is computed for the created particle.
  93756. * @param worldMatrix is the world matrix of the particle system
  93757. * @param directionToUpdate is the direction vector to update with the result
  93758. * @param particle is the particle we are computed the direction for
  93759. * @param isLocal defines if the direction should be set in local space
  93760. */
  93761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93762. /**
  93763. * Called by the particle System when the position is computed for the created particle.
  93764. * @param worldMatrix is the world matrix of the particle system
  93765. * @param positionToUpdate is the position vector to update with the result
  93766. * @param particle is the particle we are computed the position for
  93767. * @param isLocal defines if the position should be set in local space
  93768. */
  93769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93770. /**
  93771. * Clones the current emitter and returns a copy of it
  93772. * @returns the new emitter
  93773. */
  93774. clone(): CylinderParticleEmitter;
  93775. /**
  93776. * Called by the GPUParticleSystem to setup the update shader
  93777. * @param effect defines the update shader
  93778. */
  93779. applyToShader(effect: Effect): void;
  93780. /**
  93781. * Returns a string to use to update the GPU particles update shader
  93782. * @returns a string containng the defines string
  93783. */
  93784. getEffectDefines(): string;
  93785. /**
  93786. * Returns the string "CylinderParticleEmitter"
  93787. * @returns a string containing the class name
  93788. */
  93789. getClassName(): string;
  93790. /**
  93791. * Serializes the particle system to a JSON object.
  93792. * @returns the JSON object
  93793. */
  93794. serialize(): any;
  93795. /**
  93796. * Parse properties from a JSON object
  93797. * @param serializationObject defines the JSON object
  93798. */
  93799. parse(serializationObject: any): void;
  93800. }
  93801. /**
  93802. * Particle emitter emitting particles from the inside of a cylinder.
  93803. * It emits the particles randomly between two vectors.
  93804. */
  93805. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93806. /**
  93807. * The min limit of the emission direction.
  93808. */
  93809. direction1: Vector3;
  93810. /**
  93811. * The max limit of the emission direction.
  93812. */
  93813. direction2: Vector3;
  93814. /**
  93815. * Creates a new instance CylinderDirectedParticleEmitter
  93816. * @param radius the radius of the emission cylinder (1 by default)
  93817. * @param height the height of the emission cylinder (1 by default)
  93818. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93819. * @param direction1 the min limit of the emission direction (up vector by default)
  93820. * @param direction2 the max limit of the emission direction (up vector by default)
  93821. */
  93822. constructor(radius?: number, height?: number, radiusRange?: number,
  93823. /**
  93824. * The min limit of the emission direction.
  93825. */
  93826. direction1?: Vector3,
  93827. /**
  93828. * The max limit of the emission direction.
  93829. */
  93830. direction2?: Vector3);
  93831. /**
  93832. * Called by the particle System when the direction is computed for the created particle.
  93833. * @param worldMatrix is the world matrix of the particle system
  93834. * @param directionToUpdate is the direction vector to update with the result
  93835. * @param particle is the particle we are computed the direction for
  93836. */
  93837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93838. /**
  93839. * Clones the current emitter and returns a copy of it
  93840. * @returns the new emitter
  93841. */
  93842. clone(): CylinderDirectedParticleEmitter;
  93843. /**
  93844. * Called by the GPUParticleSystem to setup the update shader
  93845. * @param effect defines the update shader
  93846. */
  93847. applyToShader(effect: Effect): void;
  93848. /**
  93849. * Returns a string to use to update the GPU particles update shader
  93850. * @returns a string containng the defines string
  93851. */
  93852. getEffectDefines(): string;
  93853. /**
  93854. * Returns the string "CylinderDirectedParticleEmitter"
  93855. * @returns a string containing the class name
  93856. */
  93857. getClassName(): string;
  93858. /**
  93859. * Serializes the particle system to a JSON object.
  93860. * @returns the JSON object
  93861. */
  93862. serialize(): any;
  93863. /**
  93864. * Parse properties from a JSON object
  93865. * @param serializationObject defines the JSON object
  93866. */
  93867. parse(serializationObject: any): void;
  93868. }
  93869. }
  93870. declare module BABYLON {
  93871. /**
  93872. * Particle emitter emitting particles from the inside of a hemisphere.
  93873. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93874. */
  93875. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93876. /**
  93877. * The radius of the emission hemisphere.
  93878. */
  93879. radius: number;
  93880. /**
  93881. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93882. */
  93883. radiusRange: number;
  93884. /**
  93885. * How much to randomize the particle direction [0-1].
  93886. */
  93887. directionRandomizer: number;
  93888. /**
  93889. * Creates a new instance HemisphericParticleEmitter
  93890. * @param radius the radius of the emission hemisphere (1 by default)
  93891. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93893. */
  93894. constructor(
  93895. /**
  93896. * The radius of the emission hemisphere.
  93897. */
  93898. radius?: number,
  93899. /**
  93900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93901. */
  93902. radiusRange?: number,
  93903. /**
  93904. * How much to randomize the particle direction [0-1].
  93905. */
  93906. directionRandomizer?: number);
  93907. /**
  93908. * Called by the particle System when the direction is computed for the created particle.
  93909. * @param worldMatrix is the world matrix of the particle system
  93910. * @param directionToUpdate is the direction vector to update with the result
  93911. * @param particle is the particle we are computed the direction for
  93912. * @param isLocal defines if the direction should be set in local space
  93913. */
  93914. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93915. /**
  93916. * Called by the particle System when the position is computed for the created particle.
  93917. * @param worldMatrix is the world matrix of the particle system
  93918. * @param positionToUpdate is the position vector to update with the result
  93919. * @param particle is the particle we are computed the position for
  93920. * @param isLocal defines if the position should be set in local space
  93921. */
  93922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93923. /**
  93924. * Clones the current emitter and returns a copy of it
  93925. * @returns the new emitter
  93926. */
  93927. clone(): HemisphericParticleEmitter;
  93928. /**
  93929. * Called by the GPUParticleSystem to setup the update shader
  93930. * @param effect defines the update shader
  93931. */
  93932. applyToShader(effect: Effect): void;
  93933. /**
  93934. * Returns a string to use to update the GPU particles update shader
  93935. * @returns a string containng the defines string
  93936. */
  93937. getEffectDefines(): string;
  93938. /**
  93939. * Returns the string "HemisphericParticleEmitter"
  93940. * @returns a string containing the class name
  93941. */
  93942. getClassName(): string;
  93943. /**
  93944. * Serializes the particle system to a JSON object.
  93945. * @returns the JSON object
  93946. */
  93947. serialize(): any;
  93948. /**
  93949. * Parse properties from a JSON object
  93950. * @param serializationObject defines the JSON object
  93951. */
  93952. parse(serializationObject: any): void;
  93953. }
  93954. }
  93955. declare module BABYLON {
  93956. /**
  93957. * Particle emitter emitting particles from a point.
  93958. * It emits the particles randomly between 2 given directions.
  93959. */
  93960. export class PointParticleEmitter implements IParticleEmitterType {
  93961. /**
  93962. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93963. */
  93964. direction1: Vector3;
  93965. /**
  93966. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93967. */
  93968. direction2: Vector3;
  93969. /**
  93970. * Creates a new instance PointParticleEmitter
  93971. */
  93972. constructor();
  93973. /**
  93974. * Called by the particle System when the direction is computed for the created particle.
  93975. * @param worldMatrix is the world matrix of the particle system
  93976. * @param directionToUpdate is the direction vector to update with the result
  93977. * @param particle is the particle we are computed the direction for
  93978. * @param isLocal defines if the direction should be set in local space
  93979. */
  93980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93981. /**
  93982. * Called by the particle System when the position is computed for the created particle.
  93983. * @param worldMatrix is the world matrix of the particle system
  93984. * @param positionToUpdate is the position vector to update with the result
  93985. * @param particle is the particle we are computed the position for
  93986. * @param isLocal defines if the position should be set in local space
  93987. */
  93988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93989. /**
  93990. * Clones the current emitter and returns a copy of it
  93991. * @returns the new emitter
  93992. */
  93993. clone(): PointParticleEmitter;
  93994. /**
  93995. * Called by the GPUParticleSystem to setup the update shader
  93996. * @param effect defines the update shader
  93997. */
  93998. applyToShader(effect: Effect): void;
  93999. /**
  94000. * Returns a string to use to update the GPU particles update shader
  94001. * @returns a string containng the defines string
  94002. */
  94003. getEffectDefines(): string;
  94004. /**
  94005. * Returns the string "PointParticleEmitter"
  94006. * @returns a string containing the class name
  94007. */
  94008. getClassName(): string;
  94009. /**
  94010. * Serializes the particle system to a JSON object.
  94011. * @returns the JSON object
  94012. */
  94013. serialize(): any;
  94014. /**
  94015. * Parse properties from a JSON object
  94016. * @param serializationObject defines the JSON object
  94017. */
  94018. parse(serializationObject: any): void;
  94019. }
  94020. }
  94021. declare module BABYLON {
  94022. /**
  94023. * Particle emitter emitting particles from the inside of a sphere.
  94024. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94025. */
  94026. export class SphereParticleEmitter implements IParticleEmitterType {
  94027. /**
  94028. * The radius of the emission sphere.
  94029. */
  94030. radius: number;
  94031. /**
  94032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94033. */
  94034. radiusRange: number;
  94035. /**
  94036. * How much to randomize the particle direction [0-1].
  94037. */
  94038. directionRandomizer: number;
  94039. /**
  94040. * Creates a new instance SphereParticleEmitter
  94041. * @param radius the radius of the emission sphere (1 by default)
  94042. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94043. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94044. */
  94045. constructor(
  94046. /**
  94047. * The radius of the emission sphere.
  94048. */
  94049. radius?: number,
  94050. /**
  94051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94052. */
  94053. radiusRange?: number,
  94054. /**
  94055. * How much to randomize the particle direction [0-1].
  94056. */
  94057. directionRandomizer?: number);
  94058. /**
  94059. * Called by the particle System when the direction is computed for the created particle.
  94060. * @param worldMatrix is the world matrix of the particle system
  94061. * @param directionToUpdate is the direction vector to update with the result
  94062. * @param particle is the particle we are computed the direction for
  94063. * @param isLocal defines if the direction should be set in local space
  94064. */
  94065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94066. /**
  94067. * Called by the particle System when the position is computed for the created particle.
  94068. * @param worldMatrix is the world matrix of the particle system
  94069. * @param positionToUpdate is the position vector to update with the result
  94070. * @param particle is the particle we are computed the position for
  94071. * @param isLocal defines if the position should be set in local space
  94072. */
  94073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94074. /**
  94075. * Clones the current emitter and returns a copy of it
  94076. * @returns the new emitter
  94077. */
  94078. clone(): SphereParticleEmitter;
  94079. /**
  94080. * Called by the GPUParticleSystem to setup the update shader
  94081. * @param effect defines the update shader
  94082. */
  94083. applyToShader(effect: Effect): void;
  94084. /**
  94085. * Returns a string to use to update the GPU particles update shader
  94086. * @returns a string containng the defines string
  94087. */
  94088. getEffectDefines(): string;
  94089. /**
  94090. * Returns the string "SphereParticleEmitter"
  94091. * @returns a string containing the class name
  94092. */
  94093. getClassName(): string;
  94094. /**
  94095. * Serializes the particle system to a JSON object.
  94096. * @returns the JSON object
  94097. */
  94098. serialize(): any;
  94099. /**
  94100. * Parse properties from a JSON object
  94101. * @param serializationObject defines the JSON object
  94102. */
  94103. parse(serializationObject: any): void;
  94104. }
  94105. /**
  94106. * Particle emitter emitting particles from the inside of a sphere.
  94107. * It emits the particles randomly between two vectors.
  94108. */
  94109. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94110. /**
  94111. * The min limit of the emission direction.
  94112. */
  94113. direction1: Vector3;
  94114. /**
  94115. * The max limit of the emission direction.
  94116. */
  94117. direction2: Vector3;
  94118. /**
  94119. * Creates a new instance SphereDirectedParticleEmitter
  94120. * @param radius the radius of the emission sphere (1 by default)
  94121. * @param direction1 the min limit of the emission direction (up vector by default)
  94122. * @param direction2 the max limit of the emission direction (up vector by default)
  94123. */
  94124. constructor(radius?: number,
  94125. /**
  94126. * The min limit of the emission direction.
  94127. */
  94128. direction1?: Vector3,
  94129. /**
  94130. * The max limit of the emission direction.
  94131. */
  94132. direction2?: Vector3);
  94133. /**
  94134. * Called by the particle System when the direction is computed for the created particle.
  94135. * @param worldMatrix is the world matrix of the particle system
  94136. * @param directionToUpdate is the direction vector to update with the result
  94137. * @param particle is the particle we are computed the direction for
  94138. */
  94139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94140. /**
  94141. * Clones the current emitter and returns a copy of it
  94142. * @returns the new emitter
  94143. */
  94144. clone(): SphereDirectedParticleEmitter;
  94145. /**
  94146. * Called by the GPUParticleSystem to setup the update shader
  94147. * @param effect defines the update shader
  94148. */
  94149. applyToShader(effect: Effect): void;
  94150. /**
  94151. * Returns a string to use to update the GPU particles update shader
  94152. * @returns a string containng the defines string
  94153. */
  94154. getEffectDefines(): string;
  94155. /**
  94156. * Returns the string "SphereDirectedParticleEmitter"
  94157. * @returns a string containing the class name
  94158. */
  94159. getClassName(): string;
  94160. /**
  94161. * Serializes the particle system to a JSON object.
  94162. * @returns the JSON object
  94163. */
  94164. serialize(): any;
  94165. /**
  94166. * Parse properties from a JSON object
  94167. * @param serializationObject defines the JSON object
  94168. */
  94169. parse(serializationObject: any): void;
  94170. }
  94171. }
  94172. declare module BABYLON {
  94173. /**
  94174. * Particle emitter emitting particles from a custom list of positions.
  94175. */
  94176. export class CustomParticleEmitter implements IParticleEmitterType {
  94177. /**
  94178. * Gets or sets the position generator that will create the inital position of each particle.
  94179. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94180. */
  94181. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94182. /**
  94183. * Gets or sets the destination generator that will create the final destination of each particle.
  94184. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94185. */
  94186. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94187. /**
  94188. * Creates a new instance CustomParticleEmitter
  94189. */
  94190. constructor();
  94191. /**
  94192. * Called by the particle System when the direction is computed for the created particle.
  94193. * @param worldMatrix is the world matrix of the particle system
  94194. * @param directionToUpdate is the direction vector to update with the result
  94195. * @param particle is the particle we are computed the direction for
  94196. * @param isLocal defines if the direction should be set in local space
  94197. */
  94198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94199. /**
  94200. * Called by the particle System when the position is computed for the created particle.
  94201. * @param worldMatrix is the world matrix of the particle system
  94202. * @param positionToUpdate is the position vector to update with the result
  94203. * @param particle is the particle we are computed the position for
  94204. * @param isLocal defines if the position should be set in local space
  94205. */
  94206. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94207. /**
  94208. * Clones the current emitter and returns a copy of it
  94209. * @returns the new emitter
  94210. */
  94211. clone(): CustomParticleEmitter;
  94212. /**
  94213. * Called by the GPUParticleSystem to setup the update shader
  94214. * @param effect defines the update shader
  94215. */
  94216. applyToShader(effect: Effect): void;
  94217. /**
  94218. * Returns a string to use to update the GPU particles update shader
  94219. * @returns a string containng the defines string
  94220. */
  94221. getEffectDefines(): string;
  94222. /**
  94223. * Returns the string "PointParticleEmitter"
  94224. * @returns a string containing the class name
  94225. */
  94226. getClassName(): string;
  94227. /**
  94228. * Serializes the particle system to a JSON object.
  94229. * @returns the JSON object
  94230. */
  94231. serialize(): any;
  94232. /**
  94233. * Parse properties from a JSON object
  94234. * @param serializationObject defines the JSON object
  94235. */
  94236. parse(serializationObject: any): void;
  94237. }
  94238. }
  94239. declare module BABYLON {
  94240. /**
  94241. * Particle emitter emitting particles from the inside of a box.
  94242. * It emits the particles randomly between 2 given directions.
  94243. */
  94244. export class MeshParticleEmitter implements IParticleEmitterType {
  94245. private _indices;
  94246. private _positions;
  94247. private _normals;
  94248. private _storedNormal;
  94249. private _mesh;
  94250. /**
  94251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94252. */
  94253. direction1: Vector3;
  94254. /**
  94255. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94256. */
  94257. direction2: Vector3;
  94258. /**
  94259. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94260. */
  94261. useMeshNormalsForDirection: boolean;
  94262. /** Defines the mesh to use as source */
  94263. get mesh(): Nullable<AbstractMesh>;
  94264. set mesh(value: Nullable<AbstractMesh>);
  94265. /**
  94266. * Creates a new instance MeshParticleEmitter
  94267. * @param mesh defines the mesh to use as source
  94268. */
  94269. constructor(mesh?: Nullable<AbstractMesh>);
  94270. /**
  94271. * Called by the particle System when the direction is computed for the created particle.
  94272. * @param worldMatrix is the world matrix of the particle system
  94273. * @param directionToUpdate is the direction vector to update with the result
  94274. * @param particle is the particle we are computed the direction for
  94275. * @param isLocal defines if the direction should be set in local space
  94276. */
  94277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94278. /**
  94279. * Called by the particle System when the position is computed for the created particle.
  94280. * @param worldMatrix is the world matrix of the particle system
  94281. * @param positionToUpdate is the position vector to update with the result
  94282. * @param particle is the particle we are computed the position for
  94283. * @param isLocal defines if the position should be set in local space
  94284. */
  94285. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94286. /**
  94287. * Clones the current emitter and returns a copy of it
  94288. * @returns the new emitter
  94289. */
  94290. clone(): MeshParticleEmitter;
  94291. /**
  94292. * Called by the GPUParticleSystem to setup the update shader
  94293. * @param effect defines the update shader
  94294. */
  94295. applyToShader(effect: Effect): void;
  94296. /**
  94297. * Returns a string to use to update the GPU particles update shader
  94298. * @returns a string containng the defines string
  94299. */
  94300. getEffectDefines(): string;
  94301. /**
  94302. * Returns the string "BoxParticleEmitter"
  94303. * @returns a string containing the class name
  94304. */
  94305. getClassName(): string;
  94306. /**
  94307. * Serializes the particle system to a JSON object.
  94308. * @returns the JSON object
  94309. */
  94310. serialize(): any;
  94311. /**
  94312. * Parse properties from a JSON object
  94313. * @param serializationObject defines the JSON object
  94314. * @param scene defines the hosting scene
  94315. */
  94316. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * Interface representing a particle system in Babylon.js.
  94322. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94323. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94324. */
  94325. export interface IParticleSystem {
  94326. /**
  94327. * List of animations used by the particle system.
  94328. */
  94329. animations: Animation[];
  94330. /**
  94331. * The id of the Particle system.
  94332. */
  94333. id: string;
  94334. /**
  94335. * The name of the Particle system.
  94336. */
  94337. name: string;
  94338. /**
  94339. * The emitter represents the Mesh or position we are attaching the particle system to.
  94340. */
  94341. emitter: Nullable<AbstractMesh | Vector3>;
  94342. /**
  94343. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94344. */
  94345. isBillboardBased: boolean;
  94346. /**
  94347. * The rendering group used by the Particle system to chose when to render.
  94348. */
  94349. renderingGroupId: number;
  94350. /**
  94351. * The layer mask we are rendering the particles through.
  94352. */
  94353. layerMask: number;
  94354. /**
  94355. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94356. */
  94357. updateSpeed: number;
  94358. /**
  94359. * The amount of time the particle system is running (depends of the overall update speed).
  94360. */
  94361. targetStopDuration: number;
  94362. /**
  94363. * The texture used to render each particle. (this can be a spritesheet)
  94364. */
  94365. particleTexture: Nullable<BaseTexture>;
  94366. /**
  94367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94368. */
  94369. blendMode: number;
  94370. /**
  94371. * Minimum life time of emitting particles.
  94372. */
  94373. minLifeTime: number;
  94374. /**
  94375. * Maximum life time of emitting particles.
  94376. */
  94377. maxLifeTime: number;
  94378. /**
  94379. * Minimum Size of emitting particles.
  94380. */
  94381. minSize: number;
  94382. /**
  94383. * Maximum Size of emitting particles.
  94384. */
  94385. maxSize: number;
  94386. /**
  94387. * Minimum scale of emitting particles on X axis.
  94388. */
  94389. minScaleX: number;
  94390. /**
  94391. * Maximum scale of emitting particles on X axis.
  94392. */
  94393. maxScaleX: number;
  94394. /**
  94395. * Minimum scale of emitting particles on Y axis.
  94396. */
  94397. minScaleY: number;
  94398. /**
  94399. * Maximum scale of emitting particles on Y axis.
  94400. */
  94401. maxScaleY: number;
  94402. /**
  94403. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94404. */
  94405. color1: Color4;
  94406. /**
  94407. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94408. */
  94409. color2: Color4;
  94410. /**
  94411. * Color the particle will have at the end of its lifetime.
  94412. */
  94413. colorDead: Color4;
  94414. /**
  94415. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94416. */
  94417. emitRate: number;
  94418. /**
  94419. * You can use gravity if you want to give an orientation to your particles.
  94420. */
  94421. gravity: Vector3;
  94422. /**
  94423. * Minimum power of emitting particles.
  94424. */
  94425. minEmitPower: number;
  94426. /**
  94427. * Maximum power of emitting particles.
  94428. */
  94429. maxEmitPower: number;
  94430. /**
  94431. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94432. */
  94433. minAngularSpeed: number;
  94434. /**
  94435. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94436. */
  94437. maxAngularSpeed: number;
  94438. /**
  94439. * Gets or sets the minimal initial rotation in radians.
  94440. */
  94441. minInitialRotation: number;
  94442. /**
  94443. * Gets or sets the maximal initial rotation in radians.
  94444. */
  94445. maxInitialRotation: number;
  94446. /**
  94447. * The particle emitter type defines the emitter used by the particle system.
  94448. * It can be for example box, sphere, or cone...
  94449. */
  94450. particleEmitterType: Nullable<IParticleEmitterType>;
  94451. /**
  94452. * Defines the delay in milliseconds before starting the system (0 by default)
  94453. */
  94454. startDelay: number;
  94455. /**
  94456. * 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
  94457. */
  94458. preWarmCycles: number;
  94459. /**
  94460. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94461. */
  94462. preWarmStepOffset: number;
  94463. /**
  94464. * 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)
  94465. */
  94466. spriteCellChangeSpeed: number;
  94467. /**
  94468. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94469. */
  94470. startSpriteCellID: number;
  94471. /**
  94472. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94473. */
  94474. endSpriteCellID: number;
  94475. /**
  94476. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94477. */
  94478. spriteCellWidth: number;
  94479. /**
  94480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94481. */
  94482. spriteCellHeight: number;
  94483. /**
  94484. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94485. */
  94486. spriteRandomStartCell: boolean;
  94487. /**
  94488. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94489. */
  94490. isAnimationSheetEnabled: boolean;
  94491. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94492. translationPivot: Vector2;
  94493. /**
  94494. * Gets or sets a texture used to add random noise to particle positions
  94495. */
  94496. noiseTexture: Nullable<BaseTexture>;
  94497. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94498. noiseStrength: Vector3;
  94499. /**
  94500. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94501. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94502. */
  94503. billboardMode: number;
  94504. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94505. limitVelocityDamping: number;
  94506. /**
  94507. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94508. */
  94509. beginAnimationOnStart: boolean;
  94510. /**
  94511. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94512. */
  94513. beginAnimationFrom: number;
  94514. /**
  94515. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94516. */
  94517. beginAnimationTo: number;
  94518. /**
  94519. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94520. */
  94521. beginAnimationLoop: boolean;
  94522. /**
  94523. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94524. */
  94525. disposeOnStop: boolean;
  94526. /**
  94527. * Specifies if the particles are updated in emitter local space or world space
  94528. */
  94529. isLocal: boolean;
  94530. /** Snippet ID if the particle system was created from the snippet server */
  94531. snippetId: string;
  94532. /** Gets or sets a matrix to use to compute projection */
  94533. defaultProjectionMatrix: Matrix;
  94534. /**
  94535. * Gets the maximum number of particles active at the same time.
  94536. * @returns The max number of active particles.
  94537. */
  94538. getCapacity(): number;
  94539. /**
  94540. * Gets the number of particles active at the same time.
  94541. * @returns The number of active particles.
  94542. */
  94543. getActiveCount(): number;
  94544. /**
  94545. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94546. * @returns True if it has been started, otherwise false.
  94547. */
  94548. isStarted(): boolean;
  94549. /**
  94550. * Animates the particle system for this frame.
  94551. */
  94552. animate(): void;
  94553. /**
  94554. * Renders the particle system in its current state.
  94555. * @returns the current number of particles
  94556. */
  94557. render(): number;
  94558. /**
  94559. * Dispose the particle system and frees its associated resources.
  94560. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94561. */
  94562. dispose(disposeTexture?: boolean): void;
  94563. /**
  94564. * An event triggered when the system is disposed
  94565. */
  94566. onDisposeObservable: Observable<IParticleSystem>;
  94567. /**
  94568. * Clones the particle system.
  94569. * @param name The name of the cloned object
  94570. * @param newEmitter The new emitter to use
  94571. * @returns the cloned particle system
  94572. */
  94573. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94574. /**
  94575. * Serializes the particle system to a JSON object
  94576. * @param serializeTexture defines if the texture must be serialized as well
  94577. * @returns the JSON object
  94578. */
  94579. serialize(serializeTexture: boolean): any;
  94580. /**
  94581. * Rebuild the particle system
  94582. */
  94583. rebuild(): void;
  94584. /** Force the system to rebuild all gradients that need to be resync */
  94585. forceRefreshGradients(): void;
  94586. /**
  94587. * Starts the particle system and begins to emit
  94588. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94589. */
  94590. start(delay?: number): void;
  94591. /**
  94592. * Stops the particle system.
  94593. */
  94594. stop(): void;
  94595. /**
  94596. * Remove all active particles
  94597. */
  94598. reset(): void;
  94599. /**
  94600. * Gets a boolean indicating that the system is stopping
  94601. * @returns true if the system is currently stopping
  94602. */
  94603. isStopping(): boolean;
  94604. /**
  94605. * Is this system ready to be used/rendered
  94606. * @return true if the system is ready
  94607. */
  94608. isReady(): boolean;
  94609. /**
  94610. * Returns the string "ParticleSystem"
  94611. * @returns a string containing the class name
  94612. */
  94613. getClassName(): string;
  94614. /**
  94615. * Gets the custom effect used to render the particles
  94616. * @param blendMode Blend mode for which the effect should be retrieved
  94617. * @returns The effect
  94618. */
  94619. getCustomEffect(blendMode: number): Nullable<Effect>;
  94620. /**
  94621. * Sets the custom effect used to render the particles
  94622. * @param effect The effect to set
  94623. * @param blendMode Blend mode for which the effect should be set
  94624. */
  94625. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94626. /**
  94627. * Fill the defines array according to the current settings of the particle system
  94628. * @param defines Array to be updated
  94629. * @param blendMode blend mode to take into account when updating the array
  94630. */
  94631. fillDefines(defines: Array<string>, blendMode: number): void;
  94632. /**
  94633. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94634. * @param uniforms Uniforms array to fill
  94635. * @param attributes Attributes array to fill
  94636. * @param samplers Samplers array to fill
  94637. */
  94638. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94639. /**
  94640. * Observable that will be called just before the particles are drawn
  94641. */
  94642. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94643. /**
  94644. * Gets the name of the particle vertex shader
  94645. */
  94646. vertexShaderName: string;
  94647. /**
  94648. * Adds a new color gradient
  94649. * @param gradient defines the gradient to use (between 0 and 1)
  94650. * @param color1 defines the color to affect to the specified gradient
  94651. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94652. * @returns the current particle system
  94653. */
  94654. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94655. /**
  94656. * Remove a specific color gradient
  94657. * @param gradient defines the gradient to remove
  94658. * @returns the current particle system
  94659. */
  94660. removeColorGradient(gradient: number): IParticleSystem;
  94661. /**
  94662. * Adds a new size gradient
  94663. * @param gradient defines the gradient to use (between 0 and 1)
  94664. * @param factor defines the size factor to affect to the specified gradient
  94665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94666. * @returns the current particle system
  94667. */
  94668. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94669. /**
  94670. * Remove a specific size gradient
  94671. * @param gradient defines the gradient to remove
  94672. * @returns the current particle system
  94673. */
  94674. removeSizeGradient(gradient: number): IParticleSystem;
  94675. /**
  94676. * Gets the current list of color gradients.
  94677. * You must use addColorGradient and removeColorGradient to udpate this list
  94678. * @returns the list of color gradients
  94679. */
  94680. getColorGradients(): Nullable<Array<ColorGradient>>;
  94681. /**
  94682. * Gets the current list of size gradients.
  94683. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94684. * @returns the list of size gradients
  94685. */
  94686. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94687. /**
  94688. * Gets the current list of angular speed gradients.
  94689. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94690. * @returns the list of angular speed gradients
  94691. */
  94692. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94693. /**
  94694. * Adds a new angular speed gradient
  94695. * @param gradient defines the gradient to use (between 0 and 1)
  94696. * @param factor defines the angular speed to affect to the specified gradient
  94697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94698. * @returns the current particle system
  94699. */
  94700. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94701. /**
  94702. * Remove a specific angular speed gradient
  94703. * @param gradient defines the gradient to remove
  94704. * @returns the current particle system
  94705. */
  94706. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94707. /**
  94708. * Gets the current list of velocity gradients.
  94709. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94710. * @returns the list of velocity gradients
  94711. */
  94712. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94713. /**
  94714. * Adds a new velocity gradient
  94715. * @param gradient defines the gradient to use (between 0 and 1)
  94716. * @param factor defines the velocity to affect to the specified gradient
  94717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94718. * @returns the current particle system
  94719. */
  94720. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94721. /**
  94722. * Remove a specific velocity gradient
  94723. * @param gradient defines the gradient to remove
  94724. * @returns the current particle system
  94725. */
  94726. removeVelocityGradient(gradient: number): IParticleSystem;
  94727. /**
  94728. * Gets the current list of limit velocity gradients.
  94729. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94730. * @returns the list of limit velocity gradients
  94731. */
  94732. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94733. /**
  94734. * Adds a new limit velocity gradient
  94735. * @param gradient defines the gradient to use (between 0 and 1)
  94736. * @param factor defines the limit velocity to affect to the specified gradient
  94737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94738. * @returns the current particle system
  94739. */
  94740. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94741. /**
  94742. * Remove a specific limit velocity gradient
  94743. * @param gradient defines the gradient to remove
  94744. * @returns the current particle system
  94745. */
  94746. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94747. /**
  94748. * Adds a new drag gradient
  94749. * @param gradient defines the gradient to use (between 0 and 1)
  94750. * @param factor defines the drag to affect to the specified gradient
  94751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94752. * @returns the current particle system
  94753. */
  94754. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94755. /**
  94756. * Remove a specific drag gradient
  94757. * @param gradient defines the gradient to remove
  94758. * @returns the current particle system
  94759. */
  94760. removeDragGradient(gradient: number): IParticleSystem;
  94761. /**
  94762. * Gets the current list of drag gradients.
  94763. * You must use addDragGradient and removeDragGradient to udpate this list
  94764. * @returns the list of drag gradients
  94765. */
  94766. getDragGradients(): Nullable<Array<FactorGradient>>;
  94767. /**
  94768. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94769. * @param gradient defines the gradient to use (between 0 and 1)
  94770. * @param factor defines the emit rate to affect to the specified gradient
  94771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94772. * @returns the current particle system
  94773. */
  94774. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94775. /**
  94776. * Remove a specific emit rate gradient
  94777. * @param gradient defines the gradient to remove
  94778. * @returns the current particle system
  94779. */
  94780. removeEmitRateGradient(gradient: number): IParticleSystem;
  94781. /**
  94782. * Gets the current list of emit rate gradients.
  94783. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94784. * @returns the list of emit rate gradients
  94785. */
  94786. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94787. /**
  94788. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94789. * @param gradient defines the gradient to use (between 0 and 1)
  94790. * @param factor defines the start size to affect to the specified gradient
  94791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94792. * @returns the current particle system
  94793. */
  94794. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94795. /**
  94796. * Remove a specific start size gradient
  94797. * @param gradient defines the gradient to remove
  94798. * @returns the current particle system
  94799. */
  94800. removeStartSizeGradient(gradient: number): IParticleSystem;
  94801. /**
  94802. * Gets the current list of start size gradients.
  94803. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94804. * @returns the list of start size gradients
  94805. */
  94806. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94807. /**
  94808. * Adds a new life time gradient
  94809. * @param gradient defines the gradient to use (between 0 and 1)
  94810. * @param factor defines the life time factor to affect to the specified gradient
  94811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94812. * @returns the current particle system
  94813. */
  94814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94815. /**
  94816. * Remove a specific life time gradient
  94817. * @param gradient defines the gradient to remove
  94818. * @returns the current particle system
  94819. */
  94820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94821. /**
  94822. * Gets the current list of life time gradients.
  94823. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94824. * @returns the list of life time gradients
  94825. */
  94826. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94827. /**
  94828. * Gets the current list of color gradients.
  94829. * You must use addColorGradient and removeColorGradient to udpate this list
  94830. * @returns the list of color gradients
  94831. */
  94832. getColorGradients(): Nullable<Array<ColorGradient>>;
  94833. /**
  94834. * Adds a new ramp gradient used to remap particle colors
  94835. * @param gradient defines the gradient to use (between 0 and 1)
  94836. * @param color defines the color to affect to the specified gradient
  94837. * @returns the current particle system
  94838. */
  94839. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94840. /**
  94841. * Gets the current list of ramp gradients.
  94842. * You must use addRampGradient and removeRampGradient to udpate this list
  94843. * @returns the list of ramp gradients
  94844. */
  94845. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94846. /** Gets or sets a boolean indicating that ramp gradients must be used
  94847. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94848. */
  94849. useRampGradients: boolean;
  94850. /**
  94851. * Adds a new color remap gradient
  94852. * @param gradient defines the gradient to use (between 0 and 1)
  94853. * @param min defines the color remap minimal range
  94854. * @param max defines the color remap maximal range
  94855. * @returns the current particle system
  94856. */
  94857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94858. /**
  94859. * Gets the current list of color remap gradients.
  94860. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94861. * @returns the list of color remap gradients
  94862. */
  94863. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94864. /**
  94865. * Adds a new alpha remap gradient
  94866. * @param gradient defines the gradient to use (between 0 and 1)
  94867. * @param min defines the alpha remap minimal range
  94868. * @param max defines the alpha remap maximal range
  94869. * @returns the current particle system
  94870. */
  94871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94872. /**
  94873. * Gets the current list of alpha remap gradients.
  94874. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94875. * @returns the list of alpha remap gradients
  94876. */
  94877. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94878. /**
  94879. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94880. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94881. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94882. * @returns the emitter
  94883. */
  94884. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94885. /**
  94886. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94887. * @param radius The radius of the hemisphere to emit from
  94888. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94889. * @returns the emitter
  94890. */
  94891. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94892. /**
  94893. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94894. * @param radius The radius of the sphere to emit from
  94895. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94896. * @returns the emitter
  94897. */
  94898. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94899. /**
  94900. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94901. * @param radius The radius of the sphere to emit from
  94902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94904. * @returns the emitter
  94905. */
  94906. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94907. /**
  94908. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94909. * @param radius The radius of the emission cylinder
  94910. * @param height The height of the emission cylinder
  94911. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94912. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94913. * @returns the emitter
  94914. */
  94915. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94916. /**
  94917. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94918. * @param radius The radius of the cylinder to emit from
  94919. * @param height The height of the emission cylinder
  94920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94921. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94922. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94923. * @returns the emitter
  94924. */
  94925. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94926. /**
  94927. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94928. * @param radius The radius of the cone to emit from
  94929. * @param angle The base angle of the cone
  94930. * @returns the emitter
  94931. */
  94932. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94933. /**
  94934. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94935. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94936. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94937. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94938. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94939. * @returns the emitter
  94940. */
  94941. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94942. /**
  94943. * Get hosting scene
  94944. * @returns the scene
  94945. */
  94946. getScene(): Nullable<Scene>;
  94947. }
  94948. }
  94949. declare module BABYLON {
  94950. /**
  94951. * 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.
  94952. * @see https://doc.babylonjs.com/how_to/transformnode
  94953. */
  94954. export class TransformNode extends Node {
  94955. /**
  94956. * Object will not rotate to face the camera
  94957. */
  94958. static BILLBOARDMODE_NONE: number;
  94959. /**
  94960. * Object will rotate to face the camera but only on the x axis
  94961. */
  94962. static BILLBOARDMODE_X: number;
  94963. /**
  94964. * Object will rotate to face the camera but only on the y axis
  94965. */
  94966. static BILLBOARDMODE_Y: number;
  94967. /**
  94968. * Object will rotate to face the camera but only on the z axis
  94969. */
  94970. static BILLBOARDMODE_Z: number;
  94971. /**
  94972. * Object will rotate to face the camera
  94973. */
  94974. static BILLBOARDMODE_ALL: number;
  94975. /**
  94976. * Object will rotate to face the camera's position instead of orientation
  94977. */
  94978. static BILLBOARDMODE_USE_POSITION: number;
  94979. private static _TmpRotation;
  94980. private static _TmpScaling;
  94981. private static _TmpTranslation;
  94982. private _forward;
  94983. private _forwardInverted;
  94984. private _up;
  94985. private _right;
  94986. private _rightInverted;
  94987. private _position;
  94988. private _rotation;
  94989. private _rotationQuaternion;
  94990. protected _scaling: Vector3;
  94991. protected _isDirty: boolean;
  94992. private _transformToBoneReferal;
  94993. private _isAbsoluteSynced;
  94994. private _billboardMode;
  94995. /**
  94996. * Gets or sets the billboard mode. Default is 0.
  94997. *
  94998. * | Value | Type | Description |
  94999. * | --- | --- | --- |
  95000. * | 0 | BILLBOARDMODE_NONE | |
  95001. * | 1 | BILLBOARDMODE_X | |
  95002. * | 2 | BILLBOARDMODE_Y | |
  95003. * | 4 | BILLBOARDMODE_Z | |
  95004. * | 7 | BILLBOARDMODE_ALL | |
  95005. *
  95006. */
  95007. get billboardMode(): number;
  95008. set billboardMode(value: number);
  95009. private _preserveParentRotationForBillboard;
  95010. /**
  95011. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95012. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95013. */
  95014. get preserveParentRotationForBillboard(): boolean;
  95015. set preserveParentRotationForBillboard(value: boolean);
  95016. /**
  95017. * 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
  95018. */
  95019. scalingDeterminant: number;
  95020. private _infiniteDistance;
  95021. /**
  95022. * Gets or sets the distance of the object to max, often used by skybox
  95023. */
  95024. get infiniteDistance(): boolean;
  95025. set infiniteDistance(value: boolean);
  95026. /**
  95027. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95028. * By default the system will update normals to compensate
  95029. */
  95030. ignoreNonUniformScaling: boolean;
  95031. /**
  95032. * 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
  95033. */
  95034. reIntegrateRotationIntoRotationQuaternion: boolean;
  95035. /** @hidden */
  95036. _poseMatrix: Nullable<Matrix>;
  95037. /** @hidden */
  95038. _localMatrix: Matrix;
  95039. private _usePivotMatrix;
  95040. private _absolutePosition;
  95041. private _absoluteScaling;
  95042. private _absoluteRotationQuaternion;
  95043. private _pivotMatrix;
  95044. private _pivotMatrixInverse;
  95045. /** @hidden */
  95046. _postMultiplyPivotMatrix: boolean;
  95047. protected _isWorldMatrixFrozen: boolean;
  95048. /** @hidden */
  95049. _indexInSceneTransformNodesArray: number;
  95050. /**
  95051. * An event triggered after the world matrix is updated
  95052. */
  95053. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95054. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95055. /**
  95056. * Gets a string identifying the name of the class
  95057. * @returns "TransformNode" string
  95058. */
  95059. getClassName(): string;
  95060. /**
  95061. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95062. */
  95063. get position(): Vector3;
  95064. set position(newPosition: Vector3);
  95065. /**
  95066. * 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)).
  95067. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95068. */
  95069. get rotation(): Vector3;
  95070. set rotation(newRotation: Vector3);
  95071. /**
  95072. * 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)).
  95073. */
  95074. get scaling(): Vector3;
  95075. set scaling(newScaling: Vector3);
  95076. /**
  95077. * 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).
  95078. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95079. */
  95080. get rotationQuaternion(): Nullable<Quaternion>;
  95081. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95082. /**
  95083. * The forward direction of that transform in world space.
  95084. */
  95085. get forward(): Vector3;
  95086. /**
  95087. * The up direction of that transform in world space.
  95088. */
  95089. get up(): Vector3;
  95090. /**
  95091. * The right direction of that transform in world space.
  95092. */
  95093. get right(): Vector3;
  95094. /**
  95095. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95096. * @param matrix the matrix to copy the pose from
  95097. * @returns this TransformNode.
  95098. */
  95099. updatePoseMatrix(matrix: Matrix): TransformNode;
  95100. /**
  95101. * Returns the mesh Pose matrix.
  95102. * @returns the pose matrix
  95103. */
  95104. getPoseMatrix(): Matrix;
  95105. /** @hidden */
  95106. _isSynchronized(): boolean;
  95107. /** @hidden */
  95108. _initCache(): void;
  95109. /**
  95110. * Flag the transform node as dirty (Forcing it to update everything)
  95111. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95112. * @returns this transform node
  95113. */
  95114. markAsDirty(property: string): TransformNode;
  95115. /**
  95116. * Returns the current mesh absolute position.
  95117. * Returns a Vector3.
  95118. */
  95119. get absolutePosition(): Vector3;
  95120. /**
  95121. * Returns the current mesh absolute scaling.
  95122. * Returns a Vector3.
  95123. */
  95124. get absoluteScaling(): Vector3;
  95125. /**
  95126. * Returns the current mesh absolute rotation.
  95127. * Returns a Quaternion.
  95128. */
  95129. get absoluteRotationQuaternion(): Quaternion;
  95130. /**
  95131. * Sets a new matrix to apply before all other transformation
  95132. * @param matrix defines the transform matrix
  95133. * @returns the current TransformNode
  95134. */
  95135. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95136. /**
  95137. * Sets a new pivot matrix to the current node
  95138. * @param matrix defines the new pivot matrix to use
  95139. * @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
  95140. * @returns the current TransformNode
  95141. */
  95142. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95143. /**
  95144. * Returns the mesh pivot matrix.
  95145. * Default : Identity.
  95146. * @returns the matrix
  95147. */
  95148. getPivotMatrix(): Matrix;
  95149. /**
  95150. * Instantiate (when possible) or clone that node with its hierarchy
  95151. * @param newParent defines the new parent to use for the instance (or clone)
  95152. * @param options defines options to configure how copy is done
  95153. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95154. * @returns an instance (or a clone) of the current node with its hiearchy
  95155. */
  95156. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95157. doNotInstantiate: boolean;
  95158. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95159. /**
  95160. * Prevents the World matrix to be computed any longer
  95161. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95162. * @returns the TransformNode.
  95163. */
  95164. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95165. /**
  95166. * Allows back the World matrix computation.
  95167. * @returns the TransformNode.
  95168. */
  95169. unfreezeWorldMatrix(): this;
  95170. /**
  95171. * True if the World matrix has been frozen.
  95172. */
  95173. get isWorldMatrixFrozen(): boolean;
  95174. /**
  95175. * Retuns the mesh absolute position in the World.
  95176. * @returns a Vector3.
  95177. */
  95178. getAbsolutePosition(): Vector3;
  95179. /**
  95180. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95181. * @param absolutePosition the absolute position to set
  95182. * @returns the TransformNode.
  95183. */
  95184. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95185. /**
  95186. * Sets the mesh position in its local space.
  95187. * @param vector3 the position to set in localspace
  95188. * @returns the TransformNode.
  95189. */
  95190. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95191. /**
  95192. * Returns the mesh position in the local space from the current World matrix values.
  95193. * @returns a new Vector3.
  95194. */
  95195. getPositionExpressedInLocalSpace(): Vector3;
  95196. /**
  95197. * Translates the mesh along the passed Vector3 in its local space.
  95198. * @param vector3 the distance to translate in localspace
  95199. * @returns the TransformNode.
  95200. */
  95201. locallyTranslate(vector3: Vector3): TransformNode;
  95202. private static _lookAtVectorCache;
  95203. /**
  95204. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95205. * @param targetPoint the position (must be in same space as current mesh) to look at
  95206. * @param yawCor optional yaw (y-axis) correction in radians
  95207. * @param pitchCor optional pitch (x-axis) correction in radians
  95208. * @param rollCor optional roll (z-axis) correction in radians
  95209. * @param space the choosen space of the target
  95210. * @returns the TransformNode.
  95211. */
  95212. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95213. /**
  95214. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95215. * This Vector3 is expressed in the World space.
  95216. * @param localAxis axis to rotate
  95217. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95218. */
  95219. getDirection(localAxis: Vector3): Vector3;
  95220. /**
  95221. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95222. * localAxis is expressed in the mesh local space.
  95223. * result is computed in the Wordl space from the mesh World matrix.
  95224. * @param localAxis axis to rotate
  95225. * @param result the resulting transformnode
  95226. * @returns this TransformNode.
  95227. */
  95228. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95229. /**
  95230. * Sets this transform node rotation to the given local axis.
  95231. * @param localAxis the axis in local space
  95232. * @param yawCor optional yaw (y-axis) correction in radians
  95233. * @param pitchCor optional pitch (x-axis) correction in radians
  95234. * @param rollCor optional roll (z-axis) correction in radians
  95235. * @returns this TransformNode
  95236. */
  95237. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95238. /**
  95239. * Sets a new pivot point to the current node
  95240. * @param point defines the new pivot point to use
  95241. * @param space defines if the point is in world or local space (local by default)
  95242. * @returns the current TransformNode
  95243. */
  95244. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95245. /**
  95246. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95247. * @returns the pivot point
  95248. */
  95249. getPivotPoint(): Vector3;
  95250. /**
  95251. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95252. * @param result the vector3 to store the result
  95253. * @returns this TransformNode.
  95254. */
  95255. getPivotPointToRef(result: Vector3): TransformNode;
  95256. /**
  95257. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95258. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95259. */
  95260. getAbsolutePivotPoint(): Vector3;
  95261. /**
  95262. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95263. * @param result vector3 to store the result
  95264. * @returns this TransformNode.
  95265. */
  95266. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95267. /**
  95268. * Defines the passed node as the parent of the current node.
  95269. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95270. * @see https://doc.babylonjs.com/how_to/parenting
  95271. * @param node the node ot set as the parent
  95272. * @returns this TransformNode.
  95273. */
  95274. setParent(node: Nullable<Node>): TransformNode;
  95275. private _nonUniformScaling;
  95276. /**
  95277. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95278. */
  95279. get nonUniformScaling(): boolean;
  95280. /** @hidden */
  95281. _updateNonUniformScalingState(value: boolean): boolean;
  95282. /**
  95283. * Attach the current TransformNode to another TransformNode associated with a bone
  95284. * @param bone Bone affecting the TransformNode
  95285. * @param affectedTransformNode TransformNode associated with the bone
  95286. * @returns this object
  95287. */
  95288. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95289. /**
  95290. * Detach the transform node if its associated with a bone
  95291. * @returns this object
  95292. */
  95293. detachFromBone(): TransformNode;
  95294. private static _rotationAxisCache;
  95295. /**
  95296. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95297. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95298. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95299. * The passed axis is also normalized.
  95300. * @param axis the axis to rotate around
  95301. * @param amount the amount to rotate in radians
  95302. * @param space Space to rotate in (Default: local)
  95303. * @returns the TransformNode.
  95304. */
  95305. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95306. /**
  95307. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95308. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95309. * The passed axis is also normalized. .
  95310. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95311. * @param point the point to rotate around
  95312. * @param axis the axis to rotate around
  95313. * @param amount the amount to rotate in radians
  95314. * @returns the TransformNode
  95315. */
  95316. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95317. /**
  95318. * Translates the mesh along the axis vector for the passed distance in the given space.
  95319. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95320. * @param axis the axis to translate in
  95321. * @param distance the distance to translate
  95322. * @param space Space to rotate in (Default: local)
  95323. * @returns the TransformNode.
  95324. */
  95325. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95326. /**
  95327. * Adds a rotation step to the mesh current rotation.
  95328. * x, y, z are Euler angles expressed in radians.
  95329. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95330. * This means this rotation is made in the mesh local space only.
  95331. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95332. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95333. * ```javascript
  95334. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95335. * ```
  95336. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95337. * 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.
  95338. * @param x Rotation to add
  95339. * @param y Rotation to add
  95340. * @param z Rotation to add
  95341. * @returns the TransformNode.
  95342. */
  95343. addRotation(x: number, y: number, z: number): TransformNode;
  95344. /**
  95345. * @hidden
  95346. */
  95347. protected _getEffectiveParent(): Nullable<Node>;
  95348. /**
  95349. * Computes the world matrix of the node
  95350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95351. * @returns the world matrix
  95352. */
  95353. computeWorldMatrix(force?: boolean): Matrix;
  95354. /**
  95355. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95356. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95357. */
  95358. resetLocalMatrix(independentOfChildren?: boolean): void;
  95359. protected _afterComputeWorldMatrix(): void;
  95360. /**
  95361. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95362. * @param func callback function to add
  95363. *
  95364. * @returns the TransformNode.
  95365. */
  95366. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95367. /**
  95368. * Removes a registered callback function.
  95369. * @param func callback function to remove
  95370. * @returns the TransformNode.
  95371. */
  95372. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95373. /**
  95374. * Gets the position of the current mesh in camera space
  95375. * @param camera defines the camera to use
  95376. * @returns a position
  95377. */
  95378. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95379. /**
  95380. * Returns the distance from the mesh to the active camera
  95381. * @param camera defines the camera to use
  95382. * @returns the distance
  95383. */
  95384. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95385. /**
  95386. * Clone the current transform node
  95387. * @param name Name of the new clone
  95388. * @param newParent New parent for the clone
  95389. * @param doNotCloneChildren Do not clone children hierarchy
  95390. * @returns the new transform node
  95391. */
  95392. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95393. /**
  95394. * Serializes the objects information.
  95395. * @param currentSerializationObject defines the object to serialize in
  95396. * @returns the serialized object
  95397. */
  95398. serialize(currentSerializationObject?: any): any;
  95399. /**
  95400. * Returns a new TransformNode object parsed from the source provided.
  95401. * @param parsedTransformNode is the source.
  95402. * @param scene the scne the object belongs to
  95403. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95404. * @returns a new TransformNode object parsed from the source provided.
  95405. */
  95406. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95407. /**
  95408. * Get all child-transformNodes of this node
  95409. * @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
  95410. * @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
  95411. * @returns an array of TransformNode
  95412. */
  95413. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95414. /**
  95415. * Releases resources associated with this transform node.
  95416. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95417. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95418. */
  95419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95420. /**
  95421. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95422. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95423. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95424. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95425. * @returns the current mesh
  95426. */
  95427. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95428. private _syncAbsoluteScalingAndRotation;
  95429. }
  95430. }
  95431. declare module BABYLON {
  95432. /**
  95433. * Class used to override all child animations of a given target
  95434. */
  95435. export class AnimationPropertiesOverride {
  95436. /**
  95437. * Gets or sets a value indicating if animation blending must be used
  95438. */
  95439. enableBlending: boolean;
  95440. /**
  95441. * Gets or sets the blending speed to use when enableBlending is true
  95442. */
  95443. blendingSpeed: number;
  95444. /**
  95445. * Gets or sets the default loop mode to use
  95446. */
  95447. loopMode: number;
  95448. }
  95449. }
  95450. declare module BABYLON {
  95451. /**
  95452. * Class used to store bone information
  95453. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95454. */
  95455. export class Bone extends Node {
  95456. /**
  95457. * defines the bone name
  95458. */
  95459. name: string;
  95460. private static _tmpVecs;
  95461. private static _tmpQuat;
  95462. private static _tmpMats;
  95463. /**
  95464. * Gets the list of child bones
  95465. */
  95466. children: Bone[];
  95467. /** Gets the animations associated with this bone */
  95468. animations: Animation[];
  95469. /**
  95470. * Gets or sets bone length
  95471. */
  95472. length: number;
  95473. /**
  95474. * @hidden Internal only
  95475. * Set this value to map this bone to a different index in the transform matrices
  95476. * Set this value to -1 to exclude the bone from the transform matrices
  95477. */
  95478. _index: Nullable<number>;
  95479. private _skeleton;
  95480. private _localMatrix;
  95481. private _restPose;
  95482. private _bindPose;
  95483. private _baseMatrix;
  95484. private _absoluteTransform;
  95485. private _invertedAbsoluteTransform;
  95486. private _parent;
  95487. private _scalingDeterminant;
  95488. private _worldTransform;
  95489. private _localScaling;
  95490. private _localRotation;
  95491. private _localPosition;
  95492. private _needToDecompose;
  95493. private _needToCompose;
  95494. /** @hidden */
  95495. _linkedTransformNode: Nullable<TransformNode>;
  95496. /** @hidden */
  95497. _waitingTransformNodeId: Nullable<string>;
  95498. /** @hidden */
  95499. get _matrix(): Matrix;
  95500. /** @hidden */
  95501. set _matrix(value: Matrix);
  95502. /**
  95503. * Create a new bone
  95504. * @param name defines the bone name
  95505. * @param skeleton defines the parent skeleton
  95506. * @param parentBone defines the parent (can be null if the bone is the root)
  95507. * @param localMatrix defines the local matrix
  95508. * @param restPose defines the rest pose matrix
  95509. * @param baseMatrix defines the base matrix
  95510. * @param index defines index of the bone in the hiearchy
  95511. */
  95512. constructor(
  95513. /**
  95514. * defines the bone name
  95515. */
  95516. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95517. /**
  95518. * Gets the current object class name.
  95519. * @return the class name
  95520. */
  95521. getClassName(): string;
  95522. /**
  95523. * Gets the parent skeleton
  95524. * @returns a skeleton
  95525. */
  95526. getSkeleton(): Skeleton;
  95527. /**
  95528. * Gets parent bone
  95529. * @returns a bone or null if the bone is the root of the bone hierarchy
  95530. */
  95531. getParent(): Nullable<Bone>;
  95532. /**
  95533. * Returns an array containing the root bones
  95534. * @returns an array containing the root bones
  95535. */
  95536. getChildren(): Array<Bone>;
  95537. /**
  95538. * Gets the node index in matrix array generated for rendering
  95539. * @returns the node index
  95540. */
  95541. getIndex(): number;
  95542. /**
  95543. * Sets the parent bone
  95544. * @param parent defines the parent (can be null if the bone is the root)
  95545. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95546. */
  95547. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95548. /**
  95549. * Gets the local matrix
  95550. * @returns a matrix
  95551. */
  95552. getLocalMatrix(): Matrix;
  95553. /**
  95554. * Gets the base matrix (initial matrix which remains unchanged)
  95555. * @returns a matrix
  95556. */
  95557. getBaseMatrix(): Matrix;
  95558. /**
  95559. * Gets the rest pose matrix
  95560. * @returns a matrix
  95561. */
  95562. getRestPose(): Matrix;
  95563. /**
  95564. * Sets the rest pose matrix
  95565. * @param matrix the local-space rest pose to set for this bone
  95566. */
  95567. setRestPose(matrix: Matrix): void;
  95568. /**
  95569. * Gets the bind pose matrix
  95570. * @returns the bind pose matrix
  95571. */
  95572. getBindPose(): Matrix;
  95573. /**
  95574. * Sets the bind pose matrix
  95575. * @param matrix the local-space bind pose to set for this bone
  95576. */
  95577. setBindPose(matrix: Matrix): void;
  95578. /**
  95579. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95580. */
  95581. getWorldMatrix(): Matrix;
  95582. /**
  95583. * Sets the local matrix to rest pose matrix
  95584. */
  95585. returnToRest(): void;
  95586. /**
  95587. * Gets the inverse of the absolute transform matrix.
  95588. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95589. * @returns a matrix
  95590. */
  95591. getInvertedAbsoluteTransform(): Matrix;
  95592. /**
  95593. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95594. * @returns a matrix
  95595. */
  95596. getAbsoluteTransform(): Matrix;
  95597. /**
  95598. * Links with the given transform node.
  95599. * The local matrix of this bone is copied from the transform node every frame.
  95600. * @param transformNode defines the transform node to link to
  95601. */
  95602. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95603. /**
  95604. * Gets the node used to drive the bone's transformation
  95605. * @returns a transform node or null
  95606. */
  95607. getTransformNode(): Nullable<TransformNode>;
  95608. /** Gets or sets current position (in local space) */
  95609. get position(): Vector3;
  95610. set position(newPosition: Vector3);
  95611. /** Gets or sets current rotation (in local space) */
  95612. get rotation(): Vector3;
  95613. set rotation(newRotation: Vector3);
  95614. /** Gets or sets current rotation quaternion (in local space) */
  95615. get rotationQuaternion(): Quaternion;
  95616. set rotationQuaternion(newRotation: Quaternion);
  95617. /** Gets or sets current scaling (in local space) */
  95618. get scaling(): Vector3;
  95619. set scaling(newScaling: Vector3);
  95620. /**
  95621. * Gets the animation properties override
  95622. */
  95623. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95624. private _decompose;
  95625. private _compose;
  95626. /**
  95627. * Update the base and local matrices
  95628. * @param matrix defines the new base or local matrix
  95629. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95630. * @param updateLocalMatrix defines if the local matrix should be updated
  95631. */
  95632. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95633. /** @hidden */
  95634. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95635. /**
  95636. * Flag the bone as dirty (Forcing it to update everything)
  95637. */
  95638. markAsDirty(): void;
  95639. /** @hidden */
  95640. _markAsDirtyAndCompose(): void;
  95641. private _markAsDirtyAndDecompose;
  95642. /**
  95643. * Translate the bone in local or world space
  95644. * @param vec The amount to translate the bone
  95645. * @param space The space that the translation is in
  95646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95647. */
  95648. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95649. /**
  95650. * Set the postion of the bone in local or world space
  95651. * @param position The position to set the bone
  95652. * @param space The space that the position is in
  95653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95654. */
  95655. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95656. /**
  95657. * Set the absolute position of the bone (world space)
  95658. * @param position The position to set the bone
  95659. * @param mesh The mesh that this bone is attached to
  95660. */
  95661. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95662. /**
  95663. * Scale the bone on the x, y and z axes (in local space)
  95664. * @param x The amount to scale the bone on the x axis
  95665. * @param y The amount to scale the bone on the y axis
  95666. * @param z The amount to scale the bone on the z axis
  95667. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95668. */
  95669. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95670. /**
  95671. * Set the bone scaling in local space
  95672. * @param scale defines the scaling vector
  95673. */
  95674. setScale(scale: Vector3): void;
  95675. /**
  95676. * Gets the current scaling in local space
  95677. * @returns the current scaling vector
  95678. */
  95679. getScale(): Vector3;
  95680. /**
  95681. * Gets the current scaling in local space and stores it in a target vector
  95682. * @param result defines the target vector
  95683. */
  95684. getScaleToRef(result: Vector3): void;
  95685. /**
  95686. * Set the yaw, pitch, and roll of the bone in local or world space
  95687. * @param yaw The rotation of the bone on the y axis
  95688. * @param pitch The rotation of the bone on the x axis
  95689. * @param roll The rotation of the bone on the z axis
  95690. * @param space The space that the axes of rotation are in
  95691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95692. */
  95693. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95694. /**
  95695. * Add a rotation to the bone on an axis in local or world space
  95696. * @param axis The axis to rotate the bone on
  95697. * @param amount The amount to rotate the bone
  95698. * @param space The space that the axis is in
  95699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95700. */
  95701. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95702. /**
  95703. * Set the rotation of the bone to a particular axis angle in local or world space
  95704. * @param axis The axis to rotate the bone on
  95705. * @param angle The angle that the bone should be rotated to
  95706. * @param space The space that the axis is in
  95707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95708. */
  95709. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95710. /**
  95711. * Set the euler rotation of the bone in local or world space
  95712. * @param rotation The euler rotation that the bone should be set to
  95713. * @param space The space that the rotation is in
  95714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95715. */
  95716. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95717. /**
  95718. * Set the quaternion rotation of the bone in local or world space
  95719. * @param quat The quaternion rotation that the bone should be set to
  95720. * @param space The space that the rotation is in
  95721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95722. */
  95723. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95724. /**
  95725. * Set the rotation matrix of the bone in local or world space
  95726. * @param rotMat The rotation matrix that the bone should be set to
  95727. * @param space The space that the rotation is in
  95728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95729. */
  95730. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95731. private _rotateWithMatrix;
  95732. private _getNegativeRotationToRef;
  95733. /**
  95734. * Get the position of the bone in local or world space
  95735. * @param space The space that the returned position is in
  95736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95737. * @returns The position of the bone
  95738. */
  95739. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95740. /**
  95741. * Copy the position of the bone to a vector3 in local or world space
  95742. * @param space The space that the returned position is in
  95743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95744. * @param result The vector3 to copy the position to
  95745. */
  95746. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95747. /**
  95748. * Get the absolute position of the bone (world space)
  95749. * @param mesh The mesh that this bone is attached to
  95750. * @returns The absolute position of the bone
  95751. */
  95752. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95753. /**
  95754. * Copy the absolute position of the bone (world space) to the result param
  95755. * @param mesh The mesh that this bone is attached to
  95756. * @param result The vector3 to copy the absolute position to
  95757. */
  95758. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95759. /**
  95760. * Compute the absolute transforms of this bone and its children
  95761. */
  95762. computeAbsoluteTransforms(): void;
  95763. /**
  95764. * Get the world direction from an axis that is in the local space of the bone
  95765. * @param localAxis The local direction that is used to compute the world direction
  95766. * @param mesh The mesh that this bone is attached to
  95767. * @returns The world direction
  95768. */
  95769. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95770. /**
  95771. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95772. * @param localAxis The local direction that is used to compute the world direction
  95773. * @param mesh The mesh that this bone is attached to
  95774. * @param result The vector3 that the world direction will be copied to
  95775. */
  95776. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95777. /**
  95778. * Get the euler rotation of the bone in local or world space
  95779. * @param space The space that the rotation should be in
  95780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95781. * @returns The euler rotation
  95782. */
  95783. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95784. /**
  95785. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95786. * @param space The space that the rotation should be in
  95787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95788. * @param result The vector3 that the rotation should be copied to
  95789. */
  95790. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95791. /**
  95792. * Get the quaternion rotation of the bone in either local or world space
  95793. * @param space The space that the rotation should be in
  95794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95795. * @returns The quaternion rotation
  95796. */
  95797. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95798. /**
  95799. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95800. * @param space The space that the rotation should be in
  95801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95802. * @param result The quaternion that the rotation should be copied to
  95803. */
  95804. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95805. /**
  95806. * Get the rotation matrix of the bone in local or world space
  95807. * @param space The space that the rotation should be in
  95808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95809. * @returns The rotation matrix
  95810. */
  95811. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95812. /**
  95813. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95814. * @param space The space that the rotation should be in
  95815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95816. * @param result The quaternion that the rotation should be copied to
  95817. */
  95818. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95819. /**
  95820. * Get the world position of a point that is in the local space of the bone
  95821. * @param position The local position
  95822. * @param mesh The mesh that this bone is attached to
  95823. * @returns The world position
  95824. */
  95825. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95826. /**
  95827. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95828. * @param position The local position
  95829. * @param mesh The mesh that this bone is attached to
  95830. * @param result The vector3 that the world position should be copied to
  95831. */
  95832. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95833. /**
  95834. * Get the local position of a point that is in world space
  95835. * @param position The world position
  95836. * @param mesh The mesh that this bone is attached to
  95837. * @returns The local position
  95838. */
  95839. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95840. /**
  95841. * Get the local position of a point that is in world space and copy it to the result param
  95842. * @param position The world position
  95843. * @param mesh The mesh that this bone is attached to
  95844. * @param result The vector3 that the local position should be copied to
  95845. */
  95846. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95847. /**
  95848. * Set the current local matrix as the restPose for this bone.
  95849. */
  95850. setCurrentPoseAsRest(): void;
  95851. }
  95852. }
  95853. declare module BABYLON {
  95854. /**
  95855. * Defines a runtime animation
  95856. */
  95857. export class RuntimeAnimation {
  95858. private _events;
  95859. /**
  95860. * The current frame of the runtime animation
  95861. */
  95862. private _currentFrame;
  95863. /**
  95864. * The animation used by the runtime animation
  95865. */
  95866. private _animation;
  95867. /**
  95868. * The target of the runtime animation
  95869. */
  95870. private _target;
  95871. /**
  95872. * The initiating animatable
  95873. */
  95874. private _host;
  95875. /**
  95876. * The original value of the runtime animation
  95877. */
  95878. private _originalValue;
  95879. /**
  95880. * The original blend value of the runtime animation
  95881. */
  95882. private _originalBlendValue;
  95883. /**
  95884. * The offsets cache of the runtime animation
  95885. */
  95886. private _offsetsCache;
  95887. /**
  95888. * The high limits cache of the runtime animation
  95889. */
  95890. private _highLimitsCache;
  95891. /**
  95892. * Specifies if the runtime animation has been stopped
  95893. */
  95894. private _stopped;
  95895. /**
  95896. * The blending factor of the runtime animation
  95897. */
  95898. private _blendingFactor;
  95899. /**
  95900. * The BabylonJS scene
  95901. */
  95902. private _scene;
  95903. /**
  95904. * The current value of the runtime animation
  95905. */
  95906. private _currentValue;
  95907. /** @hidden */
  95908. _animationState: _IAnimationState;
  95909. /**
  95910. * The active target of the runtime animation
  95911. */
  95912. private _activeTargets;
  95913. private _currentActiveTarget;
  95914. private _directTarget;
  95915. /**
  95916. * The target path of the runtime animation
  95917. */
  95918. private _targetPath;
  95919. /**
  95920. * The weight of the runtime animation
  95921. */
  95922. private _weight;
  95923. /**
  95924. * The ratio offset of the runtime animation
  95925. */
  95926. private _ratioOffset;
  95927. /**
  95928. * The previous delay of the runtime animation
  95929. */
  95930. private _previousDelay;
  95931. /**
  95932. * The previous ratio of the runtime animation
  95933. */
  95934. private _previousRatio;
  95935. private _enableBlending;
  95936. private _keys;
  95937. private _minFrame;
  95938. private _maxFrame;
  95939. private _minValue;
  95940. private _maxValue;
  95941. private _targetIsArray;
  95942. /**
  95943. * Gets the current frame of the runtime animation
  95944. */
  95945. get currentFrame(): number;
  95946. /**
  95947. * Gets the weight of the runtime animation
  95948. */
  95949. get weight(): number;
  95950. /**
  95951. * Gets the current value of the runtime animation
  95952. */
  95953. get currentValue(): any;
  95954. /**
  95955. * Gets the target path of the runtime animation
  95956. */
  95957. get targetPath(): string;
  95958. /**
  95959. * Gets the actual target of the runtime animation
  95960. */
  95961. get target(): any;
  95962. /**
  95963. * Gets the additive state of the runtime animation
  95964. */
  95965. get isAdditive(): boolean;
  95966. /** @hidden */
  95967. _onLoop: () => void;
  95968. /**
  95969. * Create a new RuntimeAnimation object
  95970. * @param target defines the target of the animation
  95971. * @param animation defines the source animation object
  95972. * @param scene defines the hosting scene
  95973. * @param host defines the initiating Animatable
  95974. */
  95975. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95976. private _preparePath;
  95977. /**
  95978. * Gets the animation from the runtime animation
  95979. */
  95980. get animation(): Animation;
  95981. /**
  95982. * Resets the runtime animation to the beginning
  95983. * @param restoreOriginal defines whether to restore the target property to the original value
  95984. */
  95985. reset(restoreOriginal?: boolean): void;
  95986. /**
  95987. * Specifies if the runtime animation is stopped
  95988. * @returns Boolean specifying if the runtime animation is stopped
  95989. */
  95990. isStopped(): boolean;
  95991. /**
  95992. * Disposes of the runtime animation
  95993. */
  95994. dispose(): void;
  95995. /**
  95996. * Apply the interpolated value to the target
  95997. * @param currentValue defines the value computed by the animation
  95998. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95999. */
  96000. setValue(currentValue: any, weight: number): void;
  96001. private _getOriginalValues;
  96002. private _setValue;
  96003. /**
  96004. * Gets the loop pmode of the runtime animation
  96005. * @returns Loop Mode
  96006. */
  96007. private _getCorrectLoopMode;
  96008. /**
  96009. * Move the current animation to a given frame
  96010. * @param frame defines the frame to move to
  96011. */
  96012. goToFrame(frame: number): void;
  96013. /**
  96014. * @hidden Internal use only
  96015. */
  96016. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96017. /**
  96018. * Execute the current animation
  96019. * @param delay defines the delay to add to the current frame
  96020. * @param from defines the lower bound of the animation range
  96021. * @param to defines the upper bound of the animation range
  96022. * @param loop defines if the current animation must loop
  96023. * @param speedRatio defines the current speed ratio
  96024. * @param weight defines the weight of the animation (default is -1 so no weight)
  96025. * @param onLoop optional callback called when animation loops
  96026. * @returns a boolean indicating if the animation is running
  96027. */
  96028. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96029. }
  96030. }
  96031. declare module BABYLON {
  96032. /**
  96033. * Class used to store an actual running animation
  96034. */
  96035. export class Animatable {
  96036. /** defines the target object */
  96037. target: any;
  96038. /** defines the starting frame number (default is 0) */
  96039. fromFrame: number;
  96040. /** defines the ending frame number (default is 100) */
  96041. toFrame: number;
  96042. /** defines if the animation must loop (default is false) */
  96043. loopAnimation: boolean;
  96044. /** defines a callback to call when animation ends if it is not looping */
  96045. onAnimationEnd?: (() => void) | null | undefined;
  96046. /** defines a callback to call when animation loops */
  96047. onAnimationLoop?: (() => void) | null | undefined;
  96048. /** defines whether the animation should be evaluated additively */
  96049. isAdditive: boolean;
  96050. private _localDelayOffset;
  96051. private _pausedDelay;
  96052. private _runtimeAnimations;
  96053. private _paused;
  96054. private _scene;
  96055. private _speedRatio;
  96056. private _weight;
  96057. private _syncRoot;
  96058. /**
  96059. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96060. * This will only apply for non looping animation (default is true)
  96061. */
  96062. disposeOnEnd: boolean;
  96063. /**
  96064. * Gets a boolean indicating if the animation has started
  96065. */
  96066. animationStarted: boolean;
  96067. /**
  96068. * Observer raised when the animation ends
  96069. */
  96070. onAnimationEndObservable: Observable<Animatable>;
  96071. /**
  96072. * Observer raised when the animation loops
  96073. */
  96074. onAnimationLoopObservable: Observable<Animatable>;
  96075. /**
  96076. * Gets the root Animatable used to synchronize and normalize animations
  96077. */
  96078. get syncRoot(): Nullable<Animatable>;
  96079. /**
  96080. * Gets the current frame of the first RuntimeAnimation
  96081. * Used to synchronize Animatables
  96082. */
  96083. get masterFrame(): number;
  96084. /**
  96085. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96086. */
  96087. get weight(): number;
  96088. set weight(value: number);
  96089. /**
  96090. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96091. */
  96092. get speedRatio(): number;
  96093. set speedRatio(value: number);
  96094. /**
  96095. * Creates a new Animatable
  96096. * @param scene defines the hosting scene
  96097. * @param target defines the target object
  96098. * @param fromFrame defines the starting frame number (default is 0)
  96099. * @param toFrame defines the ending frame number (default is 100)
  96100. * @param loopAnimation defines if the animation must loop (default is false)
  96101. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96102. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96103. * @param animations defines a group of animation to add to the new Animatable
  96104. * @param onAnimationLoop defines a callback to call when animation loops
  96105. * @param isAdditive defines whether the animation should be evaluated additively
  96106. */
  96107. constructor(scene: Scene,
  96108. /** defines the target object */
  96109. target: any,
  96110. /** defines the starting frame number (default is 0) */
  96111. fromFrame?: number,
  96112. /** defines the ending frame number (default is 100) */
  96113. toFrame?: number,
  96114. /** defines if the animation must loop (default is false) */
  96115. loopAnimation?: boolean, speedRatio?: number,
  96116. /** defines a callback to call when animation ends if it is not looping */
  96117. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96118. /** defines a callback to call when animation loops */
  96119. onAnimationLoop?: (() => void) | null | undefined,
  96120. /** defines whether the animation should be evaluated additively */
  96121. isAdditive?: boolean);
  96122. /**
  96123. * Synchronize and normalize current Animatable with a source Animatable
  96124. * This is useful when using animation weights and when animations are not of the same length
  96125. * @param root defines the root Animatable to synchronize with
  96126. * @returns the current Animatable
  96127. */
  96128. syncWith(root: Animatable): Animatable;
  96129. /**
  96130. * Gets the list of runtime animations
  96131. * @returns an array of RuntimeAnimation
  96132. */
  96133. getAnimations(): RuntimeAnimation[];
  96134. /**
  96135. * Adds more animations to the current animatable
  96136. * @param target defines the target of the animations
  96137. * @param animations defines the new animations to add
  96138. */
  96139. appendAnimations(target: any, animations: Animation[]): void;
  96140. /**
  96141. * Gets the source animation for a specific property
  96142. * @param property defines the propertyu to look for
  96143. * @returns null or the source animation for the given property
  96144. */
  96145. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96146. /**
  96147. * Gets the runtime animation for a specific property
  96148. * @param property defines the propertyu to look for
  96149. * @returns null or the runtime animation for the given property
  96150. */
  96151. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96152. /**
  96153. * Resets the animatable to its original state
  96154. */
  96155. reset(): void;
  96156. /**
  96157. * Allows the animatable to blend with current running animations
  96158. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96159. * @param blendingSpeed defines the blending speed to use
  96160. */
  96161. enableBlending(blendingSpeed: number): void;
  96162. /**
  96163. * Disable animation blending
  96164. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96165. */
  96166. disableBlending(): void;
  96167. /**
  96168. * Jump directly to a given frame
  96169. * @param frame defines the frame to jump to
  96170. */
  96171. goToFrame(frame: number): void;
  96172. /**
  96173. * Pause the animation
  96174. */
  96175. pause(): void;
  96176. /**
  96177. * Restart the animation
  96178. */
  96179. restart(): void;
  96180. private _raiseOnAnimationEnd;
  96181. /**
  96182. * Stop and delete the current animation
  96183. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96184. * @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)
  96185. */
  96186. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96187. /**
  96188. * Wait asynchronously for the animation to end
  96189. * @returns a promise which will be fullfilled when the animation ends
  96190. */
  96191. waitAsync(): Promise<Animatable>;
  96192. /** @hidden */
  96193. _animate(delay: number): boolean;
  96194. }
  96195. interface Scene {
  96196. /** @hidden */
  96197. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96198. /** @hidden */
  96199. _processLateAnimationBindingsForMatrices(holder: {
  96200. totalWeight: number;
  96201. totalAdditiveWeight: number;
  96202. animations: RuntimeAnimation[];
  96203. additiveAnimations: RuntimeAnimation[];
  96204. originalValue: Matrix;
  96205. }): any;
  96206. /** @hidden */
  96207. _processLateAnimationBindingsForQuaternions(holder: {
  96208. totalWeight: number;
  96209. totalAdditiveWeight: number;
  96210. animations: RuntimeAnimation[];
  96211. additiveAnimations: RuntimeAnimation[];
  96212. originalValue: Quaternion;
  96213. }, refQuaternion: Quaternion): Quaternion;
  96214. /** @hidden */
  96215. _processLateAnimationBindings(): void;
  96216. /**
  96217. * Will start the animation sequence of a given target
  96218. * @param target defines the target
  96219. * @param from defines from which frame should animation start
  96220. * @param to defines until which frame should animation run.
  96221. * @param weight defines the weight to apply to the animation (1.0 by default)
  96222. * @param loop defines if the animation loops
  96223. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96224. * @param onAnimationEnd defines the function to be executed when the animation ends
  96225. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96226. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96227. * @param onAnimationLoop defines the callback to call when an animation loops
  96228. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96229. * @returns the animatable object created for this animation
  96230. */
  96231. 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;
  96232. /**
  96233. * Will start the animation sequence of a given target
  96234. * @param target defines the target
  96235. * @param from defines from which frame should animation start
  96236. * @param to defines until which frame should animation run.
  96237. * @param loop defines if the animation loops
  96238. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96239. * @param onAnimationEnd defines the function to be executed when the animation ends
  96240. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96241. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96242. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96243. * @param onAnimationLoop defines the callback to call when an animation loops
  96244. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96245. * @returns the animatable object created for this animation
  96246. */
  96247. 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;
  96248. /**
  96249. * Will start the animation sequence of a given target and its hierarchy
  96250. * @param target defines the target
  96251. * @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.
  96252. * @param from defines from which frame should animation start
  96253. * @param to defines until which frame should animation run.
  96254. * @param loop defines if the animation loops
  96255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96256. * @param onAnimationEnd defines the function to be executed when the animation ends
  96257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96260. * @param onAnimationLoop defines the callback to call when an animation loops
  96261. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96262. * @returns the list of created animatables
  96263. */
  96264. 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[];
  96265. /**
  96266. * Begin a new animation on a given node
  96267. * @param target defines the target where the animation will take place
  96268. * @param animations defines the list of animations to start
  96269. * @param from defines the initial value
  96270. * @param to defines the final value
  96271. * @param loop defines if you want animation to loop (off by default)
  96272. * @param speedRatio defines the speed ratio to apply to all animations
  96273. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96274. * @param onAnimationLoop defines the callback to call when an animation loops
  96275. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96276. * @returns the list of created animatables
  96277. */
  96278. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96279. /**
  96280. * Begin a new animation on a given node and its hierarchy
  96281. * @param target defines the root node where the animation will take place
  96282. * @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.
  96283. * @param animations defines the list of animations to start
  96284. * @param from defines the initial value
  96285. * @param to defines the final value
  96286. * @param loop defines if you want animation to loop (off by default)
  96287. * @param speedRatio defines the speed ratio to apply to all animations
  96288. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96289. * @param onAnimationLoop defines the callback to call when an animation loops
  96290. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96291. * @returns the list of animatables created for all nodes
  96292. */
  96293. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96294. /**
  96295. * Gets the animatable associated with a specific target
  96296. * @param target defines the target of the animatable
  96297. * @returns the required animatable if found
  96298. */
  96299. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96300. /**
  96301. * Gets all animatables associated with a given target
  96302. * @param target defines the target to look animatables for
  96303. * @returns an array of Animatables
  96304. */
  96305. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96306. /**
  96307. * Stops and removes all animations that have been applied to the scene
  96308. */
  96309. stopAllAnimations(): void;
  96310. /**
  96311. * Gets the current delta time used by animation engine
  96312. */
  96313. deltaTime: number;
  96314. }
  96315. interface Bone {
  96316. /**
  96317. * Copy an animation range from another bone
  96318. * @param source defines the source bone
  96319. * @param rangeName defines the range name to copy
  96320. * @param frameOffset defines the frame offset
  96321. * @param rescaleAsRequired defines if rescaling must be applied if required
  96322. * @param skelDimensionsRatio defines the scaling ratio
  96323. * @returns true if operation was successful
  96324. */
  96325. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96326. }
  96327. }
  96328. declare module BABYLON {
  96329. /**
  96330. * Class used to handle skinning animations
  96331. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96332. */
  96333. export class Skeleton implements IAnimatable {
  96334. /** defines the skeleton name */
  96335. name: string;
  96336. /** defines the skeleton Id */
  96337. id: string;
  96338. /**
  96339. * Defines the list of child bones
  96340. */
  96341. bones: Bone[];
  96342. /**
  96343. * Defines an estimate of the dimension of the skeleton at rest
  96344. */
  96345. dimensionsAtRest: Vector3;
  96346. /**
  96347. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96348. */
  96349. needInitialSkinMatrix: boolean;
  96350. /**
  96351. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96352. */
  96353. overrideMesh: Nullable<AbstractMesh>;
  96354. /**
  96355. * Gets the list of animations attached to this skeleton
  96356. */
  96357. animations: Array<Animation>;
  96358. private _scene;
  96359. private _isDirty;
  96360. private _transformMatrices;
  96361. private _transformMatrixTexture;
  96362. private _meshesWithPoseMatrix;
  96363. private _animatables;
  96364. private _identity;
  96365. private _synchronizedWithMesh;
  96366. private _ranges;
  96367. private _lastAbsoluteTransformsUpdateId;
  96368. private _canUseTextureForBones;
  96369. private _uniqueId;
  96370. /** @hidden */
  96371. _numBonesWithLinkedTransformNode: number;
  96372. /** @hidden */
  96373. _hasWaitingData: Nullable<boolean>;
  96374. /** @hidden */
  96375. _waitingOverrideMeshId: Nullable<string>;
  96376. /**
  96377. * Specifies if the skeleton should be serialized
  96378. */
  96379. doNotSerialize: boolean;
  96380. private _useTextureToStoreBoneMatrices;
  96381. /**
  96382. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96383. * Please note that this option is not available if the hardware does not support it
  96384. */
  96385. get useTextureToStoreBoneMatrices(): boolean;
  96386. set useTextureToStoreBoneMatrices(value: boolean);
  96387. private _animationPropertiesOverride;
  96388. /**
  96389. * Gets or sets the animation properties override
  96390. */
  96391. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96392. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96393. /**
  96394. * List of inspectable custom properties (used by the Inspector)
  96395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96396. */
  96397. inspectableCustomProperties: IInspectable[];
  96398. /**
  96399. * An observable triggered before computing the skeleton's matrices
  96400. */
  96401. onBeforeComputeObservable: Observable<Skeleton>;
  96402. /**
  96403. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96404. */
  96405. get isUsingTextureForMatrices(): boolean;
  96406. /**
  96407. * Gets the unique ID of this skeleton
  96408. */
  96409. get uniqueId(): number;
  96410. /**
  96411. * Creates a new skeleton
  96412. * @param name defines the skeleton name
  96413. * @param id defines the skeleton Id
  96414. * @param scene defines the hosting scene
  96415. */
  96416. constructor(
  96417. /** defines the skeleton name */
  96418. name: string,
  96419. /** defines the skeleton Id */
  96420. id: string, scene: Scene);
  96421. /**
  96422. * Gets the current object class name.
  96423. * @return the class name
  96424. */
  96425. getClassName(): string;
  96426. /**
  96427. * Returns an array containing the root bones
  96428. * @returns an array containing the root bones
  96429. */
  96430. getChildren(): Array<Bone>;
  96431. /**
  96432. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96433. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96434. * @returns a Float32Array containing matrices data
  96435. */
  96436. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96437. /**
  96438. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96439. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96440. * @returns a raw texture containing the data
  96441. */
  96442. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96443. /**
  96444. * Gets the current hosting scene
  96445. * @returns a scene object
  96446. */
  96447. getScene(): Scene;
  96448. /**
  96449. * Gets a string representing the current skeleton data
  96450. * @param fullDetails defines a boolean indicating if we want a verbose version
  96451. * @returns a string representing the current skeleton data
  96452. */
  96453. toString(fullDetails?: boolean): string;
  96454. /**
  96455. * Get bone's index searching by name
  96456. * @param name defines bone's name to search for
  96457. * @return the indice of the bone. Returns -1 if not found
  96458. */
  96459. getBoneIndexByName(name: string): number;
  96460. /**
  96461. * Creater a new animation range
  96462. * @param name defines the name of the range
  96463. * @param from defines the start key
  96464. * @param to defines the end key
  96465. */
  96466. createAnimationRange(name: string, from: number, to: number): void;
  96467. /**
  96468. * Delete a specific animation range
  96469. * @param name defines the name of the range
  96470. * @param deleteFrames defines if frames must be removed as well
  96471. */
  96472. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96473. /**
  96474. * Gets a specific animation range
  96475. * @param name defines the name of the range to look for
  96476. * @returns the requested animation range or null if not found
  96477. */
  96478. getAnimationRange(name: string): Nullable<AnimationRange>;
  96479. /**
  96480. * Gets the list of all animation ranges defined on this skeleton
  96481. * @returns an array
  96482. */
  96483. getAnimationRanges(): Nullable<AnimationRange>[];
  96484. /**
  96485. * Copy animation range from a source skeleton.
  96486. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96487. * @param source defines the source skeleton
  96488. * @param name defines the name of the range to copy
  96489. * @param rescaleAsRequired defines if rescaling must be applied if required
  96490. * @returns true if operation was successful
  96491. */
  96492. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96493. /**
  96494. * Forces the skeleton to go to rest pose
  96495. */
  96496. returnToRest(): void;
  96497. private _getHighestAnimationFrame;
  96498. /**
  96499. * Begin a specific animation range
  96500. * @param name defines the name of the range to start
  96501. * @param loop defines if looping must be turned on (false by default)
  96502. * @param speedRatio defines the speed ratio to apply (1 by default)
  96503. * @param onAnimationEnd defines a callback which will be called when animation will end
  96504. * @returns a new animatable
  96505. */
  96506. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96507. /**
  96508. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96509. * @param skeleton defines the Skeleton containing the animation range to convert
  96510. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96511. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96512. * @returns the original skeleton
  96513. */
  96514. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96515. /** @hidden */
  96516. _markAsDirty(): void;
  96517. /** @hidden */
  96518. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96519. /** @hidden */
  96520. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96521. private _computeTransformMatrices;
  96522. /**
  96523. * Build all resources required to render a skeleton
  96524. */
  96525. prepare(): void;
  96526. /**
  96527. * Gets the list of animatables currently running for this skeleton
  96528. * @returns an array of animatables
  96529. */
  96530. getAnimatables(): IAnimatable[];
  96531. /**
  96532. * Clone the current skeleton
  96533. * @param name defines the name of the new skeleton
  96534. * @param id defines the id of the new skeleton
  96535. * @returns the new skeleton
  96536. */
  96537. clone(name: string, id?: string): Skeleton;
  96538. /**
  96539. * Enable animation blending for this skeleton
  96540. * @param blendingSpeed defines the blending speed to apply
  96541. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96542. */
  96543. enableBlending(blendingSpeed?: number): void;
  96544. /**
  96545. * Releases all resources associated with the current skeleton
  96546. */
  96547. dispose(): void;
  96548. /**
  96549. * Serialize the skeleton in a JSON object
  96550. * @returns a JSON object
  96551. */
  96552. serialize(): any;
  96553. /**
  96554. * Creates a new skeleton from serialized data
  96555. * @param parsedSkeleton defines the serialized data
  96556. * @param scene defines the hosting scene
  96557. * @returns a new skeleton
  96558. */
  96559. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96560. /**
  96561. * Compute all node absolute transforms
  96562. * @param forceUpdate defines if computation must be done even if cache is up to date
  96563. */
  96564. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96565. /**
  96566. * Gets the root pose matrix
  96567. * @returns a matrix
  96568. */
  96569. getPoseMatrix(): Nullable<Matrix>;
  96570. /**
  96571. * Sorts bones per internal index
  96572. */
  96573. sortBones(): void;
  96574. private _sortBones;
  96575. /**
  96576. * Set the current local matrix as the restPose for all bones in the skeleton.
  96577. */
  96578. setCurrentPoseAsRest(): void;
  96579. }
  96580. }
  96581. declare module BABYLON {
  96582. /**
  96583. * Creates an instance based on a source mesh.
  96584. */
  96585. export class InstancedMesh extends AbstractMesh {
  96586. private _sourceMesh;
  96587. private _currentLOD;
  96588. /** @hidden */
  96589. _indexInSourceMeshInstanceArray: number;
  96590. constructor(name: string, source: Mesh);
  96591. /**
  96592. * Returns the string "InstancedMesh".
  96593. */
  96594. getClassName(): string;
  96595. /** Gets the list of lights affecting that mesh */
  96596. get lightSources(): Light[];
  96597. _resyncLightSources(): void;
  96598. _resyncLightSource(light: Light): void;
  96599. _removeLightSource(light: Light, dispose: boolean): void;
  96600. /**
  96601. * If the source mesh receives shadows
  96602. */
  96603. get receiveShadows(): boolean;
  96604. /**
  96605. * The material of the source mesh
  96606. */
  96607. get material(): Nullable<Material>;
  96608. /**
  96609. * Visibility of the source mesh
  96610. */
  96611. get visibility(): number;
  96612. /**
  96613. * Skeleton of the source mesh
  96614. */
  96615. get skeleton(): Nullable<Skeleton>;
  96616. /**
  96617. * Rendering ground id of the source mesh
  96618. */
  96619. get renderingGroupId(): number;
  96620. set renderingGroupId(value: number);
  96621. /**
  96622. * Returns the total number of vertices (integer).
  96623. */
  96624. getTotalVertices(): number;
  96625. /**
  96626. * Returns a positive integer : the total number of indices in this mesh geometry.
  96627. * @returns the numner of indices or zero if the mesh has no geometry.
  96628. */
  96629. getTotalIndices(): number;
  96630. /**
  96631. * The source mesh of the instance
  96632. */
  96633. get sourceMesh(): Mesh;
  96634. /**
  96635. * Creates a new InstancedMesh object from the mesh model.
  96636. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96637. * @param name defines the name of the new instance
  96638. * @returns a new InstancedMesh
  96639. */
  96640. createInstance(name: string): InstancedMesh;
  96641. /**
  96642. * Is this node ready to be used/rendered
  96643. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96644. * @return {boolean} is it ready
  96645. */
  96646. isReady(completeCheck?: boolean): boolean;
  96647. /**
  96648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96649. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96650. * @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.
  96651. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96652. */
  96653. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96654. /**
  96655. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96656. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96657. * The `data` are either a numeric array either a Float32Array.
  96658. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96659. * 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).
  96660. * Note that a new underlying VertexBuffer object is created each call.
  96661. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96662. *
  96663. * Possible `kind` values :
  96664. * - VertexBuffer.PositionKind
  96665. * - VertexBuffer.UVKind
  96666. * - VertexBuffer.UV2Kind
  96667. * - VertexBuffer.UV3Kind
  96668. * - VertexBuffer.UV4Kind
  96669. * - VertexBuffer.UV5Kind
  96670. * - VertexBuffer.UV6Kind
  96671. * - VertexBuffer.ColorKind
  96672. * - VertexBuffer.MatricesIndicesKind
  96673. * - VertexBuffer.MatricesIndicesExtraKind
  96674. * - VertexBuffer.MatricesWeightsKind
  96675. * - VertexBuffer.MatricesWeightsExtraKind
  96676. *
  96677. * Returns the Mesh.
  96678. */
  96679. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96680. /**
  96681. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96682. * If the mesh has no geometry, it is simply returned as it is.
  96683. * The `data` are either a numeric array either a Float32Array.
  96684. * No new underlying VertexBuffer object is created.
  96685. * 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.
  96686. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96687. *
  96688. * Possible `kind` values :
  96689. * - VertexBuffer.PositionKind
  96690. * - VertexBuffer.UVKind
  96691. * - VertexBuffer.UV2Kind
  96692. * - VertexBuffer.UV3Kind
  96693. * - VertexBuffer.UV4Kind
  96694. * - VertexBuffer.UV5Kind
  96695. * - VertexBuffer.UV6Kind
  96696. * - VertexBuffer.ColorKind
  96697. * - VertexBuffer.MatricesIndicesKind
  96698. * - VertexBuffer.MatricesIndicesExtraKind
  96699. * - VertexBuffer.MatricesWeightsKind
  96700. * - VertexBuffer.MatricesWeightsExtraKind
  96701. *
  96702. * Returns the Mesh.
  96703. */
  96704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96705. /**
  96706. * Sets the mesh indices.
  96707. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96708. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96709. * This method creates a new index buffer each call.
  96710. * Returns the Mesh.
  96711. */
  96712. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96713. /**
  96714. * Boolean : True if the mesh owns the requested kind of data.
  96715. */
  96716. isVerticesDataPresent(kind: string): boolean;
  96717. /**
  96718. * Returns an array of indices (IndicesArray).
  96719. */
  96720. getIndices(): Nullable<IndicesArray>;
  96721. get _positions(): Nullable<Vector3[]>;
  96722. /**
  96723. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96724. * This means the mesh underlying bounding box and sphere are recomputed.
  96725. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96726. * @returns the current mesh
  96727. */
  96728. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96729. /** @hidden */
  96730. _preActivate(): InstancedMesh;
  96731. /** @hidden */
  96732. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96733. /** @hidden */
  96734. _postActivate(): void;
  96735. getWorldMatrix(): Matrix;
  96736. get isAnInstance(): boolean;
  96737. /**
  96738. * Returns the current associated LOD AbstractMesh.
  96739. */
  96740. getLOD(camera: Camera): AbstractMesh;
  96741. /** @hidden */
  96742. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96743. /** @hidden */
  96744. _syncSubMeshes(): InstancedMesh;
  96745. /** @hidden */
  96746. _generatePointsArray(): boolean;
  96747. /** @hidden */
  96748. _updateBoundingInfo(): AbstractMesh;
  96749. /**
  96750. * Creates a new InstancedMesh from the current mesh.
  96751. * - name (string) : the cloned mesh name
  96752. * - newParent (optional Node) : the optional Node to parent the clone to.
  96753. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96754. *
  96755. * Returns the clone.
  96756. */
  96757. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96758. /**
  96759. * Disposes the InstancedMesh.
  96760. * Returns nothing.
  96761. */
  96762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96763. }
  96764. interface Mesh {
  96765. /**
  96766. * Register a custom buffer that will be instanced
  96767. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96768. * @param kind defines the buffer kind
  96769. * @param stride defines the stride in floats
  96770. */
  96771. registerInstancedBuffer(kind: string, stride: number): void;
  96772. /**
  96773. * true to use the edge renderer for all instances of this mesh
  96774. */
  96775. edgesShareWithInstances: boolean;
  96776. /** @hidden */
  96777. _userInstancedBuffersStorage: {
  96778. data: {
  96779. [key: string]: Float32Array;
  96780. };
  96781. sizes: {
  96782. [key: string]: number;
  96783. };
  96784. vertexBuffers: {
  96785. [key: string]: Nullable<VertexBuffer>;
  96786. };
  96787. strides: {
  96788. [key: string]: number;
  96789. };
  96790. };
  96791. }
  96792. interface AbstractMesh {
  96793. /**
  96794. * Object used to store instanced buffers defined by user
  96795. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96796. */
  96797. instancedBuffers: {
  96798. [key: string]: any;
  96799. };
  96800. }
  96801. }
  96802. declare module BABYLON {
  96803. /**
  96804. * Defines the options associated with the creation of a shader material.
  96805. */
  96806. export interface IShaderMaterialOptions {
  96807. /**
  96808. * Does the material work in alpha blend mode
  96809. */
  96810. needAlphaBlending: boolean;
  96811. /**
  96812. * Does the material work in alpha test mode
  96813. */
  96814. needAlphaTesting: boolean;
  96815. /**
  96816. * The list of attribute names used in the shader
  96817. */
  96818. attributes: string[];
  96819. /**
  96820. * The list of unifrom names used in the shader
  96821. */
  96822. uniforms: string[];
  96823. /**
  96824. * The list of UBO names used in the shader
  96825. */
  96826. uniformBuffers: string[];
  96827. /**
  96828. * The list of sampler names used in the shader
  96829. */
  96830. samplers: string[];
  96831. /**
  96832. * The list of defines used in the shader
  96833. */
  96834. defines: string[];
  96835. }
  96836. /**
  96837. * 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.
  96838. *
  96839. * This returned material effects how the mesh will look based on the code in the shaders.
  96840. *
  96841. * @see https://doc.babylonjs.com/how_to/shader_material
  96842. */
  96843. export class ShaderMaterial extends Material {
  96844. private _shaderPath;
  96845. private _options;
  96846. private _textures;
  96847. private _textureArrays;
  96848. private _floats;
  96849. private _ints;
  96850. private _floatsArrays;
  96851. private _colors3;
  96852. private _colors3Arrays;
  96853. private _colors4;
  96854. private _colors4Arrays;
  96855. private _vectors2;
  96856. private _vectors3;
  96857. private _vectors4;
  96858. private _matrices;
  96859. private _matrixArrays;
  96860. private _matrices3x3;
  96861. private _matrices2x2;
  96862. private _vectors2Arrays;
  96863. private _vectors3Arrays;
  96864. private _vectors4Arrays;
  96865. private _cachedWorldViewMatrix;
  96866. private _cachedWorldViewProjectionMatrix;
  96867. private _renderId;
  96868. private _multiview;
  96869. private _cachedDefines;
  96870. /** Define the Url to load snippets */
  96871. static SnippetUrl: string;
  96872. /** Snippet ID if the material was created from the snippet server */
  96873. snippetId: string;
  96874. /**
  96875. * Instantiate a new shader material.
  96876. * 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.
  96877. * This returned material effects how the mesh will look based on the code in the shaders.
  96878. * @see https://doc.babylonjs.com/how_to/shader_material
  96879. * @param name Define the name of the material in the scene
  96880. * @param scene Define the scene the material belongs to
  96881. * @param shaderPath Defines the route to the shader code in one of three ways:
  96882. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96883. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96884. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96885. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96886. * @param options Define the options used to create the shader
  96887. */
  96888. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96889. /**
  96890. * Gets the shader path used to define the shader code
  96891. * It can be modified to trigger a new compilation
  96892. */
  96893. get shaderPath(): any;
  96894. /**
  96895. * Sets the shader path used to define the shader code
  96896. * It can be modified to trigger a new compilation
  96897. */
  96898. set shaderPath(shaderPath: any);
  96899. /**
  96900. * Gets the options used to compile the shader.
  96901. * They can be modified to trigger a new compilation
  96902. */
  96903. get options(): IShaderMaterialOptions;
  96904. /**
  96905. * Gets the current class name of the material e.g. "ShaderMaterial"
  96906. * Mainly use in serialization.
  96907. * @returns the class name
  96908. */
  96909. getClassName(): string;
  96910. /**
  96911. * Specifies if the material will require alpha blending
  96912. * @returns a boolean specifying if alpha blending is needed
  96913. */
  96914. needAlphaBlending(): boolean;
  96915. /**
  96916. * Specifies if this material should be rendered in alpha test mode
  96917. * @returns a boolean specifying if an alpha test is needed.
  96918. */
  96919. needAlphaTesting(): boolean;
  96920. private _checkUniform;
  96921. /**
  96922. * Set a texture in the shader.
  96923. * @param name Define the name of the uniform samplers as defined in the shader
  96924. * @param texture Define the texture to bind to this sampler
  96925. * @return the material itself allowing "fluent" like uniform updates
  96926. */
  96927. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96928. /**
  96929. * Set a texture array in the shader.
  96930. * @param name Define the name of the uniform sampler array as defined in the shader
  96931. * @param textures Define the list of textures to bind to this sampler
  96932. * @return the material itself allowing "fluent" like uniform updates
  96933. */
  96934. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96935. /**
  96936. * Set a float in the shader.
  96937. * @param name Define the name of the uniform as defined in the shader
  96938. * @param value Define the value to give to the uniform
  96939. * @return the material itself allowing "fluent" like uniform updates
  96940. */
  96941. setFloat(name: string, value: number): ShaderMaterial;
  96942. /**
  96943. * Set a int in the shader.
  96944. * @param name Define the name of the uniform as defined in the shader
  96945. * @param value Define the value to give to the uniform
  96946. * @return the material itself allowing "fluent" like uniform updates
  96947. */
  96948. setInt(name: string, value: number): ShaderMaterial;
  96949. /**
  96950. * Set an array of floats in the shader.
  96951. * @param name Define the name of the uniform as defined in the shader
  96952. * @param value Define the value to give to the uniform
  96953. * @return the material itself allowing "fluent" like uniform updates
  96954. */
  96955. setFloats(name: string, value: number[]): ShaderMaterial;
  96956. /**
  96957. * Set a vec3 in the shader from a Color3.
  96958. * @param name Define the name of the uniform as defined in the shader
  96959. * @param value Define the value to give to the uniform
  96960. * @return the material itself allowing "fluent" like uniform updates
  96961. */
  96962. setColor3(name: string, value: Color3): ShaderMaterial;
  96963. /**
  96964. * Set a vec3 array in the shader from a Color3 array.
  96965. * @param name Define the name of the uniform as defined in the shader
  96966. * @param value Define the value to give to the uniform
  96967. * @return the material itself allowing "fluent" like uniform updates
  96968. */
  96969. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96970. /**
  96971. * Set a vec4 in the shader from a Color4.
  96972. * @param name Define the name of the uniform as defined in the shader
  96973. * @param value Define the value to give to the uniform
  96974. * @return the material itself allowing "fluent" like uniform updates
  96975. */
  96976. setColor4(name: string, value: Color4): ShaderMaterial;
  96977. /**
  96978. * Set a vec4 array in the shader from a Color4 array.
  96979. * @param name Define the name of the uniform as defined in the shader
  96980. * @param value Define the value to give to the uniform
  96981. * @return the material itself allowing "fluent" like uniform updates
  96982. */
  96983. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96984. /**
  96985. * Set a vec2 in the shader from a Vector2.
  96986. * @param name Define the name of the uniform as defined in the shader
  96987. * @param value Define the value to give to the uniform
  96988. * @return the material itself allowing "fluent" like uniform updates
  96989. */
  96990. setVector2(name: string, value: Vector2): ShaderMaterial;
  96991. /**
  96992. * Set a vec3 in the shader from a Vector3.
  96993. * @param name Define the name of the uniform as defined in the shader
  96994. * @param value Define the value to give to the uniform
  96995. * @return the material itself allowing "fluent" like uniform updates
  96996. */
  96997. setVector3(name: string, value: Vector3): ShaderMaterial;
  96998. /**
  96999. * Set a vec4 in the shader from a Vector4.
  97000. * @param name Define the name of the uniform as defined in the shader
  97001. * @param value Define the value to give to the uniform
  97002. * @return the material itself allowing "fluent" like uniform updates
  97003. */
  97004. setVector4(name: string, value: Vector4): ShaderMaterial;
  97005. /**
  97006. * Set a mat4 in the shader from a Matrix.
  97007. * @param name Define the name of the uniform as defined in the shader
  97008. * @param value Define the value to give to the uniform
  97009. * @return the material itself allowing "fluent" like uniform updates
  97010. */
  97011. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97012. /**
  97013. * Set a float32Array in the shader from a matrix array.
  97014. * @param name Define the name of the uniform as defined in the shader
  97015. * @param value Define the value to give to the uniform
  97016. * @return the material itself allowing "fluent" like uniform updates
  97017. */
  97018. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97019. /**
  97020. * Set a mat3 in the shader from a Float32Array.
  97021. * @param name Define the name of the uniform as defined in the shader
  97022. * @param value Define the value to give to the uniform
  97023. * @return the material itself allowing "fluent" like uniform updates
  97024. */
  97025. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97026. /**
  97027. * Set a mat2 in the shader from a Float32Array.
  97028. * @param name Define the name of the uniform as defined in the shader
  97029. * @param value Define the value to give to the uniform
  97030. * @return the material itself allowing "fluent" like uniform updates
  97031. */
  97032. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97033. /**
  97034. * Set a vec2 array in the shader from a number array.
  97035. * @param name Define the name of the uniform as defined in the shader
  97036. * @param value Define the value to give to the uniform
  97037. * @return the material itself allowing "fluent" like uniform updates
  97038. */
  97039. setArray2(name: string, value: number[]): ShaderMaterial;
  97040. /**
  97041. * Set a vec3 array in the shader from a number array.
  97042. * @param name Define the name of the uniform as defined in the shader
  97043. * @param value Define the value to give to the uniform
  97044. * @return the material itself allowing "fluent" like uniform updates
  97045. */
  97046. setArray3(name: string, value: number[]): ShaderMaterial;
  97047. /**
  97048. * Set a vec4 array in the shader from a number array.
  97049. * @param name Define the name of the uniform as defined in the shader
  97050. * @param value Define the value to give to the uniform
  97051. * @return the material itself allowing "fluent" like uniform updates
  97052. */
  97053. setArray4(name: string, value: number[]): ShaderMaterial;
  97054. private _checkCache;
  97055. /**
  97056. * Specifies that the submesh is ready to be used
  97057. * @param mesh defines the mesh to check
  97058. * @param subMesh defines which submesh to check
  97059. * @param useInstances specifies that instances should be used
  97060. * @returns a boolean indicating that the submesh is ready or not
  97061. */
  97062. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97063. /**
  97064. * Checks if the material is ready to render the requested mesh
  97065. * @param mesh Define the mesh to render
  97066. * @param useInstances Define whether or not the material is used with instances
  97067. * @returns true if ready, otherwise false
  97068. */
  97069. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97070. /**
  97071. * Binds the world matrix to the material
  97072. * @param world defines the world transformation matrix
  97073. * @param effectOverride - If provided, use this effect instead of internal effect
  97074. */
  97075. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97076. /**
  97077. * Binds the submesh to this material by preparing the effect and shader to draw
  97078. * @param world defines the world transformation matrix
  97079. * @param mesh defines the mesh containing the submesh
  97080. * @param subMesh defines the submesh to bind the material to
  97081. */
  97082. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97083. /**
  97084. * Binds the material to the mesh
  97085. * @param world defines the world transformation matrix
  97086. * @param mesh defines the mesh to bind the material to
  97087. * @param effectOverride - If provided, use this effect instead of internal effect
  97088. */
  97089. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97090. protected _afterBind(mesh?: Mesh): void;
  97091. /**
  97092. * Gets the active textures from the material
  97093. * @returns an array of textures
  97094. */
  97095. getActiveTextures(): BaseTexture[];
  97096. /**
  97097. * Specifies if the material uses a texture
  97098. * @param texture defines the texture to check against the material
  97099. * @returns a boolean specifying if the material uses the texture
  97100. */
  97101. hasTexture(texture: BaseTexture): boolean;
  97102. /**
  97103. * Makes a duplicate of the material, and gives it a new name
  97104. * @param name defines the new name for the duplicated material
  97105. * @returns the cloned material
  97106. */
  97107. clone(name: string): ShaderMaterial;
  97108. /**
  97109. * Disposes the material
  97110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97111. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97112. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97113. */
  97114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97115. /**
  97116. * Serializes this material in a JSON representation
  97117. * @returns the serialized material object
  97118. */
  97119. serialize(): any;
  97120. /**
  97121. * Creates a shader material from parsed shader material data
  97122. * @param source defines the JSON represnetation of the material
  97123. * @param scene defines the hosting scene
  97124. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97125. * @returns a new material
  97126. */
  97127. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97128. /**
  97129. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97130. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97131. * @param url defines the url to load from
  97132. * @param scene defines the hosting scene
  97133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97134. * @returns a promise that will resolve to the new ShaderMaterial
  97135. */
  97136. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97137. /**
  97138. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97139. * @param snippetId defines the snippet to load
  97140. * @param scene defines the hosting scene
  97141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97142. * @returns a promise that will resolve to the new ShaderMaterial
  97143. */
  97144. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97145. }
  97146. }
  97147. declare module BABYLON {
  97148. /** @hidden */
  97149. export var colorPixelShader: {
  97150. name: string;
  97151. shader: string;
  97152. };
  97153. }
  97154. declare module BABYLON {
  97155. /** @hidden */
  97156. export var colorVertexShader: {
  97157. name: string;
  97158. shader: string;
  97159. };
  97160. }
  97161. declare module BABYLON {
  97162. /**
  97163. * Line mesh
  97164. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97165. */
  97166. export class LinesMesh extends Mesh {
  97167. /**
  97168. * If vertex color should be applied to the mesh
  97169. */
  97170. readonly useVertexColor?: boolean | undefined;
  97171. /**
  97172. * If vertex alpha should be applied to the mesh
  97173. */
  97174. readonly useVertexAlpha?: boolean | undefined;
  97175. /**
  97176. * Color of the line (Default: White)
  97177. */
  97178. color: Color3;
  97179. /**
  97180. * Alpha of the line (Default: 1)
  97181. */
  97182. alpha: number;
  97183. /**
  97184. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97185. * This margin is expressed in world space coordinates, so its value may vary.
  97186. * Default value is 0.1
  97187. */
  97188. intersectionThreshold: number;
  97189. private _colorShader;
  97190. private color4;
  97191. /**
  97192. * Creates a new LinesMesh
  97193. * @param name defines the name
  97194. * @param scene defines the hosting scene
  97195. * @param parent defines the parent mesh if any
  97196. * @param source defines the optional source LinesMesh used to clone data from
  97197. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97198. * When false, achieved by calling a clone(), also passing False.
  97199. * This will make creation of children, recursive.
  97200. * @param useVertexColor defines if this LinesMesh supports vertex color
  97201. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97202. */
  97203. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97204. /**
  97205. * If vertex color should be applied to the mesh
  97206. */
  97207. useVertexColor?: boolean | undefined,
  97208. /**
  97209. * If vertex alpha should be applied to the mesh
  97210. */
  97211. useVertexAlpha?: boolean | undefined);
  97212. private _addClipPlaneDefine;
  97213. private _removeClipPlaneDefine;
  97214. isReady(): boolean;
  97215. /**
  97216. * Returns the string "LineMesh"
  97217. */
  97218. getClassName(): string;
  97219. /**
  97220. * @hidden
  97221. */
  97222. get material(): Material;
  97223. /**
  97224. * @hidden
  97225. */
  97226. set material(value: Material);
  97227. /**
  97228. * @hidden
  97229. */
  97230. get checkCollisions(): boolean;
  97231. /** @hidden */
  97232. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97233. /** @hidden */
  97234. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97235. /**
  97236. * Disposes of the line mesh
  97237. * @param doNotRecurse If children should be disposed
  97238. */
  97239. dispose(doNotRecurse?: boolean): void;
  97240. /**
  97241. * Returns a new LineMesh object cloned from the current one.
  97242. */
  97243. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97244. /**
  97245. * Creates a new InstancedLinesMesh object from the mesh model.
  97246. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97247. * @param name defines the name of the new instance
  97248. * @returns a new InstancedLinesMesh
  97249. */
  97250. createInstance(name: string): InstancedLinesMesh;
  97251. }
  97252. /**
  97253. * Creates an instance based on a source LinesMesh
  97254. */
  97255. export class InstancedLinesMesh extends InstancedMesh {
  97256. /**
  97257. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97258. * This margin is expressed in world space coordinates, so its value may vary.
  97259. * Initilized with the intersectionThreshold value of the source LinesMesh
  97260. */
  97261. intersectionThreshold: number;
  97262. constructor(name: string, source: LinesMesh);
  97263. /**
  97264. * Returns the string "InstancedLinesMesh".
  97265. */
  97266. getClassName(): string;
  97267. }
  97268. }
  97269. declare module BABYLON {
  97270. /** @hidden */
  97271. export var linePixelShader: {
  97272. name: string;
  97273. shader: string;
  97274. };
  97275. }
  97276. declare module BABYLON {
  97277. /** @hidden */
  97278. export var lineVertexShader: {
  97279. name: string;
  97280. shader: string;
  97281. };
  97282. }
  97283. declare module BABYLON {
  97284. interface Scene {
  97285. /** @hidden */
  97286. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97287. }
  97288. interface AbstractMesh {
  97289. /**
  97290. * Gets the edgesRenderer associated with the mesh
  97291. */
  97292. edgesRenderer: Nullable<EdgesRenderer>;
  97293. }
  97294. interface LinesMesh {
  97295. /**
  97296. * Enables the edge rendering mode on the mesh.
  97297. * This mode makes the mesh edges visible
  97298. * @param epsilon defines the maximal distance between two angles to detect a face
  97299. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97300. * @returns the currentAbstractMesh
  97301. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97302. */
  97303. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97304. }
  97305. interface InstancedLinesMesh {
  97306. /**
  97307. * Enables the edge rendering mode on the mesh.
  97308. * This mode makes the mesh edges visible
  97309. * @param epsilon defines the maximal distance between two angles to detect a face
  97310. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97311. * @returns the current InstancedLinesMesh
  97312. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97313. */
  97314. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97315. }
  97316. /**
  97317. * Defines the minimum contract an Edges renderer should follow.
  97318. */
  97319. export interface IEdgesRenderer extends IDisposable {
  97320. /**
  97321. * Gets or sets a boolean indicating if the edgesRenderer is active
  97322. */
  97323. isEnabled: boolean;
  97324. /**
  97325. * Renders the edges of the attached mesh,
  97326. */
  97327. render(): void;
  97328. /**
  97329. * Checks wether or not the edges renderer is ready to render.
  97330. * @return true if ready, otherwise false.
  97331. */
  97332. isReady(): boolean;
  97333. /**
  97334. * List of instances to render in case the source mesh has instances
  97335. */
  97336. customInstances: SmartArray<Matrix>;
  97337. }
  97338. /**
  97339. * Defines the additional options of the edges renderer
  97340. */
  97341. export interface IEdgesRendererOptions {
  97342. /**
  97343. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97344. * If not defined, the default value is true
  97345. */
  97346. useAlternateEdgeFinder?: boolean;
  97347. /**
  97348. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97349. * If not defined, the default value is true.
  97350. * 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)
  97351. * This option is used only if useAlternateEdgeFinder = true
  97352. */
  97353. useFastVertexMerger?: boolean;
  97354. /**
  97355. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97356. * The default value is 1e-6
  97357. * This option is used only if useAlternateEdgeFinder = true
  97358. */
  97359. epsilonVertexMerge?: number;
  97360. /**
  97361. * 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
  97362. * 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.
  97363. * This option is used only if useAlternateEdgeFinder = true
  97364. */
  97365. applyTessellation?: boolean;
  97366. /**
  97367. * 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
  97368. * The default value is 1e-6
  97369. * This option is used only if useAlternateEdgeFinder = true
  97370. */
  97371. epsilonVertexAligned?: number;
  97372. }
  97373. /**
  97374. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97375. */
  97376. export class EdgesRenderer implements IEdgesRenderer {
  97377. /**
  97378. * Define the size of the edges with an orthographic camera
  97379. */
  97380. edgesWidthScalerForOrthographic: number;
  97381. /**
  97382. * Define the size of the edges with a perspective camera
  97383. */
  97384. edgesWidthScalerForPerspective: number;
  97385. protected _source: AbstractMesh;
  97386. protected _linesPositions: number[];
  97387. protected _linesNormals: number[];
  97388. protected _linesIndices: number[];
  97389. protected _epsilon: number;
  97390. protected _indicesCount: number;
  97391. protected _lineShader: ShaderMaterial;
  97392. protected _ib: DataBuffer;
  97393. protected _buffers: {
  97394. [key: string]: Nullable<VertexBuffer>;
  97395. };
  97396. protected _buffersForInstances: {
  97397. [key: string]: Nullable<VertexBuffer>;
  97398. };
  97399. protected _checkVerticesInsteadOfIndices: boolean;
  97400. protected _options: Nullable<IEdgesRendererOptions>;
  97401. private _meshRebuildObserver;
  97402. private _meshDisposeObserver;
  97403. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97404. isEnabled: boolean;
  97405. /**
  97406. * List of instances to render in case the source mesh has instances
  97407. */
  97408. customInstances: SmartArray<Matrix>;
  97409. private static GetShader;
  97410. /**
  97411. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97412. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97413. * @param source Mesh used to create edges
  97414. * @param epsilon sum of angles in adjacency to check for edge
  97415. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97416. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97417. * @param options The options to apply when generating the edges
  97418. */
  97419. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97420. protected _prepareRessources(): void;
  97421. /** @hidden */
  97422. _rebuild(): void;
  97423. /**
  97424. * Releases the required resources for the edges renderer
  97425. */
  97426. dispose(): void;
  97427. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97428. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97429. /**
  97430. * Checks if the pair of p0 and p1 is en edge
  97431. * @param faceIndex
  97432. * @param edge
  97433. * @param faceNormals
  97434. * @param p0
  97435. * @param p1
  97436. * @private
  97437. */
  97438. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97439. /**
  97440. * push line into the position, normal and index buffer
  97441. * @protected
  97442. */
  97443. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97444. /**
  97445. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97446. */
  97447. private _tessellateTriangle;
  97448. private _generateEdgesLinesAlternate;
  97449. /**
  97450. * Generates lines edges from adjacencjes
  97451. * @private
  97452. */
  97453. _generateEdgesLines(): void;
  97454. /**
  97455. * Checks wether or not the edges renderer is ready to render.
  97456. * @return true if ready, otherwise false.
  97457. */
  97458. isReady(): boolean;
  97459. /**
  97460. * Renders the edges of the attached mesh,
  97461. */
  97462. render(): void;
  97463. }
  97464. /**
  97465. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97466. */
  97467. export class LineEdgesRenderer extends EdgesRenderer {
  97468. /**
  97469. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97470. * @param source LineMesh used to generate edges
  97471. * @param epsilon not important (specified angle for edge detection)
  97472. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97473. */
  97474. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97475. /**
  97476. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97477. */
  97478. _generateEdgesLines(): void;
  97479. }
  97480. }
  97481. declare module BABYLON {
  97482. /**
  97483. * This represents the object necessary to create a rendering group.
  97484. * This is exclusively used and created by the rendering manager.
  97485. * To modify the behavior, you use the available helpers in your scene or meshes.
  97486. * @hidden
  97487. */
  97488. export class RenderingGroup {
  97489. index: number;
  97490. private static _zeroVector;
  97491. private _scene;
  97492. private _opaqueSubMeshes;
  97493. private _transparentSubMeshes;
  97494. private _alphaTestSubMeshes;
  97495. private _depthOnlySubMeshes;
  97496. private _particleSystems;
  97497. private _spriteManagers;
  97498. private _opaqueSortCompareFn;
  97499. private _alphaTestSortCompareFn;
  97500. private _transparentSortCompareFn;
  97501. private _renderOpaque;
  97502. private _renderAlphaTest;
  97503. private _renderTransparent;
  97504. /** @hidden */
  97505. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97506. onBeforeTransparentRendering: () => void;
  97507. /**
  97508. * Set the opaque sort comparison function.
  97509. * If null the sub meshes will be render in the order they were created
  97510. */
  97511. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97512. /**
  97513. * Set the alpha test sort comparison function.
  97514. * If null the sub meshes will be render in the order they were created
  97515. */
  97516. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97517. /**
  97518. * Set the transparent sort comparison function.
  97519. * If null the sub meshes will be render in the order they were created
  97520. */
  97521. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97522. /**
  97523. * Creates a new rendering group.
  97524. * @param index The rendering group index
  97525. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97526. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97527. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97528. */
  97529. 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>);
  97530. /**
  97531. * Render all the sub meshes contained in the group.
  97532. * @param customRenderFunction Used to override the default render behaviour of the group.
  97533. * @returns true if rendered some submeshes.
  97534. */
  97535. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97536. /**
  97537. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97538. * @param subMeshes The submeshes to render
  97539. */
  97540. private renderOpaqueSorted;
  97541. /**
  97542. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97543. * @param subMeshes The submeshes to render
  97544. */
  97545. private renderAlphaTestSorted;
  97546. /**
  97547. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97548. * @param subMeshes The submeshes to render
  97549. */
  97550. private renderTransparentSorted;
  97551. /**
  97552. * Renders the submeshes in a specified order.
  97553. * @param subMeshes The submeshes to sort before render
  97554. * @param sortCompareFn The comparison function use to sort
  97555. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97556. * @param transparent Specifies to activate blending if true
  97557. */
  97558. private static renderSorted;
  97559. /**
  97560. * Renders the submeshes in the order they were dispatched (no sort applied).
  97561. * @param subMeshes The submeshes to render
  97562. */
  97563. private static renderUnsorted;
  97564. /**
  97565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97566. * are rendered back to front if in the same alpha index.
  97567. *
  97568. * @param a The first submesh
  97569. * @param b The second submesh
  97570. * @returns The result of the comparison
  97571. */
  97572. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97573. /**
  97574. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97575. * are rendered back to front.
  97576. *
  97577. * @param a The first submesh
  97578. * @param b The second submesh
  97579. * @returns The result of the comparison
  97580. */
  97581. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97582. /**
  97583. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97584. * are rendered front to back (prevent overdraw).
  97585. *
  97586. * @param a The first submesh
  97587. * @param b The second submesh
  97588. * @returns The result of the comparison
  97589. */
  97590. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97591. /**
  97592. * Resets the different lists of submeshes to prepare a new frame.
  97593. */
  97594. prepare(): void;
  97595. dispose(): void;
  97596. /**
  97597. * Inserts the submesh in its correct queue depending on its material.
  97598. * @param subMesh The submesh to dispatch
  97599. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97600. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97601. */
  97602. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97603. dispatchSprites(spriteManager: ISpriteManager): void;
  97604. dispatchParticles(particleSystem: IParticleSystem): void;
  97605. private _renderParticles;
  97606. private _renderSprites;
  97607. }
  97608. }
  97609. declare module BABYLON {
  97610. /**
  97611. * Interface describing the different options available in the rendering manager
  97612. * regarding Auto Clear between groups.
  97613. */
  97614. export interface IRenderingManagerAutoClearSetup {
  97615. /**
  97616. * Defines whether or not autoclear is enable.
  97617. */
  97618. autoClear: boolean;
  97619. /**
  97620. * Defines whether or not to autoclear the depth buffer.
  97621. */
  97622. depth: boolean;
  97623. /**
  97624. * Defines whether or not to autoclear the stencil buffer.
  97625. */
  97626. stencil: boolean;
  97627. }
  97628. /**
  97629. * This class is used by the onRenderingGroupObservable
  97630. */
  97631. export class RenderingGroupInfo {
  97632. /**
  97633. * The Scene that being rendered
  97634. */
  97635. scene: Scene;
  97636. /**
  97637. * The camera currently used for the rendering pass
  97638. */
  97639. camera: Nullable<Camera>;
  97640. /**
  97641. * The ID of the renderingGroup being processed
  97642. */
  97643. renderingGroupId: number;
  97644. }
  97645. /**
  97646. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97647. * It is enable to manage the different groups as well as the different necessary sort functions.
  97648. * This should not be used directly aside of the few static configurations
  97649. */
  97650. export class RenderingManager {
  97651. /**
  97652. * The max id used for rendering groups (not included)
  97653. */
  97654. static MAX_RENDERINGGROUPS: number;
  97655. /**
  97656. * The min id used for rendering groups (included)
  97657. */
  97658. static MIN_RENDERINGGROUPS: number;
  97659. /**
  97660. * Used to globally prevent autoclearing scenes.
  97661. */
  97662. static AUTOCLEAR: boolean;
  97663. /**
  97664. * @hidden
  97665. */
  97666. _useSceneAutoClearSetup: boolean;
  97667. private _scene;
  97668. private _renderingGroups;
  97669. private _depthStencilBufferAlreadyCleaned;
  97670. private _autoClearDepthStencil;
  97671. private _customOpaqueSortCompareFn;
  97672. private _customAlphaTestSortCompareFn;
  97673. private _customTransparentSortCompareFn;
  97674. private _renderingGroupInfo;
  97675. /**
  97676. * Instantiates a new rendering group for a particular scene
  97677. * @param scene Defines the scene the groups belongs to
  97678. */
  97679. constructor(scene: Scene);
  97680. private _clearDepthStencilBuffer;
  97681. /**
  97682. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97683. * @hidden
  97684. */
  97685. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97686. /**
  97687. * Resets the different information of the group to prepare a new frame
  97688. * @hidden
  97689. */
  97690. reset(): void;
  97691. /**
  97692. * Dispose and release the group and its associated resources.
  97693. * @hidden
  97694. */
  97695. dispose(): void;
  97696. /**
  97697. * Clear the info related to rendering groups preventing retention points during dispose.
  97698. */
  97699. freeRenderingGroups(): void;
  97700. private _prepareRenderingGroup;
  97701. /**
  97702. * Add a sprite manager to the rendering manager in order to render it this frame.
  97703. * @param spriteManager Define the sprite manager to render
  97704. */
  97705. dispatchSprites(spriteManager: ISpriteManager): void;
  97706. /**
  97707. * Add a particle system to the rendering manager in order to render it this frame.
  97708. * @param particleSystem Define the particle system to render
  97709. */
  97710. dispatchParticles(particleSystem: IParticleSystem): void;
  97711. /**
  97712. * Add a submesh to the manager in order to render it this frame
  97713. * @param subMesh The submesh to dispatch
  97714. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97715. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97716. */
  97717. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97718. /**
  97719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97720. * This allowed control for front to back rendering or reversly depending of the special needs.
  97721. *
  97722. * @param renderingGroupId The rendering group id corresponding to its index
  97723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97726. */
  97727. 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;
  97728. /**
  97729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97730. *
  97731. * @param renderingGroupId The rendering group id corresponding to its index
  97732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97733. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97734. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97735. */
  97736. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97737. /**
  97738. * Gets the current auto clear configuration for one rendering group of the rendering
  97739. * manager.
  97740. * @param index the rendering group index to get the information for
  97741. * @returns The auto clear setup for the requested rendering group
  97742. */
  97743. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97744. }
  97745. }
  97746. declare module BABYLON {
  97747. /**
  97748. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97749. */
  97750. export interface ICustomShaderOptions {
  97751. /**
  97752. * Gets or sets the custom shader name to use
  97753. */
  97754. shaderName: string;
  97755. /**
  97756. * The list of attribute names used in the shader
  97757. */
  97758. attributes?: string[];
  97759. /**
  97760. * The list of unifrom names used in the shader
  97761. */
  97762. uniforms?: string[];
  97763. /**
  97764. * The list of sampler names used in the shader
  97765. */
  97766. samplers?: string[];
  97767. /**
  97768. * The list of defines used in the shader
  97769. */
  97770. defines?: string[];
  97771. }
  97772. /**
  97773. * Interface to implement to create a shadow generator compatible with BJS.
  97774. */
  97775. export interface IShadowGenerator {
  97776. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97777. id: string;
  97778. /**
  97779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97780. * @returns The render target texture if present otherwise, null
  97781. */
  97782. getShadowMap(): Nullable<RenderTargetTexture>;
  97783. /**
  97784. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97785. * @param subMesh The submesh we want to render in the shadow map
  97786. * @param useInstances Defines wether will draw in the map using instances
  97787. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97788. * @returns true if ready otherwise, false
  97789. */
  97790. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97791. /**
  97792. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97793. * @param defines Defines of the material we want to update
  97794. * @param lightIndex Index of the light in the enabled light list of the material
  97795. */
  97796. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97797. /**
  97798. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97799. * defined in the generator but impacting the effect).
  97800. * It implies the unifroms available on the materials are the standard BJS ones.
  97801. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97802. * @param effect The effect we are binfing the information for
  97803. */
  97804. bindShadowLight(lightIndex: string, effect: Effect): void;
  97805. /**
  97806. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97807. * (eq to shadow prjection matrix * light transform matrix)
  97808. * @returns The transform matrix used to create the shadow map
  97809. */
  97810. getTransformMatrix(): Matrix;
  97811. /**
  97812. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97813. * Cube and 2D textures for instance.
  97814. */
  97815. recreateShadowMap(): void;
  97816. /**
  97817. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97818. * @param onCompiled Callback triggered at the and of the effects compilation
  97819. * @param options Sets of optional options forcing the compilation with different modes
  97820. */
  97821. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97822. useInstances: boolean;
  97823. }>): void;
  97824. /**
  97825. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97826. * @param options Sets of optional options forcing the compilation with different modes
  97827. * @returns A promise that resolves when the compilation completes
  97828. */
  97829. forceCompilationAsync(options?: Partial<{
  97830. useInstances: boolean;
  97831. }>): Promise<void>;
  97832. /**
  97833. * Serializes the shadow generator setup to a json object.
  97834. * @returns The serialized JSON object
  97835. */
  97836. serialize(): any;
  97837. /**
  97838. * Disposes the Shadow map and related Textures and effects.
  97839. */
  97840. dispose(): void;
  97841. }
  97842. /**
  97843. * Default implementation IShadowGenerator.
  97844. * This is the main object responsible of generating shadows in the framework.
  97845. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97846. */
  97847. export class ShadowGenerator implements IShadowGenerator {
  97848. /**
  97849. * Name of the shadow generator class
  97850. */
  97851. static CLASSNAME: string;
  97852. /**
  97853. * Shadow generator mode None: no filtering applied.
  97854. */
  97855. static readonly FILTER_NONE: number;
  97856. /**
  97857. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97858. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97859. */
  97860. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97861. /**
  97862. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97863. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97864. */
  97865. static readonly FILTER_POISSONSAMPLING: number;
  97866. /**
  97867. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97868. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97869. */
  97870. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97871. /**
  97872. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97873. * edge artifacts on steep falloff.
  97874. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97875. */
  97876. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97877. /**
  97878. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97879. * edge artifacts on steep falloff.
  97880. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97881. */
  97882. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97883. /**
  97884. * Shadow generator mode PCF: Percentage Closer Filtering
  97885. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97886. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97887. */
  97888. static readonly FILTER_PCF: number;
  97889. /**
  97890. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97891. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97892. * Contact Hardening
  97893. */
  97894. static readonly FILTER_PCSS: number;
  97895. /**
  97896. * Reserved for PCF and PCSS
  97897. * Highest Quality.
  97898. *
  97899. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97900. *
  97901. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97902. */
  97903. static readonly QUALITY_HIGH: number;
  97904. /**
  97905. * Reserved for PCF and PCSS
  97906. * Good tradeoff for quality/perf cross devices
  97907. *
  97908. * Execute PCF on a 3*3 kernel.
  97909. *
  97910. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97911. */
  97912. static readonly QUALITY_MEDIUM: number;
  97913. /**
  97914. * Reserved for PCF and PCSS
  97915. * The lowest quality but the fastest.
  97916. *
  97917. * Execute PCF on a 1*1 kernel.
  97918. *
  97919. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97920. */
  97921. static readonly QUALITY_LOW: number;
  97922. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97923. id: string;
  97924. /** Gets or sets the custom shader name to use */
  97925. customShaderOptions: ICustomShaderOptions;
  97926. /**
  97927. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97928. */
  97929. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97930. /**
  97931. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97932. */
  97933. onAfterShadowMapRenderObservable: Observable<Effect>;
  97934. /**
  97935. * Observable triggered before a mesh is rendered in the shadow map.
  97936. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97937. */
  97938. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97939. /**
  97940. * Observable triggered after a mesh is rendered in the shadow map.
  97941. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97942. */
  97943. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97944. protected _bias: number;
  97945. /**
  97946. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97947. */
  97948. get bias(): number;
  97949. /**
  97950. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97951. */
  97952. set bias(bias: number);
  97953. protected _normalBias: number;
  97954. /**
  97955. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97956. */
  97957. get normalBias(): number;
  97958. /**
  97959. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97960. */
  97961. set normalBias(normalBias: number);
  97962. protected _blurBoxOffset: number;
  97963. /**
  97964. * Gets the blur box offset: offset applied during the blur pass.
  97965. * Only useful if useKernelBlur = false
  97966. */
  97967. get blurBoxOffset(): number;
  97968. /**
  97969. * Sets the blur box offset: offset applied during the blur pass.
  97970. * Only useful if useKernelBlur = false
  97971. */
  97972. set blurBoxOffset(value: number);
  97973. protected _blurScale: number;
  97974. /**
  97975. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97976. * 2 means half of the size.
  97977. */
  97978. get blurScale(): number;
  97979. /**
  97980. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97981. * 2 means half of the size.
  97982. */
  97983. set blurScale(value: number);
  97984. protected _blurKernel: number;
  97985. /**
  97986. * Gets the blur kernel: kernel size of the blur pass.
  97987. * Only useful if useKernelBlur = true
  97988. */
  97989. get blurKernel(): number;
  97990. /**
  97991. * Sets the blur kernel: kernel size of the blur pass.
  97992. * Only useful if useKernelBlur = true
  97993. */
  97994. set blurKernel(value: number);
  97995. protected _useKernelBlur: boolean;
  97996. /**
  97997. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97998. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97999. */
  98000. get useKernelBlur(): boolean;
  98001. /**
  98002. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98003. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98004. */
  98005. set useKernelBlur(value: boolean);
  98006. protected _depthScale: number;
  98007. /**
  98008. * Gets the depth scale used in ESM mode.
  98009. */
  98010. get depthScale(): number;
  98011. /**
  98012. * Sets the depth scale used in ESM mode.
  98013. * This can override the scale stored on the light.
  98014. */
  98015. set depthScale(value: number);
  98016. protected _validateFilter(filter: number): number;
  98017. protected _filter: number;
  98018. /**
  98019. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98020. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98021. */
  98022. get filter(): number;
  98023. /**
  98024. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98025. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98026. */
  98027. set filter(value: number);
  98028. /**
  98029. * Gets if the current filter is set to Poisson Sampling.
  98030. */
  98031. get usePoissonSampling(): boolean;
  98032. /**
  98033. * Sets the current filter to Poisson Sampling.
  98034. */
  98035. set usePoissonSampling(value: boolean);
  98036. /**
  98037. * Gets if the current filter is set to ESM.
  98038. */
  98039. get useExponentialShadowMap(): boolean;
  98040. /**
  98041. * Sets the current filter is to ESM.
  98042. */
  98043. set useExponentialShadowMap(value: boolean);
  98044. /**
  98045. * Gets if the current filter is set to filtered ESM.
  98046. */
  98047. get useBlurExponentialShadowMap(): boolean;
  98048. /**
  98049. * Gets if the current filter is set to filtered ESM.
  98050. */
  98051. set useBlurExponentialShadowMap(value: boolean);
  98052. /**
  98053. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98054. * exponential to prevent steep falloff artifacts).
  98055. */
  98056. get useCloseExponentialShadowMap(): boolean;
  98057. /**
  98058. * Sets the current filter to "close ESM" (using the inverse of the
  98059. * exponential to prevent steep falloff artifacts).
  98060. */
  98061. set useCloseExponentialShadowMap(value: boolean);
  98062. /**
  98063. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98064. * exponential to prevent steep falloff artifacts).
  98065. */
  98066. get useBlurCloseExponentialShadowMap(): boolean;
  98067. /**
  98068. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98069. * exponential to prevent steep falloff artifacts).
  98070. */
  98071. set useBlurCloseExponentialShadowMap(value: boolean);
  98072. /**
  98073. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98074. */
  98075. get usePercentageCloserFiltering(): boolean;
  98076. /**
  98077. * Sets the current filter to "PCF" (percentage closer filtering).
  98078. */
  98079. set usePercentageCloserFiltering(value: boolean);
  98080. protected _filteringQuality: number;
  98081. /**
  98082. * Gets the PCF or PCSS Quality.
  98083. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98084. */
  98085. get filteringQuality(): number;
  98086. /**
  98087. * Sets the PCF or PCSS Quality.
  98088. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98089. */
  98090. set filteringQuality(filteringQuality: number);
  98091. /**
  98092. * Gets if the current filter is set to "PCSS" (contact hardening).
  98093. */
  98094. get useContactHardeningShadow(): boolean;
  98095. /**
  98096. * Sets the current filter to "PCSS" (contact hardening).
  98097. */
  98098. set useContactHardeningShadow(value: boolean);
  98099. protected _contactHardeningLightSizeUVRatio: number;
  98100. /**
  98101. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98102. * Using a ratio helps keeping shape stability independently of the map size.
  98103. *
  98104. * It does not account for the light projection as it was having too much
  98105. * instability during the light setup or during light position changes.
  98106. *
  98107. * Only valid if useContactHardeningShadow is true.
  98108. */
  98109. get contactHardeningLightSizeUVRatio(): number;
  98110. /**
  98111. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98112. * Using a ratio helps keeping shape stability independently of the map size.
  98113. *
  98114. * It does not account for the light projection as it was having too much
  98115. * instability during the light setup or during light position changes.
  98116. *
  98117. * Only valid if useContactHardeningShadow is true.
  98118. */
  98119. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98120. protected _darkness: number;
  98121. /** Gets or sets the actual darkness of a shadow */
  98122. get darkness(): number;
  98123. set darkness(value: number);
  98124. /**
  98125. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98126. * 0 means strongest and 1 would means no shadow.
  98127. * @returns the darkness.
  98128. */
  98129. getDarkness(): number;
  98130. /**
  98131. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98132. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98133. * @returns the shadow generator allowing fluent coding.
  98134. */
  98135. setDarkness(darkness: number): ShadowGenerator;
  98136. protected _transparencyShadow: boolean;
  98137. /** Gets or sets the ability to have transparent shadow */
  98138. get transparencyShadow(): boolean;
  98139. set transparencyShadow(value: boolean);
  98140. /**
  98141. * Sets the ability to have transparent shadow (boolean).
  98142. * @param transparent True if transparent else False
  98143. * @returns the shadow generator allowing fluent coding
  98144. */
  98145. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98146. /**
  98147. * Enables or disables shadows with varying strength based on the transparency
  98148. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98149. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98150. * mesh.visibility * alphaTexture.a
  98151. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98152. */
  98153. enableSoftTransparentShadow: boolean;
  98154. protected _shadowMap: Nullable<RenderTargetTexture>;
  98155. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98156. /**
  98157. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98158. * @returns The render target texture if present otherwise, null
  98159. */
  98160. getShadowMap(): Nullable<RenderTargetTexture>;
  98161. /**
  98162. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98163. * @returns The render target texture if the shadow map is present otherwise, null
  98164. */
  98165. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98166. /**
  98167. * Gets the class name of that object
  98168. * @returns "ShadowGenerator"
  98169. */
  98170. getClassName(): string;
  98171. /**
  98172. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98173. * @param mesh Mesh to add
  98174. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98175. * @returns the Shadow Generator itself
  98176. */
  98177. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98178. /**
  98179. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98180. * @param mesh Mesh to remove
  98181. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98182. * @returns the Shadow Generator itself
  98183. */
  98184. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98185. /**
  98186. * Controls the extent to which the shadows fade out at the edge of the frustum
  98187. */
  98188. frustumEdgeFalloff: number;
  98189. protected _light: IShadowLight;
  98190. /**
  98191. * Returns the associated light object.
  98192. * @returns the light generating the shadow
  98193. */
  98194. getLight(): IShadowLight;
  98195. /**
  98196. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98197. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98198. * It might on the other hand introduce peter panning.
  98199. */
  98200. forceBackFacesOnly: boolean;
  98201. protected _scene: Scene;
  98202. protected _lightDirection: Vector3;
  98203. protected _effect: Effect;
  98204. protected _viewMatrix: Matrix;
  98205. protected _projectionMatrix: Matrix;
  98206. protected _transformMatrix: Matrix;
  98207. protected _cachedPosition: Vector3;
  98208. protected _cachedDirection: Vector3;
  98209. protected _cachedDefines: string;
  98210. protected _currentRenderID: number;
  98211. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98212. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98213. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98214. protected _blurPostProcesses: PostProcess[];
  98215. protected _mapSize: number;
  98216. protected _currentFaceIndex: number;
  98217. protected _currentFaceIndexCache: number;
  98218. protected _textureType: number;
  98219. protected _defaultTextureMatrix: Matrix;
  98220. protected _storedUniqueId: Nullable<number>;
  98221. /** @hidden */
  98222. static _SceneComponentInitialization: (scene: Scene) => void;
  98223. /**
  98224. * Creates a ShadowGenerator object.
  98225. * A ShadowGenerator is the required tool to use the shadows.
  98226. * Each light casting shadows needs to use its own ShadowGenerator.
  98227. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98228. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98229. * @param light The light object generating the shadows.
  98230. * @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.
  98231. */
  98232. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98233. protected _initializeGenerator(): void;
  98234. protected _createTargetRenderTexture(): void;
  98235. protected _initializeShadowMap(): void;
  98236. protected _initializeBlurRTTAndPostProcesses(): void;
  98237. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98238. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98239. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98240. protected _applyFilterValues(): void;
  98241. /**
  98242. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98243. * @param onCompiled Callback triggered at the and of the effects compilation
  98244. * @param options Sets of optional options forcing the compilation with different modes
  98245. */
  98246. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98247. useInstances: boolean;
  98248. }>): void;
  98249. /**
  98250. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98251. * @param options Sets of optional options forcing the compilation with different modes
  98252. * @returns A promise that resolves when the compilation completes
  98253. */
  98254. forceCompilationAsync(options?: Partial<{
  98255. useInstances: boolean;
  98256. }>): Promise<void>;
  98257. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98258. private _prepareShadowDefines;
  98259. /**
  98260. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98261. * @param subMesh The submesh we want to render in the shadow map
  98262. * @param useInstances Defines wether will draw in the map using instances
  98263. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98264. * @returns true if ready otherwise, false
  98265. */
  98266. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98267. /**
  98268. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98269. * @param defines Defines of the material we want to update
  98270. * @param lightIndex Index of the light in the enabled light list of the material
  98271. */
  98272. prepareDefines(defines: any, lightIndex: number): void;
  98273. /**
  98274. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98275. * defined in the generator but impacting the effect).
  98276. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98277. * @param effect The effect we are binfing the information for
  98278. */
  98279. bindShadowLight(lightIndex: string, effect: Effect): void;
  98280. /**
  98281. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98282. * (eq to shadow prjection matrix * light transform matrix)
  98283. * @returns The transform matrix used to create the shadow map
  98284. */
  98285. getTransformMatrix(): Matrix;
  98286. /**
  98287. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98288. * Cube and 2D textures for instance.
  98289. */
  98290. recreateShadowMap(): void;
  98291. protected _disposeBlurPostProcesses(): void;
  98292. protected _disposeRTTandPostProcesses(): void;
  98293. /**
  98294. * Disposes the ShadowGenerator.
  98295. * Returns nothing.
  98296. */
  98297. dispose(): void;
  98298. /**
  98299. * Serializes the shadow generator setup to a json object.
  98300. * @returns The serialized JSON object
  98301. */
  98302. serialize(): any;
  98303. /**
  98304. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98305. * @param parsedShadowGenerator The JSON object to parse
  98306. * @param scene The scene to create the shadow map for
  98307. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98308. * @returns The parsed shadow generator
  98309. */
  98310. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98311. }
  98312. }
  98313. declare module BABYLON {
  98314. /**
  98315. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98316. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98317. * 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.
  98318. */
  98319. export abstract class Light extends Node {
  98320. /**
  98321. * Falloff Default: light is falling off following the material specification:
  98322. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98323. */
  98324. static readonly FALLOFF_DEFAULT: number;
  98325. /**
  98326. * Falloff Physical: light is falling off following the inverse squared distance law.
  98327. */
  98328. static readonly FALLOFF_PHYSICAL: number;
  98329. /**
  98330. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98331. * to enhance interoperability with other engines.
  98332. */
  98333. static readonly FALLOFF_GLTF: number;
  98334. /**
  98335. * Falloff Standard: light is falling off like in the standard material
  98336. * to enhance interoperability with other materials.
  98337. */
  98338. static readonly FALLOFF_STANDARD: number;
  98339. /**
  98340. * If every light affecting the material is in this lightmapMode,
  98341. * material.lightmapTexture adds or multiplies
  98342. * (depends on material.useLightmapAsShadowmap)
  98343. * after every other light calculations.
  98344. */
  98345. static readonly LIGHTMAP_DEFAULT: number;
  98346. /**
  98347. * material.lightmapTexture as only diffuse lighting from this light
  98348. * adds only specular lighting from this light
  98349. * adds dynamic shadows
  98350. */
  98351. static readonly LIGHTMAP_SPECULAR: number;
  98352. /**
  98353. * material.lightmapTexture as only lighting
  98354. * no light calculation from this light
  98355. * only adds dynamic shadows from this light
  98356. */
  98357. static readonly LIGHTMAP_SHADOWSONLY: number;
  98358. /**
  98359. * Each light type uses the default quantity according to its type:
  98360. * point/spot lights use luminous intensity
  98361. * directional lights use illuminance
  98362. */
  98363. static readonly INTENSITYMODE_AUTOMATIC: number;
  98364. /**
  98365. * lumen (lm)
  98366. */
  98367. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98368. /**
  98369. * candela (lm/sr)
  98370. */
  98371. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98372. /**
  98373. * lux (lm/m^2)
  98374. */
  98375. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98376. /**
  98377. * nit (cd/m^2)
  98378. */
  98379. static readonly INTENSITYMODE_LUMINANCE: number;
  98380. /**
  98381. * Light type const id of the point light.
  98382. */
  98383. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98384. /**
  98385. * Light type const id of the directional light.
  98386. */
  98387. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98388. /**
  98389. * Light type const id of the spot light.
  98390. */
  98391. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98392. /**
  98393. * Light type const id of the hemispheric light.
  98394. */
  98395. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98396. /**
  98397. * Diffuse gives the basic color to an object.
  98398. */
  98399. diffuse: Color3;
  98400. /**
  98401. * Specular produces a highlight color on an object.
  98402. * Note: This is note affecting PBR materials.
  98403. */
  98404. specular: Color3;
  98405. /**
  98406. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98407. * falling off base on range or angle.
  98408. * This can be set to any values in Light.FALLOFF_x.
  98409. *
  98410. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98411. * other types of materials.
  98412. */
  98413. falloffType: number;
  98414. /**
  98415. * Strength of the light.
  98416. * Note: By default it is define in the framework own unit.
  98417. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98418. */
  98419. intensity: number;
  98420. private _range;
  98421. protected _inverseSquaredRange: number;
  98422. /**
  98423. * Defines how far from the source the light is impacting in scene units.
  98424. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98425. */
  98426. get range(): number;
  98427. /**
  98428. * Defines how far from the source the light is impacting in scene units.
  98429. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98430. */
  98431. set range(value: number);
  98432. /**
  98433. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98434. * of light.
  98435. */
  98436. private _photometricScale;
  98437. private _intensityMode;
  98438. /**
  98439. * Gets the photometric scale used to interpret the intensity.
  98440. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98441. */
  98442. get intensityMode(): number;
  98443. /**
  98444. * Sets the photometric scale used to interpret the intensity.
  98445. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98446. */
  98447. set intensityMode(value: number);
  98448. private _radius;
  98449. /**
  98450. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98451. */
  98452. get radius(): number;
  98453. /**
  98454. * sets the light radius used by PBR Materials to simulate soft area lights.
  98455. */
  98456. set radius(value: number);
  98457. private _renderPriority;
  98458. /**
  98459. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98460. * exceeding the number allowed of the materials.
  98461. */
  98462. renderPriority: number;
  98463. private _shadowEnabled;
  98464. /**
  98465. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98466. * the current shadow generator.
  98467. */
  98468. get shadowEnabled(): boolean;
  98469. /**
  98470. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98471. * the current shadow generator.
  98472. */
  98473. set shadowEnabled(value: boolean);
  98474. private _includedOnlyMeshes;
  98475. /**
  98476. * Gets the only meshes impacted by this light.
  98477. */
  98478. get includedOnlyMeshes(): AbstractMesh[];
  98479. /**
  98480. * Sets the only meshes impacted by this light.
  98481. */
  98482. set includedOnlyMeshes(value: AbstractMesh[]);
  98483. private _excludedMeshes;
  98484. /**
  98485. * Gets the meshes not impacted by this light.
  98486. */
  98487. get excludedMeshes(): AbstractMesh[];
  98488. /**
  98489. * Sets the meshes not impacted by this light.
  98490. */
  98491. set excludedMeshes(value: AbstractMesh[]);
  98492. private _excludeWithLayerMask;
  98493. /**
  98494. * Gets the layer id use to find what meshes are not impacted by the light.
  98495. * Inactive if 0
  98496. */
  98497. get excludeWithLayerMask(): number;
  98498. /**
  98499. * Sets the layer id use to find what meshes are not impacted by the light.
  98500. * Inactive if 0
  98501. */
  98502. set excludeWithLayerMask(value: number);
  98503. private _includeOnlyWithLayerMask;
  98504. /**
  98505. * Gets the layer id use to find what meshes are impacted by the light.
  98506. * Inactive if 0
  98507. */
  98508. get includeOnlyWithLayerMask(): number;
  98509. /**
  98510. * Sets the layer id use to find what meshes are impacted by the light.
  98511. * Inactive if 0
  98512. */
  98513. set includeOnlyWithLayerMask(value: number);
  98514. private _lightmapMode;
  98515. /**
  98516. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98517. */
  98518. get lightmapMode(): number;
  98519. /**
  98520. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98521. */
  98522. set lightmapMode(value: number);
  98523. /**
  98524. * Shadow generator associted to the light.
  98525. * @hidden Internal use only.
  98526. */
  98527. _shadowGenerator: Nullable<IShadowGenerator>;
  98528. /**
  98529. * @hidden Internal use only.
  98530. */
  98531. _excludedMeshesIds: string[];
  98532. /**
  98533. * @hidden Internal use only.
  98534. */
  98535. _includedOnlyMeshesIds: string[];
  98536. /**
  98537. * The current light unifom buffer.
  98538. * @hidden Internal use only.
  98539. */
  98540. _uniformBuffer: UniformBuffer;
  98541. /** @hidden */
  98542. _renderId: number;
  98543. /**
  98544. * Creates a Light object in the scene.
  98545. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98546. * @param name The firendly name of the light
  98547. * @param scene The scene the light belongs too
  98548. */
  98549. constructor(name: string, scene: Scene);
  98550. protected abstract _buildUniformLayout(): void;
  98551. /**
  98552. * Sets the passed Effect "effect" with the Light information.
  98553. * @param effect The effect to update
  98554. * @param lightIndex The index of the light in the effect to update
  98555. * @returns The light
  98556. */
  98557. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98558. /**
  98559. * Sets the passed Effect "effect" with the Light textures.
  98560. * @param effect The effect to update
  98561. * @param lightIndex The index of the light in the effect to update
  98562. * @returns The light
  98563. */
  98564. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98565. /**
  98566. * Binds the lights information from the scene to the effect for the given mesh.
  98567. * @param lightIndex Light index
  98568. * @param scene The scene where the light belongs to
  98569. * @param effect The effect we are binding the data to
  98570. * @param useSpecular Defines if specular is supported
  98571. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98572. */
  98573. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98574. /**
  98575. * Sets the passed Effect "effect" with the Light information.
  98576. * @param effect The effect to update
  98577. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98578. * @returns The light
  98579. */
  98580. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98581. /**
  98582. * Returns the string "Light".
  98583. * @returns the class name
  98584. */
  98585. getClassName(): string;
  98586. /** @hidden */
  98587. readonly _isLight: boolean;
  98588. /**
  98589. * Converts the light information to a readable string for debug purpose.
  98590. * @param fullDetails Supports for multiple levels of logging within scene loading
  98591. * @returns the human readable light info
  98592. */
  98593. toString(fullDetails?: boolean): string;
  98594. /** @hidden */
  98595. protected _syncParentEnabledState(): void;
  98596. /**
  98597. * Set the enabled state of this node.
  98598. * @param value - the new enabled state
  98599. */
  98600. setEnabled(value: boolean): void;
  98601. /**
  98602. * Returns the Light associated shadow generator if any.
  98603. * @return the associated shadow generator.
  98604. */
  98605. getShadowGenerator(): Nullable<IShadowGenerator>;
  98606. /**
  98607. * Returns a Vector3, the absolute light position in the World.
  98608. * @returns the world space position of the light
  98609. */
  98610. getAbsolutePosition(): Vector3;
  98611. /**
  98612. * Specifies if the light will affect the passed mesh.
  98613. * @param mesh The mesh to test against the light
  98614. * @return true the mesh is affected otherwise, false.
  98615. */
  98616. canAffectMesh(mesh: AbstractMesh): boolean;
  98617. /**
  98618. * Sort function to order lights for rendering.
  98619. * @param a First Light object to compare to second.
  98620. * @param b Second Light object to compare first.
  98621. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98622. */
  98623. static CompareLightsPriority(a: Light, b: Light): number;
  98624. /**
  98625. * Releases resources associated with this node.
  98626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98628. */
  98629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98630. /**
  98631. * Returns the light type ID (integer).
  98632. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98633. */
  98634. getTypeID(): number;
  98635. /**
  98636. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98637. * @returns the scaled intensity in intensity mode unit
  98638. */
  98639. getScaledIntensity(): number;
  98640. /**
  98641. * Returns a new Light object, named "name", from the current one.
  98642. * @param name The name of the cloned light
  98643. * @param newParent The parent of this light, if it has one
  98644. * @returns the new created light
  98645. */
  98646. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98647. /**
  98648. * Serializes the current light into a Serialization object.
  98649. * @returns the serialized object.
  98650. */
  98651. serialize(): any;
  98652. /**
  98653. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98654. * This new light is named "name" and added to the passed scene.
  98655. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98656. * @param name The friendly name of the light
  98657. * @param scene The scene the new light will belong to
  98658. * @returns the constructor function
  98659. */
  98660. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98661. /**
  98662. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98663. * @param parsedLight The JSON representation of the light
  98664. * @param scene The scene to create the parsed light in
  98665. * @returns the created light after parsing
  98666. */
  98667. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98668. private _hookArrayForExcluded;
  98669. private _hookArrayForIncludedOnly;
  98670. private _resyncMeshes;
  98671. /**
  98672. * Forces the meshes to update their light related information in their rendering used effects
  98673. * @hidden Internal Use Only
  98674. */
  98675. _markMeshesAsLightDirty(): void;
  98676. /**
  98677. * Recomputes the cached photometric scale if needed.
  98678. */
  98679. private _computePhotometricScale;
  98680. /**
  98681. * Returns the Photometric Scale according to the light type and intensity mode.
  98682. */
  98683. private _getPhotometricScale;
  98684. /**
  98685. * Reorder the light in the scene according to their defined priority.
  98686. * @hidden Internal Use Only
  98687. */
  98688. _reorderLightsInScene(): void;
  98689. /**
  98690. * Prepares the list of defines specific to the light type.
  98691. * @param defines the list of defines
  98692. * @param lightIndex defines the index of the light for the effect
  98693. */
  98694. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98695. }
  98696. }
  98697. declare module BABYLON {
  98698. /**
  98699. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98700. * This is the base of the follow, arc rotate cameras and Free camera
  98701. * @see https://doc.babylonjs.com/features/cameras
  98702. */
  98703. export class TargetCamera extends Camera {
  98704. private static _RigCamTransformMatrix;
  98705. private static _TargetTransformMatrix;
  98706. private static _TargetFocalPoint;
  98707. private _tmpUpVector;
  98708. private _tmpTargetVector;
  98709. /**
  98710. * Define the current direction the camera is moving to
  98711. */
  98712. cameraDirection: Vector3;
  98713. /**
  98714. * Define the current rotation the camera is rotating to
  98715. */
  98716. cameraRotation: Vector2;
  98717. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98718. ignoreParentScaling: boolean;
  98719. /**
  98720. * When set, the up vector of the camera will be updated by the rotation of the camera
  98721. */
  98722. updateUpVectorFromRotation: boolean;
  98723. private _tmpQuaternion;
  98724. /**
  98725. * Define the current rotation of the camera
  98726. */
  98727. rotation: Vector3;
  98728. /**
  98729. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98730. */
  98731. rotationQuaternion: Quaternion;
  98732. /**
  98733. * Define the current speed of the camera
  98734. */
  98735. speed: number;
  98736. /**
  98737. * Add constraint to the camera to prevent it to move freely in all directions and
  98738. * around all axis.
  98739. */
  98740. noRotationConstraint: boolean;
  98741. /**
  98742. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98743. * panning
  98744. */
  98745. invertRotation: boolean;
  98746. /**
  98747. * Speed multiplier for inverse camera panning
  98748. */
  98749. inverseRotationSpeed: number;
  98750. /**
  98751. * Define the current target of the camera as an object or a position.
  98752. */
  98753. lockedTarget: any;
  98754. /** @hidden */
  98755. _currentTarget: Vector3;
  98756. /** @hidden */
  98757. _initialFocalDistance: number;
  98758. /** @hidden */
  98759. _viewMatrix: Matrix;
  98760. /** @hidden */
  98761. _camMatrix: Matrix;
  98762. /** @hidden */
  98763. _cameraTransformMatrix: Matrix;
  98764. /** @hidden */
  98765. _cameraRotationMatrix: Matrix;
  98766. /** @hidden */
  98767. _referencePoint: Vector3;
  98768. /** @hidden */
  98769. _transformedReferencePoint: Vector3;
  98770. /** @hidden */
  98771. _reset: () => void;
  98772. private _defaultUp;
  98773. /**
  98774. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98775. * This is the base of the follow, arc rotate cameras and Free camera
  98776. * @see https://doc.babylonjs.com/features/cameras
  98777. * @param name Defines the name of the camera in the scene
  98778. * @param position Defines the start position of the camera in the scene
  98779. * @param scene Defines the scene the camera belongs to
  98780. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98781. */
  98782. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98783. /**
  98784. * Gets the position in front of the camera at a given distance.
  98785. * @param distance The distance from the camera we want the position to be
  98786. * @returns the position
  98787. */
  98788. getFrontPosition(distance: number): Vector3;
  98789. /** @hidden */
  98790. _getLockedTargetPosition(): Nullable<Vector3>;
  98791. private _storedPosition;
  98792. private _storedRotation;
  98793. private _storedRotationQuaternion;
  98794. /**
  98795. * Store current camera state of the camera (fov, position, rotation, etc..)
  98796. * @returns the camera
  98797. */
  98798. storeState(): Camera;
  98799. /**
  98800. * Restored camera state. You must call storeState() first
  98801. * @returns whether it was successful or not
  98802. * @hidden
  98803. */
  98804. _restoreStateValues(): boolean;
  98805. /** @hidden */
  98806. _initCache(): void;
  98807. /** @hidden */
  98808. _updateCache(ignoreParentClass?: boolean): void;
  98809. /** @hidden */
  98810. _isSynchronizedViewMatrix(): boolean;
  98811. /** @hidden */
  98812. _computeLocalCameraSpeed(): number;
  98813. /**
  98814. * Defines the target the camera should look at.
  98815. * @param target Defines the new target as a Vector or a mesh
  98816. */
  98817. setTarget(target: Vector3): void;
  98818. /**
  98819. * Defines the target point of the camera.
  98820. * The camera looks towards it form the radius distance.
  98821. */
  98822. get target(): Vector3;
  98823. set target(value: Vector3);
  98824. /**
  98825. * Return the current target position of the camera. This value is expressed in local space.
  98826. * @returns the target position
  98827. */
  98828. getTarget(): Vector3;
  98829. /** @hidden */
  98830. _decideIfNeedsToMove(): boolean;
  98831. /** @hidden */
  98832. _updatePosition(): void;
  98833. /** @hidden */
  98834. _checkInputs(): void;
  98835. protected _updateCameraRotationMatrix(): void;
  98836. /**
  98837. * 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)
  98838. * @returns the current camera
  98839. */
  98840. private _rotateUpVectorWithCameraRotationMatrix;
  98841. private _cachedRotationZ;
  98842. private _cachedQuaternionRotationZ;
  98843. /** @hidden */
  98844. _getViewMatrix(): Matrix;
  98845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98846. /**
  98847. * @hidden
  98848. */
  98849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98850. /**
  98851. * @hidden
  98852. */
  98853. _updateRigCameras(): void;
  98854. private _getRigCamPositionAndTarget;
  98855. /**
  98856. * Gets the current object class name.
  98857. * @return the class name
  98858. */
  98859. getClassName(): string;
  98860. }
  98861. }
  98862. declare module BABYLON {
  98863. /**
  98864. * Gather the list of keyboard event types as constants.
  98865. */
  98866. export class KeyboardEventTypes {
  98867. /**
  98868. * The keydown event is fired when a key becomes active (pressed).
  98869. */
  98870. static readonly KEYDOWN: number;
  98871. /**
  98872. * The keyup event is fired when a key has been released.
  98873. */
  98874. static readonly KEYUP: number;
  98875. }
  98876. /**
  98877. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98878. */
  98879. export class KeyboardInfo {
  98880. /**
  98881. * Defines the type of event (KeyboardEventTypes)
  98882. */
  98883. type: number;
  98884. /**
  98885. * Defines the related dom event
  98886. */
  98887. event: KeyboardEvent;
  98888. /**
  98889. * Instantiates a new keyboard info.
  98890. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98891. * @param type Defines the type of event (KeyboardEventTypes)
  98892. * @param event Defines the related dom event
  98893. */
  98894. constructor(
  98895. /**
  98896. * Defines the type of event (KeyboardEventTypes)
  98897. */
  98898. type: number,
  98899. /**
  98900. * Defines the related dom event
  98901. */
  98902. event: KeyboardEvent);
  98903. }
  98904. /**
  98905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98906. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98907. */
  98908. export class KeyboardInfoPre extends KeyboardInfo {
  98909. /**
  98910. * Defines the type of event (KeyboardEventTypes)
  98911. */
  98912. type: number;
  98913. /**
  98914. * Defines the related dom event
  98915. */
  98916. event: KeyboardEvent;
  98917. /**
  98918. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98919. */
  98920. skipOnPointerObservable: boolean;
  98921. /**
  98922. * Instantiates a new keyboard pre info.
  98923. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98924. * @param type Defines the type of event (KeyboardEventTypes)
  98925. * @param event Defines the related dom event
  98926. */
  98927. constructor(
  98928. /**
  98929. * Defines the type of event (KeyboardEventTypes)
  98930. */
  98931. type: number,
  98932. /**
  98933. * Defines the related dom event
  98934. */
  98935. event: KeyboardEvent);
  98936. }
  98937. }
  98938. declare module BABYLON {
  98939. /**
  98940. * Manage the keyboard inputs to control the movement of a free camera.
  98941. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98942. */
  98943. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98944. /**
  98945. * Defines the camera the input is attached to.
  98946. */
  98947. camera: FreeCamera;
  98948. /**
  98949. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98950. */
  98951. keysUp: number[];
  98952. /**
  98953. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98954. */
  98955. keysUpward: number[];
  98956. /**
  98957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98958. */
  98959. keysDown: number[];
  98960. /**
  98961. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98962. */
  98963. keysDownward: number[];
  98964. /**
  98965. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98966. */
  98967. keysLeft: number[];
  98968. /**
  98969. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98970. */
  98971. keysRight: number[];
  98972. private _keys;
  98973. private _onCanvasBlurObserver;
  98974. private _onKeyboardObserver;
  98975. private _engine;
  98976. private _scene;
  98977. /**
  98978. * Attach the input controls to a specific dom element to get the input from.
  98979. * @param element Defines the element the controls should be listened from
  98980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98981. */
  98982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98983. /**
  98984. * Detach the current controls from the specified dom element.
  98985. * @param element Defines the element to stop listening the inputs from
  98986. */
  98987. detachControl(element: Nullable<HTMLElement>): void;
  98988. /**
  98989. * Update the current camera state depending on the inputs that have been used this frame.
  98990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98991. */
  98992. checkInputs(): void;
  98993. /**
  98994. * Gets the class name of the current intput.
  98995. * @returns the class name
  98996. */
  98997. getClassName(): string;
  98998. /** @hidden */
  98999. _onLostFocus(): void;
  99000. /**
  99001. * Get the friendly name associated with the input class.
  99002. * @returns the input friendly name
  99003. */
  99004. getSimpleName(): string;
  99005. }
  99006. }
  99007. declare module BABYLON {
  99008. /**
  99009. * Gather the list of pointer event types as constants.
  99010. */
  99011. export class PointerEventTypes {
  99012. /**
  99013. * 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.
  99014. */
  99015. static readonly POINTERDOWN: number;
  99016. /**
  99017. * The pointerup event is fired when a pointer is no longer active.
  99018. */
  99019. static readonly POINTERUP: number;
  99020. /**
  99021. * The pointermove event is fired when a pointer changes coordinates.
  99022. */
  99023. static readonly POINTERMOVE: number;
  99024. /**
  99025. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99026. */
  99027. static readonly POINTERWHEEL: number;
  99028. /**
  99029. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99030. */
  99031. static readonly POINTERPICK: number;
  99032. /**
  99033. * The pointertap event is fired when a the object has been touched and released without drag.
  99034. */
  99035. static readonly POINTERTAP: number;
  99036. /**
  99037. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99038. */
  99039. static readonly POINTERDOUBLETAP: number;
  99040. }
  99041. /**
  99042. * Base class of pointer info types.
  99043. */
  99044. export class PointerInfoBase {
  99045. /**
  99046. * Defines the type of event (PointerEventTypes)
  99047. */
  99048. type: number;
  99049. /**
  99050. * Defines the related dom event
  99051. */
  99052. event: PointerEvent | MouseWheelEvent;
  99053. /**
  99054. * Instantiates the base class of pointers info.
  99055. * @param type Defines the type of event (PointerEventTypes)
  99056. * @param event Defines the related dom event
  99057. */
  99058. constructor(
  99059. /**
  99060. * Defines the type of event (PointerEventTypes)
  99061. */
  99062. type: number,
  99063. /**
  99064. * Defines the related dom event
  99065. */
  99066. event: PointerEvent | MouseWheelEvent);
  99067. }
  99068. /**
  99069. * This class is used to store pointer related info for the onPrePointerObservable event.
  99070. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99071. */
  99072. export class PointerInfoPre extends PointerInfoBase {
  99073. /**
  99074. * Ray from a pointer if availible (eg. 6dof controller)
  99075. */
  99076. ray: Nullable<Ray>;
  99077. /**
  99078. * Defines the local position of the pointer on the canvas.
  99079. */
  99080. localPosition: Vector2;
  99081. /**
  99082. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99083. */
  99084. skipOnPointerObservable: boolean;
  99085. /**
  99086. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99087. * @param type Defines the type of event (PointerEventTypes)
  99088. * @param event Defines the related dom event
  99089. * @param localX Defines the local x coordinates of the pointer when the event occured
  99090. * @param localY Defines the local y coordinates of the pointer when the event occured
  99091. */
  99092. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99093. }
  99094. /**
  99095. * This type contains all the data related to a pointer event in Babylon.js.
  99096. * 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.
  99097. */
  99098. export class PointerInfo extends PointerInfoBase {
  99099. /**
  99100. * Defines the picking info associated to the info (if any)\
  99101. */
  99102. pickInfo: Nullable<PickingInfo>;
  99103. /**
  99104. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99105. * @param type Defines the type of event (PointerEventTypes)
  99106. * @param event Defines the related dom event
  99107. * @param pickInfo Defines the picking info associated to the info (if any)\
  99108. */
  99109. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99110. /**
  99111. * Defines the picking info associated to the info (if any)\
  99112. */
  99113. pickInfo: Nullable<PickingInfo>);
  99114. }
  99115. /**
  99116. * Data relating to a touch event on the screen.
  99117. */
  99118. export interface PointerTouch {
  99119. /**
  99120. * X coordinate of touch.
  99121. */
  99122. x: number;
  99123. /**
  99124. * Y coordinate of touch.
  99125. */
  99126. y: number;
  99127. /**
  99128. * Id of touch. Unique for each finger.
  99129. */
  99130. pointerId: number;
  99131. /**
  99132. * Event type passed from DOM.
  99133. */
  99134. type: any;
  99135. }
  99136. }
  99137. declare module BABYLON {
  99138. /**
  99139. * Manage the mouse inputs to control the movement of a free camera.
  99140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99141. */
  99142. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99143. /**
  99144. * Define if touch is enabled in the mouse input
  99145. */
  99146. touchEnabled: boolean;
  99147. /**
  99148. * Defines the camera the input is attached to.
  99149. */
  99150. camera: FreeCamera;
  99151. /**
  99152. * Defines the buttons associated with the input to handle camera move.
  99153. */
  99154. buttons: number[];
  99155. /**
  99156. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99157. */
  99158. angularSensibility: number;
  99159. private _pointerInput;
  99160. private _onMouseMove;
  99161. private _observer;
  99162. private previousPosition;
  99163. /**
  99164. * Observable for when a pointer move event occurs containing the move offset
  99165. */
  99166. onPointerMovedObservable: Observable<{
  99167. offsetX: number;
  99168. offsetY: number;
  99169. }>;
  99170. /**
  99171. * @hidden
  99172. * If the camera should be rotated automatically based on pointer movement
  99173. */
  99174. _allowCameraRotation: boolean;
  99175. /**
  99176. * Manage the mouse inputs to control the movement of a free camera.
  99177. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99178. * @param touchEnabled Defines if touch is enabled or not
  99179. */
  99180. constructor(
  99181. /**
  99182. * Define if touch is enabled in the mouse input
  99183. */
  99184. touchEnabled?: boolean);
  99185. /**
  99186. * Attach the input controls to a specific dom element to get the input from.
  99187. * @param element Defines the element the controls should be listened from
  99188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99189. */
  99190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99191. /**
  99192. * Called on JS contextmenu event.
  99193. * Override this method to provide functionality.
  99194. */
  99195. protected onContextMenu(evt: PointerEvent): void;
  99196. /**
  99197. * Detach the current controls from the specified dom element.
  99198. * @param element Defines the element to stop listening the inputs from
  99199. */
  99200. detachControl(element: Nullable<HTMLElement>): void;
  99201. /**
  99202. * Gets the class name of the current intput.
  99203. * @returns the class name
  99204. */
  99205. getClassName(): string;
  99206. /**
  99207. * Get the friendly name associated with the input class.
  99208. * @returns the input friendly name
  99209. */
  99210. getSimpleName(): string;
  99211. }
  99212. }
  99213. declare module BABYLON {
  99214. /**
  99215. * Manage the touch inputs to control the movement of a free camera.
  99216. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99217. */
  99218. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99219. /**
  99220. * Define if mouse events can be treated as touch events
  99221. */
  99222. allowMouse: boolean;
  99223. /**
  99224. * Defines the camera the input is attached to.
  99225. */
  99226. camera: FreeCamera;
  99227. /**
  99228. * Defines the touch sensibility for rotation.
  99229. * The higher the faster.
  99230. */
  99231. touchAngularSensibility: number;
  99232. /**
  99233. * Defines the touch sensibility for move.
  99234. * The higher the faster.
  99235. */
  99236. touchMoveSensibility: number;
  99237. private _offsetX;
  99238. private _offsetY;
  99239. private _pointerPressed;
  99240. private _pointerInput;
  99241. private _observer;
  99242. private _onLostFocus;
  99243. /**
  99244. * Manage the touch inputs to control the movement of a free camera.
  99245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99246. * @param allowMouse Defines if mouse events can be treated as touch events
  99247. */
  99248. constructor(
  99249. /**
  99250. * Define if mouse events can be treated as touch events
  99251. */
  99252. allowMouse?: boolean);
  99253. /**
  99254. * Attach the input controls to a specific dom element to get the input from.
  99255. * @param element Defines the element the controls should be listened from
  99256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99257. */
  99258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99259. /**
  99260. * Detach the current controls from the specified dom element.
  99261. * @param element Defines the element to stop listening the inputs from
  99262. */
  99263. detachControl(element: Nullable<HTMLElement>): void;
  99264. /**
  99265. * Update the current camera state depending on the inputs that have been used this frame.
  99266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99267. */
  99268. checkInputs(): void;
  99269. /**
  99270. * Gets the class name of the current intput.
  99271. * @returns the class name
  99272. */
  99273. getClassName(): string;
  99274. /**
  99275. * Get the friendly name associated with the input class.
  99276. * @returns the input friendly name
  99277. */
  99278. getSimpleName(): string;
  99279. }
  99280. }
  99281. declare module BABYLON {
  99282. /**
  99283. * Default Inputs manager for the FreeCamera.
  99284. * It groups all the default supported inputs for ease of use.
  99285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99286. */
  99287. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99288. /**
  99289. * @hidden
  99290. */
  99291. _mouseInput: Nullable<FreeCameraMouseInput>;
  99292. /**
  99293. * Instantiates a new FreeCameraInputsManager.
  99294. * @param camera Defines the camera the inputs belong to
  99295. */
  99296. constructor(camera: FreeCamera);
  99297. /**
  99298. * Add keyboard input support to the input manager.
  99299. * @returns the current input manager
  99300. */
  99301. addKeyboard(): FreeCameraInputsManager;
  99302. /**
  99303. * Add mouse input support to the input manager.
  99304. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99305. * @returns the current input manager
  99306. */
  99307. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99308. /**
  99309. * Removes the mouse input support from the manager
  99310. * @returns the current input manager
  99311. */
  99312. removeMouse(): FreeCameraInputsManager;
  99313. /**
  99314. * Add touch input support to the input manager.
  99315. * @returns the current input manager
  99316. */
  99317. addTouch(): FreeCameraInputsManager;
  99318. /**
  99319. * Remove all attached input methods from a camera
  99320. */
  99321. clear(): void;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99327. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99328. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99329. */
  99330. export class FreeCamera extends TargetCamera {
  99331. /**
  99332. * Define the collision ellipsoid of the camera.
  99333. * This is helpful to simulate a camera body like the player body around the camera
  99334. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99335. */
  99336. ellipsoid: Vector3;
  99337. /**
  99338. * Define an offset for the position of the ellipsoid around the camera.
  99339. * This can be helpful to determine the center of the body near the gravity center of the body
  99340. * instead of its head.
  99341. */
  99342. ellipsoidOffset: Vector3;
  99343. /**
  99344. * Enable or disable collisions of the camera with the rest of the scene objects.
  99345. */
  99346. checkCollisions: boolean;
  99347. /**
  99348. * Enable or disable gravity on the camera.
  99349. */
  99350. applyGravity: boolean;
  99351. /**
  99352. * Define the input manager associated to the camera.
  99353. */
  99354. inputs: FreeCameraInputsManager;
  99355. /**
  99356. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99357. * Higher values reduce sensitivity.
  99358. */
  99359. get angularSensibility(): number;
  99360. /**
  99361. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99362. * Higher values reduce sensitivity.
  99363. */
  99364. set angularSensibility(value: number);
  99365. /**
  99366. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99367. */
  99368. get keysUp(): number[];
  99369. set keysUp(value: number[]);
  99370. /**
  99371. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99372. */
  99373. get keysUpward(): number[];
  99374. set keysUpward(value: number[]);
  99375. /**
  99376. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99377. */
  99378. get keysDown(): number[];
  99379. set keysDown(value: number[]);
  99380. /**
  99381. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99382. */
  99383. get keysDownward(): number[];
  99384. set keysDownward(value: number[]);
  99385. /**
  99386. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99387. */
  99388. get keysLeft(): number[];
  99389. set keysLeft(value: number[]);
  99390. /**
  99391. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99392. */
  99393. get keysRight(): number[];
  99394. set keysRight(value: number[]);
  99395. /**
  99396. * Event raised when the camera collide with a mesh in the scene.
  99397. */
  99398. onCollide: (collidedMesh: AbstractMesh) => void;
  99399. private _collider;
  99400. private _needMoveForGravity;
  99401. private _oldPosition;
  99402. private _diffPosition;
  99403. private _newPosition;
  99404. /** @hidden */
  99405. _localDirection: Vector3;
  99406. /** @hidden */
  99407. _transformedDirection: Vector3;
  99408. /**
  99409. * Instantiates a Free Camera.
  99410. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99411. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99412. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99413. * @param name Define the name of the camera in the scene
  99414. * @param position Define the start position of the camera in the scene
  99415. * @param scene Define the scene the camera belongs to
  99416. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99417. */
  99418. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99419. /**
  99420. * Attached controls to the current camera.
  99421. * @param element Defines the element the controls should be listened from
  99422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99423. */
  99424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99425. /**
  99426. * Detach the current controls from the camera.
  99427. * The camera will stop reacting to inputs.
  99428. * @param element Defines the element to stop listening the inputs from
  99429. */
  99430. detachControl(element: HTMLElement): void;
  99431. private _collisionMask;
  99432. /**
  99433. * Define a collision mask to limit the list of object the camera can collide with
  99434. */
  99435. get collisionMask(): number;
  99436. set collisionMask(mask: number);
  99437. /** @hidden */
  99438. _collideWithWorld(displacement: Vector3): void;
  99439. private _onCollisionPositionChange;
  99440. /** @hidden */
  99441. _checkInputs(): void;
  99442. /** @hidden */
  99443. _decideIfNeedsToMove(): boolean;
  99444. /** @hidden */
  99445. _updatePosition(): void;
  99446. /**
  99447. * Destroy the camera and release the current resources hold by it.
  99448. */
  99449. dispose(): void;
  99450. /**
  99451. * Gets the current object class name.
  99452. * @return the class name
  99453. */
  99454. getClassName(): string;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Represents a gamepad control stick position
  99460. */
  99461. export class StickValues {
  99462. /**
  99463. * The x component of the control stick
  99464. */
  99465. x: number;
  99466. /**
  99467. * The y component of the control stick
  99468. */
  99469. y: number;
  99470. /**
  99471. * Initializes the gamepad x and y control stick values
  99472. * @param x The x component of the gamepad control stick value
  99473. * @param y The y component of the gamepad control stick value
  99474. */
  99475. constructor(
  99476. /**
  99477. * The x component of the control stick
  99478. */
  99479. x: number,
  99480. /**
  99481. * The y component of the control stick
  99482. */
  99483. y: number);
  99484. }
  99485. /**
  99486. * An interface which manages callbacks for gamepad button changes
  99487. */
  99488. export interface GamepadButtonChanges {
  99489. /**
  99490. * Called when a gamepad has been changed
  99491. */
  99492. changed: boolean;
  99493. /**
  99494. * Called when a gamepad press event has been triggered
  99495. */
  99496. pressChanged: boolean;
  99497. /**
  99498. * Called when a touch event has been triggered
  99499. */
  99500. touchChanged: boolean;
  99501. /**
  99502. * Called when a value has changed
  99503. */
  99504. valueChanged: boolean;
  99505. }
  99506. /**
  99507. * Represents a gamepad
  99508. */
  99509. export class Gamepad {
  99510. /**
  99511. * The id of the gamepad
  99512. */
  99513. id: string;
  99514. /**
  99515. * The index of the gamepad
  99516. */
  99517. index: number;
  99518. /**
  99519. * The browser gamepad
  99520. */
  99521. browserGamepad: any;
  99522. /**
  99523. * Specifies what type of gamepad this represents
  99524. */
  99525. type: number;
  99526. private _leftStick;
  99527. private _rightStick;
  99528. /** @hidden */
  99529. _isConnected: boolean;
  99530. private _leftStickAxisX;
  99531. private _leftStickAxisY;
  99532. private _rightStickAxisX;
  99533. private _rightStickAxisY;
  99534. /**
  99535. * Triggered when the left control stick has been changed
  99536. */
  99537. private _onleftstickchanged;
  99538. /**
  99539. * Triggered when the right control stick has been changed
  99540. */
  99541. private _onrightstickchanged;
  99542. /**
  99543. * Represents a gamepad controller
  99544. */
  99545. static GAMEPAD: number;
  99546. /**
  99547. * Represents a generic controller
  99548. */
  99549. static GENERIC: number;
  99550. /**
  99551. * Represents an XBox controller
  99552. */
  99553. static XBOX: number;
  99554. /**
  99555. * Represents a pose-enabled controller
  99556. */
  99557. static POSE_ENABLED: number;
  99558. /**
  99559. * Represents an Dual Shock controller
  99560. */
  99561. static DUALSHOCK: number;
  99562. /**
  99563. * Specifies whether the left control stick should be Y-inverted
  99564. */
  99565. protected _invertLeftStickY: boolean;
  99566. /**
  99567. * Specifies if the gamepad has been connected
  99568. */
  99569. get isConnected(): boolean;
  99570. /**
  99571. * Initializes the gamepad
  99572. * @param id The id of the gamepad
  99573. * @param index The index of the gamepad
  99574. * @param browserGamepad The browser gamepad
  99575. * @param leftStickX The x component of the left joystick
  99576. * @param leftStickY The y component of the left joystick
  99577. * @param rightStickX The x component of the right joystick
  99578. * @param rightStickY The y component of the right joystick
  99579. */
  99580. constructor(
  99581. /**
  99582. * The id of the gamepad
  99583. */
  99584. id: string,
  99585. /**
  99586. * The index of the gamepad
  99587. */
  99588. index: number,
  99589. /**
  99590. * The browser gamepad
  99591. */
  99592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99593. /**
  99594. * Callback triggered when the left joystick has changed
  99595. * @param callback
  99596. */
  99597. onleftstickchanged(callback: (values: StickValues) => void): void;
  99598. /**
  99599. * Callback triggered when the right joystick has changed
  99600. * @param callback
  99601. */
  99602. onrightstickchanged(callback: (values: StickValues) => void): void;
  99603. /**
  99604. * Gets the left joystick
  99605. */
  99606. get leftStick(): StickValues;
  99607. /**
  99608. * Sets the left joystick values
  99609. */
  99610. set leftStick(newValues: StickValues);
  99611. /**
  99612. * Gets the right joystick
  99613. */
  99614. get rightStick(): StickValues;
  99615. /**
  99616. * Sets the right joystick value
  99617. */
  99618. set rightStick(newValues: StickValues);
  99619. /**
  99620. * Updates the gamepad joystick positions
  99621. */
  99622. update(): void;
  99623. /**
  99624. * Disposes the gamepad
  99625. */
  99626. dispose(): void;
  99627. }
  99628. /**
  99629. * Represents a generic gamepad
  99630. */
  99631. export class GenericPad extends Gamepad {
  99632. private _buttons;
  99633. private _onbuttondown;
  99634. private _onbuttonup;
  99635. /**
  99636. * Observable triggered when a button has been pressed
  99637. */
  99638. onButtonDownObservable: Observable<number>;
  99639. /**
  99640. * Observable triggered when a button has been released
  99641. */
  99642. onButtonUpObservable: Observable<number>;
  99643. /**
  99644. * Callback triggered when a button has been pressed
  99645. * @param callback Called when a button has been pressed
  99646. */
  99647. onbuttondown(callback: (buttonPressed: number) => void): void;
  99648. /**
  99649. * Callback triggered when a button has been released
  99650. * @param callback Called when a button has been released
  99651. */
  99652. onbuttonup(callback: (buttonReleased: number) => void): void;
  99653. /**
  99654. * Initializes the generic gamepad
  99655. * @param id The id of the generic gamepad
  99656. * @param index The index of the generic gamepad
  99657. * @param browserGamepad The browser gamepad
  99658. */
  99659. constructor(id: string, index: number, browserGamepad: any);
  99660. private _setButtonValue;
  99661. /**
  99662. * Updates the generic gamepad
  99663. */
  99664. update(): void;
  99665. /**
  99666. * Disposes the generic gamepad
  99667. */
  99668. dispose(): void;
  99669. }
  99670. }
  99671. declare module BABYLON {
  99672. /**
  99673. * Defines the types of pose enabled controllers that are supported
  99674. */
  99675. export enum PoseEnabledControllerType {
  99676. /**
  99677. * HTC Vive
  99678. */
  99679. VIVE = 0,
  99680. /**
  99681. * Oculus Rift
  99682. */
  99683. OCULUS = 1,
  99684. /**
  99685. * Windows mixed reality
  99686. */
  99687. WINDOWS = 2,
  99688. /**
  99689. * Samsung gear VR
  99690. */
  99691. GEAR_VR = 3,
  99692. /**
  99693. * Google Daydream
  99694. */
  99695. DAYDREAM = 4,
  99696. /**
  99697. * Generic
  99698. */
  99699. GENERIC = 5
  99700. }
  99701. /**
  99702. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99703. */
  99704. export interface MutableGamepadButton {
  99705. /**
  99706. * Value of the button/trigger
  99707. */
  99708. value: number;
  99709. /**
  99710. * If the button/trigger is currently touched
  99711. */
  99712. touched: boolean;
  99713. /**
  99714. * If the button/trigger is currently pressed
  99715. */
  99716. pressed: boolean;
  99717. }
  99718. /**
  99719. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99720. * @hidden
  99721. */
  99722. export interface ExtendedGamepadButton extends GamepadButton {
  99723. /**
  99724. * If the button/trigger is currently pressed
  99725. */
  99726. readonly pressed: boolean;
  99727. /**
  99728. * If the button/trigger is currently touched
  99729. */
  99730. readonly touched: boolean;
  99731. /**
  99732. * Value of the button/trigger
  99733. */
  99734. readonly value: number;
  99735. }
  99736. /** @hidden */
  99737. export interface _GamePadFactory {
  99738. /**
  99739. * Returns whether or not the current gamepad can be created for this type of controller.
  99740. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99741. * @returns true if it can be created, otherwise false
  99742. */
  99743. canCreate(gamepadInfo: any): boolean;
  99744. /**
  99745. * Creates a new instance of the Gamepad.
  99746. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99747. * @returns the new gamepad instance
  99748. */
  99749. create(gamepadInfo: any): Gamepad;
  99750. }
  99751. /**
  99752. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99753. */
  99754. export class PoseEnabledControllerHelper {
  99755. /** @hidden */
  99756. static _ControllerFactories: _GamePadFactory[];
  99757. /** @hidden */
  99758. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99759. /**
  99760. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99761. * @param vrGamepad the gamepad to initialized
  99762. * @returns a vr controller of the type the gamepad identified as
  99763. */
  99764. static InitiateController(vrGamepad: any): Gamepad;
  99765. }
  99766. /**
  99767. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99768. */
  99769. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99770. /**
  99771. * If the controller is used in a webXR session
  99772. */
  99773. isXR: boolean;
  99774. private _deviceRoomPosition;
  99775. private _deviceRoomRotationQuaternion;
  99776. /**
  99777. * The device position in babylon space
  99778. */
  99779. devicePosition: Vector3;
  99780. /**
  99781. * The device rotation in babylon space
  99782. */
  99783. deviceRotationQuaternion: Quaternion;
  99784. /**
  99785. * The scale factor of the device in babylon space
  99786. */
  99787. deviceScaleFactor: number;
  99788. /**
  99789. * (Likely devicePosition should be used instead) The device position in its room space
  99790. */
  99791. position: Vector3;
  99792. /**
  99793. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99794. */
  99795. rotationQuaternion: Quaternion;
  99796. /**
  99797. * The type of controller (Eg. Windows mixed reality)
  99798. */
  99799. controllerType: PoseEnabledControllerType;
  99800. protected _calculatedPosition: Vector3;
  99801. private _calculatedRotation;
  99802. /**
  99803. * The raw pose from the device
  99804. */
  99805. rawPose: DevicePose;
  99806. private _trackPosition;
  99807. private _maxRotationDistFromHeadset;
  99808. private _draggedRoomRotation;
  99809. /**
  99810. * @hidden
  99811. */
  99812. _disableTrackPosition(fixedPosition: Vector3): void;
  99813. /**
  99814. * Internal, the mesh attached to the controller
  99815. * @hidden
  99816. */
  99817. _mesh: Nullable<AbstractMesh>;
  99818. private _poseControlledCamera;
  99819. private _leftHandSystemQuaternion;
  99820. /**
  99821. * Internal, matrix used to convert room space to babylon space
  99822. * @hidden
  99823. */
  99824. _deviceToWorld: Matrix;
  99825. /**
  99826. * Node to be used when casting a ray from the controller
  99827. * @hidden
  99828. */
  99829. _pointingPoseNode: Nullable<TransformNode>;
  99830. /**
  99831. * Name of the child mesh that can be used to cast a ray from the controller
  99832. */
  99833. static readonly POINTING_POSE: string;
  99834. /**
  99835. * Creates a new PoseEnabledController from a gamepad
  99836. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99837. */
  99838. constructor(browserGamepad: any);
  99839. private _workingMatrix;
  99840. /**
  99841. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99842. */
  99843. update(): void;
  99844. /**
  99845. * Updates only the pose device and mesh without doing any button event checking
  99846. */
  99847. protected _updatePoseAndMesh(): void;
  99848. /**
  99849. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99850. * @param poseData raw pose fromthe device
  99851. */
  99852. updateFromDevice(poseData: DevicePose): void;
  99853. /**
  99854. * @hidden
  99855. */
  99856. _meshAttachedObservable: Observable<AbstractMesh>;
  99857. /**
  99858. * Attaches a mesh to the controller
  99859. * @param mesh the mesh to be attached
  99860. */
  99861. attachToMesh(mesh: AbstractMesh): void;
  99862. /**
  99863. * Attaches the controllers mesh to a camera
  99864. * @param camera the camera the mesh should be attached to
  99865. */
  99866. attachToPoseControlledCamera(camera: TargetCamera): void;
  99867. /**
  99868. * Disposes of the controller
  99869. */
  99870. dispose(): void;
  99871. /**
  99872. * The mesh that is attached to the controller
  99873. */
  99874. get mesh(): Nullable<AbstractMesh>;
  99875. /**
  99876. * Gets the ray of the controller in the direction the controller is pointing
  99877. * @param length the length the resulting ray should be
  99878. * @returns a ray in the direction the controller is pointing
  99879. */
  99880. getForwardRay(length?: number): Ray;
  99881. }
  99882. }
  99883. declare module BABYLON {
  99884. /**
  99885. * Defines the WebVRController object that represents controllers tracked in 3D space
  99886. */
  99887. export abstract class WebVRController extends PoseEnabledController {
  99888. /**
  99889. * Internal, the default controller model for the controller
  99890. */
  99891. protected _defaultModel: Nullable<AbstractMesh>;
  99892. /**
  99893. * Fired when the trigger state has changed
  99894. */
  99895. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99896. /**
  99897. * Fired when the main button state has changed
  99898. */
  99899. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99900. /**
  99901. * Fired when the secondary button state has changed
  99902. */
  99903. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99904. /**
  99905. * Fired when the pad state has changed
  99906. */
  99907. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99908. /**
  99909. * Fired when controllers stick values have changed
  99910. */
  99911. onPadValuesChangedObservable: Observable<StickValues>;
  99912. /**
  99913. * Array of button availible on the controller
  99914. */
  99915. protected _buttons: Array<MutableGamepadButton>;
  99916. private _onButtonStateChange;
  99917. /**
  99918. * Fired when a controller button's state has changed
  99919. * @param callback the callback containing the button that was modified
  99920. */
  99921. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99922. /**
  99923. * X and Y axis corresponding to the controllers joystick
  99924. */
  99925. pad: StickValues;
  99926. /**
  99927. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99928. */
  99929. hand: string;
  99930. /**
  99931. * The default controller model for the controller
  99932. */
  99933. get defaultModel(): Nullable<AbstractMesh>;
  99934. /**
  99935. * Creates a new WebVRController from a gamepad
  99936. * @param vrGamepad the gamepad that the WebVRController should be created from
  99937. */
  99938. constructor(vrGamepad: any);
  99939. /**
  99940. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99941. */
  99942. update(): void;
  99943. /**
  99944. * Function to be called when a button is modified
  99945. */
  99946. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99947. /**
  99948. * Loads a mesh and attaches it to the controller
  99949. * @param scene the scene the mesh should be added to
  99950. * @param meshLoaded callback for when the mesh has been loaded
  99951. */
  99952. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99953. private _setButtonValue;
  99954. private _changes;
  99955. private _checkChanges;
  99956. /**
  99957. * Disposes of th webVRCOntroller
  99958. */
  99959. dispose(): void;
  99960. }
  99961. }
  99962. declare module BABYLON {
  99963. /**
  99964. * The HemisphericLight simulates the ambient environment light,
  99965. * so the passed direction is the light reflection direction, not the incoming direction.
  99966. */
  99967. export class HemisphericLight extends Light {
  99968. /**
  99969. * The groundColor is the light in the opposite direction to the one specified during creation.
  99970. * 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.
  99971. */
  99972. groundColor: Color3;
  99973. /**
  99974. * The light reflection direction, not the incoming direction.
  99975. */
  99976. direction: Vector3;
  99977. /**
  99978. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99979. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99980. * The HemisphericLight can't cast shadows.
  99981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99982. * @param name The friendly name of the light
  99983. * @param direction The direction of the light reflection
  99984. * @param scene The scene the light belongs to
  99985. */
  99986. constructor(name: string, direction: Vector3, scene: Scene);
  99987. protected _buildUniformLayout(): void;
  99988. /**
  99989. * Returns the string "HemisphericLight".
  99990. * @return The class name
  99991. */
  99992. getClassName(): string;
  99993. /**
  99994. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99995. * Returns the updated direction.
  99996. * @param target The target the direction should point to
  99997. * @return The computed direction
  99998. */
  99999. setDirectionToTarget(target: Vector3): Vector3;
  100000. /**
  100001. * Returns the shadow generator associated to the light.
  100002. * @returns Always null for hemispheric lights because it does not support shadows.
  100003. */
  100004. getShadowGenerator(): Nullable<IShadowGenerator>;
  100005. /**
  100006. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100007. * @param effect The effect to update
  100008. * @param lightIndex The index of the light in the effect to update
  100009. * @returns The hemispheric light
  100010. */
  100011. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100012. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100013. /**
  100014. * Computes the world matrix of the node
  100015. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100016. * @param useWasUpdatedFlag defines a reserved property
  100017. * @returns the world matrix
  100018. */
  100019. computeWorldMatrix(): Matrix;
  100020. /**
  100021. * Returns the integer 3.
  100022. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100023. */
  100024. getTypeID(): number;
  100025. /**
  100026. * Prepares the list of defines specific to the light type.
  100027. * @param defines the list of defines
  100028. * @param lightIndex defines the index of the light for the effect
  100029. */
  100030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100031. }
  100032. }
  100033. declare module BABYLON {
  100034. /** @hidden */
  100035. export var vrMultiviewToSingleviewPixelShader: {
  100036. name: string;
  100037. shader: string;
  100038. };
  100039. }
  100040. declare module BABYLON {
  100041. /**
  100042. * Renders to multiple views with a single draw call
  100043. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100044. */
  100045. export class MultiviewRenderTarget extends RenderTargetTexture {
  100046. /**
  100047. * Creates a multiview render target
  100048. * @param scene scene used with the render target
  100049. * @param size the size of the render target (used for each view)
  100050. */
  100051. constructor(scene: Scene, size?: number | {
  100052. width: number;
  100053. height: number;
  100054. } | {
  100055. ratio: number;
  100056. });
  100057. /**
  100058. * @hidden
  100059. * @param faceIndex the face index, if its a cube texture
  100060. */
  100061. _bindFrameBuffer(faceIndex?: number): void;
  100062. /**
  100063. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100064. * @returns the view count
  100065. */
  100066. getViewCount(): number;
  100067. }
  100068. }
  100069. declare module BABYLON {
  100070. interface Engine {
  100071. /**
  100072. * Creates a new multiview render target
  100073. * @param width defines the width of the texture
  100074. * @param height defines the height of the texture
  100075. * @returns the created multiview texture
  100076. */
  100077. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100078. /**
  100079. * Binds a multiview framebuffer to be drawn to
  100080. * @param multiviewTexture texture to bind
  100081. */
  100082. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100083. }
  100084. interface Camera {
  100085. /**
  100086. * @hidden
  100087. * 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)
  100088. */
  100089. _useMultiviewToSingleView: boolean;
  100090. /**
  100091. * @hidden
  100092. * 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)
  100093. */
  100094. _multiviewTexture: Nullable<RenderTargetTexture>;
  100095. /**
  100096. * @hidden
  100097. * ensures the multiview texture of the camera exists and has the specified width/height
  100098. * @param width height to set on the multiview texture
  100099. * @param height width to set on the multiview texture
  100100. */
  100101. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100102. }
  100103. interface Scene {
  100104. /** @hidden */
  100105. _transformMatrixR: Matrix;
  100106. /** @hidden */
  100107. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100108. /** @hidden */
  100109. _createMultiviewUbo(): void;
  100110. /** @hidden */
  100111. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100112. /** @hidden */
  100113. _renderMultiviewToSingleView(camera: Camera): void;
  100114. }
  100115. }
  100116. declare module BABYLON {
  100117. /**
  100118. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100119. * This will not be used for webXR as it supports displaying texture arrays directly
  100120. */
  100121. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100122. /**
  100123. * Gets a string identifying the name of the class
  100124. * @returns "VRMultiviewToSingleviewPostProcess" string
  100125. */
  100126. getClassName(): string;
  100127. /**
  100128. * Initializes a VRMultiviewToSingleview
  100129. * @param name name of the post process
  100130. * @param camera camera to be applied to
  100131. * @param scaleFactor scaling factor to the size of the output texture
  100132. */
  100133. constructor(name: string, camera: Camera, scaleFactor: number);
  100134. }
  100135. }
  100136. declare module BABYLON {
  100137. /**
  100138. * Interface used to define additional presentation attributes
  100139. */
  100140. export interface IVRPresentationAttributes {
  100141. /**
  100142. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100143. */
  100144. highRefreshRate: boolean;
  100145. /**
  100146. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100147. */
  100148. foveationLevel: number;
  100149. }
  100150. interface Engine {
  100151. /** @hidden */
  100152. _vrDisplay: any;
  100153. /** @hidden */
  100154. _vrSupported: boolean;
  100155. /** @hidden */
  100156. _oldSize: Size;
  100157. /** @hidden */
  100158. _oldHardwareScaleFactor: number;
  100159. /** @hidden */
  100160. _vrExclusivePointerMode: boolean;
  100161. /** @hidden */
  100162. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100163. /** @hidden */
  100164. _onVRDisplayPointerRestricted: () => void;
  100165. /** @hidden */
  100166. _onVRDisplayPointerUnrestricted: () => void;
  100167. /** @hidden */
  100168. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100169. /** @hidden */
  100170. _onVrDisplayDisconnect: Nullable<() => void>;
  100171. /** @hidden */
  100172. _onVrDisplayPresentChange: Nullable<() => void>;
  100173. /**
  100174. * Observable signaled when VR display mode changes
  100175. */
  100176. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100177. /**
  100178. * Observable signaled when VR request present is complete
  100179. */
  100180. onVRRequestPresentComplete: Observable<boolean>;
  100181. /**
  100182. * Observable signaled when VR request present starts
  100183. */
  100184. onVRRequestPresentStart: Observable<Engine>;
  100185. /**
  100186. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100187. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100188. */
  100189. isInVRExclusivePointerMode: boolean;
  100190. /**
  100191. * Gets a boolean indicating if a webVR device was detected
  100192. * @returns true if a webVR device was detected
  100193. */
  100194. isVRDevicePresent(): boolean;
  100195. /**
  100196. * Gets the current webVR device
  100197. * @returns the current webVR device (or null)
  100198. */
  100199. getVRDevice(): any;
  100200. /**
  100201. * Initializes a webVR display and starts listening to display change events
  100202. * The onVRDisplayChangedObservable will be notified upon these changes
  100203. * @returns A promise containing a VRDisplay and if vr is supported
  100204. */
  100205. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100206. /** @hidden */
  100207. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100208. /**
  100209. * Gets or sets the presentation attributes used to configure VR rendering
  100210. */
  100211. vrPresentationAttributes?: IVRPresentationAttributes;
  100212. /**
  100213. * Call this function to switch to webVR mode
  100214. * Will do nothing if webVR is not supported or if there is no webVR device
  100215. * @param options the webvr options provided to the camera. mainly used for multiview
  100216. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100217. */
  100218. enableVR(options: WebVROptions): void;
  100219. /** @hidden */
  100220. _onVRFullScreenTriggered(): void;
  100221. }
  100222. }
  100223. declare module BABYLON {
  100224. /**
  100225. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100226. * IMPORTANT!! The data is right-hand data.
  100227. * @export
  100228. * @interface DevicePose
  100229. */
  100230. export interface DevicePose {
  100231. /**
  100232. * The position of the device, values in array are [x,y,z].
  100233. */
  100234. readonly position: Nullable<Float32Array>;
  100235. /**
  100236. * The linearVelocity of the device, values in array are [x,y,z].
  100237. */
  100238. readonly linearVelocity: Nullable<Float32Array>;
  100239. /**
  100240. * The linearAcceleration of the device, values in array are [x,y,z].
  100241. */
  100242. readonly linearAcceleration: Nullable<Float32Array>;
  100243. /**
  100244. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100245. */
  100246. readonly orientation: Nullable<Float32Array>;
  100247. /**
  100248. * The angularVelocity of the device, values in array are [x,y,z].
  100249. */
  100250. readonly angularVelocity: Nullable<Float32Array>;
  100251. /**
  100252. * The angularAcceleration of the device, values in array are [x,y,z].
  100253. */
  100254. readonly angularAcceleration: Nullable<Float32Array>;
  100255. }
  100256. /**
  100257. * Interface representing a pose controlled object in Babylon.
  100258. * A pose controlled object has both regular pose values as well as pose values
  100259. * from an external device such as a VR head mounted display
  100260. */
  100261. export interface PoseControlled {
  100262. /**
  100263. * The position of the object in babylon space.
  100264. */
  100265. position: Vector3;
  100266. /**
  100267. * The rotation quaternion of the object in babylon space.
  100268. */
  100269. rotationQuaternion: Quaternion;
  100270. /**
  100271. * The position of the device in babylon space.
  100272. */
  100273. devicePosition?: Vector3;
  100274. /**
  100275. * The rotation quaternion of the device in babylon space.
  100276. */
  100277. deviceRotationQuaternion: Quaternion;
  100278. /**
  100279. * The raw pose coming from the device.
  100280. */
  100281. rawPose: Nullable<DevicePose>;
  100282. /**
  100283. * The scale of the device to be used when translating from device space to babylon space.
  100284. */
  100285. deviceScaleFactor: number;
  100286. /**
  100287. * Updates the poseControlled values based on the input device pose.
  100288. * @param poseData the pose data to update the object with
  100289. */
  100290. updateFromDevice(poseData: DevicePose): void;
  100291. }
  100292. /**
  100293. * Set of options to customize the webVRCamera
  100294. */
  100295. export interface WebVROptions {
  100296. /**
  100297. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100298. */
  100299. trackPosition?: boolean;
  100300. /**
  100301. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100302. */
  100303. positionScale?: number;
  100304. /**
  100305. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100306. */
  100307. displayName?: string;
  100308. /**
  100309. * Should the native controller meshes be initialized. (default: true)
  100310. */
  100311. controllerMeshes?: boolean;
  100312. /**
  100313. * Creating a default HemiLight only on controllers. (default: true)
  100314. */
  100315. defaultLightingOnControllers?: boolean;
  100316. /**
  100317. * If you don't want to use the default VR button of the helper. (default: false)
  100318. */
  100319. useCustomVRButton?: boolean;
  100320. /**
  100321. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100322. */
  100323. customVRButton?: HTMLButtonElement;
  100324. /**
  100325. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100326. */
  100327. rayLength?: number;
  100328. /**
  100329. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100330. */
  100331. defaultHeight?: number;
  100332. /**
  100333. * If multiview should be used if availible (default: false)
  100334. */
  100335. useMultiview?: boolean;
  100336. }
  100337. /**
  100338. * This represents a WebVR camera.
  100339. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100340. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100341. */
  100342. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100343. private webVROptions;
  100344. /**
  100345. * @hidden
  100346. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100347. */
  100348. _vrDevice: any;
  100349. /**
  100350. * The rawPose of the vrDevice.
  100351. */
  100352. rawPose: Nullable<DevicePose>;
  100353. private _onVREnabled;
  100354. private _specsVersion;
  100355. private _attached;
  100356. private _frameData;
  100357. protected _descendants: Array<Node>;
  100358. private _deviceRoomPosition;
  100359. /** @hidden */
  100360. _deviceRoomRotationQuaternion: Quaternion;
  100361. private _standingMatrix;
  100362. /**
  100363. * Represents device position in babylon space.
  100364. */
  100365. devicePosition: Vector3;
  100366. /**
  100367. * Represents device rotation in babylon space.
  100368. */
  100369. deviceRotationQuaternion: Quaternion;
  100370. /**
  100371. * The scale of the device to be used when translating from device space to babylon space.
  100372. */
  100373. deviceScaleFactor: number;
  100374. private _deviceToWorld;
  100375. private _worldToDevice;
  100376. /**
  100377. * References to the webVR controllers for the vrDevice.
  100378. */
  100379. controllers: Array<WebVRController>;
  100380. /**
  100381. * Emits an event when a controller is attached.
  100382. */
  100383. onControllersAttachedObservable: Observable<WebVRController[]>;
  100384. /**
  100385. * Emits an event when a controller's mesh has been loaded;
  100386. */
  100387. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100388. /**
  100389. * Emits an event when the HMD's pose has been updated.
  100390. */
  100391. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100392. private _poseSet;
  100393. /**
  100394. * If the rig cameras be used as parent instead of this camera.
  100395. */
  100396. rigParenting: boolean;
  100397. private _lightOnControllers;
  100398. private _defaultHeight?;
  100399. /**
  100400. * Instantiates a WebVRFreeCamera.
  100401. * @param name The name of the WebVRFreeCamera
  100402. * @param position The starting anchor position for the camera
  100403. * @param scene The scene the camera belongs to
  100404. * @param webVROptions a set of customizable options for the webVRCamera
  100405. */
  100406. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100407. /**
  100408. * Gets the device distance from the ground in meters.
  100409. * @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.
  100410. */
  100411. deviceDistanceToRoomGround(): number;
  100412. /**
  100413. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100414. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100415. */
  100416. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100417. /**
  100418. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100419. * @returns A promise with a boolean set to if the standing matrix is supported.
  100420. */
  100421. useStandingMatrixAsync(): Promise<boolean>;
  100422. /**
  100423. * Disposes the camera
  100424. */
  100425. dispose(): void;
  100426. /**
  100427. * Gets a vrController by name.
  100428. * @param name The name of the controller to retreive
  100429. * @returns the controller matching the name specified or null if not found
  100430. */
  100431. getControllerByName(name: string): Nullable<WebVRController>;
  100432. private _leftController;
  100433. /**
  100434. * The controller corresponding to the users left hand.
  100435. */
  100436. get leftController(): Nullable<WebVRController>;
  100437. private _rightController;
  100438. /**
  100439. * The controller corresponding to the users right hand.
  100440. */
  100441. get rightController(): Nullable<WebVRController>;
  100442. /**
  100443. * Casts a ray forward from the vrCamera's gaze.
  100444. * @param length Length of the ray (default: 100)
  100445. * @returns the ray corresponding to the gaze
  100446. */
  100447. getForwardRay(length?: number): Ray;
  100448. /**
  100449. * @hidden
  100450. * Updates the camera based on device's frame data
  100451. */
  100452. _checkInputs(): void;
  100453. /**
  100454. * Updates the poseControlled values based on the input device pose.
  100455. * @param poseData Pose coming from the device
  100456. */
  100457. updateFromDevice(poseData: DevicePose): void;
  100458. private _htmlElementAttached;
  100459. private _detachIfAttached;
  100460. /**
  100461. * WebVR's attach control will start broadcasting frames to the device.
  100462. * Note that in certain browsers (chrome for example) this function must be called
  100463. * within a user-interaction callback. Example:
  100464. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100465. *
  100466. * @param element html element to attach the vrDevice to
  100467. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100468. */
  100469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100470. /**
  100471. * Detaches the camera from the html element and disables VR
  100472. *
  100473. * @param element html element to detach from
  100474. */
  100475. detachControl(element: HTMLElement): void;
  100476. /**
  100477. * @returns the name of this class
  100478. */
  100479. getClassName(): string;
  100480. /**
  100481. * Calls resetPose on the vrDisplay
  100482. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100483. */
  100484. resetToCurrentRotation(): void;
  100485. /**
  100486. * @hidden
  100487. * Updates the rig cameras (left and right eye)
  100488. */
  100489. _updateRigCameras(): void;
  100490. private _workingVector;
  100491. private _oneVector;
  100492. private _workingMatrix;
  100493. private updateCacheCalled;
  100494. private _correctPositionIfNotTrackPosition;
  100495. /**
  100496. * @hidden
  100497. * Updates the cached values of the camera
  100498. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100499. */
  100500. _updateCache(ignoreParentClass?: boolean): void;
  100501. /**
  100502. * @hidden
  100503. * Get current device position in babylon world
  100504. */
  100505. _computeDevicePosition(): void;
  100506. /**
  100507. * Updates the current device position and rotation in the babylon world
  100508. */
  100509. update(): void;
  100510. /**
  100511. * @hidden
  100512. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100513. * @returns an identity matrix
  100514. */
  100515. _getViewMatrix(): Matrix;
  100516. private _tmpMatrix;
  100517. /**
  100518. * This function is called by the two RIG cameras.
  100519. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100520. * @hidden
  100521. */
  100522. _getWebVRViewMatrix(): Matrix;
  100523. /** @hidden */
  100524. _getWebVRProjectionMatrix(): Matrix;
  100525. private _onGamepadConnectedObserver;
  100526. private _onGamepadDisconnectedObserver;
  100527. private _updateCacheWhenTrackingDisabledObserver;
  100528. /**
  100529. * Initializes the controllers and their meshes
  100530. */
  100531. initControllers(): void;
  100532. }
  100533. }
  100534. declare module BABYLON {
  100535. /**
  100536. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100537. *
  100538. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100539. *
  100540. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100541. */
  100542. export class MaterialHelper {
  100543. /**
  100544. * Bind the current view position to an effect.
  100545. * @param effect The effect to be bound
  100546. * @param scene The scene the eyes position is used from
  100547. * @param variableName name of the shader variable that will hold the eye position
  100548. */
  100549. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100550. /**
  100551. * Helps preparing the defines values about the UVs in used in the effect.
  100552. * UVs are shared as much as we can accross channels in the shaders.
  100553. * @param texture The texture we are preparing the UVs for
  100554. * @param defines The defines to update
  100555. * @param key The channel key "diffuse", "specular"... used in the shader
  100556. */
  100557. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100558. /**
  100559. * Binds a texture matrix value to its corrsponding uniform
  100560. * @param texture The texture to bind the matrix for
  100561. * @param uniformBuffer The uniform buffer receivin the data
  100562. * @param key The channel key "diffuse", "specular"... used in the shader
  100563. */
  100564. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100565. /**
  100566. * Gets the current status of the fog (should it be enabled?)
  100567. * @param mesh defines the mesh to evaluate for fog support
  100568. * @param scene defines the hosting scene
  100569. * @returns true if fog must be enabled
  100570. */
  100571. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100572. /**
  100573. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100574. * @param mesh defines the current mesh
  100575. * @param scene defines the current scene
  100576. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100577. * @param pointsCloud defines if point cloud rendering has to be turned on
  100578. * @param fogEnabled defines if fog has to be turned on
  100579. * @param alphaTest defines if alpha testing has to be turned on
  100580. * @param defines defines the current list of defines
  100581. */
  100582. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100583. /**
  100584. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100585. * @param scene defines the current scene
  100586. * @param engine defines the current engine
  100587. * @param defines specifies the list of active defines
  100588. * @param useInstances defines if instances have to be turned on
  100589. * @param useClipPlane defines if clip plane have to be turned on
  100590. * @param useInstances defines if instances have to be turned on
  100591. * @param useThinInstances defines if thin instances have to be turned on
  100592. */
  100593. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100594. /**
  100595. * Prepares the defines for bones
  100596. * @param mesh The mesh containing the geometry data we will draw
  100597. * @param defines The defines to update
  100598. */
  100599. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100600. /**
  100601. * Prepares the defines for morph targets
  100602. * @param mesh The mesh containing the geometry data we will draw
  100603. * @param defines The defines to update
  100604. */
  100605. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100606. /**
  100607. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100608. * @param mesh The mesh containing the geometry data we will draw
  100609. * @param defines The defines to update
  100610. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100611. * @param useBones Precise whether bones should be used or not (override mesh info)
  100612. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100613. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100614. * @returns false if defines are considered not dirty and have not been checked
  100615. */
  100616. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100617. /**
  100618. * Prepares the defines related to multiview
  100619. * @param scene The scene we are intending to draw
  100620. * @param defines The defines to update
  100621. */
  100622. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100623. /**
  100624. * Prepares the defines related to the prepass
  100625. * @param scene The scene we are intending to draw
  100626. * @param defines The defines to update
  100627. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100628. */
  100629. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100630. /**
  100631. * Prepares the defines related to the light information passed in parameter
  100632. * @param scene The scene we are intending to draw
  100633. * @param mesh The mesh the effect is compiling for
  100634. * @param light The light the effect is compiling for
  100635. * @param lightIndex The index of the light
  100636. * @param defines The defines to update
  100637. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100638. * @param state Defines the current state regarding what is needed (normals, etc...)
  100639. */
  100640. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100641. needNormals: boolean;
  100642. needRebuild: boolean;
  100643. shadowEnabled: boolean;
  100644. specularEnabled: boolean;
  100645. lightmapMode: boolean;
  100646. }): void;
  100647. /**
  100648. * Prepares the defines related to the light information passed in parameter
  100649. * @param scene The scene we are intending to draw
  100650. * @param mesh The mesh the effect is compiling for
  100651. * @param defines The defines to update
  100652. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100653. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100654. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100655. * @returns true if normals will be required for the rest of the effect
  100656. */
  100657. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100658. /**
  100659. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100660. * @param lightIndex defines the light index
  100661. * @param uniformsList The uniform list
  100662. * @param samplersList The sampler list
  100663. * @param projectedLightTexture defines if projected texture must be used
  100664. * @param uniformBuffersList defines an optional list of uniform buffers
  100665. */
  100666. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100667. /**
  100668. * Prepares the uniforms and samplers list to be used in the effect
  100669. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100670. * @param samplersList The sampler list
  100671. * @param defines The defines helping in the list generation
  100672. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100673. */
  100674. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100675. /**
  100676. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100677. * @param defines The defines to update while falling back
  100678. * @param fallbacks The authorized effect fallbacks
  100679. * @param maxSimultaneousLights The maximum number of lights allowed
  100680. * @param rank the current rank of the Effect
  100681. * @returns The newly affected rank
  100682. */
  100683. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100684. private static _TmpMorphInfluencers;
  100685. /**
  100686. * Prepares the list of attributes required for morph targets according to the effect defines.
  100687. * @param attribs The current list of supported attribs
  100688. * @param mesh The mesh to prepare the morph targets attributes for
  100689. * @param influencers The number of influencers
  100690. */
  100691. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100692. /**
  100693. * Prepares the list of attributes required for morph targets according to the effect defines.
  100694. * @param attribs The current list of supported attribs
  100695. * @param mesh The mesh to prepare the morph targets attributes for
  100696. * @param defines The current Defines of the effect
  100697. */
  100698. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100699. /**
  100700. * Prepares the list of attributes required for bones according to the effect defines.
  100701. * @param attribs The current list of supported attribs
  100702. * @param mesh The mesh to prepare the bones attributes for
  100703. * @param defines The current Defines of the effect
  100704. * @param fallbacks The current efffect fallback strategy
  100705. */
  100706. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100707. /**
  100708. * Check and prepare the list of attributes required for instances according to the effect defines.
  100709. * @param attribs The current list of supported attribs
  100710. * @param defines The current MaterialDefines of the effect
  100711. */
  100712. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100713. /**
  100714. * Add the list of attributes required for instances to the attribs array.
  100715. * @param attribs The current list of supported attribs
  100716. */
  100717. static PushAttributesForInstances(attribs: string[]): void;
  100718. /**
  100719. * Binds the light information to the effect.
  100720. * @param light The light containing the generator
  100721. * @param effect The effect we are binding the data to
  100722. * @param lightIndex The light index in the effect used to render
  100723. */
  100724. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100725. /**
  100726. * Binds the lights information from the scene to the effect for the given mesh.
  100727. * @param light Light to bind
  100728. * @param lightIndex Light index
  100729. * @param scene The scene where the light belongs to
  100730. * @param effect The effect we are binding the data to
  100731. * @param useSpecular Defines if specular is supported
  100732. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100733. */
  100734. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100735. /**
  100736. * Binds the lights information from the scene to the effect for the given mesh.
  100737. * @param scene The scene the lights belongs to
  100738. * @param mesh The mesh we are binding the information to render
  100739. * @param effect The effect we are binding the data to
  100740. * @param defines The generated defines for the effect
  100741. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100742. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100743. */
  100744. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100745. private static _tempFogColor;
  100746. /**
  100747. * Binds the fog information from the scene to the effect for the given mesh.
  100748. * @param scene The scene the lights belongs to
  100749. * @param mesh The mesh we are binding the information to render
  100750. * @param effect The effect we are binding the data to
  100751. * @param linearSpace Defines if the fog effect is applied in linear space
  100752. */
  100753. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100754. /**
  100755. * Binds the bones information from the mesh to the effect.
  100756. * @param mesh The mesh we are binding the information to render
  100757. * @param effect The effect we are binding the data to
  100758. */
  100759. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100760. /**
  100761. * Binds the morph targets information from the mesh to the effect.
  100762. * @param abstractMesh The mesh we are binding the information to render
  100763. * @param effect The effect we are binding the data to
  100764. */
  100765. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100766. /**
  100767. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100768. * @param defines The generated defines used in the effect
  100769. * @param effect The effect we are binding the data to
  100770. * @param scene The scene we are willing to render with logarithmic scale for
  100771. */
  100772. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100773. /**
  100774. * Binds the clip plane information from the scene to the effect.
  100775. * @param scene The scene the clip plane information are extracted from
  100776. * @param effect The effect we are binding the data to
  100777. */
  100778. static BindClipPlane(effect: Effect, scene: Scene): void;
  100779. }
  100780. }
  100781. declare module BABYLON {
  100782. /**
  100783. * Block used to expose an input value
  100784. */
  100785. export class InputBlock extends NodeMaterialBlock {
  100786. private _mode;
  100787. private _associatedVariableName;
  100788. private _storedValue;
  100789. private _valueCallback;
  100790. private _type;
  100791. private _animationType;
  100792. /** Gets or set a value used to limit the range of float values */
  100793. min: number;
  100794. /** Gets or set a value used to limit the range of float values */
  100795. max: number;
  100796. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100797. isBoolean: boolean;
  100798. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100799. matrixMode: number;
  100800. /** @hidden */
  100801. _systemValue: Nullable<NodeMaterialSystemValues>;
  100802. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100803. isConstant: boolean;
  100804. /** Gets or sets the group to use to display this block in the Inspector */
  100805. groupInInspector: string;
  100806. /** Gets an observable raised when the value is changed */
  100807. onValueChangedObservable: Observable<InputBlock>;
  100808. /**
  100809. * Gets or sets the connection point type (default is float)
  100810. */
  100811. get type(): NodeMaterialBlockConnectionPointTypes;
  100812. /**
  100813. * Creates a new InputBlock
  100814. * @param name defines the block name
  100815. * @param target defines the target of that block (Vertex by default)
  100816. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100817. */
  100818. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100819. /**
  100820. * Validates if a name is a reserve word.
  100821. * @param newName the new name to be given to the node.
  100822. * @returns false if the name is a reserve word, else true.
  100823. */
  100824. validateBlockName(newName: string): boolean;
  100825. /**
  100826. * Gets the output component
  100827. */
  100828. get output(): NodeMaterialConnectionPoint;
  100829. /**
  100830. * Set the source of this connection point to a vertex attribute
  100831. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100832. * @returns the current connection point
  100833. */
  100834. setAsAttribute(attributeName?: string): InputBlock;
  100835. /**
  100836. * Set the source of this connection point to a system value
  100837. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100838. * @returns the current connection point
  100839. */
  100840. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100841. /**
  100842. * Gets or sets the value of that point.
  100843. * Please note that this value will be ignored if valueCallback is defined
  100844. */
  100845. get value(): any;
  100846. set value(value: any);
  100847. /**
  100848. * Gets or sets a callback used to get the value of that point.
  100849. * Please note that setting this value will force the connection point to ignore the value property
  100850. */
  100851. get valueCallback(): () => any;
  100852. set valueCallback(value: () => any);
  100853. /**
  100854. * Gets or sets the associated variable name in the shader
  100855. */
  100856. get associatedVariableName(): string;
  100857. set associatedVariableName(value: string);
  100858. /** Gets or sets the type of animation applied to the input */
  100859. get animationType(): AnimatedInputBlockTypes;
  100860. set animationType(value: AnimatedInputBlockTypes);
  100861. /**
  100862. * Gets a boolean indicating that this connection point not defined yet
  100863. */
  100864. get isUndefined(): boolean;
  100865. /**
  100866. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100867. * In this case the connection point name must be the name of the uniform to use.
  100868. * Can only be set on inputs
  100869. */
  100870. get isUniform(): boolean;
  100871. set isUniform(value: boolean);
  100872. /**
  100873. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100874. * In this case the connection point name must be the name of the attribute to use
  100875. * Can only be set on inputs
  100876. */
  100877. get isAttribute(): boolean;
  100878. set isAttribute(value: boolean);
  100879. /**
  100880. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100881. * Can only be set on exit points
  100882. */
  100883. get isVarying(): boolean;
  100884. set isVarying(value: boolean);
  100885. /**
  100886. * Gets a boolean indicating that the current connection point is a system value
  100887. */
  100888. get isSystemValue(): boolean;
  100889. /**
  100890. * Gets or sets the current well known value or null if not defined as a system value
  100891. */
  100892. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100893. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100894. /**
  100895. * Gets the current class name
  100896. * @returns the class name
  100897. */
  100898. getClassName(): string;
  100899. /**
  100900. * Animate the input if animationType !== None
  100901. * @param scene defines the rendering scene
  100902. */
  100903. animate(scene: Scene): void;
  100904. private _emitDefine;
  100905. initialize(state: NodeMaterialBuildState): void;
  100906. /**
  100907. * Set the input block to its default value (based on its type)
  100908. */
  100909. setDefaultValue(): void;
  100910. private _emitConstant;
  100911. /** @hidden */
  100912. get _noContextSwitch(): boolean;
  100913. private _emit;
  100914. /** @hidden */
  100915. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100916. /** @hidden */
  100917. _transmit(effect: Effect, scene: Scene): void;
  100918. protected _buildBlock(state: NodeMaterialBuildState): void;
  100919. protected _dumpPropertiesCode(): string;
  100920. dispose(): void;
  100921. serialize(): any;
  100922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100923. }
  100924. }
  100925. declare module BABYLON {
  100926. /**
  100927. * Enum used to define the compatibility state between two connection points
  100928. */
  100929. export enum NodeMaterialConnectionPointCompatibilityStates {
  100930. /** Points are compatibles */
  100931. Compatible = 0,
  100932. /** Points are incompatible because of their types */
  100933. TypeIncompatible = 1,
  100934. /** Points are incompatible because of their targets (vertex vs fragment) */
  100935. TargetIncompatible = 2
  100936. }
  100937. /**
  100938. * Defines the direction of a connection point
  100939. */
  100940. export enum NodeMaterialConnectionPointDirection {
  100941. /** Input */
  100942. Input = 0,
  100943. /** Output */
  100944. Output = 1
  100945. }
  100946. /**
  100947. * Defines a connection point for a block
  100948. */
  100949. export class NodeMaterialConnectionPoint {
  100950. /** @hidden */
  100951. _ownerBlock: NodeMaterialBlock;
  100952. /** @hidden */
  100953. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100954. private _endpoints;
  100955. private _associatedVariableName;
  100956. private _direction;
  100957. /** @hidden */
  100958. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100959. /** @hidden */
  100960. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100961. private _type;
  100962. /** @hidden */
  100963. _enforceAssociatedVariableName: boolean;
  100964. /** Gets the direction of the point */
  100965. get direction(): NodeMaterialConnectionPointDirection;
  100966. /** Indicates that this connection point needs dual validation before being connected to another point */
  100967. needDualDirectionValidation: boolean;
  100968. /**
  100969. * Gets or sets the additional types supported by this connection point
  100970. */
  100971. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100972. /**
  100973. * Gets or sets the additional types excluded by this connection point
  100974. */
  100975. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100976. /**
  100977. * Observable triggered when this point is connected
  100978. */
  100979. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100980. /**
  100981. * Gets or sets the associated variable name in the shader
  100982. */
  100983. get associatedVariableName(): string;
  100984. set associatedVariableName(value: string);
  100985. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100986. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100987. /**
  100988. * Gets or sets the connection point type (default is float)
  100989. */
  100990. get type(): NodeMaterialBlockConnectionPointTypes;
  100991. set type(value: NodeMaterialBlockConnectionPointTypes);
  100992. /**
  100993. * Gets or sets the connection point name
  100994. */
  100995. name: string;
  100996. /**
  100997. * Gets or sets the connection point name
  100998. */
  100999. displayName: string;
  101000. /**
  101001. * Gets or sets a boolean indicating that this connection point can be omitted
  101002. */
  101003. isOptional: boolean;
  101004. /**
  101005. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101006. */
  101007. isExposedOnFrame: boolean;
  101008. /**
  101009. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101010. */
  101011. define: string;
  101012. /** @hidden */
  101013. _prioritizeVertex: boolean;
  101014. private _target;
  101015. /** Gets or sets the target of that connection point */
  101016. get target(): NodeMaterialBlockTargets;
  101017. set target(value: NodeMaterialBlockTargets);
  101018. /**
  101019. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101020. */
  101021. get isConnected(): boolean;
  101022. /**
  101023. * Gets a boolean indicating that the current point is connected to an input block
  101024. */
  101025. get isConnectedToInputBlock(): boolean;
  101026. /**
  101027. * Gets a the connected input block (if any)
  101028. */
  101029. get connectInputBlock(): Nullable<InputBlock>;
  101030. /** Get the other side of the connection (if any) */
  101031. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101032. /** Get the block that owns this connection point */
  101033. get ownerBlock(): NodeMaterialBlock;
  101034. /** Get the block connected on the other side of this connection (if any) */
  101035. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101036. /** Get the block connected on the endpoints of this connection (if any) */
  101037. get connectedBlocks(): Array<NodeMaterialBlock>;
  101038. /** Gets the list of connected endpoints */
  101039. get endpoints(): NodeMaterialConnectionPoint[];
  101040. /** Gets a boolean indicating if that output point is connected to at least one input */
  101041. get hasEndpoints(): boolean;
  101042. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101043. get isConnectedInVertexShader(): boolean;
  101044. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101045. get isConnectedInFragmentShader(): boolean;
  101046. /**
  101047. * Creates a block suitable to be used as an input for this input point.
  101048. * If null is returned, a block based on the point type will be created.
  101049. * @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
  101050. */
  101051. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101052. /**
  101053. * Creates a new connection point
  101054. * @param name defines the connection point name
  101055. * @param ownerBlock defines the block hosting this connection point
  101056. * @param direction defines the direction of the connection point
  101057. */
  101058. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101059. /**
  101060. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101061. * @returns the class name
  101062. */
  101063. getClassName(): string;
  101064. /**
  101065. * Gets a boolean indicating if the current point can be connected to another point
  101066. * @param connectionPoint defines the other connection point
  101067. * @returns a boolean
  101068. */
  101069. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101070. /**
  101071. * Gets a number indicating if the current point can be connected to another point
  101072. * @param connectionPoint defines the other connection point
  101073. * @returns a number defining the compatibility state
  101074. */
  101075. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101076. /**
  101077. * Connect this point to another connection point
  101078. * @param connectionPoint defines the other connection point
  101079. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101080. * @returns the current connection point
  101081. */
  101082. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101083. /**
  101084. * Disconnect this point from one of his endpoint
  101085. * @param endpoint defines the other connection point
  101086. * @returns the current connection point
  101087. */
  101088. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101089. /**
  101090. * Serializes this point in a JSON representation
  101091. * @param isInput defines if the connection point is an input (default is true)
  101092. * @returns the serialized point object
  101093. */
  101094. serialize(isInput?: boolean): any;
  101095. /**
  101096. * Release resources
  101097. */
  101098. dispose(): void;
  101099. }
  101100. }
  101101. declare module BABYLON {
  101102. /**
  101103. * Enum used to define the material modes
  101104. */
  101105. export enum NodeMaterialModes {
  101106. /** Regular material */
  101107. Material = 0,
  101108. /** For post process */
  101109. PostProcess = 1,
  101110. /** For particle system */
  101111. Particle = 2,
  101112. /** For procedural texture */
  101113. ProceduralTexture = 3
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. /**
  101118. * Block used to read a texture from a sampler
  101119. */
  101120. export class TextureBlock extends NodeMaterialBlock {
  101121. private _defineName;
  101122. private _linearDefineName;
  101123. private _gammaDefineName;
  101124. private _tempTextureRead;
  101125. private _samplerName;
  101126. private _transformedUVName;
  101127. private _textureTransformName;
  101128. private _textureInfoName;
  101129. private _mainUVName;
  101130. private _mainUVDefineName;
  101131. private _fragmentOnly;
  101132. /**
  101133. * Gets or sets the texture associated with the node
  101134. */
  101135. texture: Nullable<Texture>;
  101136. /**
  101137. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101138. */
  101139. convertToGammaSpace: boolean;
  101140. /**
  101141. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101142. */
  101143. convertToLinearSpace: boolean;
  101144. /**
  101145. * Create a new TextureBlock
  101146. * @param name defines the block name
  101147. */
  101148. constructor(name: string, fragmentOnly?: boolean);
  101149. /**
  101150. * Gets the current class name
  101151. * @returns the class name
  101152. */
  101153. getClassName(): string;
  101154. /**
  101155. * Gets the uv input component
  101156. */
  101157. get uv(): NodeMaterialConnectionPoint;
  101158. /**
  101159. * Gets the rgba output component
  101160. */
  101161. get rgba(): NodeMaterialConnectionPoint;
  101162. /**
  101163. * Gets the rgb output component
  101164. */
  101165. get rgb(): NodeMaterialConnectionPoint;
  101166. /**
  101167. * Gets the r output component
  101168. */
  101169. get r(): NodeMaterialConnectionPoint;
  101170. /**
  101171. * Gets the g output component
  101172. */
  101173. get g(): NodeMaterialConnectionPoint;
  101174. /**
  101175. * Gets the b output component
  101176. */
  101177. get b(): NodeMaterialConnectionPoint;
  101178. /**
  101179. * Gets the a output component
  101180. */
  101181. get a(): NodeMaterialConnectionPoint;
  101182. get target(): NodeMaterialBlockTargets;
  101183. autoConfigure(material: NodeMaterial): void;
  101184. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101186. isReady(): boolean;
  101187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101188. private get _isMixed();
  101189. private _injectVertexCode;
  101190. private _writeTextureRead;
  101191. private _writeOutput;
  101192. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101193. protected _dumpPropertiesCode(): string;
  101194. serialize(): any;
  101195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101196. }
  101197. }
  101198. declare module BABYLON {
  101199. /** @hidden */
  101200. export var reflectionFunction: {
  101201. name: string;
  101202. shader: string;
  101203. };
  101204. }
  101205. declare module BABYLON {
  101206. /**
  101207. * Base block used to read a reflection texture from a sampler
  101208. */
  101209. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101210. /** @hidden */
  101211. _define3DName: string;
  101212. /** @hidden */
  101213. _defineCubicName: string;
  101214. /** @hidden */
  101215. _defineExplicitName: string;
  101216. /** @hidden */
  101217. _defineProjectionName: string;
  101218. /** @hidden */
  101219. _defineLocalCubicName: string;
  101220. /** @hidden */
  101221. _defineSphericalName: string;
  101222. /** @hidden */
  101223. _definePlanarName: string;
  101224. /** @hidden */
  101225. _defineEquirectangularName: string;
  101226. /** @hidden */
  101227. _defineMirroredEquirectangularFixedName: string;
  101228. /** @hidden */
  101229. _defineEquirectangularFixedName: string;
  101230. /** @hidden */
  101231. _defineSkyboxName: string;
  101232. /** @hidden */
  101233. _defineOppositeZ: string;
  101234. /** @hidden */
  101235. _cubeSamplerName: string;
  101236. /** @hidden */
  101237. _2DSamplerName: string;
  101238. protected _positionUVWName: string;
  101239. protected _directionWName: string;
  101240. protected _reflectionVectorName: string;
  101241. /** @hidden */
  101242. _reflectionCoordsName: string;
  101243. /** @hidden */
  101244. _reflectionMatrixName: string;
  101245. protected _reflectionColorName: string;
  101246. /**
  101247. * Gets or sets the texture associated with the node
  101248. */
  101249. texture: Nullable<BaseTexture>;
  101250. /**
  101251. * Create a new ReflectionTextureBaseBlock
  101252. * @param name defines the block name
  101253. */
  101254. constructor(name: string);
  101255. /**
  101256. * Gets the current class name
  101257. * @returns the class name
  101258. */
  101259. getClassName(): string;
  101260. /**
  101261. * Gets the world position input component
  101262. */
  101263. abstract get position(): NodeMaterialConnectionPoint;
  101264. /**
  101265. * Gets the world position input component
  101266. */
  101267. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101268. /**
  101269. * Gets the world normal input component
  101270. */
  101271. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101272. /**
  101273. * Gets the world input component
  101274. */
  101275. abstract get world(): NodeMaterialConnectionPoint;
  101276. /**
  101277. * Gets the camera (or eye) position component
  101278. */
  101279. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101280. /**
  101281. * Gets the view input component
  101282. */
  101283. abstract get view(): NodeMaterialConnectionPoint;
  101284. protected _getTexture(): Nullable<BaseTexture>;
  101285. autoConfigure(material: NodeMaterial): void;
  101286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101287. isReady(): boolean;
  101288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101289. /**
  101290. * Gets the code to inject in the vertex shader
  101291. * @param state current state of the node material building
  101292. * @returns the shader code
  101293. */
  101294. handleVertexSide(state: NodeMaterialBuildState): string;
  101295. /**
  101296. * Handles the inits for the fragment code path
  101297. * @param state node material build state
  101298. */
  101299. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101300. /**
  101301. * Generates the reflection coords code for the fragment code path
  101302. * @param worldNormalVarName name of the world normal variable
  101303. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101304. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101305. * @returns the shader code
  101306. */
  101307. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101308. /**
  101309. * Generates the reflection color code for the fragment code path
  101310. * @param lodVarName name of the lod variable
  101311. * @param swizzleLookupTexture swizzle to use for the final color variable
  101312. * @returns the shader code
  101313. */
  101314. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101315. /**
  101316. * Generates the code corresponding to the connected output points
  101317. * @param state node material build state
  101318. * @param varName name of the variable to output
  101319. * @returns the shader code
  101320. */
  101321. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101322. protected _buildBlock(state: NodeMaterialBuildState): this;
  101323. protected _dumpPropertiesCode(): string;
  101324. serialize(): any;
  101325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101326. }
  101327. }
  101328. declare module BABYLON {
  101329. /**
  101330. * Defines a connection point to be used for points with a custom object type
  101331. */
  101332. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101333. private _blockType;
  101334. private _blockName;
  101335. private _nameForCheking?;
  101336. /**
  101337. * Creates a new connection point
  101338. * @param name defines the connection point name
  101339. * @param ownerBlock defines the block hosting this connection point
  101340. * @param direction defines the direction of the connection point
  101341. */
  101342. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101343. /**
  101344. * Gets a number indicating if the current point can be connected to another point
  101345. * @param connectionPoint defines the other connection point
  101346. * @returns a number defining the compatibility state
  101347. */
  101348. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101349. /**
  101350. * Creates a block suitable to be used as an input for this input point.
  101351. * If null is returned, a block based on the point type will be created.
  101352. * @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
  101353. */
  101354. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101355. }
  101356. }
  101357. declare module BABYLON {
  101358. /**
  101359. * Enum defining the type of properties that can be edited in the property pages in the NME
  101360. */
  101361. export enum PropertyTypeForEdition {
  101362. /** property is a boolean */
  101363. Boolean = 0,
  101364. /** property is a float */
  101365. Float = 1,
  101366. /** property is a Vector2 */
  101367. Vector2 = 2,
  101368. /** property is a list of values */
  101369. List = 3
  101370. }
  101371. /**
  101372. * Interface that defines an option in a variable of type list
  101373. */
  101374. export interface IEditablePropertyListOption {
  101375. /** label of the option */
  101376. "label": string;
  101377. /** value of the option */
  101378. "value": number;
  101379. }
  101380. /**
  101381. * Interface that defines the options available for an editable property
  101382. */
  101383. export interface IEditablePropertyOption {
  101384. /** min value */
  101385. "min"?: number;
  101386. /** max value */
  101387. "max"?: number;
  101388. /** notifiers: indicates which actions to take when the property is changed */
  101389. "notifiers"?: {
  101390. /** the material should be rebuilt */
  101391. "rebuild"?: boolean;
  101392. /** the preview should be updated */
  101393. "update"?: boolean;
  101394. };
  101395. /** list of the options for a variable of type list */
  101396. "options"?: IEditablePropertyListOption[];
  101397. }
  101398. /**
  101399. * Interface that describes an editable property
  101400. */
  101401. export interface IPropertyDescriptionForEdition {
  101402. /** name of the property */
  101403. "propertyName": string;
  101404. /** display name of the property */
  101405. "displayName": string;
  101406. /** type of the property */
  101407. "type": PropertyTypeForEdition;
  101408. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101409. "groupName": string;
  101410. /** options for the property */
  101411. "options": IEditablePropertyOption;
  101412. }
  101413. /**
  101414. * Decorator that flags a property in a node material block as being editable
  101415. */
  101416. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101417. }
  101418. declare module BABYLON {
  101419. /**
  101420. * Block used to implement the refraction part of the sub surface module of the PBR material
  101421. */
  101422. export class RefractionBlock extends NodeMaterialBlock {
  101423. /** @hidden */
  101424. _define3DName: string;
  101425. /** @hidden */
  101426. _refractionMatrixName: string;
  101427. /** @hidden */
  101428. _defineLODRefractionAlpha: string;
  101429. /** @hidden */
  101430. _defineLinearSpecularRefraction: string;
  101431. /** @hidden */
  101432. _defineOppositeZ: string;
  101433. /** @hidden */
  101434. _cubeSamplerName: string;
  101435. /** @hidden */
  101436. _2DSamplerName: string;
  101437. /** @hidden */
  101438. _vRefractionMicrosurfaceInfosName: string;
  101439. /** @hidden */
  101440. _vRefractionInfosName: string;
  101441. private _scene;
  101442. /**
  101443. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101444. * Materials half opaque for instance using refraction could benefit from this control.
  101445. */
  101446. linkRefractionWithTransparency: boolean;
  101447. /**
  101448. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101449. */
  101450. invertRefractionY: boolean;
  101451. /**
  101452. * Gets or sets the texture associated with the node
  101453. */
  101454. texture: Nullable<BaseTexture>;
  101455. /**
  101456. * Create a new RefractionBlock
  101457. * @param name defines the block name
  101458. */
  101459. constructor(name: string);
  101460. /**
  101461. * Gets the current class name
  101462. * @returns the class name
  101463. */
  101464. getClassName(): string;
  101465. /**
  101466. * Gets the intensity input component
  101467. */
  101468. get intensity(): NodeMaterialConnectionPoint;
  101469. /**
  101470. * Gets the index of refraction input component
  101471. */
  101472. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101473. /**
  101474. * Gets the tint at distance input component
  101475. */
  101476. get tintAtDistance(): NodeMaterialConnectionPoint;
  101477. /**
  101478. * Gets the view input component
  101479. */
  101480. get view(): NodeMaterialConnectionPoint;
  101481. /**
  101482. * Gets the refraction object output component
  101483. */
  101484. get refraction(): NodeMaterialConnectionPoint;
  101485. /**
  101486. * Returns true if the block has a texture
  101487. */
  101488. get hasTexture(): boolean;
  101489. protected _getTexture(): Nullable<BaseTexture>;
  101490. autoConfigure(material: NodeMaterial): void;
  101491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101492. isReady(): boolean;
  101493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101494. /**
  101495. * Gets the main code of the block (fragment side)
  101496. * @param state current state of the node material building
  101497. * @returns the shader code
  101498. */
  101499. getCode(state: NodeMaterialBuildState): string;
  101500. protected _buildBlock(state: NodeMaterialBuildState): this;
  101501. protected _dumpPropertiesCode(): string;
  101502. serialize(): any;
  101503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101504. }
  101505. }
  101506. declare module BABYLON {
  101507. /**
  101508. * Base block used as input for post process
  101509. */
  101510. export class CurrentScreenBlock extends NodeMaterialBlock {
  101511. private _samplerName;
  101512. private _linearDefineName;
  101513. private _gammaDefineName;
  101514. private _mainUVName;
  101515. private _tempTextureRead;
  101516. /**
  101517. * Gets or sets the texture associated with the node
  101518. */
  101519. texture: Nullable<BaseTexture>;
  101520. /**
  101521. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101522. */
  101523. convertToGammaSpace: boolean;
  101524. /**
  101525. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101526. */
  101527. convertToLinearSpace: boolean;
  101528. /**
  101529. * Create a new CurrentScreenBlock
  101530. * @param name defines the block name
  101531. */
  101532. constructor(name: string);
  101533. /**
  101534. * Gets the current class name
  101535. * @returns the class name
  101536. */
  101537. getClassName(): string;
  101538. /**
  101539. * Gets the uv input component
  101540. */
  101541. get uv(): NodeMaterialConnectionPoint;
  101542. /**
  101543. * Gets the rgba output component
  101544. */
  101545. get rgba(): NodeMaterialConnectionPoint;
  101546. /**
  101547. * Gets the rgb output component
  101548. */
  101549. get rgb(): NodeMaterialConnectionPoint;
  101550. /**
  101551. * Gets the r output component
  101552. */
  101553. get r(): NodeMaterialConnectionPoint;
  101554. /**
  101555. * Gets the g output component
  101556. */
  101557. get g(): NodeMaterialConnectionPoint;
  101558. /**
  101559. * Gets the b output component
  101560. */
  101561. get b(): NodeMaterialConnectionPoint;
  101562. /**
  101563. * Gets the a output component
  101564. */
  101565. get a(): NodeMaterialConnectionPoint;
  101566. /**
  101567. * Initialize the block and prepare the context for build
  101568. * @param state defines the state that will be used for the build
  101569. */
  101570. initialize(state: NodeMaterialBuildState): void;
  101571. get target(): NodeMaterialBlockTargets;
  101572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101573. isReady(): boolean;
  101574. private _injectVertexCode;
  101575. private _writeTextureRead;
  101576. private _writeOutput;
  101577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101578. serialize(): any;
  101579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101580. }
  101581. }
  101582. declare module BABYLON {
  101583. /**
  101584. * Base block used for the particle texture
  101585. */
  101586. export class ParticleTextureBlock extends NodeMaterialBlock {
  101587. private _samplerName;
  101588. private _linearDefineName;
  101589. private _gammaDefineName;
  101590. private _tempTextureRead;
  101591. /**
  101592. * Gets or sets the texture associated with the node
  101593. */
  101594. texture: Nullable<BaseTexture>;
  101595. /**
  101596. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101597. */
  101598. convertToGammaSpace: boolean;
  101599. /**
  101600. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101601. */
  101602. convertToLinearSpace: boolean;
  101603. /**
  101604. * Create a new ParticleTextureBlock
  101605. * @param name defines the block name
  101606. */
  101607. constructor(name: string);
  101608. /**
  101609. * Gets the current class name
  101610. * @returns the class name
  101611. */
  101612. getClassName(): string;
  101613. /**
  101614. * Gets the uv input component
  101615. */
  101616. get uv(): NodeMaterialConnectionPoint;
  101617. /**
  101618. * Gets the rgba output component
  101619. */
  101620. get rgba(): NodeMaterialConnectionPoint;
  101621. /**
  101622. * Gets the rgb output component
  101623. */
  101624. get rgb(): NodeMaterialConnectionPoint;
  101625. /**
  101626. * Gets the r output component
  101627. */
  101628. get r(): NodeMaterialConnectionPoint;
  101629. /**
  101630. * Gets the g output component
  101631. */
  101632. get g(): NodeMaterialConnectionPoint;
  101633. /**
  101634. * Gets the b output component
  101635. */
  101636. get b(): NodeMaterialConnectionPoint;
  101637. /**
  101638. * Gets the a output component
  101639. */
  101640. get a(): NodeMaterialConnectionPoint;
  101641. /**
  101642. * Initialize the block and prepare the context for build
  101643. * @param state defines the state that will be used for the build
  101644. */
  101645. initialize(state: NodeMaterialBuildState): void;
  101646. autoConfigure(material: NodeMaterial): void;
  101647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101648. isReady(): boolean;
  101649. private _writeOutput;
  101650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101651. serialize(): any;
  101652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101653. }
  101654. }
  101655. declare module BABYLON {
  101656. /**
  101657. * Class used to store shared data between 2 NodeMaterialBuildState
  101658. */
  101659. export class NodeMaterialBuildStateSharedData {
  101660. /**
  101661. * Gets the list of emitted varyings
  101662. */
  101663. temps: string[];
  101664. /**
  101665. * Gets the list of emitted varyings
  101666. */
  101667. varyings: string[];
  101668. /**
  101669. * Gets the varying declaration string
  101670. */
  101671. varyingDeclaration: string;
  101672. /**
  101673. * Input blocks
  101674. */
  101675. inputBlocks: InputBlock[];
  101676. /**
  101677. * Input blocks
  101678. */
  101679. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101680. /**
  101681. * Bindable blocks (Blocks that need to set data to the effect)
  101682. */
  101683. bindableBlocks: NodeMaterialBlock[];
  101684. /**
  101685. * List of blocks that can provide a compilation fallback
  101686. */
  101687. blocksWithFallbacks: NodeMaterialBlock[];
  101688. /**
  101689. * List of blocks that can provide a define update
  101690. */
  101691. blocksWithDefines: NodeMaterialBlock[];
  101692. /**
  101693. * List of blocks that can provide a repeatable content
  101694. */
  101695. repeatableContentBlocks: NodeMaterialBlock[];
  101696. /**
  101697. * List of blocks that can provide a dynamic list of uniforms
  101698. */
  101699. dynamicUniformBlocks: NodeMaterialBlock[];
  101700. /**
  101701. * List of blocks that can block the isReady function for the material
  101702. */
  101703. blockingBlocks: NodeMaterialBlock[];
  101704. /**
  101705. * Gets the list of animated inputs
  101706. */
  101707. animatedInputs: InputBlock[];
  101708. /**
  101709. * Build Id used to avoid multiple recompilations
  101710. */
  101711. buildId: number;
  101712. /** List of emitted variables */
  101713. variableNames: {
  101714. [key: string]: number;
  101715. };
  101716. /** List of emitted defines */
  101717. defineNames: {
  101718. [key: string]: number;
  101719. };
  101720. /** Should emit comments? */
  101721. emitComments: boolean;
  101722. /** Emit build activity */
  101723. verbose: boolean;
  101724. /** Gets or sets the hosting scene */
  101725. scene: Scene;
  101726. /**
  101727. * Gets the compilation hints emitted at compilation time
  101728. */
  101729. hints: {
  101730. needWorldViewMatrix: boolean;
  101731. needWorldViewProjectionMatrix: boolean;
  101732. needAlphaBlending: boolean;
  101733. needAlphaTesting: boolean;
  101734. };
  101735. /**
  101736. * List of compilation checks
  101737. */
  101738. checks: {
  101739. emitVertex: boolean;
  101740. emitFragment: boolean;
  101741. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101742. };
  101743. /**
  101744. * Is vertex program allowed to be empty?
  101745. */
  101746. allowEmptyVertexProgram: boolean;
  101747. /** Creates a new shared data */
  101748. constructor();
  101749. /**
  101750. * Emits console errors and exceptions if there is a failing check
  101751. */
  101752. emitErrors(): void;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * Class used to store node based material build state
  101758. */
  101759. export class NodeMaterialBuildState {
  101760. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101761. supportUniformBuffers: boolean;
  101762. /**
  101763. * Gets the list of emitted attributes
  101764. */
  101765. attributes: string[];
  101766. /**
  101767. * Gets the list of emitted uniforms
  101768. */
  101769. uniforms: string[];
  101770. /**
  101771. * Gets the list of emitted constants
  101772. */
  101773. constants: string[];
  101774. /**
  101775. * Gets the list of emitted samplers
  101776. */
  101777. samplers: string[];
  101778. /**
  101779. * Gets the list of emitted functions
  101780. */
  101781. functions: {
  101782. [key: string]: string;
  101783. };
  101784. /**
  101785. * Gets the list of emitted extensions
  101786. */
  101787. extensions: {
  101788. [key: string]: string;
  101789. };
  101790. /**
  101791. * Gets the target of the compilation state
  101792. */
  101793. target: NodeMaterialBlockTargets;
  101794. /**
  101795. * Gets the list of emitted counters
  101796. */
  101797. counters: {
  101798. [key: string]: number;
  101799. };
  101800. /**
  101801. * Shared data between multiple NodeMaterialBuildState instances
  101802. */
  101803. sharedData: NodeMaterialBuildStateSharedData;
  101804. /** @hidden */
  101805. _vertexState: NodeMaterialBuildState;
  101806. /** @hidden */
  101807. _attributeDeclaration: string;
  101808. /** @hidden */
  101809. _uniformDeclaration: string;
  101810. /** @hidden */
  101811. _constantDeclaration: string;
  101812. /** @hidden */
  101813. _samplerDeclaration: string;
  101814. /** @hidden */
  101815. _varyingTransfer: string;
  101816. /** @hidden */
  101817. _injectAtEnd: string;
  101818. private _repeatableContentAnchorIndex;
  101819. /** @hidden */
  101820. _builtCompilationString: string;
  101821. /**
  101822. * Gets the emitted compilation strings
  101823. */
  101824. compilationString: string;
  101825. /**
  101826. * Finalize the compilation strings
  101827. * @param state defines the current compilation state
  101828. */
  101829. finalize(state: NodeMaterialBuildState): void;
  101830. /** @hidden */
  101831. get _repeatableContentAnchor(): string;
  101832. /** @hidden */
  101833. _getFreeVariableName(prefix: string): string;
  101834. /** @hidden */
  101835. _getFreeDefineName(prefix: string): string;
  101836. /** @hidden */
  101837. _excludeVariableName(name: string): void;
  101838. /** @hidden */
  101839. _emit2DSampler(name: string): void;
  101840. /** @hidden */
  101841. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101842. /** @hidden */
  101843. _emitExtension(name: string, extension: string, define?: string): void;
  101844. /** @hidden */
  101845. _emitFunction(name: string, code: string, comments: string): void;
  101846. /** @hidden */
  101847. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101848. replaceStrings?: {
  101849. search: RegExp;
  101850. replace: string;
  101851. }[];
  101852. repeatKey?: string;
  101853. }): string;
  101854. /** @hidden */
  101855. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101856. repeatKey?: string;
  101857. removeAttributes?: boolean;
  101858. removeUniforms?: boolean;
  101859. removeVaryings?: boolean;
  101860. removeIfDef?: boolean;
  101861. replaceStrings?: {
  101862. search: RegExp;
  101863. replace: string;
  101864. }[];
  101865. }, storeKey?: string): void;
  101866. /** @hidden */
  101867. _registerTempVariable(name: string): boolean;
  101868. /** @hidden */
  101869. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101870. /** @hidden */
  101871. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101872. /** @hidden */
  101873. _emitFloat(value: number): string;
  101874. }
  101875. }
  101876. declare module BABYLON {
  101877. /**
  101878. * Helper class used to generate session unique ID
  101879. */
  101880. export class UniqueIdGenerator {
  101881. private static _UniqueIdCounter;
  101882. /**
  101883. * Gets an unique (relatively to the current scene) Id
  101884. */
  101885. static get UniqueId(): number;
  101886. }
  101887. }
  101888. declare module BABYLON {
  101889. /**
  101890. * Defines a block that can be used inside a node based material
  101891. */
  101892. export class NodeMaterialBlock {
  101893. private _buildId;
  101894. private _buildTarget;
  101895. private _target;
  101896. private _isFinalMerger;
  101897. private _isInput;
  101898. private _name;
  101899. protected _isUnique: boolean;
  101900. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101901. inputsAreExclusive: boolean;
  101902. /** @hidden */
  101903. _codeVariableName: string;
  101904. /** @hidden */
  101905. _inputs: NodeMaterialConnectionPoint[];
  101906. /** @hidden */
  101907. _outputs: NodeMaterialConnectionPoint[];
  101908. /** @hidden */
  101909. _preparationId: number;
  101910. /**
  101911. * Gets the name of the block
  101912. */
  101913. get name(): string;
  101914. /**
  101915. * Sets the name of the block. Will check if the name is valid.
  101916. */
  101917. set name(newName: string);
  101918. /**
  101919. * Gets or sets the unique id of the node
  101920. */
  101921. uniqueId: number;
  101922. /**
  101923. * Gets or sets the comments associated with this block
  101924. */
  101925. comments: string;
  101926. /**
  101927. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101928. */
  101929. get isUnique(): boolean;
  101930. /**
  101931. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101932. */
  101933. get isFinalMerger(): boolean;
  101934. /**
  101935. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101936. */
  101937. get isInput(): boolean;
  101938. /**
  101939. * Gets or sets the build Id
  101940. */
  101941. get buildId(): number;
  101942. set buildId(value: number);
  101943. /**
  101944. * Gets or sets the target of the block
  101945. */
  101946. get target(): NodeMaterialBlockTargets;
  101947. set target(value: NodeMaterialBlockTargets);
  101948. /**
  101949. * Gets the list of input points
  101950. */
  101951. get inputs(): NodeMaterialConnectionPoint[];
  101952. /** Gets the list of output points */
  101953. get outputs(): NodeMaterialConnectionPoint[];
  101954. /**
  101955. * Find an input by its name
  101956. * @param name defines the name of the input to look for
  101957. * @returns the input or null if not found
  101958. */
  101959. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101960. /**
  101961. * Find an output by its name
  101962. * @param name defines the name of the outputto look for
  101963. * @returns the output or null if not found
  101964. */
  101965. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101966. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101967. visibleInInspector: boolean;
  101968. /**
  101969. * Creates a new NodeMaterialBlock
  101970. * @param name defines the block name
  101971. * @param target defines the target of that block (Vertex by default)
  101972. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101973. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101974. */
  101975. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101976. /**
  101977. * Initialize the block and prepare the context for build
  101978. * @param state defines the state that will be used for the build
  101979. */
  101980. initialize(state: NodeMaterialBuildState): void;
  101981. /**
  101982. * Bind data to effect. Will only be called for blocks with isBindable === true
  101983. * @param effect defines the effect to bind data to
  101984. * @param nodeMaterial defines the hosting NodeMaterial
  101985. * @param mesh defines the mesh that will be rendered
  101986. * @param subMesh defines the submesh that will be rendered
  101987. */
  101988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101989. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101990. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101991. protected _writeFloat(value: number): string;
  101992. /**
  101993. * Gets the current class name e.g. "NodeMaterialBlock"
  101994. * @returns the class name
  101995. */
  101996. getClassName(): string;
  101997. /**
  101998. * Register a new input. Must be called inside a block constructor
  101999. * @param name defines the connection point name
  102000. * @param type defines the connection point type
  102001. * @param isOptional defines a boolean indicating that this input can be omitted
  102002. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102003. * @param point an already created connection point. If not provided, create a new one
  102004. * @returns the current block
  102005. */
  102006. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102007. /**
  102008. * Register a new output. Must be called inside a block constructor
  102009. * @param name defines the connection point name
  102010. * @param type defines the connection point type
  102011. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102012. * @param point an already created connection point. If not provided, create a new one
  102013. * @returns the current block
  102014. */
  102015. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102016. /**
  102017. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102018. * @param forOutput defines an optional connection point to check compatibility with
  102019. * @returns the first available input or null
  102020. */
  102021. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102022. /**
  102023. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102024. * @param forBlock defines an optional block to check compatibility with
  102025. * @returns the first available input or null
  102026. */
  102027. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102028. /**
  102029. * Gets the sibling of the given output
  102030. * @param current defines the current output
  102031. * @returns the next output in the list or null
  102032. */
  102033. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102034. /**
  102035. * Connect current block with another block
  102036. * @param other defines the block to connect with
  102037. * @param options define the various options to help pick the right connections
  102038. * @returns the current block
  102039. */
  102040. connectTo(other: NodeMaterialBlock, options?: {
  102041. input?: string;
  102042. output?: string;
  102043. outputSwizzle?: string;
  102044. }): this | undefined;
  102045. protected _buildBlock(state: NodeMaterialBuildState): void;
  102046. /**
  102047. * Add uniforms, samplers and uniform buffers at compilation time
  102048. * @param state defines the state to update
  102049. * @param nodeMaterial defines the node material requesting the update
  102050. * @param defines defines the material defines to update
  102051. * @param uniformBuffers defines the list of uniform buffer names
  102052. */
  102053. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102054. /**
  102055. * Add potential fallbacks if shader compilation fails
  102056. * @param mesh defines the mesh to be rendered
  102057. * @param fallbacks defines the current prioritized list of fallbacks
  102058. */
  102059. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102060. /**
  102061. * Initialize defines for shader compilation
  102062. * @param mesh defines the mesh to be rendered
  102063. * @param nodeMaterial defines the node material requesting the update
  102064. * @param defines defines the material defines to update
  102065. * @param useInstances specifies that instances should be used
  102066. */
  102067. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102068. /**
  102069. * Update defines for shader compilation
  102070. * @param mesh defines the mesh to be rendered
  102071. * @param nodeMaterial defines the node material requesting the update
  102072. * @param defines defines the material defines to update
  102073. * @param useInstances specifies that instances should be used
  102074. * @param subMesh defines which submesh to render
  102075. */
  102076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102077. /**
  102078. * Lets the block try to connect some inputs automatically
  102079. * @param material defines the hosting NodeMaterial
  102080. */
  102081. autoConfigure(material: NodeMaterial): void;
  102082. /**
  102083. * Function called when a block is declared as repeatable content generator
  102084. * @param vertexShaderState defines the current compilation state for the vertex shader
  102085. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102086. * @param mesh defines the mesh to be rendered
  102087. * @param defines defines the material defines to update
  102088. */
  102089. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102090. /**
  102091. * Checks if the block is ready
  102092. * @param mesh defines the mesh to be rendered
  102093. * @param nodeMaterial defines the node material requesting the update
  102094. * @param defines defines the material defines to update
  102095. * @param useInstances specifies that instances should be used
  102096. * @returns true if the block is ready
  102097. */
  102098. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102099. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102100. private _processBuild;
  102101. /**
  102102. * Validates the new name for the block node.
  102103. * @param newName the new name to be given to the node.
  102104. * @returns false if the name is a reserve word, else true.
  102105. */
  102106. validateBlockName(newName: string): boolean;
  102107. /**
  102108. * Compile the current node and generate the shader code
  102109. * @param state defines the current compilation state (uniforms, samplers, current string)
  102110. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102111. * @returns true if already built
  102112. */
  102113. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102114. protected _inputRename(name: string): string;
  102115. protected _outputRename(name: string): string;
  102116. protected _dumpPropertiesCode(): string;
  102117. /** @hidden */
  102118. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102119. /** @hidden */
  102120. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102121. /**
  102122. * Clone the current block to a new identical block
  102123. * @param scene defines the hosting scene
  102124. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102125. * @returns a copy of the current block
  102126. */
  102127. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102128. /**
  102129. * Serializes this block in a JSON representation
  102130. * @returns the serialized block object
  102131. */
  102132. serialize(): any;
  102133. /** @hidden */
  102134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102135. private _deserializePortDisplayNamesAndExposedOnFrame;
  102136. /**
  102137. * Release resources
  102138. */
  102139. dispose(): void;
  102140. }
  102141. }
  102142. declare module BABYLON {
  102143. /**
  102144. * Base class of materials working in push mode in babylon JS
  102145. * @hidden
  102146. */
  102147. export class PushMaterial extends Material {
  102148. protected _activeEffect: Effect;
  102149. protected _normalMatrix: Matrix;
  102150. constructor(name: string, scene: Scene);
  102151. getEffect(): Effect;
  102152. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102153. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102154. /**
  102155. * Binds the given world matrix to the active effect
  102156. *
  102157. * @param world the matrix to bind
  102158. */
  102159. bindOnlyWorldMatrix(world: Matrix): void;
  102160. /**
  102161. * Binds the given normal matrix to the active effect
  102162. *
  102163. * @param normalMatrix the matrix to bind
  102164. */
  102165. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102166. bind(world: Matrix, mesh?: Mesh): void;
  102167. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102168. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /**
  102173. * Root class for all node material optimizers
  102174. */
  102175. export class NodeMaterialOptimizer {
  102176. /**
  102177. * Function used to optimize a NodeMaterial graph
  102178. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102179. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102180. */
  102181. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102182. }
  102183. }
  102184. declare module BABYLON {
  102185. /**
  102186. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102187. */
  102188. export class TransformBlock extends NodeMaterialBlock {
  102189. /**
  102190. * Defines the value to use to complement W value to transform it to a Vector4
  102191. */
  102192. complementW: number;
  102193. /**
  102194. * Defines the value to use to complement z value to transform it to a Vector4
  102195. */
  102196. complementZ: number;
  102197. /**
  102198. * Creates a new TransformBlock
  102199. * @param name defines the block name
  102200. */
  102201. constructor(name: string);
  102202. /**
  102203. * Gets the current class name
  102204. * @returns the class name
  102205. */
  102206. getClassName(): string;
  102207. /**
  102208. * Gets the vector input
  102209. */
  102210. get vector(): NodeMaterialConnectionPoint;
  102211. /**
  102212. * Gets the output component
  102213. */
  102214. get output(): NodeMaterialConnectionPoint;
  102215. /**
  102216. * Gets the xyz output component
  102217. */
  102218. get xyz(): NodeMaterialConnectionPoint;
  102219. /**
  102220. * Gets the matrix transform input
  102221. */
  102222. get transform(): NodeMaterialConnectionPoint;
  102223. protected _buildBlock(state: NodeMaterialBuildState): this;
  102224. /**
  102225. * Update defines for shader compilation
  102226. * @param mesh defines the mesh to be rendered
  102227. * @param nodeMaterial defines the node material requesting the update
  102228. * @param defines defines the material defines to update
  102229. * @param useInstances specifies that instances should be used
  102230. * @param subMesh defines which submesh to render
  102231. */
  102232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102233. serialize(): any;
  102234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102235. protected _dumpPropertiesCode(): string;
  102236. }
  102237. }
  102238. declare module BABYLON {
  102239. /**
  102240. * Block used to output the vertex position
  102241. */
  102242. export class VertexOutputBlock extends NodeMaterialBlock {
  102243. /**
  102244. * Creates a new VertexOutputBlock
  102245. * @param name defines the block name
  102246. */
  102247. constructor(name: string);
  102248. /**
  102249. * Gets the current class name
  102250. * @returns the class name
  102251. */
  102252. getClassName(): string;
  102253. /**
  102254. * Gets the vector input component
  102255. */
  102256. get vector(): NodeMaterialConnectionPoint;
  102257. protected _buildBlock(state: NodeMaterialBuildState): this;
  102258. }
  102259. }
  102260. declare module BABYLON {
  102261. /**
  102262. * Block used to output the final color
  102263. */
  102264. export class FragmentOutputBlock extends NodeMaterialBlock {
  102265. /**
  102266. * Create a new FragmentOutputBlock
  102267. * @param name defines the block name
  102268. */
  102269. constructor(name: string);
  102270. /**
  102271. * Gets the current class name
  102272. * @returns the class name
  102273. */
  102274. getClassName(): string;
  102275. /**
  102276. * Gets the rgba input component
  102277. */
  102278. get rgba(): NodeMaterialConnectionPoint;
  102279. /**
  102280. * Gets the rgb input component
  102281. */
  102282. get rgb(): NodeMaterialConnectionPoint;
  102283. /**
  102284. * Gets the a input component
  102285. */
  102286. get a(): NodeMaterialConnectionPoint;
  102287. protected _buildBlock(state: NodeMaterialBuildState): this;
  102288. }
  102289. }
  102290. declare module BABYLON {
  102291. /**
  102292. * Block used for the particle ramp gradient section
  102293. */
  102294. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102295. /**
  102296. * Create a new ParticleRampGradientBlock
  102297. * @param name defines the block name
  102298. */
  102299. constructor(name: string);
  102300. /**
  102301. * Gets the current class name
  102302. * @returns the class name
  102303. */
  102304. getClassName(): string;
  102305. /**
  102306. * Gets the color input component
  102307. */
  102308. get color(): NodeMaterialConnectionPoint;
  102309. /**
  102310. * Gets the rampColor output component
  102311. */
  102312. get rampColor(): NodeMaterialConnectionPoint;
  102313. /**
  102314. * Initialize the block and prepare the context for build
  102315. * @param state defines the state that will be used for the build
  102316. */
  102317. initialize(state: NodeMaterialBuildState): void;
  102318. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102319. }
  102320. }
  102321. declare module BABYLON {
  102322. /**
  102323. * Block used for the particle blend multiply section
  102324. */
  102325. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102326. /**
  102327. * Create a new ParticleBlendMultiplyBlock
  102328. * @param name defines the block name
  102329. */
  102330. constructor(name: string);
  102331. /**
  102332. * Gets the current class name
  102333. * @returns the class name
  102334. */
  102335. getClassName(): string;
  102336. /**
  102337. * Gets the color input component
  102338. */
  102339. get color(): NodeMaterialConnectionPoint;
  102340. /**
  102341. * Gets the alphaTexture input component
  102342. */
  102343. get alphaTexture(): NodeMaterialConnectionPoint;
  102344. /**
  102345. * Gets the alphaColor input component
  102346. */
  102347. get alphaColor(): NodeMaterialConnectionPoint;
  102348. /**
  102349. * Gets the blendColor output component
  102350. */
  102351. get blendColor(): NodeMaterialConnectionPoint;
  102352. /**
  102353. * Initialize the block and prepare the context for build
  102354. * @param state defines the state that will be used for the build
  102355. */
  102356. initialize(state: NodeMaterialBuildState): void;
  102357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102358. }
  102359. }
  102360. declare module BABYLON {
  102361. /**
  102362. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102363. */
  102364. export class VectorMergerBlock extends NodeMaterialBlock {
  102365. /**
  102366. * Create a new VectorMergerBlock
  102367. * @param name defines the block name
  102368. */
  102369. constructor(name: string);
  102370. /**
  102371. * Gets the current class name
  102372. * @returns the class name
  102373. */
  102374. getClassName(): string;
  102375. /**
  102376. * Gets the xyz component (input)
  102377. */
  102378. get xyzIn(): NodeMaterialConnectionPoint;
  102379. /**
  102380. * Gets the xy component (input)
  102381. */
  102382. get xyIn(): NodeMaterialConnectionPoint;
  102383. /**
  102384. * Gets the x component (input)
  102385. */
  102386. get x(): NodeMaterialConnectionPoint;
  102387. /**
  102388. * Gets the y component (input)
  102389. */
  102390. get y(): NodeMaterialConnectionPoint;
  102391. /**
  102392. * Gets the z component (input)
  102393. */
  102394. get z(): NodeMaterialConnectionPoint;
  102395. /**
  102396. * Gets the w component (input)
  102397. */
  102398. get w(): NodeMaterialConnectionPoint;
  102399. /**
  102400. * Gets the xyzw component (output)
  102401. */
  102402. get xyzw(): NodeMaterialConnectionPoint;
  102403. /**
  102404. * Gets the xyz component (output)
  102405. */
  102406. get xyzOut(): NodeMaterialConnectionPoint;
  102407. /**
  102408. * Gets the xy component (output)
  102409. */
  102410. get xyOut(): NodeMaterialConnectionPoint;
  102411. /**
  102412. * Gets the xy component (output)
  102413. * @deprecated Please use xyOut instead.
  102414. */
  102415. get xy(): NodeMaterialConnectionPoint;
  102416. /**
  102417. * Gets the xyz component (output)
  102418. * @deprecated Please use xyzOut instead.
  102419. */
  102420. get xyz(): NodeMaterialConnectionPoint;
  102421. protected _buildBlock(state: NodeMaterialBuildState): this;
  102422. }
  102423. }
  102424. declare module BABYLON {
  102425. /**
  102426. * Block used to remap a float from a range to a new one
  102427. */
  102428. export class RemapBlock extends NodeMaterialBlock {
  102429. /**
  102430. * Gets or sets the source range
  102431. */
  102432. sourceRange: Vector2;
  102433. /**
  102434. * Gets or sets the target range
  102435. */
  102436. targetRange: Vector2;
  102437. /**
  102438. * Creates a new RemapBlock
  102439. * @param name defines the block name
  102440. */
  102441. constructor(name: string);
  102442. /**
  102443. * Gets the current class name
  102444. * @returns the class name
  102445. */
  102446. getClassName(): string;
  102447. /**
  102448. * Gets the input component
  102449. */
  102450. get input(): NodeMaterialConnectionPoint;
  102451. /**
  102452. * Gets the source min input component
  102453. */
  102454. get sourceMin(): NodeMaterialConnectionPoint;
  102455. /**
  102456. * Gets the source max input component
  102457. */
  102458. get sourceMax(): NodeMaterialConnectionPoint;
  102459. /**
  102460. * Gets the target min input component
  102461. */
  102462. get targetMin(): NodeMaterialConnectionPoint;
  102463. /**
  102464. * Gets the target max input component
  102465. */
  102466. get targetMax(): NodeMaterialConnectionPoint;
  102467. /**
  102468. * Gets the output component
  102469. */
  102470. get output(): NodeMaterialConnectionPoint;
  102471. protected _buildBlock(state: NodeMaterialBuildState): this;
  102472. protected _dumpPropertiesCode(): string;
  102473. serialize(): any;
  102474. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102475. }
  102476. }
  102477. declare module BABYLON {
  102478. /**
  102479. * Block used to multiply 2 values
  102480. */
  102481. export class MultiplyBlock extends NodeMaterialBlock {
  102482. /**
  102483. * Creates a new MultiplyBlock
  102484. * @param name defines the block name
  102485. */
  102486. constructor(name: string);
  102487. /**
  102488. * Gets the current class name
  102489. * @returns the class name
  102490. */
  102491. getClassName(): string;
  102492. /**
  102493. * Gets the left operand input component
  102494. */
  102495. get left(): NodeMaterialConnectionPoint;
  102496. /**
  102497. * Gets the right operand input component
  102498. */
  102499. get right(): NodeMaterialConnectionPoint;
  102500. /**
  102501. * Gets the output component
  102502. */
  102503. get output(): NodeMaterialConnectionPoint;
  102504. protected _buildBlock(state: NodeMaterialBuildState): this;
  102505. }
  102506. }
  102507. declare module BABYLON {
  102508. /**
  102509. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102510. */
  102511. export class ColorSplitterBlock extends NodeMaterialBlock {
  102512. /**
  102513. * Create a new ColorSplitterBlock
  102514. * @param name defines the block name
  102515. */
  102516. constructor(name: string);
  102517. /**
  102518. * Gets the current class name
  102519. * @returns the class name
  102520. */
  102521. getClassName(): string;
  102522. /**
  102523. * Gets the rgba component (input)
  102524. */
  102525. get rgba(): NodeMaterialConnectionPoint;
  102526. /**
  102527. * Gets the rgb component (input)
  102528. */
  102529. get rgbIn(): NodeMaterialConnectionPoint;
  102530. /**
  102531. * Gets the rgb component (output)
  102532. */
  102533. get rgbOut(): NodeMaterialConnectionPoint;
  102534. /**
  102535. * Gets the r component (output)
  102536. */
  102537. get r(): NodeMaterialConnectionPoint;
  102538. /**
  102539. * Gets the g component (output)
  102540. */
  102541. get g(): NodeMaterialConnectionPoint;
  102542. /**
  102543. * Gets the b component (output)
  102544. */
  102545. get b(): NodeMaterialConnectionPoint;
  102546. /**
  102547. * Gets the a component (output)
  102548. */
  102549. get a(): NodeMaterialConnectionPoint;
  102550. protected _inputRename(name: string): string;
  102551. protected _outputRename(name: string): string;
  102552. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102553. }
  102554. }
  102555. declare module BABYLON {
  102556. /**
  102557. * Operations supported by the Trigonometry block
  102558. */
  102559. export enum TrigonometryBlockOperations {
  102560. /** Cos */
  102561. Cos = 0,
  102562. /** Sin */
  102563. Sin = 1,
  102564. /** Abs */
  102565. Abs = 2,
  102566. /** Exp */
  102567. Exp = 3,
  102568. /** Exp2 */
  102569. Exp2 = 4,
  102570. /** Round */
  102571. Round = 5,
  102572. /** Floor */
  102573. Floor = 6,
  102574. /** Ceiling */
  102575. Ceiling = 7,
  102576. /** Square root */
  102577. Sqrt = 8,
  102578. /** Log */
  102579. Log = 9,
  102580. /** Tangent */
  102581. Tan = 10,
  102582. /** Arc tangent */
  102583. ArcTan = 11,
  102584. /** Arc cosinus */
  102585. ArcCos = 12,
  102586. /** Arc sinus */
  102587. ArcSin = 13,
  102588. /** Fraction */
  102589. Fract = 14,
  102590. /** Sign */
  102591. Sign = 15,
  102592. /** To radians (from degrees) */
  102593. Radians = 16,
  102594. /** To degrees (from radians) */
  102595. Degrees = 17
  102596. }
  102597. /**
  102598. * Block used to apply trigonometry operation to floats
  102599. */
  102600. export class TrigonometryBlock extends NodeMaterialBlock {
  102601. /**
  102602. * Gets or sets the operation applied by the block
  102603. */
  102604. operation: TrigonometryBlockOperations;
  102605. /**
  102606. * Creates a new TrigonometryBlock
  102607. * @param name defines the block name
  102608. */
  102609. constructor(name: string);
  102610. /**
  102611. * Gets the current class name
  102612. * @returns the class name
  102613. */
  102614. getClassName(): string;
  102615. /**
  102616. * Gets the input component
  102617. */
  102618. get input(): NodeMaterialConnectionPoint;
  102619. /**
  102620. * Gets the output component
  102621. */
  102622. get output(): NodeMaterialConnectionPoint;
  102623. protected _buildBlock(state: NodeMaterialBuildState): this;
  102624. serialize(): any;
  102625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102626. protected _dumpPropertiesCode(): string;
  102627. }
  102628. }
  102629. declare module BABYLON {
  102630. /**
  102631. * Interface used to configure the node material editor
  102632. */
  102633. export interface INodeMaterialEditorOptions {
  102634. /** Define the URl to load node editor script */
  102635. editorURL?: string;
  102636. }
  102637. /** @hidden */
  102638. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102639. NORMAL: boolean;
  102640. TANGENT: boolean;
  102641. UV1: boolean;
  102642. /** BONES */
  102643. NUM_BONE_INFLUENCERS: number;
  102644. BonesPerMesh: number;
  102645. BONETEXTURE: boolean;
  102646. /** MORPH TARGETS */
  102647. MORPHTARGETS: boolean;
  102648. MORPHTARGETS_NORMAL: boolean;
  102649. MORPHTARGETS_TANGENT: boolean;
  102650. MORPHTARGETS_UV: boolean;
  102651. NUM_MORPH_INFLUENCERS: number;
  102652. /** IMAGE PROCESSING */
  102653. IMAGEPROCESSING: boolean;
  102654. VIGNETTE: boolean;
  102655. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102656. VIGNETTEBLENDMODEOPAQUE: boolean;
  102657. TONEMAPPING: boolean;
  102658. TONEMAPPING_ACES: boolean;
  102659. CONTRAST: boolean;
  102660. EXPOSURE: boolean;
  102661. COLORCURVES: boolean;
  102662. COLORGRADING: boolean;
  102663. COLORGRADING3D: boolean;
  102664. SAMPLER3DGREENDEPTH: boolean;
  102665. SAMPLER3DBGRMAP: boolean;
  102666. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102667. /** MISC. */
  102668. BUMPDIRECTUV: number;
  102669. constructor();
  102670. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102671. }
  102672. /**
  102673. * Class used to configure NodeMaterial
  102674. */
  102675. export interface INodeMaterialOptions {
  102676. /**
  102677. * Defines if blocks should emit comments
  102678. */
  102679. emitComments: boolean;
  102680. }
  102681. /**
  102682. * Class used to create a node based material built by assembling shader blocks
  102683. */
  102684. export class NodeMaterial extends PushMaterial {
  102685. private static _BuildIdGenerator;
  102686. private _options;
  102687. private _vertexCompilationState;
  102688. private _fragmentCompilationState;
  102689. private _sharedData;
  102690. private _buildId;
  102691. private _buildWasSuccessful;
  102692. private _cachedWorldViewMatrix;
  102693. private _cachedWorldViewProjectionMatrix;
  102694. private _optimizers;
  102695. private _animationFrame;
  102696. /** Define the Url to load node editor script */
  102697. static EditorURL: string;
  102698. /** Define the Url to load snippets */
  102699. static SnippetUrl: string;
  102700. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102701. static IgnoreTexturesAtLoadTime: boolean;
  102702. private BJSNODEMATERIALEDITOR;
  102703. /** Get the inspector from bundle or global */
  102704. private _getGlobalNodeMaterialEditor;
  102705. /**
  102706. * Snippet ID if the material was created from the snippet server
  102707. */
  102708. snippetId: string;
  102709. /**
  102710. * Gets or sets data used by visual editor
  102711. * @see https://nme.babylonjs.com
  102712. */
  102713. editorData: any;
  102714. /**
  102715. * 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)
  102716. */
  102717. ignoreAlpha: boolean;
  102718. /**
  102719. * Defines the maximum number of lights that can be used in the material
  102720. */
  102721. maxSimultaneousLights: number;
  102722. /**
  102723. * Observable raised when the material is built
  102724. */
  102725. onBuildObservable: Observable<NodeMaterial>;
  102726. /**
  102727. * Gets or sets the root nodes of the material vertex shader
  102728. */
  102729. _vertexOutputNodes: NodeMaterialBlock[];
  102730. /**
  102731. * Gets or sets the root nodes of the material fragment (pixel) shader
  102732. */
  102733. _fragmentOutputNodes: NodeMaterialBlock[];
  102734. /** Gets or sets options to control the node material overall behavior */
  102735. get options(): INodeMaterialOptions;
  102736. set options(options: INodeMaterialOptions);
  102737. /**
  102738. * Default configuration related to image processing available in the standard Material.
  102739. */
  102740. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102741. /**
  102742. * Gets the image processing configuration used either in this material.
  102743. */
  102744. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102745. /**
  102746. * Sets the Default image processing configuration used either in the this material.
  102747. *
  102748. * If sets to null, the scene one is in use.
  102749. */
  102750. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102751. /**
  102752. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102753. */
  102754. attachedBlocks: NodeMaterialBlock[];
  102755. /**
  102756. * Specifies the mode of the node material
  102757. * @hidden
  102758. */
  102759. _mode: NodeMaterialModes;
  102760. /**
  102761. * Gets the mode property
  102762. */
  102763. get mode(): NodeMaterialModes;
  102764. /**
  102765. * Create a new node based material
  102766. * @param name defines the material name
  102767. * @param scene defines the hosting scene
  102768. * @param options defines creation option
  102769. */
  102770. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102771. /**
  102772. * Gets the current class name of the material e.g. "NodeMaterial"
  102773. * @returns the class name
  102774. */
  102775. getClassName(): string;
  102776. /**
  102777. * Keep track of the image processing observer to allow dispose and replace.
  102778. */
  102779. private _imageProcessingObserver;
  102780. /**
  102781. * Attaches a new image processing configuration to the Standard Material.
  102782. * @param configuration
  102783. */
  102784. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102785. /**
  102786. * Get a block by its name
  102787. * @param name defines the name of the block to retrieve
  102788. * @returns the required block or null if not found
  102789. */
  102790. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102791. /**
  102792. * Get a block by its name
  102793. * @param predicate defines the predicate used to find the good candidate
  102794. * @returns the required block or null if not found
  102795. */
  102796. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102797. /**
  102798. * Get an input block by its name
  102799. * @param predicate defines the predicate used to find the good candidate
  102800. * @returns the required input block or null if not found
  102801. */
  102802. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102803. /**
  102804. * Gets the list of input blocks attached to this material
  102805. * @returns an array of InputBlocks
  102806. */
  102807. getInputBlocks(): InputBlock[];
  102808. /**
  102809. * Adds a new optimizer to the list of optimizers
  102810. * @param optimizer defines the optimizers to add
  102811. * @returns the current material
  102812. */
  102813. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102814. /**
  102815. * Remove an optimizer from the list of optimizers
  102816. * @param optimizer defines the optimizers to remove
  102817. * @returns the current material
  102818. */
  102819. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102820. /**
  102821. * Add a new block to the list of output nodes
  102822. * @param node defines the node to add
  102823. * @returns the current material
  102824. */
  102825. addOutputNode(node: NodeMaterialBlock): this;
  102826. /**
  102827. * Remove a block from the list of root nodes
  102828. * @param node defines the node to remove
  102829. * @returns the current material
  102830. */
  102831. removeOutputNode(node: NodeMaterialBlock): this;
  102832. private _addVertexOutputNode;
  102833. private _removeVertexOutputNode;
  102834. private _addFragmentOutputNode;
  102835. private _removeFragmentOutputNode;
  102836. /**
  102837. * Specifies if the material will require alpha blending
  102838. * @returns a boolean specifying if alpha blending is needed
  102839. */
  102840. needAlphaBlending(): boolean;
  102841. /**
  102842. * Specifies if this material should be rendered in alpha test mode
  102843. * @returns a boolean specifying if an alpha test is needed.
  102844. */
  102845. needAlphaTesting(): boolean;
  102846. private _initializeBlock;
  102847. private _resetDualBlocks;
  102848. /**
  102849. * Remove a block from the current node material
  102850. * @param block defines the block to remove
  102851. */
  102852. removeBlock(block: NodeMaterialBlock): void;
  102853. /**
  102854. * Build the material and generates the inner effect
  102855. * @param verbose defines if the build should log activity
  102856. */
  102857. build(verbose?: boolean): void;
  102858. /**
  102859. * Runs an otpimization phase to try to improve the shader code
  102860. */
  102861. optimize(): void;
  102862. private _prepareDefinesForAttributes;
  102863. /**
  102864. * Create a post process from the material
  102865. * @param camera The camera to apply the render pass to.
  102866. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102868. * @param engine The engine which the post process will be applied. (default: current engine)
  102869. * @param reusable If the post process can be reused on the same frame. (default: false)
  102870. * @param textureType Type of textures used when performing the post process. (default: 0)
  102871. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102872. * @returns the post process created
  102873. */
  102874. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102875. /**
  102876. * Create the post process effect from the material
  102877. * @param postProcess The post process to create the effect for
  102878. */
  102879. createEffectForPostProcess(postProcess: PostProcess): void;
  102880. private _createEffectForPostProcess;
  102881. /**
  102882. * Create a new procedural texture based on this node material
  102883. * @param size defines the size of the texture
  102884. * @param scene defines the hosting scene
  102885. * @returns the new procedural texture attached to this node material
  102886. */
  102887. createProceduralTexture(size: number | {
  102888. width: number;
  102889. height: number;
  102890. layers?: number;
  102891. }, scene: Scene): Nullable<ProceduralTexture>;
  102892. private _createEffectForParticles;
  102893. private _checkInternals;
  102894. /**
  102895. * Create the effect to be used as the custom effect for a particle system
  102896. * @param particleSystem Particle system to create the effect for
  102897. * @param onCompiled defines a function to call when the effect creation is successful
  102898. * @param onError defines a function to call when the effect creation has failed
  102899. */
  102900. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102901. private _processDefines;
  102902. /**
  102903. * Get if the submesh is ready to be used and all its information available.
  102904. * Child classes can use it to update shaders
  102905. * @param mesh defines the mesh to check
  102906. * @param subMesh defines which submesh to check
  102907. * @param useInstances specifies that instances should be used
  102908. * @returns a boolean indicating that the submesh is ready or not
  102909. */
  102910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102911. /**
  102912. * Get a string representing the shaders built by the current node graph
  102913. */
  102914. get compiledShaders(): string;
  102915. /**
  102916. * Binds the world matrix to the material
  102917. * @param world defines the world transformation matrix
  102918. */
  102919. bindOnlyWorldMatrix(world: Matrix): void;
  102920. /**
  102921. * Binds the submesh to this material by preparing the effect and shader to draw
  102922. * @param world defines the world transformation matrix
  102923. * @param mesh defines the mesh containing the submesh
  102924. * @param subMesh defines the submesh to bind the material to
  102925. */
  102926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102927. /**
  102928. * Gets the active textures from the material
  102929. * @returns an array of textures
  102930. */
  102931. getActiveTextures(): BaseTexture[];
  102932. /**
  102933. * Gets the list of texture blocks
  102934. * @returns an array of texture blocks
  102935. */
  102936. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102937. /**
  102938. * Specifies if the material uses a texture
  102939. * @param texture defines the texture to check against the material
  102940. * @returns a boolean specifying if the material uses the texture
  102941. */
  102942. hasTexture(texture: BaseTexture): boolean;
  102943. /**
  102944. * Disposes the material
  102945. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102946. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102947. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102948. */
  102949. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102950. /** Creates the node editor window. */
  102951. private _createNodeEditor;
  102952. /**
  102953. * Launch the node material editor
  102954. * @param config Define the configuration of the editor
  102955. * @return a promise fulfilled when the node editor is visible
  102956. */
  102957. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102958. /**
  102959. * Clear the current material
  102960. */
  102961. clear(): void;
  102962. /**
  102963. * Clear the current material and set it to a default state
  102964. */
  102965. setToDefault(): void;
  102966. /**
  102967. * Clear the current material and set it to a default state for post process
  102968. */
  102969. setToDefaultPostProcess(): void;
  102970. /**
  102971. * Clear the current material and set it to a default state for procedural texture
  102972. */
  102973. setToDefaultProceduralTexture(): void;
  102974. /**
  102975. * Clear the current material and set it to a default state for particle
  102976. */
  102977. setToDefaultParticle(): void;
  102978. /**
  102979. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102980. * @param url defines the url to load from
  102981. * @returns a promise that will fullfil when the material is fully loaded
  102982. */
  102983. loadAsync(url: string): Promise<void>;
  102984. private _gatherBlocks;
  102985. /**
  102986. * Generate a string containing the code declaration required to create an equivalent of this material
  102987. * @returns a string
  102988. */
  102989. generateCode(): string;
  102990. /**
  102991. * Serializes this material in a JSON representation
  102992. * @returns the serialized material object
  102993. */
  102994. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102995. private _restoreConnections;
  102996. /**
  102997. * Clear the current graph and load a new one from a serialization object
  102998. * @param source defines the JSON representation of the material
  102999. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103000. * @param merge defines whether or not the source must be merged or replace the current content
  103001. */
  103002. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103003. /**
  103004. * Makes a duplicate of the current material.
  103005. * @param name - name to use for the new material.
  103006. */
  103007. clone(name: string): NodeMaterial;
  103008. /**
  103009. * Creates a node material from parsed material data
  103010. * @param source defines the JSON representation of the material
  103011. * @param scene defines the hosting scene
  103012. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103013. * @returns a new node material
  103014. */
  103015. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103016. /**
  103017. * Creates a node material from a snippet saved in a remote file
  103018. * @param name defines the name of the material to create
  103019. * @param url defines the url to load from
  103020. * @param scene defines the hosting scene
  103021. * @returns a promise that will resolve to the new node material
  103022. */
  103023. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103024. /**
  103025. * Creates a node material from a snippet saved by the node material editor
  103026. * @param snippetId defines the snippet to load
  103027. * @param scene defines the hosting scene
  103028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103029. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103030. * @returns a promise that will resolve to the new node material
  103031. */
  103032. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103033. /**
  103034. * Creates a new node material set to default basic configuration
  103035. * @param name defines the name of the material
  103036. * @param scene defines the hosting scene
  103037. * @returns a new NodeMaterial
  103038. */
  103039. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103040. }
  103041. }
  103042. declare module BABYLON {
  103043. /**
  103044. * Size options for a post process
  103045. */
  103046. export type PostProcessOptions = {
  103047. width: number;
  103048. height: number;
  103049. };
  103050. /**
  103051. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103052. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103053. */
  103054. export class PostProcess {
  103055. /**
  103056. * Gets or sets the unique id of the post process
  103057. */
  103058. uniqueId: number;
  103059. /** Name of the PostProcess. */
  103060. name: string;
  103061. /**
  103062. * Width of the texture to apply the post process on
  103063. */
  103064. width: number;
  103065. /**
  103066. * Height of the texture to apply the post process on
  103067. */
  103068. height: number;
  103069. /**
  103070. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103071. */
  103072. nodeMaterialSource: Nullable<NodeMaterial>;
  103073. /**
  103074. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103075. * @hidden
  103076. */
  103077. _outputTexture: Nullable<InternalTexture>;
  103078. /**
  103079. * Sampling mode used by the shader
  103080. * See https://doc.babylonjs.com/classes/3.1/texture
  103081. */
  103082. renderTargetSamplingMode: number;
  103083. /**
  103084. * Clear color to use when screen clearing
  103085. */
  103086. clearColor: Color4;
  103087. /**
  103088. * If the buffer needs to be cleared before applying the post process. (default: true)
  103089. * Should be set to false if shader will overwrite all previous pixels.
  103090. */
  103091. autoClear: boolean;
  103092. /**
  103093. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103094. */
  103095. alphaMode: number;
  103096. /**
  103097. * Sets the setAlphaBlendConstants of the babylon engine
  103098. */
  103099. alphaConstants: Color4;
  103100. /**
  103101. * Animations to be used for the post processing
  103102. */
  103103. animations: Animation[];
  103104. /**
  103105. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103106. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103107. */
  103108. enablePixelPerfectMode: boolean;
  103109. /**
  103110. * Force the postprocess to be applied without taking in account viewport
  103111. */
  103112. forceFullscreenViewport: boolean;
  103113. /**
  103114. * List of inspectable custom properties (used by the Inspector)
  103115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103116. */
  103117. inspectableCustomProperties: IInspectable[];
  103118. /**
  103119. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103120. *
  103121. * | Value | Type | Description |
  103122. * | ----- | ----------------------------------- | ----------- |
  103123. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103124. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103125. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103126. *
  103127. */
  103128. scaleMode: number;
  103129. /**
  103130. * Force textures to be a power of two (default: false)
  103131. */
  103132. alwaysForcePOT: boolean;
  103133. private _samples;
  103134. /**
  103135. * Number of sample textures (default: 1)
  103136. */
  103137. get samples(): number;
  103138. set samples(n: number);
  103139. /**
  103140. * Modify the scale of the post process to be the same as the viewport (default: false)
  103141. */
  103142. adaptScaleToCurrentViewport: boolean;
  103143. private _camera;
  103144. protected _scene: Scene;
  103145. private _engine;
  103146. private _options;
  103147. private _reusable;
  103148. private _textureType;
  103149. private _textureFormat;
  103150. /**
  103151. * Smart array of input and output textures for the post process.
  103152. * @hidden
  103153. */
  103154. _textures: SmartArray<InternalTexture>;
  103155. /**
  103156. * The index in _textures that corresponds to the output texture.
  103157. * @hidden
  103158. */
  103159. _currentRenderTextureInd: number;
  103160. private _effect;
  103161. private _samplers;
  103162. private _fragmentUrl;
  103163. private _vertexUrl;
  103164. private _parameters;
  103165. private _scaleRatio;
  103166. protected _indexParameters: any;
  103167. private _shareOutputWithPostProcess;
  103168. private _texelSize;
  103169. private _forcedOutputTexture;
  103170. /**
  103171. * Returns the fragment url or shader name used in the post process.
  103172. * @returns the fragment url or name in the shader store.
  103173. */
  103174. getEffectName(): string;
  103175. /**
  103176. * An event triggered when the postprocess is activated.
  103177. */
  103178. onActivateObservable: Observable<Camera>;
  103179. private _onActivateObserver;
  103180. /**
  103181. * A function that is added to the onActivateObservable
  103182. */
  103183. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103184. /**
  103185. * An event triggered when the postprocess changes its size.
  103186. */
  103187. onSizeChangedObservable: Observable<PostProcess>;
  103188. private _onSizeChangedObserver;
  103189. /**
  103190. * A function that is added to the onSizeChangedObservable
  103191. */
  103192. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103193. /**
  103194. * An event triggered when the postprocess applies its effect.
  103195. */
  103196. onApplyObservable: Observable<Effect>;
  103197. private _onApplyObserver;
  103198. /**
  103199. * A function that is added to the onApplyObservable
  103200. */
  103201. set onApply(callback: (effect: Effect) => void);
  103202. /**
  103203. * An event triggered before rendering the postprocess
  103204. */
  103205. onBeforeRenderObservable: Observable<Effect>;
  103206. private _onBeforeRenderObserver;
  103207. /**
  103208. * A function that is added to the onBeforeRenderObservable
  103209. */
  103210. set onBeforeRender(callback: (effect: Effect) => void);
  103211. /**
  103212. * An event triggered after rendering the postprocess
  103213. */
  103214. onAfterRenderObservable: Observable<Effect>;
  103215. private _onAfterRenderObserver;
  103216. /**
  103217. * A function that is added to the onAfterRenderObservable
  103218. */
  103219. set onAfterRender(callback: (efect: Effect) => void);
  103220. /**
  103221. * 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
  103222. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103223. */
  103224. get inputTexture(): InternalTexture;
  103225. set inputTexture(value: InternalTexture);
  103226. /**
  103227. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103228. * the only way to unset it is to use this function to restore its internal state
  103229. */
  103230. restoreDefaultInputTexture(): void;
  103231. /**
  103232. * Gets the camera which post process is applied to.
  103233. * @returns The camera the post process is applied to.
  103234. */
  103235. getCamera(): Camera;
  103236. /**
  103237. * Gets the texel size of the postprocess.
  103238. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103239. */
  103240. get texelSize(): Vector2;
  103241. /**
  103242. * Creates a new instance PostProcess
  103243. * @param name The name of the PostProcess.
  103244. * @param fragmentUrl The url of the fragment shader to be used.
  103245. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103246. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103247. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103248. * @param camera The camera to apply the render pass to.
  103249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103250. * @param engine The engine which the post process will be applied. (default: current engine)
  103251. * @param reusable If the post process can be reused on the same frame. (default: false)
  103252. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103253. * @param textureType Type of textures used when performing the post process. (default: 0)
  103254. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103255. * @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
  103256. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103257. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103258. */
  103259. 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);
  103260. /**
  103261. * Gets a string identifying the name of the class
  103262. * @returns "PostProcess" string
  103263. */
  103264. getClassName(): string;
  103265. /**
  103266. * Gets the engine which this post process belongs to.
  103267. * @returns The engine the post process was enabled with.
  103268. */
  103269. getEngine(): Engine;
  103270. /**
  103271. * The effect that is created when initializing the post process.
  103272. * @returns The created effect corresponding the the postprocess.
  103273. */
  103274. getEffect(): Effect;
  103275. /**
  103276. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103277. * @param postProcess The post process to share the output with.
  103278. * @returns This post process.
  103279. */
  103280. shareOutputWith(postProcess: PostProcess): PostProcess;
  103281. /**
  103282. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103283. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103284. */
  103285. useOwnOutput(): void;
  103286. /**
  103287. * Updates the effect with the current post process compile time values and recompiles the shader.
  103288. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103289. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103290. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103291. * @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
  103292. * @param onCompiled Called when the shader has been compiled.
  103293. * @param onError Called if there is an error when compiling a shader.
  103294. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103295. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103296. */
  103297. 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;
  103298. /**
  103299. * The post process is reusable if it can be used multiple times within one frame.
  103300. * @returns If the post process is reusable
  103301. */
  103302. isReusable(): boolean;
  103303. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103304. markTextureDirty(): void;
  103305. /**
  103306. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103307. * 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.
  103308. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103309. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103310. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103311. * @returns The target texture that was bound to be written to.
  103312. */
  103313. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103314. /**
  103315. * If the post process is supported.
  103316. */
  103317. get isSupported(): boolean;
  103318. /**
  103319. * The aspect ratio of the output texture.
  103320. */
  103321. get aspectRatio(): number;
  103322. /**
  103323. * Get a value indicating if the post-process is ready to be used
  103324. * @returns true if the post-process is ready (shader is compiled)
  103325. */
  103326. isReady(): boolean;
  103327. /**
  103328. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103329. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103330. */
  103331. apply(): Nullable<Effect>;
  103332. private _disposeTextures;
  103333. /**
  103334. * Disposes the post process.
  103335. * @param camera The camera to dispose the post process on.
  103336. */
  103337. dispose(camera?: Camera): void;
  103338. /**
  103339. * Serializes the particle system to a JSON object
  103340. * @returns the JSON object
  103341. */
  103342. serialize(): any;
  103343. /**
  103344. * Creates a material from parsed material data
  103345. * @param parsedPostProcess defines parsed post process data
  103346. * @param scene defines the hosting scene
  103347. * @param rootUrl defines the root URL to use to load textures
  103348. * @returns a new post process
  103349. */
  103350. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103351. }
  103352. }
  103353. declare module BABYLON {
  103354. /** @hidden */
  103355. export var kernelBlurVaryingDeclaration: {
  103356. name: string;
  103357. shader: string;
  103358. };
  103359. }
  103360. declare module BABYLON {
  103361. /** @hidden */
  103362. export var kernelBlurFragment: {
  103363. name: string;
  103364. shader: string;
  103365. };
  103366. }
  103367. declare module BABYLON {
  103368. /** @hidden */
  103369. export var kernelBlurFragment2: {
  103370. name: string;
  103371. shader: string;
  103372. };
  103373. }
  103374. declare module BABYLON {
  103375. /** @hidden */
  103376. export var kernelBlurPixelShader: {
  103377. name: string;
  103378. shader: string;
  103379. };
  103380. }
  103381. declare module BABYLON {
  103382. /** @hidden */
  103383. export var kernelBlurVertex: {
  103384. name: string;
  103385. shader: string;
  103386. };
  103387. }
  103388. declare module BABYLON {
  103389. /** @hidden */
  103390. export var kernelBlurVertexShader: {
  103391. name: string;
  103392. shader: string;
  103393. };
  103394. }
  103395. declare module BABYLON {
  103396. /**
  103397. * The Blur Post Process which blurs an image based on a kernel and direction.
  103398. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103399. */
  103400. export class BlurPostProcess extends PostProcess {
  103401. private blockCompilation;
  103402. protected _kernel: number;
  103403. protected _idealKernel: number;
  103404. protected _packedFloat: boolean;
  103405. private _staticDefines;
  103406. /** The direction in which to blur the image. */
  103407. direction: Vector2;
  103408. /**
  103409. * Sets the length in pixels of the blur sample region
  103410. */
  103411. set kernel(v: number);
  103412. /**
  103413. * Gets the length in pixels of the blur sample region
  103414. */
  103415. get kernel(): number;
  103416. /**
  103417. * Sets wether or not the blur needs to unpack/repack floats
  103418. */
  103419. set packedFloat(v: boolean);
  103420. /**
  103421. * Gets wether or not the blur is unpacking/repacking floats
  103422. */
  103423. get packedFloat(): boolean;
  103424. /**
  103425. * Gets a string identifying the name of the class
  103426. * @returns "BlurPostProcess" string
  103427. */
  103428. getClassName(): string;
  103429. /**
  103430. * Creates a new instance BlurPostProcess
  103431. * @param name The name of the effect.
  103432. * @param direction The direction in which to blur the image.
  103433. * @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.
  103434. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103435. * @param camera The camera to apply the render pass to.
  103436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103437. * @param engine The engine which the post process will be applied. (default: current engine)
  103438. * @param reusable If the post process can be reused on the same frame. (default: false)
  103439. * @param textureType Type of textures used when performing the post process. (default: 0)
  103440. * @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)
  103441. */
  103442. 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);
  103443. /**
  103444. * Updates the effect with the current post process compile time values and recompiles the shader.
  103445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103448. * @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
  103449. * @param onCompiled Called when the shader has been compiled.
  103450. * @param onError Called if there is an error when compiling a shader.
  103451. */
  103452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103453. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103454. /**
  103455. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103456. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103457. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103458. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103459. * The gaps between physical kernels are compensated for in the weighting of the samples
  103460. * @param idealKernel Ideal blur kernel.
  103461. * @return Nearest best kernel.
  103462. */
  103463. protected _nearestBestKernel(idealKernel: number): number;
  103464. /**
  103465. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103466. * @param x The point on the Gaussian distribution to sample.
  103467. * @return the value of the Gaussian function at x.
  103468. */
  103469. protected _gaussianWeight(x: number): number;
  103470. /**
  103471. * Generates a string that can be used as a floating point number in GLSL.
  103472. * @param x Value to print.
  103473. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103474. * @return GLSL float string.
  103475. */
  103476. protected _glslFloat(x: number, decimalFigures?: number): string;
  103477. /** @hidden */
  103478. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103479. }
  103480. }
  103481. declare module BABYLON {
  103482. /**
  103483. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103484. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103485. * You can then easily use it as a reflectionTexture on a flat surface.
  103486. * In case the surface is not a plane, please consider relying on reflection probes.
  103487. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103488. */
  103489. export class MirrorTexture extends RenderTargetTexture {
  103490. private scene;
  103491. /**
  103492. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103493. * 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.
  103494. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103495. */
  103496. mirrorPlane: Plane;
  103497. /**
  103498. * Define the blur ratio used to blur the reflection if needed.
  103499. */
  103500. set blurRatio(value: number);
  103501. get blurRatio(): number;
  103502. /**
  103503. * Define the adaptive blur kernel used to blur the reflection if needed.
  103504. * This will autocompute the closest best match for the `blurKernel`
  103505. */
  103506. set adaptiveBlurKernel(value: number);
  103507. /**
  103508. * Define the blur kernel used to blur the reflection if needed.
  103509. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103510. */
  103511. set blurKernel(value: number);
  103512. /**
  103513. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103514. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103515. */
  103516. set blurKernelX(value: number);
  103517. get blurKernelX(): number;
  103518. /**
  103519. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103520. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103521. */
  103522. set blurKernelY(value: number);
  103523. get blurKernelY(): number;
  103524. private _autoComputeBlurKernel;
  103525. protected _onRatioRescale(): void;
  103526. private _updateGammaSpace;
  103527. private _imageProcessingConfigChangeObserver;
  103528. private _transformMatrix;
  103529. private _mirrorMatrix;
  103530. private _savedViewMatrix;
  103531. private _blurX;
  103532. private _blurY;
  103533. private _adaptiveBlurKernel;
  103534. private _blurKernelX;
  103535. private _blurKernelY;
  103536. private _blurRatio;
  103537. /**
  103538. * Instantiates a Mirror Texture.
  103539. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103540. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103541. * You can then easily use it as a reflectionTexture on a flat surface.
  103542. * In case the surface is not a plane, please consider relying on reflection probes.
  103543. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103544. * @param name
  103545. * @param size
  103546. * @param scene
  103547. * @param generateMipMaps
  103548. * @param type
  103549. * @param samplingMode
  103550. * @param generateDepthBuffer
  103551. */
  103552. constructor(name: string, size: number | {
  103553. width: number;
  103554. height: number;
  103555. } | {
  103556. ratio: number;
  103557. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103558. private _preparePostProcesses;
  103559. /**
  103560. * Clone the mirror texture.
  103561. * @returns the cloned texture
  103562. */
  103563. clone(): MirrorTexture;
  103564. /**
  103565. * Serialize the texture to a JSON representation you could use in Parse later on
  103566. * @returns the serialized JSON representation
  103567. */
  103568. serialize(): any;
  103569. /**
  103570. * Dispose the texture and release its associated resources.
  103571. */
  103572. dispose(): void;
  103573. }
  103574. }
  103575. declare module BABYLON {
  103576. /**
  103577. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103578. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103579. */
  103580. export class Texture extends BaseTexture {
  103581. /**
  103582. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103583. */
  103584. static SerializeBuffers: boolean;
  103585. /** @hidden */
  103586. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103587. /** @hidden */
  103588. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103589. /** @hidden */
  103590. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103591. /** nearest is mag = nearest and min = nearest and mip = linear */
  103592. static readonly NEAREST_SAMPLINGMODE: number;
  103593. /** nearest is mag = nearest and min = nearest and mip = linear */
  103594. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103595. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103596. static readonly BILINEAR_SAMPLINGMODE: number;
  103597. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103598. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103599. /** Trilinear is mag = linear and min = linear and mip = linear */
  103600. static readonly TRILINEAR_SAMPLINGMODE: number;
  103601. /** Trilinear is mag = linear and min = linear and mip = linear */
  103602. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103603. /** mag = nearest and min = nearest and mip = nearest */
  103604. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103605. /** mag = nearest and min = linear and mip = nearest */
  103606. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103607. /** mag = nearest and min = linear and mip = linear */
  103608. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103609. /** mag = nearest and min = linear and mip = none */
  103610. static readonly NEAREST_LINEAR: number;
  103611. /** mag = nearest and min = nearest and mip = none */
  103612. static readonly NEAREST_NEAREST: number;
  103613. /** mag = linear and min = nearest and mip = nearest */
  103614. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103615. /** mag = linear and min = nearest and mip = linear */
  103616. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103617. /** mag = linear and min = linear and mip = none */
  103618. static readonly LINEAR_LINEAR: number;
  103619. /** mag = linear and min = nearest and mip = none */
  103620. static readonly LINEAR_NEAREST: number;
  103621. /** Explicit coordinates mode */
  103622. static readonly EXPLICIT_MODE: number;
  103623. /** Spherical coordinates mode */
  103624. static readonly SPHERICAL_MODE: number;
  103625. /** Planar coordinates mode */
  103626. static readonly PLANAR_MODE: number;
  103627. /** Cubic coordinates mode */
  103628. static readonly CUBIC_MODE: number;
  103629. /** Projection coordinates mode */
  103630. static readonly PROJECTION_MODE: number;
  103631. /** Inverse Cubic coordinates mode */
  103632. static readonly SKYBOX_MODE: number;
  103633. /** Inverse Cubic coordinates mode */
  103634. static readonly INVCUBIC_MODE: number;
  103635. /** Equirectangular coordinates mode */
  103636. static readonly EQUIRECTANGULAR_MODE: number;
  103637. /** Equirectangular Fixed coordinates mode */
  103638. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103639. /** Equirectangular Fixed Mirrored coordinates mode */
  103640. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103641. /** Texture is not repeating outside of 0..1 UVs */
  103642. static readonly CLAMP_ADDRESSMODE: number;
  103643. /** Texture is repeating outside of 0..1 UVs */
  103644. static readonly WRAP_ADDRESSMODE: number;
  103645. /** Texture is repeating and mirrored */
  103646. static readonly MIRROR_ADDRESSMODE: number;
  103647. /**
  103648. * 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
  103649. */
  103650. static UseSerializedUrlIfAny: boolean;
  103651. /**
  103652. * Define the url of the texture.
  103653. */
  103654. url: Nullable<string>;
  103655. /**
  103656. * Define an offset on the texture to offset the u coordinates of the UVs
  103657. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103658. */
  103659. uOffset: number;
  103660. /**
  103661. * Define an offset on the texture to offset the v coordinates of the UVs
  103662. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103663. */
  103664. vOffset: number;
  103665. /**
  103666. * Define an offset on the texture to scale the u coordinates of the UVs
  103667. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103668. */
  103669. uScale: number;
  103670. /**
  103671. * Define an offset on the texture to scale the v coordinates of the UVs
  103672. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103673. */
  103674. vScale: number;
  103675. /**
  103676. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103677. * @see https://doc.babylonjs.com/how_to/more_materials
  103678. */
  103679. uAng: number;
  103680. /**
  103681. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103682. * @see https://doc.babylonjs.com/how_to/more_materials
  103683. */
  103684. vAng: number;
  103685. /**
  103686. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103687. * @see https://doc.babylonjs.com/how_to/more_materials
  103688. */
  103689. wAng: number;
  103690. /**
  103691. * Defines the center of rotation (U)
  103692. */
  103693. uRotationCenter: number;
  103694. /**
  103695. * Defines the center of rotation (V)
  103696. */
  103697. vRotationCenter: number;
  103698. /**
  103699. * Defines the center of rotation (W)
  103700. */
  103701. wRotationCenter: number;
  103702. /**
  103703. * Are mip maps generated for this texture or not.
  103704. */
  103705. get noMipmap(): boolean;
  103706. /**
  103707. * List of inspectable custom properties (used by the Inspector)
  103708. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103709. */
  103710. inspectableCustomProperties: Nullable<IInspectable[]>;
  103711. private _noMipmap;
  103712. /** @hidden */
  103713. _invertY: boolean;
  103714. private _rowGenerationMatrix;
  103715. private _cachedTextureMatrix;
  103716. private _projectionModeMatrix;
  103717. private _t0;
  103718. private _t1;
  103719. private _t2;
  103720. private _cachedUOffset;
  103721. private _cachedVOffset;
  103722. private _cachedUScale;
  103723. private _cachedVScale;
  103724. private _cachedUAng;
  103725. private _cachedVAng;
  103726. private _cachedWAng;
  103727. private _cachedProjectionMatrixId;
  103728. private _cachedCoordinatesMode;
  103729. /** @hidden */
  103730. protected _initialSamplingMode: number;
  103731. /** @hidden */
  103732. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103733. private _deleteBuffer;
  103734. protected _format: Nullable<number>;
  103735. private _delayedOnLoad;
  103736. private _delayedOnError;
  103737. private _mimeType?;
  103738. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103739. get mimeType(): string | undefined;
  103740. /**
  103741. * Observable triggered once the texture has been loaded.
  103742. */
  103743. onLoadObservable: Observable<Texture>;
  103744. protected _isBlocking: boolean;
  103745. /**
  103746. * Is the texture preventing material to render while loading.
  103747. * If false, a default texture will be used instead of the loading one during the preparation step.
  103748. */
  103749. set isBlocking(value: boolean);
  103750. get isBlocking(): boolean;
  103751. /**
  103752. * Get the current sampling mode associated with the texture.
  103753. */
  103754. get samplingMode(): number;
  103755. /**
  103756. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103757. */
  103758. get invertY(): boolean;
  103759. /**
  103760. * Instantiates a new texture.
  103761. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103762. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103763. * @param url defines the url of the picture to load as a texture
  103764. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103765. * @param noMipmap defines if the texture will require mip maps or not
  103766. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103767. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103768. * @param onLoad defines a callback triggered when the texture has been loaded
  103769. * @param onError defines a callback triggered when an error occurred during the loading session
  103770. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103771. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103772. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103773. * @param mimeType defines an optional mime type information
  103774. */
  103775. 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);
  103776. /**
  103777. * Update the url (and optional buffer) of this texture if url was null during construction.
  103778. * @param url the url of the texture
  103779. * @param buffer the buffer of the texture (defaults to null)
  103780. * @param onLoad callback called when the texture is loaded (defaults to null)
  103781. */
  103782. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103783. /**
  103784. * Finish the loading sequence of a texture flagged as delayed load.
  103785. * @hidden
  103786. */
  103787. delayLoad(): void;
  103788. private _prepareRowForTextureGeneration;
  103789. /**
  103790. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103791. * @returns the transform matrix of the texture.
  103792. */
  103793. getTextureMatrix(uBase?: number): Matrix;
  103794. /**
  103795. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103796. * @returns The reflection texture transform
  103797. */
  103798. getReflectionTextureMatrix(): Matrix;
  103799. /**
  103800. * Clones the texture.
  103801. * @returns the cloned texture
  103802. */
  103803. clone(): Texture;
  103804. /**
  103805. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103806. * @returns The JSON representation of the texture
  103807. */
  103808. serialize(): any;
  103809. /**
  103810. * Get the current class name of the texture useful for serialization or dynamic coding.
  103811. * @returns "Texture"
  103812. */
  103813. getClassName(): string;
  103814. /**
  103815. * Dispose the texture and release its associated resources.
  103816. */
  103817. dispose(): void;
  103818. /**
  103819. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103820. * @param parsedTexture Define the JSON representation of the texture
  103821. * @param scene Define the scene the parsed texture should be instantiated in
  103822. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103823. * @returns The parsed texture if successful
  103824. */
  103825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103826. /**
  103827. * Creates a texture from its base 64 representation.
  103828. * @param data Define the base64 payload without the data: prefix
  103829. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103830. * @param scene Define the scene the texture should belong to
  103831. * @param noMipmap Forces the texture to not create mip map information if true
  103832. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103833. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103834. * @param onLoad define a callback triggered when the texture has been loaded
  103835. * @param onError define a callback triggered when an error occurred during the loading session
  103836. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103837. * @returns the created texture
  103838. */
  103839. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103840. /**
  103841. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103842. * @param data Define the base64 payload without the data: prefix
  103843. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103844. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103845. * @param scene Define the scene the texture should belong to
  103846. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103847. * @param noMipmap Forces the texture to not create mip map information if true
  103848. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103849. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103850. * @param onLoad define a callback triggered when the texture has been loaded
  103851. * @param onError define a callback triggered when an error occurred during the loading session
  103852. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103853. * @returns the created texture
  103854. */
  103855. 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;
  103856. }
  103857. }
  103858. declare module BABYLON {
  103859. /**
  103860. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103861. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103862. */
  103863. export class PostProcessManager {
  103864. private _scene;
  103865. private _indexBuffer;
  103866. private _vertexBuffers;
  103867. /**
  103868. * Creates a new instance PostProcess
  103869. * @param scene The scene that the post process is associated with.
  103870. */
  103871. constructor(scene: Scene);
  103872. private _prepareBuffers;
  103873. private _buildIndexBuffer;
  103874. /**
  103875. * Rebuilds the vertex buffers of the manager.
  103876. * @hidden
  103877. */
  103878. _rebuild(): void;
  103879. /**
  103880. * Prepares a frame to be run through a post process.
  103881. * @param sourceTexture The input texture to the post procesess. (default: null)
  103882. * @param postProcesses An array of post processes to be run. (default: null)
  103883. * @returns True if the post processes were able to be run.
  103884. * @hidden
  103885. */
  103886. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103887. /**
  103888. * Manually render a set of post processes to a texture.
  103889. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103890. * @param postProcesses An array of post processes to be run.
  103891. * @param targetTexture The target texture to render to.
  103892. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103893. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103894. * @param lodLevel defines which lod of the texture to render to
  103895. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103896. */
  103897. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103898. /**
  103899. * Finalize the result of the output of the postprocesses.
  103900. * @param doNotPresent If true the result will not be displayed to the screen.
  103901. * @param targetTexture The target texture to render to.
  103902. * @param faceIndex The index of the face to bind the target texture to.
  103903. * @param postProcesses The array of post processes to render.
  103904. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103905. * @hidden
  103906. */
  103907. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103908. /**
  103909. * Disposes of the post process manager.
  103910. */
  103911. dispose(): void;
  103912. }
  103913. }
  103914. declare module BABYLON {
  103915. /**
  103916. * This Helps creating a texture that will be created from a camera in your scene.
  103917. * It is basically a dynamic texture that could be used to create special effects for instance.
  103918. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103919. */
  103920. export class RenderTargetTexture extends Texture {
  103921. /**
  103922. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103923. */
  103924. static readonly REFRESHRATE_RENDER_ONCE: number;
  103925. /**
  103926. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103927. */
  103928. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103929. /**
  103930. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103931. * the central point of your effect and can save a lot of performances.
  103932. */
  103933. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103934. /**
  103935. * Use this predicate to dynamically define the list of mesh you want to render.
  103936. * If set, the renderList property will be overwritten.
  103937. */
  103938. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103939. private _renderList;
  103940. /**
  103941. * Use this list to define the list of mesh you want to render.
  103942. */
  103943. get renderList(): Nullable<Array<AbstractMesh>>;
  103944. set renderList(value: Nullable<Array<AbstractMesh>>);
  103945. /**
  103946. * Use this function to overload the renderList array at rendering time.
  103947. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103948. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103949. * the cube (if the RTT is a cube, else layerOrFace=0).
  103950. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103951. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103952. * hold dummy elements!
  103953. */
  103954. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103955. private _hookArray;
  103956. /**
  103957. * Define if particles should be rendered in your texture.
  103958. */
  103959. renderParticles: boolean;
  103960. /**
  103961. * Define if sprites should be rendered in your texture.
  103962. */
  103963. renderSprites: boolean;
  103964. /**
  103965. * Define the camera used to render the texture.
  103966. */
  103967. activeCamera: Nullable<Camera>;
  103968. /**
  103969. * Override the mesh isReady function with your own one.
  103970. */
  103971. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103972. /**
  103973. * Override the render function of the texture with your own one.
  103974. */
  103975. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103976. /**
  103977. * Define if camera post processes should be use while rendering the texture.
  103978. */
  103979. useCameraPostProcesses: boolean;
  103980. /**
  103981. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103982. */
  103983. ignoreCameraViewport: boolean;
  103984. private _postProcessManager;
  103985. private _postProcesses;
  103986. private _resizeObserver;
  103987. /**
  103988. * An event triggered when the texture is unbind.
  103989. */
  103990. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103991. /**
  103992. * An event triggered when the texture is unbind.
  103993. */
  103994. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103995. private _onAfterUnbindObserver;
  103996. /**
  103997. * Set a after unbind callback in the texture.
  103998. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103999. */
  104000. set onAfterUnbind(callback: () => void);
  104001. /**
  104002. * An event triggered before rendering the texture
  104003. */
  104004. onBeforeRenderObservable: Observable<number>;
  104005. private _onBeforeRenderObserver;
  104006. /**
  104007. * Set a before render callback in the texture.
  104008. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104009. */
  104010. set onBeforeRender(callback: (faceIndex: number) => void);
  104011. /**
  104012. * An event triggered after rendering the texture
  104013. */
  104014. onAfterRenderObservable: Observable<number>;
  104015. private _onAfterRenderObserver;
  104016. /**
  104017. * Set a after render callback in the texture.
  104018. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104019. */
  104020. set onAfterRender(callback: (faceIndex: number) => void);
  104021. /**
  104022. * An event triggered after the texture clear
  104023. */
  104024. onClearObservable: Observable<Engine>;
  104025. private _onClearObserver;
  104026. /**
  104027. * Set a clear callback in the texture.
  104028. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104029. */
  104030. set onClear(callback: (Engine: Engine) => void);
  104031. /**
  104032. * An event triggered when the texture is resized.
  104033. */
  104034. onResizeObservable: Observable<RenderTargetTexture>;
  104035. /**
  104036. * Define the clear color of the Render Target if it should be different from the scene.
  104037. */
  104038. clearColor: Color4;
  104039. protected _size: number | {
  104040. width: number;
  104041. height: number;
  104042. layers?: number;
  104043. };
  104044. protected _initialSizeParameter: number | {
  104045. width: number;
  104046. height: number;
  104047. } | {
  104048. ratio: number;
  104049. };
  104050. protected _sizeRatio: Nullable<number>;
  104051. /** @hidden */
  104052. _generateMipMaps: boolean;
  104053. protected _renderingManager: RenderingManager;
  104054. /** @hidden */
  104055. _waitingRenderList?: string[];
  104056. protected _doNotChangeAspectRatio: boolean;
  104057. protected _currentRefreshId: number;
  104058. protected _refreshRate: number;
  104059. protected _textureMatrix: Matrix;
  104060. protected _samples: number;
  104061. protected _renderTargetOptions: RenderTargetCreationOptions;
  104062. /**
  104063. * Gets render target creation options that were used.
  104064. */
  104065. get renderTargetOptions(): RenderTargetCreationOptions;
  104066. protected _onRatioRescale(): void;
  104067. /**
  104068. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104069. * It must define where the camera used to render the texture is set
  104070. */
  104071. boundingBoxPosition: Vector3;
  104072. private _boundingBoxSize;
  104073. /**
  104074. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104075. * When defined, the cubemap will switch to local mode
  104076. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104077. * @example https://www.babylonjs-playground.com/#RNASML
  104078. */
  104079. set boundingBoxSize(value: Vector3);
  104080. get boundingBoxSize(): Vector3;
  104081. /**
  104082. * In case the RTT has been created with a depth texture, get the associated
  104083. * depth texture.
  104084. * Otherwise, return null.
  104085. */
  104086. get depthStencilTexture(): Nullable<InternalTexture>;
  104087. /**
  104088. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104089. * or used a shadow, depth texture...
  104090. * @param name The friendly name of the texture
  104091. * @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)
  104092. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104093. * @param generateMipMaps True if mip maps need to be generated after render.
  104094. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104095. * @param type The type of the buffer in the RTT (int, half float, float...)
  104096. * @param isCube True if a cube texture needs to be created
  104097. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104098. * @param generateDepthBuffer True to generate a depth buffer
  104099. * @param generateStencilBuffer True to generate a stencil buffer
  104100. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104101. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104102. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104103. */
  104104. constructor(name: string, size: number | {
  104105. width: number;
  104106. height: number;
  104107. layers?: number;
  104108. } | {
  104109. ratio: number;
  104110. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104111. /**
  104112. * Creates a depth stencil texture.
  104113. * This is only available in WebGL 2 or with the depth texture extension available.
  104114. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104115. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104116. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104117. */
  104118. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104119. private _processSizeParameter;
  104120. /**
  104121. * Define the number of samples to use in case of MSAA.
  104122. * It defaults to one meaning no MSAA has been enabled.
  104123. */
  104124. get samples(): number;
  104125. set samples(value: number);
  104126. /**
  104127. * Resets the refresh counter of the texture and start bak from scratch.
  104128. * Could be useful to regenerate the texture if it is setup to render only once.
  104129. */
  104130. resetRefreshCounter(): void;
  104131. /**
  104132. * Define the refresh rate of the texture or the rendering frequency.
  104133. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104134. */
  104135. get refreshRate(): number;
  104136. set refreshRate(value: number);
  104137. /**
  104138. * Adds a post process to the render target rendering passes.
  104139. * @param postProcess define the post process to add
  104140. */
  104141. addPostProcess(postProcess: PostProcess): void;
  104142. /**
  104143. * Clear all the post processes attached to the render target
  104144. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104145. */
  104146. clearPostProcesses(dispose?: boolean): void;
  104147. /**
  104148. * Remove one of the post process from the list of attached post processes to the texture
  104149. * @param postProcess define the post process to remove from the list
  104150. */
  104151. removePostProcess(postProcess: PostProcess): void;
  104152. /** @hidden */
  104153. _shouldRender(): boolean;
  104154. /**
  104155. * Gets the actual render size of the texture.
  104156. * @returns the width of the render size
  104157. */
  104158. getRenderSize(): number;
  104159. /**
  104160. * Gets the actual render width of the texture.
  104161. * @returns the width of the render size
  104162. */
  104163. getRenderWidth(): number;
  104164. /**
  104165. * Gets the actual render height of the texture.
  104166. * @returns the height of the render size
  104167. */
  104168. getRenderHeight(): number;
  104169. /**
  104170. * Gets the actual number of layers of the texture.
  104171. * @returns the number of layers
  104172. */
  104173. getRenderLayers(): number;
  104174. /**
  104175. * Get if the texture can be rescaled or not.
  104176. */
  104177. get canRescale(): boolean;
  104178. /**
  104179. * Resize the texture using a ratio.
  104180. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104181. */
  104182. scale(ratio: number): void;
  104183. /**
  104184. * Get the texture reflection matrix used to rotate/transform the reflection.
  104185. * @returns the reflection matrix
  104186. */
  104187. getReflectionTextureMatrix(): Matrix;
  104188. /**
  104189. * Resize the texture to a new desired size.
  104190. * Be carrefull as it will recreate all the data in the new texture.
  104191. * @param size Define the new size. It can be:
  104192. * - a number for squared texture,
  104193. * - an object containing { width: number, height: number }
  104194. * - or an object containing a ratio { ratio: number }
  104195. */
  104196. resize(size: number | {
  104197. width: number;
  104198. height: number;
  104199. } | {
  104200. ratio: number;
  104201. }): void;
  104202. private _defaultRenderListPrepared;
  104203. /**
  104204. * Renders all the objects from the render list into the texture.
  104205. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104206. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104207. */
  104208. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104209. private _bestReflectionRenderTargetDimension;
  104210. private _prepareRenderingManager;
  104211. /**
  104212. * @hidden
  104213. * @param faceIndex face index to bind to if this is a cubetexture
  104214. * @param layer defines the index of the texture to bind in the array
  104215. */
  104216. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104217. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104218. private renderToTarget;
  104219. /**
  104220. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104221. * This allowed control for front to back rendering or reversly depending of the special needs.
  104222. *
  104223. * @param renderingGroupId The rendering group id corresponding to its index
  104224. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104225. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104226. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104227. */
  104228. 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;
  104229. /**
  104230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104231. *
  104232. * @param renderingGroupId The rendering group id corresponding to its index
  104233. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104234. */
  104235. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104236. /**
  104237. * Clones the texture.
  104238. * @returns the cloned texture
  104239. */
  104240. clone(): RenderTargetTexture;
  104241. /**
  104242. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104243. * @returns The JSON representation of the texture
  104244. */
  104245. serialize(): any;
  104246. /**
  104247. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104248. */
  104249. disposeFramebufferObjects(): void;
  104250. /**
  104251. * Dispose the texture and release its associated resources.
  104252. */
  104253. dispose(): void;
  104254. /** @hidden */
  104255. _rebuild(): void;
  104256. /**
  104257. * Clear the info related to rendering groups preventing retention point in material dispose.
  104258. */
  104259. freeRenderingGroups(): void;
  104260. /**
  104261. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104262. * @returns the view count
  104263. */
  104264. getViewCount(): number;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. /**
  104269. * Class used to manipulate GUIDs
  104270. */
  104271. export class GUID {
  104272. /**
  104273. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104274. * Be aware Math.random() could cause collisions, but:
  104275. * "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"
  104276. * @returns a pseudo random id
  104277. */
  104278. static RandomId(): string;
  104279. }
  104280. }
  104281. declare module BABYLON {
  104282. /**
  104283. * Options to be used when creating a shadow depth material
  104284. */
  104285. export interface IIOptionShadowDepthMaterial {
  104286. /** Variables in the vertex shader code that need to have their names remapped.
  104287. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104288. * "var_name" should be either: worldPos or vNormalW
  104289. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104290. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104291. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104292. */
  104293. remappedVariables?: string[];
  104294. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104295. standalone?: boolean;
  104296. }
  104297. /**
  104298. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104299. */
  104300. export class ShadowDepthWrapper {
  104301. private _scene;
  104302. private _options?;
  104303. private _baseMaterial;
  104304. private _onEffectCreatedObserver;
  104305. private _subMeshToEffect;
  104306. private _subMeshToDepthEffect;
  104307. private _meshes;
  104308. /** @hidden */
  104309. _matriceNames: any;
  104310. /** Gets the standalone status of the wrapper */
  104311. get standalone(): boolean;
  104312. /** Gets the base material the wrapper is built upon */
  104313. get baseMaterial(): Material;
  104314. /**
  104315. * Instantiate a new shadow depth wrapper.
  104316. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104317. * generate the shadow depth map. For more information, please refer to the documentation:
  104318. * https://doc.babylonjs.com/babylon101/shadows
  104319. * @param baseMaterial Material to wrap
  104320. * @param scene Define the scene the material belongs to
  104321. * @param options Options used to create the wrapper
  104322. */
  104323. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104324. /**
  104325. * Gets the effect to use to generate the depth map
  104326. * @param subMesh subMesh to get the effect for
  104327. * @param shadowGenerator shadow generator to get the effect for
  104328. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104329. */
  104330. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104331. /**
  104332. * Specifies that the submesh is ready to be used for depth rendering
  104333. * @param subMesh submesh to check
  104334. * @param defines the list of defines to take into account when checking the effect
  104335. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104336. * @param useInstances specifies that instances should be used
  104337. * @returns a boolean indicating that the submesh is ready or not
  104338. */
  104339. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104340. /**
  104341. * Disposes the resources
  104342. */
  104343. dispose(): void;
  104344. private _makeEffect;
  104345. }
  104346. }
  104347. declare module BABYLON {
  104348. interface ThinEngine {
  104349. /**
  104350. * Unbind a list of render target textures from the webGL context
  104351. * This is used only when drawBuffer extension or webGL2 are active
  104352. * @param textures defines the render target textures to unbind
  104353. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104354. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104355. */
  104356. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104357. /**
  104358. * Create a multi render target texture
  104359. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104360. * @param size defines the size of the texture
  104361. * @param options defines the creation options
  104362. * @returns the cube texture as an InternalTexture
  104363. */
  104364. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104365. /**
  104366. * Update the sample count for a given multiple render target texture
  104367. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104368. * @param textures defines the textures to update
  104369. * @param samples defines the sample count to set
  104370. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104371. */
  104372. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104373. /**
  104374. * Select a subsets of attachments to draw to.
  104375. * @param attachments gl attachments
  104376. */
  104377. bindAttachments(attachments: number[]): void;
  104378. }
  104379. }
  104380. declare module BABYLON {
  104381. /**
  104382. * Creation options of the multi render target texture.
  104383. */
  104384. export interface IMultiRenderTargetOptions {
  104385. /**
  104386. * Define if the texture needs to create mip maps after render.
  104387. */
  104388. generateMipMaps?: boolean;
  104389. /**
  104390. * Define the types of all the draw buffers we want to create
  104391. */
  104392. types?: number[];
  104393. /**
  104394. * Define the sampling modes of all the draw buffers we want to create
  104395. */
  104396. samplingModes?: number[];
  104397. /**
  104398. * Define if a depth buffer is required
  104399. */
  104400. generateDepthBuffer?: boolean;
  104401. /**
  104402. * Define if a stencil buffer is required
  104403. */
  104404. generateStencilBuffer?: boolean;
  104405. /**
  104406. * Define if a depth texture is required instead of a depth buffer
  104407. */
  104408. generateDepthTexture?: boolean;
  104409. /**
  104410. * Define the number of desired draw buffers
  104411. */
  104412. textureCount?: number;
  104413. /**
  104414. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104415. */
  104416. doNotChangeAspectRatio?: boolean;
  104417. /**
  104418. * Define the default type of the buffers we are creating
  104419. */
  104420. defaultType?: number;
  104421. }
  104422. /**
  104423. * A multi render target, like a render target provides the ability to render to a texture.
  104424. * Unlike the render target, it can render to several draw buffers in one draw.
  104425. * This is specially interesting in deferred rendering or for any effects requiring more than
  104426. * just one color from a single pass.
  104427. */
  104428. export class MultiRenderTarget extends RenderTargetTexture {
  104429. private _internalTextures;
  104430. private _textures;
  104431. private _multiRenderTargetOptions;
  104432. private _count;
  104433. /**
  104434. * Get if draw buffers are currently supported by the used hardware and browser.
  104435. */
  104436. get isSupported(): boolean;
  104437. /**
  104438. * Get the list of textures generated by the multi render target.
  104439. */
  104440. get textures(): Texture[];
  104441. /**
  104442. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104443. */
  104444. get count(): number;
  104445. /**
  104446. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104447. */
  104448. get depthTexture(): Texture;
  104449. /**
  104450. * Set the wrapping mode on U of all the textures we are rendering to.
  104451. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104452. */
  104453. set wrapU(wrap: number);
  104454. /**
  104455. * Set the wrapping mode on V of all the textures we are rendering to.
  104456. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104457. */
  104458. set wrapV(wrap: number);
  104459. /**
  104460. * Instantiate a new multi render target texture.
  104461. * A multi render target, like a render target provides the ability to render to a texture.
  104462. * Unlike the render target, it can render to several draw buffers in one draw.
  104463. * This is specially interesting in deferred rendering or for any effects requiring more than
  104464. * just one color from a single pass.
  104465. * @param name Define the name of the texture
  104466. * @param size Define the size of the buffers to render to
  104467. * @param count Define the number of target we are rendering into
  104468. * @param scene Define the scene the texture belongs to
  104469. * @param options Define the options used to create the multi render target
  104470. */
  104471. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104472. private _initTypes;
  104473. /** @hidden */
  104474. _rebuild(forceFullRebuild?: boolean): void;
  104475. private _createInternalTextures;
  104476. private _createTextures;
  104477. /**
  104478. * Define the number of samples used if MSAA is enabled.
  104479. */
  104480. get samples(): number;
  104481. set samples(value: number);
  104482. /**
  104483. * Resize all the textures in the multi render target.
  104484. * Be careful as it will recreate all the data in the new texture.
  104485. * @param size Define the new size
  104486. */
  104487. resize(size: any): void;
  104488. /**
  104489. * Changes the number of render targets in this MRT
  104490. * Be careful as it will recreate all the data in the new texture.
  104491. * @param count new texture count
  104492. * @param options Specifies texture types and sampling modes for new textures
  104493. */
  104494. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104495. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104496. /**
  104497. * Dispose the render targets and their associated resources
  104498. */
  104499. dispose(): void;
  104500. /**
  104501. * Release all the underlying texture used as draw buffers.
  104502. */
  104503. releaseInternalTextures(): void;
  104504. }
  104505. }
  104506. declare module BABYLON {
  104507. /** @hidden */
  104508. export var imageProcessingPixelShader: {
  104509. name: string;
  104510. shader: string;
  104511. };
  104512. }
  104513. declare module BABYLON {
  104514. /**
  104515. * ImageProcessingPostProcess
  104516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104517. */
  104518. export class ImageProcessingPostProcess extends PostProcess {
  104519. /**
  104520. * Default configuration related to image processing available in the PBR Material.
  104521. */
  104522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104523. /**
  104524. * Gets the image processing configuration used either in this material.
  104525. */
  104526. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104527. /**
  104528. * Sets the Default image processing configuration used either in the this material.
  104529. *
  104530. * If sets to null, the scene one is in use.
  104531. */
  104532. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104533. /**
  104534. * Keep track of the image processing observer to allow dispose and replace.
  104535. */
  104536. private _imageProcessingObserver;
  104537. /**
  104538. * Attaches a new image processing configuration to the PBR Material.
  104539. * @param configuration
  104540. */
  104541. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104542. /**
  104543. * If the post process is supported.
  104544. */
  104545. get isSupported(): boolean;
  104546. /**
  104547. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104548. */
  104549. get colorCurves(): Nullable<ColorCurves>;
  104550. /**
  104551. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104552. */
  104553. set colorCurves(value: Nullable<ColorCurves>);
  104554. /**
  104555. * Gets wether the color curves effect is enabled.
  104556. */
  104557. get colorCurvesEnabled(): boolean;
  104558. /**
  104559. * Sets wether the color curves effect is enabled.
  104560. */
  104561. set colorCurvesEnabled(value: boolean);
  104562. /**
  104563. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104564. */
  104565. get colorGradingTexture(): Nullable<BaseTexture>;
  104566. /**
  104567. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104568. */
  104569. set colorGradingTexture(value: Nullable<BaseTexture>);
  104570. /**
  104571. * Gets wether the color grading effect is enabled.
  104572. */
  104573. get colorGradingEnabled(): boolean;
  104574. /**
  104575. * Gets wether the color grading effect is enabled.
  104576. */
  104577. set colorGradingEnabled(value: boolean);
  104578. /**
  104579. * Gets exposure used in the effect.
  104580. */
  104581. get exposure(): number;
  104582. /**
  104583. * Sets exposure used in the effect.
  104584. */
  104585. set exposure(value: number);
  104586. /**
  104587. * Gets wether tonemapping is enabled or not.
  104588. */
  104589. get toneMappingEnabled(): boolean;
  104590. /**
  104591. * Sets wether tonemapping is enabled or not
  104592. */
  104593. set toneMappingEnabled(value: boolean);
  104594. /**
  104595. * Gets the type of tone mapping effect.
  104596. */
  104597. get toneMappingType(): number;
  104598. /**
  104599. * Sets the type of tone mapping effect.
  104600. */
  104601. set toneMappingType(value: number);
  104602. /**
  104603. * Gets contrast used in the effect.
  104604. */
  104605. get contrast(): number;
  104606. /**
  104607. * Sets contrast used in the effect.
  104608. */
  104609. set contrast(value: number);
  104610. /**
  104611. * Gets Vignette stretch size.
  104612. */
  104613. get vignetteStretch(): number;
  104614. /**
  104615. * Sets Vignette stretch size.
  104616. */
  104617. set vignetteStretch(value: number);
  104618. /**
  104619. * Gets Vignette centre X Offset.
  104620. */
  104621. get vignetteCentreX(): number;
  104622. /**
  104623. * Sets Vignette centre X Offset.
  104624. */
  104625. set vignetteCentreX(value: number);
  104626. /**
  104627. * Gets Vignette centre Y Offset.
  104628. */
  104629. get vignetteCentreY(): number;
  104630. /**
  104631. * Sets Vignette centre Y Offset.
  104632. */
  104633. set vignetteCentreY(value: number);
  104634. /**
  104635. * Gets Vignette weight or intensity of the vignette effect.
  104636. */
  104637. get vignetteWeight(): number;
  104638. /**
  104639. * Sets Vignette weight or intensity of the vignette effect.
  104640. */
  104641. set vignetteWeight(value: number);
  104642. /**
  104643. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104644. * if vignetteEnabled is set to true.
  104645. */
  104646. get vignetteColor(): Color4;
  104647. /**
  104648. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104649. * if vignetteEnabled is set to true.
  104650. */
  104651. set vignetteColor(value: Color4);
  104652. /**
  104653. * Gets Camera field of view used by the Vignette effect.
  104654. */
  104655. get vignetteCameraFov(): number;
  104656. /**
  104657. * Sets Camera field of view used by the Vignette effect.
  104658. */
  104659. set vignetteCameraFov(value: number);
  104660. /**
  104661. * Gets the vignette blend mode allowing different kind of effect.
  104662. */
  104663. get vignetteBlendMode(): number;
  104664. /**
  104665. * Sets the vignette blend mode allowing different kind of effect.
  104666. */
  104667. set vignetteBlendMode(value: number);
  104668. /**
  104669. * Gets wether the vignette effect is enabled.
  104670. */
  104671. get vignetteEnabled(): boolean;
  104672. /**
  104673. * Sets wether the vignette effect is enabled.
  104674. */
  104675. set vignetteEnabled(value: boolean);
  104676. private _fromLinearSpace;
  104677. /**
  104678. * Gets wether the input of the processing is in Gamma or Linear Space.
  104679. */
  104680. get fromLinearSpace(): boolean;
  104681. /**
  104682. * Sets wether the input of the processing is in Gamma or Linear Space.
  104683. */
  104684. set fromLinearSpace(value: boolean);
  104685. /**
  104686. * Defines cache preventing GC.
  104687. */
  104688. private _defines;
  104689. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104690. /**
  104691. * "ImageProcessingPostProcess"
  104692. * @returns "ImageProcessingPostProcess"
  104693. */
  104694. getClassName(): string;
  104695. /**
  104696. * @hidden
  104697. */
  104698. _updateParameters(): void;
  104699. dispose(camera?: Camera): void;
  104700. }
  104701. }
  104702. declare module BABYLON {
  104703. /**
  104704. * Interface for defining prepass effects in the prepass post-process pipeline
  104705. */
  104706. export interface PrePassEffectConfiguration {
  104707. /**
  104708. * Name of the effect
  104709. */
  104710. name: string;
  104711. /**
  104712. * Post process to attach for this effect
  104713. */
  104714. postProcess?: PostProcess;
  104715. /**
  104716. * Textures required in the MRT
  104717. */
  104718. texturesRequired: number[];
  104719. /**
  104720. * Is the effect enabled
  104721. */
  104722. enabled: boolean;
  104723. /**
  104724. * Disposes the effect configuration
  104725. */
  104726. dispose(): void;
  104727. /**
  104728. * Creates the associated post process
  104729. */
  104730. createPostProcess?: () => PostProcess;
  104731. }
  104732. }
  104733. declare module BABYLON {
  104734. /**
  104735. * Renders a pre pass of the scene
  104736. * This means every mesh in the scene will be rendered to a render target texture
  104737. * And then this texture will be composited to the rendering canvas with post processes
  104738. * It is necessary for effects like subsurface scattering or deferred shading
  104739. */
  104740. export class PrePassRenderer {
  104741. /** @hidden */
  104742. static _SceneComponentInitialization: (scene: Scene) => void;
  104743. private _textureFormats;
  104744. private _textureIndices;
  104745. private _scene;
  104746. private _engine;
  104747. private _isDirty;
  104748. /**
  104749. * Number of textures in the multi render target texture where the scene is directly rendered
  104750. */
  104751. mrtCount: number;
  104752. /**
  104753. * The render target where the scene is directly rendered
  104754. */
  104755. prePassRT: MultiRenderTarget;
  104756. private _multiRenderAttachments;
  104757. private _defaultAttachments;
  104758. private _clearAttachments;
  104759. private _postProcesses;
  104760. private readonly _clearColor;
  104761. /**
  104762. * Image processing post process for composition
  104763. */
  104764. imageProcessingPostProcess: ImageProcessingPostProcess;
  104765. /**
  104766. * Configuration for prepass effects
  104767. */
  104768. private _effectConfigurations;
  104769. /**
  104770. * Should materials render their geometry on the MRT
  104771. */
  104772. materialsShouldRenderGeometry: boolean;
  104773. /**
  104774. * Should materials render the irradiance information on the MRT
  104775. */
  104776. materialsShouldRenderIrradiance: boolean;
  104777. private _mrtFormats;
  104778. private _mrtLayout;
  104779. private _enabled;
  104780. /**
  104781. * Indicates if the prepass is enabled
  104782. */
  104783. get enabled(): boolean;
  104784. /**
  104785. * How many samples are used for MSAA of the scene render target
  104786. */
  104787. get samples(): number;
  104788. set samples(n: number);
  104789. /**
  104790. * Instanciates a prepass renderer
  104791. * @param scene The scene
  104792. */
  104793. constructor(scene: Scene);
  104794. private _initializeAttachments;
  104795. private _createCompositionEffect;
  104796. /**
  104797. * Indicates if rendering a prepass is supported
  104798. */
  104799. get isSupported(): boolean;
  104800. /**
  104801. * Sets the proper output textures to draw in the engine.
  104802. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104803. */
  104804. bindAttachmentsForEffect(effect: Effect): void;
  104805. /**
  104806. * @hidden
  104807. */
  104808. _beforeCameraDraw(): void;
  104809. /**
  104810. * @hidden
  104811. */
  104812. _afterCameraDraw(): void;
  104813. private _checkRTSize;
  104814. private _bindFrameBuffer;
  104815. /**
  104816. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104817. */
  104818. clear(): void;
  104819. private _setState;
  104820. private _checkTextureType;
  104821. /**
  104822. * Adds an effect configuration to the prepass.
  104823. * If an effect has already been added, it won't add it twice and will return the configuration
  104824. * already present.
  104825. * @param cfg the effect configuration
  104826. * @return the effect configuration now used by the prepass
  104827. */
  104828. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104829. /**
  104830. * Returns the index of a texture in the multi render target texture array.
  104831. * @param type Texture type
  104832. * @return The index
  104833. */
  104834. getIndex(type: number): number;
  104835. private _enable;
  104836. private _disable;
  104837. private _resetLayout;
  104838. private _resetPostProcessChain;
  104839. private _bindPostProcessChain;
  104840. /**
  104841. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104842. */
  104843. markAsDirty(): void;
  104844. /**
  104845. * Enables a texture on the MultiRenderTarget for prepass
  104846. */
  104847. private _enableTextures;
  104848. private _update;
  104849. /**
  104850. * Disposes the prepass renderer.
  104851. */
  104852. dispose(): void;
  104853. }
  104854. }
  104855. declare module BABYLON {
  104856. /**
  104857. * Options for compiling materials.
  104858. */
  104859. export interface IMaterialCompilationOptions {
  104860. /**
  104861. * Defines whether clip planes are enabled.
  104862. */
  104863. clipPlane: boolean;
  104864. /**
  104865. * Defines whether instances are enabled.
  104866. */
  104867. useInstances: boolean;
  104868. }
  104869. /**
  104870. * Options passed when calling customShaderNameResolve
  104871. */
  104872. export interface ICustomShaderNameResolveOptions {
  104873. /**
  104874. * 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
  104875. */
  104876. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104877. }
  104878. /**
  104879. * Base class for the main features of a material in Babylon.js
  104880. */
  104881. export class Material implements IAnimatable {
  104882. /**
  104883. * Returns the triangle fill mode
  104884. */
  104885. static readonly TriangleFillMode: number;
  104886. /**
  104887. * Returns the wireframe mode
  104888. */
  104889. static readonly WireFrameFillMode: number;
  104890. /**
  104891. * Returns the point fill mode
  104892. */
  104893. static readonly PointFillMode: number;
  104894. /**
  104895. * Returns the point list draw mode
  104896. */
  104897. static readonly PointListDrawMode: number;
  104898. /**
  104899. * Returns the line list draw mode
  104900. */
  104901. static readonly LineListDrawMode: number;
  104902. /**
  104903. * Returns the line loop draw mode
  104904. */
  104905. static readonly LineLoopDrawMode: number;
  104906. /**
  104907. * Returns the line strip draw mode
  104908. */
  104909. static readonly LineStripDrawMode: number;
  104910. /**
  104911. * Returns the triangle strip draw mode
  104912. */
  104913. static readonly TriangleStripDrawMode: number;
  104914. /**
  104915. * Returns the triangle fan draw mode
  104916. */
  104917. static readonly TriangleFanDrawMode: number;
  104918. /**
  104919. * Stores the clock-wise side orientation
  104920. */
  104921. static readonly ClockWiseSideOrientation: number;
  104922. /**
  104923. * Stores the counter clock-wise side orientation
  104924. */
  104925. static readonly CounterClockWiseSideOrientation: number;
  104926. /**
  104927. * The dirty texture flag value
  104928. */
  104929. static readonly TextureDirtyFlag: number;
  104930. /**
  104931. * The dirty light flag value
  104932. */
  104933. static readonly LightDirtyFlag: number;
  104934. /**
  104935. * The dirty fresnel flag value
  104936. */
  104937. static readonly FresnelDirtyFlag: number;
  104938. /**
  104939. * The dirty attribute flag value
  104940. */
  104941. static readonly AttributesDirtyFlag: number;
  104942. /**
  104943. * The dirty misc flag value
  104944. */
  104945. static readonly MiscDirtyFlag: number;
  104946. /**
  104947. * The all dirty flag value
  104948. */
  104949. static readonly AllDirtyFlag: number;
  104950. /**
  104951. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104952. */
  104953. static readonly MATERIAL_OPAQUE: number;
  104954. /**
  104955. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104956. */
  104957. static readonly MATERIAL_ALPHATEST: number;
  104958. /**
  104959. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104960. */
  104961. static readonly MATERIAL_ALPHABLEND: number;
  104962. /**
  104963. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104964. * They are also discarded below the alpha cutoff threshold to improve performances.
  104965. */
  104966. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104967. /**
  104968. * The Whiteout method is used to blend normals.
  104969. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104970. */
  104971. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104972. /**
  104973. * The Reoriented Normal Mapping method is used to blend normals.
  104974. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104975. */
  104976. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104977. /**
  104978. * Custom callback helping to override the default shader used in the material.
  104979. */
  104980. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104981. /**
  104982. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104983. */
  104984. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104985. /**
  104986. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104987. * This means that the material can keep using a previous shader while a new one is being compiled.
  104988. * This is mostly used when shader parallel compilation is supported (true by default)
  104989. */
  104990. allowShaderHotSwapping: boolean;
  104991. /**
  104992. * The ID of the material
  104993. */
  104994. id: string;
  104995. /**
  104996. * Gets or sets the unique id of the material
  104997. */
  104998. uniqueId: number;
  104999. /**
  105000. * The name of the material
  105001. */
  105002. name: string;
  105003. /**
  105004. * Gets or sets user defined metadata
  105005. */
  105006. metadata: any;
  105007. /**
  105008. * For internal use only. Please do not use.
  105009. */
  105010. reservedDataStore: any;
  105011. /**
  105012. * Specifies if the ready state should be checked on each call
  105013. */
  105014. checkReadyOnEveryCall: boolean;
  105015. /**
  105016. * Specifies if the ready state should be checked once
  105017. */
  105018. checkReadyOnlyOnce: boolean;
  105019. /**
  105020. * The state of the material
  105021. */
  105022. state: string;
  105023. /**
  105024. * If the material can be rendered to several textures with MRT extension
  105025. */
  105026. get canRenderToMRT(): boolean;
  105027. /**
  105028. * The alpha value of the material
  105029. */
  105030. protected _alpha: number;
  105031. /**
  105032. * List of inspectable custom properties (used by the Inspector)
  105033. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105034. */
  105035. inspectableCustomProperties: IInspectable[];
  105036. /**
  105037. * Sets the alpha value of the material
  105038. */
  105039. set alpha(value: number);
  105040. /**
  105041. * Gets the alpha value of the material
  105042. */
  105043. get alpha(): number;
  105044. /**
  105045. * Specifies if back face culling is enabled
  105046. */
  105047. protected _backFaceCulling: boolean;
  105048. /**
  105049. * Sets the back-face culling state
  105050. */
  105051. set backFaceCulling(value: boolean);
  105052. /**
  105053. * Gets the back-face culling state
  105054. */
  105055. get backFaceCulling(): boolean;
  105056. /**
  105057. * Stores the value for side orientation
  105058. */
  105059. sideOrientation: number;
  105060. /**
  105061. * Callback triggered when the material is compiled
  105062. */
  105063. onCompiled: Nullable<(effect: Effect) => void>;
  105064. /**
  105065. * Callback triggered when an error occurs
  105066. */
  105067. onError: Nullable<(effect: Effect, errors: string) => void>;
  105068. /**
  105069. * Callback triggered to get the render target textures
  105070. */
  105071. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105072. /**
  105073. * Gets a boolean indicating that current material needs to register RTT
  105074. */
  105075. get hasRenderTargetTextures(): boolean;
  105076. /**
  105077. * Specifies if the material should be serialized
  105078. */
  105079. doNotSerialize: boolean;
  105080. /**
  105081. * @hidden
  105082. */
  105083. _storeEffectOnSubMeshes: boolean;
  105084. /**
  105085. * Stores the animations for the material
  105086. */
  105087. animations: Nullable<Array<Animation>>;
  105088. /**
  105089. * An event triggered when the material is disposed
  105090. */
  105091. onDisposeObservable: Observable<Material>;
  105092. /**
  105093. * An observer which watches for dispose events
  105094. */
  105095. private _onDisposeObserver;
  105096. private _onUnBindObservable;
  105097. /**
  105098. * Called during a dispose event
  105099. */
  105100. set onDispose(callback: () => void);
  105101. private _onBindObservable;
  105102. /**
  105103. * An event triggered when the material is bound
  105104. */
  105105. get onBindObservable(): Observable<AbstractMesh>;
  105106. /**
  105107. * An observer which watches for bind events
  105108. */
  105109. private _onBindObserver;
  105110. /**
  105111. * Called during a bind event
  105112. */
  105113. set onBind(callback: (Mesh: AbstractMesh) => void);
  105114. /**
  105115. * An event triggered when the material is unbound
  105116. */
  105117. get onUnBindObservable(): Observable<Material>;
  105118. protected _onEffectCreatedObservable: Nullable<Observable<{
  105119. effect: Effect;
  105120. subMesh: Nullable<SubMesh>;
  105121. }>>;
  105122. /**
  105123. * An event triggered when the effect is (re)created
  105124. */
  105125. get onEffectCreatedObservable(): Observable<{
  105126. effect: Effect;
  105127. subMesh: Nullable<SubMesh>;
  105128. }>;
  105129. /**
  105130. * Stores the value of the alpha mode
  105131. */
  105132. private _alphaMode;
  105133. /**
  105134. * Sets the value of the alpha mode.
  105135. *
  105136. * | Value | Type | Description |
  105137. * | --- | --- | --- |
  105138. * | 0 | ALPHA_DISABLE | |
  105139. * | 1 | ALPHA_ADD | |
  105140. * | 2 | ALPHA_COMBINE | |
  105141. * | 3 | ALPHA_SUBTRACT | |
  105142. * | 4 | ALPHA_MULTIPLY | |
  105143. * | 5 | ALPHA_MAXIMIZED | |
  105144. * | 6 | ALPHA_ONEONE | |
  105145. * | 7 | ALPHA_PREMULTIPLIED | |
  105146. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105147. * | 9 | ALPHA_INTERPOLATE | |
  105148. * | 10 | ALPHA_SCREENMODE | |
  105149. *
  105150. */
  105151. set alphaMode(value: number);
  105152. /**
  105153. * Gets the value of the alpha mode
  105154. */
  105155. get alphaMode(): number;
  105156. /**
  105157. * Stores the state of the need depth pre-pass value
  105158. */
  105159. private _needDepthPrePass;
  105160. /**
  105161. * Sets the need depth pre-pass value
  105162. */
  105163. set needDepthPrePass(value: boolean);
  105164. /**
  105165. * Gets the depth pre-pass value
  105166. */
  105167. get needDepthPrePass(): boolean;
  105168. /**
  105169. * Specifies if depth writing should be disabled
  105170. */
  105171. disableDepthWrite: boolean;
  105172. /**
  105173. * Specifies if color writing should be disabled
  105174. */
  105175. disableColorWrite: boolean;
  105176. /**
  105177. * Specifies if depth writing should be forced
  105178. */
  105179. forceDepthWrite: boolean;
  105180. /**
  105181. * Specifies the depth function that should be used. 0 means the default engine function
  105182. */
  105183. depthFunction: number;
  105184. /**
  105185. * Specifies if there should be a separate pass for culling
  105186. */
  105187. separateCullingPass: boolean;
  105188. /**
  105189. * Stores the state specifing if fog should be enabled
  105190. */
  105191. private _fogEnabled;
  105192. /**
  105193. * Sets the state for enabling fog
  105194. */
  105195. set fogEnabled(value: boolean);
  105196. /**
  105197. * Gets the value of the fog enabled state
  105198. */
  105199. get fogEnabled(): boolean;
  105200. /**
  105201. * Stores the size of points
  105202. */
  105203. pointSize: number;
  105204. /**
  105205. * Stores the z offset value
  105206. */
  105207. zOffset: number;
  105208. get wireframe(): boolean;
  105209. /**
  105210. * Sets the state of wireframe mode
  105211. */
  105212. set wireframe(value: boolean);
  105213. /**
  105214. * Gets the value specifying if point clouds are enabled
  105215. */
  105216. get pointsCloud(): boolean;
  105217. /**
  105218. * Sets the state of point cloud mode
  105219. */
  105220. set pointsCloud(value: boolean);
  105221. /**
  105222. * Gets the material fill mode
  105223. */
  105224. get fillMode(): number;
  105225. /**
  105226. * Sets the material fill mode
  105227. */
  105228. set fillMode(value: number);
  105229. /**
  105230. * @hidden
  105231. * Stores the effects for the material
  105232. */
  105233. _effect: Nullable<Effect>;
  105234. /**
  105235. * Specifies if uniform buffers should be used
  105236. */
  105237. private _useUBO;
  105238. /**
  105239. * Stores a reference to the scene
  105240. */
  105241. private _scene;
  105242. /**
  105243. * Stores the fill mode state
  105244. */
  105245. private _fillMode;
  105246. /**
  105247. * Specifies if the depth write state should be cached
  105248. */
  105249. private _cachedDepthWriteState;
  105250. /**
  105251. * Specifies if the color write state should be cached
  105252. */
  105253. private _cachedColorWriteState;
  105254. /**
  105255. * Specifies if the depth function state should be cached
  105256. */
  105257. private _cachedDepthFunctionState;
  105258. /**
  105259. * Stores the uniform buffer
  105260. */
  105261. protected _uniformBuffer: UniformBuffer;
  105262. /** @hidden */
  105263. _indexInSceneMaterialArray: number;
  105264. /** @hidden */
  105265. meshMap: Nullable<{
  105266. [id: string]: AbstractMesh | undefined;
  105267. }>;
  105268. /**
  105269. * Creates a material instance
  105270. * @param name defines the name of the material
  105271. * @param scene defines the scene to reference
  105272. * @param doNotAdd specifies if the material should be added to the scene
  105273. */
  105274. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105275. /**
  105276. * Returns a string representation of the current material
  105277. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105278. * @returns a string with material information
  105279. */
  105280. toString(fullDetails?: boolean): string;
  105281. /**
  105282. * Gets the class name of the material
  105283. * @returns a string with the class name of the material
  105284. */
  105285. getClassName(): string;
  105286. /**
  105287. * Specifies if updates for the material been locked
  105288. */
  105289. get isFrozen(): boolean;
  105290. /**
  105291. * Locks updates for the material
  105292. */
  105293. freeze(): void;
  105294. /**
  105295. * Unlocks updates for the material
  105296. */
  105297. unfreeze(): void;
  105298. /**
  105299. * Specifies if the material is ready to be used
  105300. * @param mesh defines the mesh to check
  105301. * @param useInstances specifies if instances should be used
  105302. * @returns a boolean indicating if the material is ready to be used
  105303. */
  105304. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105305. /**
  105306. * Specifies that the submesh is ready to be used
  105307. * @param mesh defines the mesh to check
  105308. * @param subMesh defines which submesh to check
  105309. * @param useInstances specifies that instances should be used
  105310. * @returns a boolean indicating that the submesh is ready or not
  105311. */
  105312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105313. /**
  105314. * Returns the material effect
  105315. * @returns the effect associated with the material
  105316. */
  105317. getEffect(): Nullable<Effect>;
  105318. /**
  105319. * Returns the current scene
  105320. * @returns a Scene
  105321. */
  105322. getScene(): Scene;
  105323. /**
  105324. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105325. */
  105326. protected _forceAlphaTest: boolean;
  105327. /**
  105328. * The transparency mode of the material.
  105329. */
  105330. protected _transparencyMode: Nullable<number>;
  105331. /**
  105332. * Gets the current transparency mode.
  105333. */
  105334. get transparencyMode(): Nullable<number>;
  105335. /**
  105336. * Sets the transparency mode of the material.
  105337. *
  105338. * | Value | Type | Description |
  105339. * | ----- | ----------------------------------- | ----------- |
  105340. * | 0 | OPAQUE | |
  105341. * | 1 | ALPHATEST | |
  105342. * | 2 | ALPHABLEND | |
  105343. * | 3 | ALPHATESTANDBLEND | |
  105344. *
  105345. */
  105346. set transparencyMode(value: Nullable<number>);
  105347. /**
  105348. * Returns true if alpha blending should be disabled.
  105349. */
  105350. protected get _disableAlphaBlending(): boolean;
  105351. /**
  105352. * Specifies whether or not this material should be rendered in alpha blend mode.
  105353. * @returns a boolean specifying if alpha blending is needed
  105354. */
  105355. needAlphaBlending(): boolean;
  105356. /**
  105357. * Specifies if the mesh will require alpha blending
  105358. * @param mesh defines the mesh to check
  105359. * @returns a boolean specifying if alpha blending is needed for the mesh
  105360. */
  105361. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105362. /**
  105363. * Specifies whether or not this material should be rendered in alpha test mode.
  105364. * @returns a boolean specifying if an alpha test is needed.
  105365. */
  105366. needAlphaTesting(): boolean;
  105367. /**
  105368. * Specifies if material alpha testing should be turned on for the mesh
  105369. * @param mesh defines the mesh to check
  105370. */
  105371. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105372. /**
  105373. * Gets the texture used for the alpha test
  105374. * @returns the texture to use for alpha testing
  105375. */
  105376. getAlphaTestTexture(): Nullable<BaseTexture>;
  105377. /**
  105378. * Marks the material to indicate that it needs to be re-calculated
  105379. */
  105380. markDirty(): void;
  105381. /** @hidden */
  105382. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105383. /**
  105384. * Binds the material to the mesh
  105385. * @param world defines the world transformation matrix
  105386. * @param mesh defines the mesh to bind the material to
  105387. */
  105388. bind(world: Matrix, mesh?: Mesh): void;
  105389. /**
  105390. * Binds the submesh to the material
  105391. * @param world defines the world transformation matrix
  105392. * @param mesh defines the mesh containing the submesh
  105393. * @param subMesh defines the submesh to bind the material to
  105394. */
  105395. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105396. /**
  105397. * Binds the world matrix to the material
  105398. * @param world defines the world transformation matrix
  105399. */
  105400. bindOnlyWorldMatrix(world: Matrix): void;
  105401. /**
  105402. * Binds the scene's uniform buffer to the effect.
  105403. * @param effect defines the effect to bind to the scene uniform buffer
  105404. * @param sceneUbo defines the uniform buffer storing scene data
  105405. */
  105406. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105407. /**
  105408. * Binds the view matrix to the effect
  105409. * @param effect defines the effect to bind the view matrix to
  105410. */
  105411. bindView(effect: Effect): void;
  105412. /**
  105413. * Binds the view projection matrix to the effect
  105414. * @param effect defines the effect to bind the view projection matrix to
  105415. */
  105416. bindViewProjection(effect: Effect): void;
  105417. /**
  105418. * Processes to execute after binding the material to a mesh
  105419. * @param mesh defines the rendered mesh
  105420. */
  105421. protected _afterBind(mesh?: Mesh): void;
  105422. /**
  105423. * Unbinds the material from the mesh
  105424. */
  105425. unbind(): void;
  105426. /**
  105427. * Gets the active textures from the material
  105428. * @returns an array of textures
  105429. */
  105430. getActiveTextures(): BaseTexture[];
  105431. /**
  105432. * Specifies if the material uses a texture
  105433. * @param texture defines the texture to check against the material
  105434. * @returns a boolean specifying if the material uses the texture
  105435. */
  105436. hasTexture(texture: BaseTexture): boolean;
  105437. /**
  105438. * Makes a duplicate of the material, and gives it a new name
  105439. * @param name defines the new name for the duplicated material
  105440. * @returns the cloned material
  105441. */
  105442. clone(name: string): Nullable<Material>;
  105443. /**
  105444. * Gets the meshes bound to the material
  105445. * @returns an array of meshes bound to the material
  105446. */
  105447. getBindedMeshes(): AbstractMesh[];
  105448. /**
  105449. * Force shader compilation
  105450. * @param mesh defines the mesh associated with this material
  105451. * @param onCompiled defines a function to execute once the material is compiled
  105452. * @param options defines the options to configure the compilation
  105453. * @param onError defines a function to execute if the material fails compiling
  105454. */
  105455. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105456. /**
  105457. * Force shader compilation
  105458. * @param mesh defines the mesh that will use this material
  105459. * @param options defines additional options for compiling the shaders
  105460. * @returns a promise that resolves when the compilation completes
  105461. */
  105462. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105463. private static readonly _AllDirtyCallBack;
  105464. private static readonly _ImageProcessingDirtyCallBack;
  105465. private static readonly _TextureDirtyCallBack;
  105466. private static readonly _FresnelDirtyCallBack;
  105467. private static readonly _MiscDirtyCallBack;
  105468. private static readonly _LightsDirtyCallBack;
  105469. private static readonly _AttributeDirtyCallBack;
  105470. private static _FresnelAndMiscDirtyCallBack;
  105471. private static _TextureAndMiscDirtyCallBack;
  105472. private static readonly _DirtyCallbackArray;
  105473. private static readonly _RunDirtyCallBacks;
  105474. /**
  105475. * Marks a define in the material to indicate that it needs to be re-computed
  105476. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105477. */
  105478. markAsDirty(flag: number): void;
  105479. /**
  105480. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105481. * @param func defines a function which checks material defines against the submeshes
  105482. */
  105483. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105484. /**
  105485. * Indicates that the scene should check if the rendering now needs a prepass
  105486. */
  105487. protected _markScenePrePassDirty(): void;
  105488. /**
  105489. * Indicates that we need to re-calculated for all submeshes
  105490. */
  105491. protected _markAllSubMeshesAsAllDirty(): void;
  105492. /**
  105493. * Indicates that image processing needs to be re-calculated for all submeshes
  105494. */
  105495. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105496. /**
  105497. * Indicates that textures need to be re-calculated for all submeshes
  105498. */
  105499. protected _markAllSubMeshesAsTexturesDirty(): void;
  105500. /**
  105501. * Indicates that fresnel needs to be re-calculated for all submeshes
  105502. */
  105503. protected _markAllSubMeshesAsFresnelDirty(): void;
  105504. /**
  105505. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105506. */
  105507. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105508. /**
  105509. * Indicates that lights need to be re-calculated for all submeshes
  105510. */
  105511. protected _markAllSubMeshesAsLightsDirty(): void;
  105512. /**
  105513. * Indicates that attributes need to be re-calculated for all submeshes
  105514. */
  105515. protected _markAllSubMeshesAsAttributesDirty(): void;
  105516. /**
  105517. * Indicates that misc needs to be re-calculated for all submeshes
  105518. */
  105519. protected _markAllSubMeshesAsMiscDirty(): void;
  105520. /**
  105521. * Indicates that textures and misc need to be re-calculated for all submeshes
  105522. */
  105523. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105524. /**
  105525. * Sets the required values to the prepass renderer.
  105526. * @param prePassRenderer defines the prepass renderer to setup.
  105527. * @returns true if the pre pass is needed.
  105528. */
  105529. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105530. /**
  105531. * Disposes the material
  105532. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105533. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105534. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105535. */
  105536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105537. /** @hidden */
  105538. private releaseVertexArrayObject;
  105539. /**
  105540. * Serializes this material
  105541. * @returns the serialized material object
  105542. */
  105543. serialize(): any;
  105544. /**
  105545. * Creates a material from parsed material data
  105546. * @param parsedMaterial defines parsed material data
  105547. * @param scene defines the hosting scene
  105548. * @param rootUrl defines the root URL to use to load textures
  105549. * @returns a new material
  105550. */
  105551. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105552. }
  105553. }
  105554. declare module BABYLON {
  105555. /**
  105556. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105557. * separate meshes. This can be use to improve performances.
  105558. * @see https://doc.babylonjs.com/how_to/multi_materials
  105559. */
  105560. export class MultiMaterial extends Material {
  105561. private _subMaterials;
  105562. /**
  105563. * Gets or Sets the list of Materials used within the multi material.
  105564. * They need to be ordered according to the submeshes order in the associated mesh
  105565. */
  105566. get subMaterials(): Nullable<Material>[];
  105567. set subMaterials(value: Nullable<Material>[]);
  105568. /**
  105569. * Function used to align with Node.getChildren()
  105570. * @returns the list of Materials used within the multi material
  105571. */
  105572. getChildren(): Nullable<Material>[];
  105573. /**
  105574. * Instantiates a new Multi Material
  105575. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105576. * separate meshes. This can be use to improve performances.
  105577. * @see https://doc.babylonjs.com/how_to/multi_materials
  105578. * @param name Define the name in the scene
  105579. * @param scene Define the scene the material belongs to
  105580. */
  105581. constructor(name: string, scene: Scene);
  105582. private _hookArray;
  105583. /**
  105584. * Get one of the submaterial by its index in the submaterials array
  105585. * @param index The index to look the sub material at
  105586. * @returns The Material if the index has been defined
  105587. */
  105588. getSubMaterial(index: number): Nullable<Material>;
  105589. /**
  105590. * Get the list of active textures for the whole sub materials list.
  105591. * @returns All the textures that will be used during the rendering
  105592. */
  105593. getActiveTextures(): BaseTexture[];
  105594. /**
  105595. * Gets the current class name of the material e.g. "MultiMaterial"
  105596. * Mainly use in serialization.
  105597. * @returns the class name
  105598. */
  105599. getClassName(): string;
  105600. /**
  105601. * Checks if the material is ready to render the requested sub mesh
  105602. * @param mesh Define the mesh the submesh belongs to
  105603. * @param subMesh Define the sub mesh to look readyness for
  105604. * @param useInstances Define whether or not the material is used with instances
  105605. * @returns true if ready, otherwise false
  105606. */
  105607. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105608. /**
  105609. * Clones the current material and its related sub materials
  105610. * @param name Define the name of the newly cloned material
  105611. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105612. * @returns the cloned material
  105613. */
  105614. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105615. /**
  105616. * Serializes the materials into a JSON representation.
  105617. * @returns the JSON representation
  105618. */
  105619. serialize(): any;
  105620. /**
  105621. * Dispose the material and release its associated resources
  105622. * @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)
  105623. * @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)
  105624. * @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)
  105625. */
  105626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105627. /**
  105628. * Creates a MultiMaterial from parsed MultiMaterial data.
  105629. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105630. * @param scene defines the hosting scene
  105631. * @returns a new MultiMaterial
  105632. */
  105633. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105634. }
  105635. }
  105636. declare module BABYLON {
  105637. /**
  105638. * Defines a subdivision inside a mesh
  105639. */
  105640. export class SubMesh implements ICullable {
  105641. /** the material index to use */
  105642. materialIndex: number;
  105643. /** vertex index start */
  105644. verticesStart: number;
  105645. /** vertices count */
  105646. verticesCount: number;
  105647. /** index start */
  105648. indexStart: number;
  105649. /** indices count */
  105650. indexCount: number;
  105651. /** @hidden */
  105652. _materialDefines: Nullable<MaterialDefines>;
  105653. /** @hidden */
  105654. _materialEffect: Nullable<Effect>;
  105655. /** @hidden */
  105656. _effectOverride: Nullable<Effect>;
  105657. /**
  105658. * Gets material defines used by the effect associated to the sub mesh
  105659. */
  105660. get materialDefines(): Nullable<MaterialDefines>;
  105661. /**
  105662. * Sets material defines used by the effect associated to the sub mesh
  105663. */
  105664. set materialDefines(defines: Nullable<MaterialDefines>);
  105665. /**
  105666. * Gets associated effect
  105667. */
  105668. get effect(): Nullable<Effect>;
  105669. /**
  105670. * Sets associated effect (effect used to render this submesh)
  105671. * @param effect defines the effect to associate with
  105672. * @param defines defines the set of defines used to compile this effect
  105673. */
  105674. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105675. /** @hidden */
  105676. _linesIndexCount: number;
  105677. private _mesh;
  105678. private _renderingMesh;
  105679. private _boundingInfo;
  105680. private _linesIndexBuffer;
  105681. /** @hidden */
  105682. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105683. /** @hidden */
  105684. _trianglePlanes: Plane[];
  105685. /** @hidden */
  105686. _lastColliderTransformMatrix: Nullable<Matrix>;
  105687. /** @hidden */
  105688. _renderId: number;
  105689. /** @hidden */
  105690. _alphaIndex: number;
  105691. /** @hidden */
  105692. _distanceToCamera: number;
  105693. /** @hidden */
  105694. _id: number;
  105695. private _currentMaterial;
  105696. /**
  105697. * Add a new submesh to a mesh
  105698. * @param materialIndex defines the material index to use
  105699. * @param verticesStart defines vertex index start
  105700. * @param verticesCount defines vertices count
  105701. * @param indexStart defines index start
  105702. * @param indexCount defines indices count
  105703. * @param mesh defines the parent mesh
  105704. * @param renderingMesh defines an optional rendering mesh
  105705. * @param createBoundingBox defines if bounding box should be created for this submesh
  105706. * @returns the new submesh
  105707. */
  105708. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105709. /**
  105710. * Creates a new submesh
  105711. * @param materialIndex defines the material index to use
  105712. * @param verticesStart defines vertex index start
  105713. * @param verticesCount defines vertices count
  105714. * @param indexStart defines index start
  105715. * @param indexCount defines indices count
  105716. * @param mesh defines the parent mesh
  105717. * @param renderingMesh defines an optional rendering mesh
  105718. * @param createBoundingBox defines if bounding box should be created for this submesh
  105719. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105720. */
  105721. constructor(
  105722. /** the material index to use */
  105723. materialIndex: number,
  105724. /** vertex index start */
  105725. verticesStart: number,
  105726. /** vertices count */
  105727. verticesCount: number,
  105728. /** index start */
  105729. indexStart: number,
  105730. /** indices count */
  105731. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105732. /**
  105733. * Returns true if this submesh covers the entire parent mesh
  105734. * @ignorenaming
  105735. */
  105736. get IsGlobal(): boolean;
  105737. /**
  105738. * Returns the submesh BoudingInfo object
  105739. * @returns current bounding info (or mesh's one if the submesh is global)
  105740. */
  105741. getBoundingInfo(): BoundingInfo;
  105742. /**
  105743. * Sets the submesh BoundingInfo
  105744. * @param boundingInfo defines the new bounding info to use
  105745. * @returns the SubMesh
  105746. */
  105747. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105748. /**
  105749. * Returns the mesh of the current submesh
  105750. * @return the parent mesh
  105751. */
  105752. getMesh(): AbstractMesh;
  105753. /**
  105754. * Returns the rendering mesh of the submesh
  105755. * @returns the rendering mesh (could be different from parent mesh)
  105756. */
  105757. getRenderingMesh(): Mesh;
  105758. /**
  105759. * Returns the replacement mesh of the submesh
  105760. * @returns the replacement mesh (could be different from parent mesh)
  105761. */
  105762. getReplacementMesh(): Nullable<AbstractMesh>;
  105763. /**
  105764. * Returns the effective mesh of the submesh
  105765. * @returns the effective mesh (could be different from parent mesh)
  105766. */
  105767. getEffectiveMesh(): AbstractMesh;
  105768. /**
  105769. * Returns the submesh material
  105770. * @returns null or the current material
  105771. */
  105772. getMaterial(): Nullable<Material>;
  105773. private _IsMultiMaterial;
  105774. /**
  105775. * Sets a new updated BoundingInfo object to the submesh
  105776. * @param data defines an optional position array to use to determine the bounding info
  105777. * @returns the SubMesh
  105778. */
  105779. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105780. /** @hidden */
  105781. _checkCollision(collider: Collider): boolean;
  105782. /**
  105783. * Updates the submesh BoundingInfo
  105784. * @param world defines the world matrix to use to update the bounding info
  105785. * @returns the submesh
  105786. */
  105787. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105788. /**
  105789. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105790. * @param frustumPlanes defines the frustum planes
  105791. * @returns true if the submesh is intersecting with the frustum
  105792. */
  105793. isInFrustum(frustumPlanes: Plane[]): boolean;
  105794. /**
  105795. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105796. * @param frustumPlanes defines the frustum planes
  105797. * @returns true if the submesh is inside the frustum
  105798. */
  105799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105800. /**
  105801. * Renders the submesh
  105802. * @param enableAlphaMode defines if alpha needs to be used
  105803. * @returns the submesh
  105804. */
  105805. render(enableAlphaMode: boolean): SubMesh;
  105806. /**
  105807. * @hidden
  105808. */
  105809. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105810. /**
  105811. * Checks if the submesh intersects with a ray
  105812. * @param ray defines the ray to test
  105813. * @returns true is the passed ray intersects the submesh bounding box
  105814. */
  105815. canIntersects(ray: Ray): boolean;
  105816. /**
  105817. * Intersects current submesh with a ray
  105818. * @param ray defines the ray to test
  105819. * @param positions defines mesh's positions array
  105820. * @param indices defines mesh's indices array
  105821. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105823. * @returns intersection info or null if no intersection
  105824. */
  105825. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105826. /** @hidden */
  105827. private _intersectLines;
  105828. /** @hidden */
  105829. private _intersectUnIndexedLines;
  105830. /** @hidden */
  105831. private _intersectTriangles;
  105832. /** @hidden */
  105833. private _intersectUnIndexedTriangles;
  105834. /** @hidden */
  105835. _rebuild(): void;
  105836. /**
  105837. * Creates a new submesh from the passed mesh
  105838. * @param newMesh defines the new hosting mesh
  105839. * @param newRenderingMesh defines an optional rendering mesh
  105840. * @returns the new submesh
  105841. */
  105842. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105843. /**
  105844. * Release associated resources
  105845. */
  105846. dispose(): void;
  105847. /**
  105848. * Gets the class name
  105849. * @returns the string "SubMesh".
  105850. */
  105851. getClassName(): string;
  105852. /**
  105853. * Creates a new submesh from indices data
  105854. * @param materialIndex the index of the main mesh material
  105855. * @param startIndex the index where to start the copy in the mesh indices array
  105856. * @param indexCount the number of indices to copy then from the startIndex
  105857. * @param mesh the main mesh to create the submesh from
  105858. * @param renderingMesh the optional rendering mesh
  105859. * @returns a new submesh
  105860. */
  105861. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105862. }
  105863. }
  105864. declare module BABYLON {
  105865. /**
  105866. * Class used to represent data loading progression
  105867. */
  105868. export class SceneLoaderFlags {
  105869. private static _ForceFullSceneLoadingForIncremental;
  105870. private static _ShowLoadingScreen;
  105871. private static _CleanBoneMatrixWeights;
  105872. private static _loggingLevel;
  105873. /**
  105874. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105875. */
  105876. static get ForceFullSceneLoadingForIncremental(): boolean;
  105877. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105878. /**
  105879. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105880. */
  105881. static get ShowLoadingScreen(): boolean;
  105882. static set ShowLoadingScreen(value: boolean);
  105883. /**
  105884. * Defines the current logging level (while loading the scene)
  105885. * @ignorenaming
  105886. */
  105887. static get loggingLevel(): number;
  105888. static set loggingLevel(value: number);
  105889. /**
  105890. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105891. */
  105892. static get CleanBoneMatrixWeights(): boolean;
  105893. static set CleanBoneMatrixWeights(value: boolean);
  105894. }
  105895. }
  105896. declare module BABYLON {
  105897. /**
  105898. * Class used to store geometry data (vertex buffers + index buffer)
  105899. */
  105900. export class Geometry implements IGetSetVerticesData {
  105901. /**
  105902. * Gets or sets the ID of the geometry
  105903. */
  105904. id: string;
  105905. /**
  105906. * Gets or sets the unique ID of the geometry
  105907. */
  105908. uniqueId: number;
  105909. /**
  105910. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105911. */
  105912. delayLoadState: number;
  105913. /**
  105914. * Gets the file containing the data to load when running in delay load state
  105915. */
  105916. delayLoadingFile: Nullable<string>;
  105917. /**
  105918. * Callback called when the geometry is updated
  105919. */
  105920. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105921. private _scene;
  105922. private _engine;
  105923. private _meshes;
  105924. private _totalVertices;
  105925. /** @hidden */
  105926. _indices: IndicesArray;
  105927. /** @hidden */
  105928. _vertexBuffers: {
  105929. [key: string]: VertexBuffer;
  105930. };
  105931. private _isDisposed;
  105932. private _extend;
  105933. private _boundingBias;
  105934. /** @hidden */
  105935. _delayInfo: Array<string>;
  105936. private _indexBuffer;
  105937. private _indexBufferIsUpdatable;
  105938. /** @hidden */
  105939. _boundingInfo: Nullable<BoundingInfo>;
  105940. /** @hidden */
  105941. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105942. /** @hidden */
  105943. _softwareSkinningFrameId: number;
  105944. private _vertexArrayObjects;
  105945. private _updatable;
  105946. /** @hidden */
  105947. _positions: Nullable<Vector3[]>;
  105948. /**
  105949. * 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
  105950. */
  105951. get boundingBias(): Vector2;
  105952. /**
  105953. * 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
  105954. */
  105955. set boundingBias(value: Vector2);
  105956. /**
  105957. * Static function used to attach a new empty geometry to a mesh
  105958. * @param mesh defines the mesh to attach the geometry to
  105959. * @returns the new Geometry
  105960. */
  105961. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105962. /** Get the list of meshes using this geometry */
  105963. get meshes(): Mesh[];
  105964. /**
  105965. * 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
  105966. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105967. */
  105968. useBoundingInfoFromGeometry: boolean;
  105969. /**
  105970. * Creates a new geometry
  105971. * @param id defines the unique ID
  105972. * @param scene defines the hosting scene
  105973. * @param vertexData defines the VertexData used to get geometry data
  105974. * @param updatable defines if geometry must be updatable (false by default)
  105975. * @param mesh defines the mesh that will be associated with the geometry
  105976. */
  105977. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105978. /**
  105979. * Gets the current extend of the geometry
  105980. */
  105981. get extend(): {
  105982. minimum: Vector3;
  105983. maximum: Vector3;
  105984. };
  105985. /**
  105986. * Gets the hosting scene
  105987. * @returns the hosting Scene
  105988. */
  105989. getScene(): Scene;
  105990. /**
  105991. * Gets the hosting engine
  105992. * @returns the hosting Engine
  105993. */
  105994. getEngine(): Engine;
  105995. /**
  105996. * Defines if the geometry is ready to use
  105997. * @returns true if the geometry is ready to be used
  105998. */
  105999. isReady(): boolean;
  106000. /**
  106001. * Gets a value indicating that the geometry should not be serialized
  106002. */
  106003. get doNotSerialize(): boolean;
  106004. /** @hidden */
  106005. _rebuild(): void;
  106006. /**
  106007. * Affects all geometry data in one call
  106008. * @param vertexData defines the geometry data
  106009. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106010. */
  106011. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106012. /**
  106013. * Set specific vertex data
  106014. * @param kind defines the data kind (Position, normal, etc...)
  106015. * @param data defines the vertex data to use
  106016. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106017. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106018. */
  106019. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106020. /**
  106021. * Removes a specific vertex data
  106022. * @param kind defines the data kind (Position, normal, etc...)
  106023. */
  106024. removeVerticesData(kind: string): void;
  106025. /**
  106026. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106027. * @param buffer defines the vertex buffer to use
  106028. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106029. */
  106030. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106031. /**
  106032. * Update a specific vertex buffer
  106033. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106034. * It will do nothing if the buffer is not updatable
  106035. * @param kind defines the data kind (Position, normal, etc...)
  106036. * @param data defines the data to use
  106037. * @param offset defines the offset in the target buffer where to store the data
  106038. * @param useBytes set to true if the offset is in bytes
  106039. */
  106040. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106041. /**
  106042. * Update a specific vertex buffer
  106043. * This function will create a new buffer if the current one is not updatable
  106044. * @param kind defines the data kind (Position, normal, etc...)
  106045. * @param data defines the data to use
  106046. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106047. */
  106048. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106049. private _updateBoundingInfo;
  106050. /** @hidden */
  106051. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106052. /**
  106053. * Gets total number of vertices
  106054. * @returns the total number of vertices
  106055. */
  106056. getTotalVertices(): number;
  106057. /**
  106058. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106059. * @param kind defines the data kind (Position, normal, etc...)
  106060. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106062. * @returns a float array containing vertex data
  106063. */
  106064. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106065. /**
  106066. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106067. * @param kind defines the data kind (Position, normal, etc...)
  106068. * @returns true if the vertex buffer with the specified kind is updatable
  106069. */
  106070. isVertexBufferUpdatable(kind: string): boolean;
  106071. /**
  106072. * Gets a specific vertex buffer
  106073. * @param kind defines the data kind (Position, normal, etc...)
  106074. * @returns a VertexBuffer
  106075. */
  106076. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106077. /**
  106078. * Returns all vertex buffers
  106079. * @return an object holding all vertex buffers indexed by kind
  106080. */
  106081. getVertexBuffers(): Nullable<{
  106082. [key: string]: VertexBuffer;
  106083. }>;
  106084. /**
  106085. * Gets a boolean indicating if specific vertex buffer is present
  106086. * @param kind defines the data kind (Position, normal, etc...)
  106087. * @returns true if data is present
  106088. */
  106089. isVerticesDataPresent(kind: string): boolean;
  106090. /**
  106091. * Gets a list of all attached data kinds (Position, normal, etc...)
  106092. * @returns a list of string containing all kinds
  106093. */
  106094. getVerticesDataKinds(): string[];
  106095. /**
  106096. * Update index buffer
  106097. * @param indices defines the indices to store in the index buffer
  106098. * @param offset defines the offset in the target buffer where to store the data
  106099. * @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)
  106100. */
  106101. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106102. /**
  106103. * Creates a new index buffer
  106104. * @param indices defines the indices to store in the index buffer
  106105. * @param totalVertices defines the total number of vertices (could be null)
  106106. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106107. */
  106108. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106109. /**
  106110. * Return the total number of indices
  106111. * @returns the total number of indices
  106112. */
  106113. getTotalIndices(): number;
  106114. /**
  106115. * Gets the index buffer array
  106116. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106117. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106118. * @returns the index buffer array
  106119. */
  106120. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106121. /**
  106122. * Gets the index buffer
  106123. * @return the index buffer
  106124. */
  106125. getIndexBuffer(): Nullable<DataBuffer>;
  106126. /** @hidden */
  106127. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106128. /**
  106129. * Release the associated resources for a specific mesh
  106130. * @param mesh defines the source mesh
  106131. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106132. */
  106133. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106134. /**
  106135. * Apply current geometry to a given mesh
  106136. * @param mesh defines the mesh to apply geometry to
  106137. */
  106138. applyToMesh(mesh: Mesh): void;
  106139. private _updateExtend;
  106140. private _applyToMesh;
  106141. private notifyUpdate;
  106142. /**
  106143. * Load the geometry if it was flagged as delay loaded
  106144. * @param scene defines the hosting scene
  106145. * @param onLoaded defines a callback called when the geometry is loaded
  106146. */
  106147. load(scene: Scene, onLoaded?: () => void): void;
  106148. private _queueLoad;
  106149. /**
  106150. * Invert the geometry to move from a right handed system to a left handed one.
  106151. */
  106152. toLeftHanded(): void;
  106153. /** @hidden */
  106154. _resetPointsArrayCache(): void;
  106155. /** @hidden */
  106156. _generatePointsArray(): boolean;
  106157. /**
  106158. * Gets a value indicating if the geometry is disposed
  106159. * @returns true if the geometry was disposed
  106160. */
  106161. isDisposed(): boolean;
  106162. private _disposeVertexArrayObjects;
  106163. /**
  106164. * Free all associated resources
  106165. */
  106166. dispose(): void;
  106167. /**
  106168. * Clone the current geometry into a new geometry
  106169. * @param id defines the unique ID of the new geometry
  106170. * @returns a new geometry object
  106171. */
  106172. copy(id: string): Geometry;
  106173. /**
  106174. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106175. * @return a JSON representation of the current geometry data (without the vertices data)
  106176. */
  106177. serialize(): any;
  106178. private toNumberArray;
  106179. /**
  106180. * Serialize all vertices data into a JSON oject
  106181. * @returns a JSON representation of the current geometry data
  106182. */
  106183. serializeVerticeData(): any;
  106184. /**
  106185. * Extracts a clone of a mesh geometry
  106186. * @param mesh defines the source mesh
  106187. * @param id defines the unique ID of the new geometry object
  106188. * @returns the new geometry object
  106189. */
  106190. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106191. /**
  106192. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106193. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106194. * Be aware Math.random() could cause collisions, but:
  106195. * "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"
  106196. * @returns a string containing a new GUID
  106197. */
  106198. static RandomId(): string;
  106199. /** @hidden */
  106200. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106201. private static _CleanMatricesWeights;
  106202. /**
  106203. * Create a new geometry from persisted data (Using .babylon file format)
  106204. * @param parsedVertexData defines the persisted data
  106205. * @param scene defines the hosting scene
  106206. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106207. * @returns the new geometry object
  106208. */
  106209. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106210. }
  106211. }
  106212. declare module BABYLON {
  106213. /**
  106214. * Define an interface for all classes that will get and set the data on vertices
  106215. */
  106216. export interface IGetSetVerticesData {
  106217. /**
  106218. * Gets a boolean indicating if specific vertex data is present
  106219. * @param kind defines the vertex data kind to use
  106220. * @returns true is data kind is present
  106221. */
  106222. isVerticesDataPresent(kind: string): boolean;
  106223. /**
  106224. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106225. * @param kind defines the data kind (Position, normal, etc...)
  106226. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106227. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106228. * @returns a float array containing vertex data
  106229. */
  106230. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106231. /**
  106232. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106233. * @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.
  106234. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106235. * @returns the indices array or an empty array if the mesh has no geometry
  106236. */
  106237. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106238. /**
  106239. * Set specific vertex data
  106240. * @param kind defines the data kind (Position, normal, etc...)
  106241. * @param data defines the vertex data to use
  106242. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106243. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106244. */
  106245. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106246. /**
  106247. * Update a specific associated vertex buffer
  106248. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106249. * - VertexBuffer.PositionKind
  106250. * - VertexBuffer.UVKind
  106251. * - VertexBuffer.UV2Kind
  106252. * - VertexBuffer.UV3Kind
  106253. * - VertexBuffer.UV4Kind
  106254. * - VertexBuffer.UV5Kind
  106255. * - VertexBuffer.UV6Kind
  106256. * - VertexBuffer.ColorKind
  106257. * - VertexBuffer.MatricesIndicesKind
  106258. * - VertexBuffer.MatricesIndicesExtraKind
  106259. * - VertexBuffer.MatricesWeightsKind
  106260. * - VertexBuffer.MatricesWeightsExtraKind
  106261. * @param data defines the data source
  106262. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106263. * @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)
  106264. */
  106265. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106266. /**
  106267. * Creates a new index buffer
  106268. * @param indices defines the indices to store in the index buffer
  106269. * @param totalVertices defines the total number of vertices (could be null)
  106270. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106271. */
  106272. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106273. }
  106274. /**
  106275. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106276. */
  106277. export class VertexData {
  106278. /**
  106279. * Mesh side orientation : usually the external or front surface
  106280. */
  106281. static readonly FRONTSIDE: number;
  106282. /**
  106283. * Mesh side orientation : usually the internal or back surface
  106284. */
  106285. static readonly BACKSIDE: number;
  106286. /**
  106287. * Mesh side orientation : both internal and external or front and back surfaces
  106288. */
  106289. static readonly DOUBLESIDE: number;
  106290. /**
  106291. * Mesh side orientation : by default, `FRONTSIDE`
  106292. */
  106293. static readonly DEFAULTSIDE: number;
  106294. /**
  106295. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106296. */
  106297. positions: Nullable<FloatArray>;
  106298. /**
  106299. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106300. */
  106301. normals: Nullable<FloatArray>;
  106302. /**
  106303. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106304. */
  106305. tangents: Nullable<FloatArray>;
  106306. /**
  106307. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106308. */
  106309. uvs: Nullable<FloatArray>;
  106310. /**
  106311. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106312. */
  106313. uvs2: Nullable<FloatArray>;
  106314. /**
  106315. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106316. */
  106317. uvs3: Nullable<FloatArray>;
  106318. /**
  106319. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106320. */
  106321. uvs4: Nullable<FloatArray>;
  106322. /**
  106323. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106324. */
  106325. uvs5: Nullable<FloatArray>;
  106326. /**
  106327. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106328. */
  106329. uvs6: Nullable<FloatArray>;
  106330. /**
  106331. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106332. */
  106333. colors: Nullable<FloatArray>;
  106334. /**
  106335. * 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).
  106336. */
  106337. matricesIndices: Nullable<FloatArray>;
  106338. /**
  106339. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106340. */
  106341. matricesWeights: Nullable<FloatArray>;
  106342. /**
  106343. * An array extending the number of possible indices
  106344. */
  106345. matricesIndicesExtra: Nullable<FloatArray>;
  106346. /**
  106347. * An array extending the number of possible weights when the number of indices is extended
  106348. */
  106349. matricesWeightsExtra: Nullable<FloatArray>;
  106350. /**
  106351. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106352. */
  106353. indices: Nullable<IndicesArray>;
  106354. /**
  106355. * Uses the passed data array to set the set the values for the specified kind of data
  106356. * @param data a linear array of floating numbers
  106357. * @param kind the type of data that is being set, eg positions, colors etc
  106358. */
  106359. set(data: FloatArray, kind: string): void;
  106360. /**
  106361. * Associates the vertexData to the passed Mesh.
  106362. * Sets it as updatable or not (default `false`)
  106363. * @param mesh the mesh the vertexData is applied to
  106364. * @param updatable when used and having the value true allows new data to update the vertexData
  106365. * @returns the VertexData
  106366. */
  106367. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106368. /**
  106369. * Associates the vertexData to the passed Geometry.
  106370. * Sets it as updatable or not (default `false`)
  106371. * @param geometry the geometry the vertexData is applied to
  106372. * @param updatable when used and having the value true allows new data to update the vertexData
  106373. * @returns VertexData
  106374. */
  106375. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106376. /**
  106377. * Updates the associated mesh
  106378. * @param mesh the mesh to be updated
  106379. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106380. * @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
  106381. * @returns VertexData
  106382. */
  106383. updateMesh(mesh: Mesh): VertexData;
  106384. /**
  106385. * Updates the associated geometry
  106386. * @param geometry the geometry to be updated
  106387. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106388. * @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
  106389. * @returns VertexData.
  106390. */
  106391. updateGeometry(geometry: Geometry): VertexData;
  106392. private _applyTo;
  106393. private _update;
  106394. /**
  106395. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106396. * @param matrix the transforming matrix
  106397. * @returns the VertexData
  106398. */
  106399. transform(matrix: Matrix): VertexData;
  106400. /**
  106401. * Merges the passed VertexData into the current one
  106402. * @param other the VertexData to be merged into the current one
  106403. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106404. * @returns the modified VertexData
  106405. */
  106406. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106407. private _mergeElement;
  106408. private _validate;
  106409. /**
  106410. * Serializes the VertexData
  106411. * @returns a serialized object
  106412. */
  106413. serialize(): any;
  106414. /**
  106415. * Extracts the vertexData from a mesh
  106416. * @param mesh the mesh from which to extract the VertexData
  106417. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106418. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106419. * @returns the object VertexData associated to the passed mesh
  106420. */
  106421. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106422. /**
  106423. * Extracts the vertexData from the geometry
  106424. * @param geometry the geometry from which to extract the VertexData
  106425. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106426. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106427. * @returns the object VertexData associated to the passed mesh
  106428. */
  106429. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106430. private static _ExtractFrom;
  106431. /**
  106432. * Creates the VertexData for a Ribbon
  106433. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106434. * * pathArray array of paths, each of which an array of successive Vector3
  106435. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106436. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106437. * * 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
  106438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106439. * * 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)
  106440. * * 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)
  106441. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106442. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106443. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106444. * @returns the VertexData of the ribbon
  106445. */
  106446. static CreateRibbon(options: {
  106447. pathArray: Vector3[][];
  106448. closeArray?: boolean;
  106449. closePath?: boolean;
  106450. offset?: number;
  106451. sideOrientation?: number;
  106452. frontUVs?: Vector4;
  106453. backUVs?: Vector4;
  106454. invertUV?: boolean;
  106455. uvs?: Vector2[];
  106456. colors?: Color4[];
  106457. }): VertexData;
  106458. /**
  106459. * Creates the VertexData for a box
  106460. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106461. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106462. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106463. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106464. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106465. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106466. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106468. * * 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)
  106469. * * 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)
  106470. * @returns the VertexData of the box
  106471. */
  106472. static CreateBox(options: {
  106473. size?: number;
  106474. width?: number;
  106475. height?: number;
  106476. depth?: number;
  106477. faceUV?: Vector4[];
  106478. faceColors?: Color4[];
  106479. sideOrientation?: number;
  106480. frontUVs?: Vector4;
  106481. backUVs?: Vector4;
  106482. }): VertexData;
  106483. /**
  106484. * Creates the VertexData for a tiled box
  106485. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106486. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106487. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106488. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106490. * @returns the VertexData of the box
  106491. */
  106492. static CreateTiledBox(options: {
  106493. pattern?: number;
  106494. width?: number;
  106495. height?: number;
  106496. depth?: number;
  106497. tileSize?: number;
  106498. tileWidth?: number;
  106499. tileHeight?: number;
  106500. alignHorizontal?: number;
  106501. alignVertical?: number;
  106502. faceUV?: Vector4[];
  106503. faceColors?: Color4[];
  106504. sideOrientation?: number;
  106505. }): VertexData;
  106506. /**
  106507. * Creates the VertexData for a tiled plane
  106508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106509. * * pattern a limited pattern arrangement depending on the number
  106510. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106511. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106512. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106514. * * 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)
  106515. * * 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)
  106516. * @returns the VertexData of the tiled plane
  106517. */
  106518. static CreateTiledPlane(options: {
  106519. pattern?: number;
  106520. tileSize?: number;
  106521. tileWidth?: number;
  106522. tileHeight?: number;
  106523. size?: number;
  106524. width?: number;
  106525. height?: number;
  106526. alignHorizontal?: number;
  106527. alignVertical?: number;
  106528. sideOrientation?: number;
  106529. frontUVs?: Vector4;
  106530. backUVs?: Vector4;
  106531. }): VertexData;
  106532. /**
  106533. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106534. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106535. * * segments sets the number of horizontal strips optional, default 32
  106536. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106537. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106538. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106539. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106540. * * 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
  106541. * * 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
  106542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106543. * * 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)
  106544. * * 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)
  106545. * @returns the VertexData of the ellipsoid
  106546. */
  106547. static CreateSphere(options: {
  106548. segments?: number;
  106549. diameter?: number;
  106550. diameterX?: number;
  106551. diameterY?: number;
  106552. diameterZ?: number;
  106553. arc?: number;
  106554. slice?: number;
  106555. sideOrientation?: number;
  106556. frontUVs?: Vector4;
  106557. backUVs?: Vector4;
  106558. }): VertexData;
  106559. /**
  106560. * Creates the VertexData for a cylinder, cone or prism
  106561. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106562. * * height sets the height (y direction) of the cylinder, optional, default 2
  106563. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106564. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106565. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106566. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106567. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106568. * * 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
  106569. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106570. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106571. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106572. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106574. * * 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)
  106575. * * 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)
  106576. * @returns the VertexData of the cylinder, cone or prism
  106577. */
  106578. static CreateCylinder(options: {
  106579. height?: number;
  106580. diameterTop?: number;
  106581. diameterBottom?: number;
  106582. diameter?: number;
  106583. tessellation?: number;
  106584. subdivisions?: number;
  106585. arc?: number;
  106586. faceColors?: Color4[];
  106587. faceUV?: Vector4[];
  106588. hasRings?: boolean;
  106589. enclose?: boolean;
  106590. sideOrientation?: number;
  106591. frontUVs?: Vector4;
  106592. backUVs?: Vector4;
  106593. }): VertexData;
  106594. /**
  106595. * Creates the VertexData for a torus
  106596. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106597. * * diameter the diameter of the torus, optional default 1
  106598. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106599. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106600. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106601. * * 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)
  106602. * * 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)
  106603. * @returns the VertexData of the torus
  106604. */
  106605. static CreateTorus(options: {
  106606. diameter?: number;
  106607. thickness?: number;
  106608. tessellation?: number;
  106609. sideOrientation?: number;
  106610. frontUVs?: Vector4;
  106611. backUVs?: Vector4;
  106612. }): VertexData;
  106613. /**
  106614. * Creates the VertexData of the LineSystem
  106615. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106616. * - lines an array of lines, each line being an array of successive Vector3
  106617. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106618. * @returns the VertexData of the LineSystem
  106619. */
  106620. static CreateLineSystem(options: {
  106621. lines: Vector3[][];
  106622. colors?: Nullable<Color4[][]>;
  106623. }): VertexData;
  106624. /**
  106625. * Create the VertexData for a DashedLines
  106626. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106627. * - points an array successive Vector3
  106628. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106629. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106630. * - dashNb the intended total number of dashes, optional, default 200
  106631. * @returns the VertexData for the DashedLines
  106632. */
  106633. static CreateDashedLines(options: {
  106634. points: Vector3[];
  106635. dashSize?: number;
  106636. gapSize?: number;
  106637. dashNb?: number;
  106638. }): VertexData;
  106639. /**
  106640. * Creates the VertexData for a Ground
  106641. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106642. * - width the width (x direction) of the ground, optional, default 1
  106643. * - height the height (z direction) of the ground, optional, default 1
  106644. * - subdivisions the number of subdivisions per side, optional, default 1
  106645. * @returns the VertexData of the Ground
  106646. */
  106647. static CreateGround(options: {
  106648. width?: number;
  106649. height?: number;
  106650. subdivisions?: number;
  106651. subdivisionsX?: number;
  106652. subdivisionsY?: number;
  106653. }): VertexData;
  106654. /**
  106655. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106656. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106657. * * xmin the ground minimum X coordinate, optional, default -1
  106658. * * zmin the ground minimum Z coordinate, optional, default -1
  106659. * * xmax the ground maximum X coordinate, optional, default 1
  106660. * * zmax the ground maximum Z coordinate, optional, default 1
  106661. * * 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}
  106662. * * 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}
  106663. * @returns the VertexData of the TiledGround
  106664. */
  106665. static CreateTiledGround(options: {
  106666. xmin: number;
  106667. zmin: number;
  106668. xmax: number;
  106669. zmax: number;
  106670. subdivisions?: {
  106671. w: number;
  106672. h: number;
  106673. };
  106674. precision?: {
  106675. w: number;
  106676. h: number;
  106677. };
  106678. }): VertexData;
  106679. /**
  106680. * Creates the VertexData of the Ground designed from a heightmap
  106681. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106682. * * width the width (x direction) of the ground
  106683. * * height the height (z direction) of the ground
  106684. * * subdivisions the number of subdivisions per side
  106685. * * minHeight the minimum altitude on the ground, optional, default 0
  106686. * * maxHeight the maximum altitude on the ground, optional default 1
  106687. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106688. * * buffer the array holding the image color data
  106689. * * bufferWidth the width of image
  106690. * * bufferHeight the height of image
  106691. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106692. * @returns the VertexData of the Ground designed from a heightmap
  106693. */
  106694. static CreateGroundFromHeightMap(options: {
  106695. width: number;
  106696. height: number;
  106697. subdivisions: number;
  106698. minHeight: number;
  106699. maxHeight: number;
  106700. colorFilter: Color3;
  106701. buffer: Uint8Array;
  106702. bufferWidth: number;
  106703. bufferHeight: number;
  106704. alphaFilter: number;
  106705. }): VertexData;
  106706. /**
  106707. * Creates the VertexData for a Plane
  106708. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106709. * * size sets the width and height of the plane to the value of size, optional default 1
  106710. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106711. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106713. * * 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)
  106714. * * 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)
  106715. * @returns the VertexData of the box
  106716. */
  106717. static CreatePlane(options: {
  106718. size?: number;
  106719. width?: number;
  106720. height?: number;
  106721. sideOrientation?: number;
  106722. frontUVs?: Vector4;
  106723. backUVs?: Vector4;
  106724. }): VertexData;
  106725. /**
  106726. * Creates the VertexData of the Disc or regular Polygon
  106727. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106728. * * radius the radius of the disc, optional default 0.5
  106729. * * tessellation the number of polygon sides, optional, default 64
  106730. * * 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
  106731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106732. * * 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)
  106733. * * 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)
  106734. * @returns the VertexData of the box
  106735. */
  106736. static CreateDisc(options: {
  106737. radius?: number;
  106738. tessellation?: number;
  106739. arc?: number;
  106740. sideOrientation?: number;
  106741. frontUVs?: Vector4;
  106742. backUVs?: Vector4;
  106743. }): VertexData;
  106744. /**
  106745. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106746. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106747. * @param polygon a mesh built from polygonTriangulation.build()
  106748. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106749. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106750. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106751. * @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)
  106752. * @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)
  106753. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106754. * @returns the VertexData of the Polygon
  106755. */
  106756. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106757. /**
  106758. * Creates the VertexData of the IcoSphere
  106759. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106760. * * radius the radius of the IcoSphere, optional default 1
  106761. * * radiusX allows stretching in the x direction, optional, default radius
  106762. * * radiusY allows stretching in the y direction, optional, default radius
  106763. * * radiusZ allows stretching in the z direction, optional, default radius
  106764. * * flat when true creates a flat shaded mesh, optional, default true
  106765. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106767. * * 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)
  106768. * * 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)
  106769. * @returns the VertexData of the IcoSphere
  106770. */
  106771. static CreateIcoSphere(options: {
  106772. radius?: number;
  106773. radiusX?: number;
  106774. radiusY?: number;
  106775. radiusZ?: number;
  106776. flat?: boolean;
  106777. subdivisions?: number;
  106778. sideOrientation?: number;
  106779. frontUVs?: Vector4;
  106780. backUVs?: Vector4;
  106781. }): VertexData;
  106782. /**
  106783. * Creates the VertexData for a Polyhedron
  106784. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106785. * * type provided types are:
  106786. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106787. * * 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)
  106788. * * size the size of the IcoSphere, optional default 1
  106789. * * sizeX allows stretching in the x direction, optional, default size
  106790. * * sizeY allows stretching in the y direction, optional, default size
  106791. * * sizeZ allows stretching in the z direction, optional, default size
  106792. * * 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
  106793. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106794. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106795. * * flat when true creates a flat shaded mesh, optional, default true
  106796. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106798. * * 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)
  106799. * * 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)
  106800. * @returns the VertexData of the Polyhedron
  106801. */
  106802. static CreatePolyhedron(options: {
  106803. type?: number;
  106804. size?: number;
  106805. sizeX?: number;
  106806. sizeY?: number;
  106807. sizeZ?: number;
  106808. custom?: any;
  106809. faceUV?: Vector4[];
  106810. faceColors?: Color4[];
  106811. flat?: boolean;
  106812. sideOrientation?: number;
  106813. frontUVs?: Vector4;
  106814. backUVs?: Vector4;
  106815. }): VertexData;
  106816. /**
  106817. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106818. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106819. * @returns the VertexData of the Capsule
  106820. */
  106821. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106822. /**
  106823. * Creates the VertexData for a TorusKnot
  106824. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106825. * * radius the radius of the torus knot, optional, default 2
  106826. * * tube the thickness of the tube, optional, default 0.5
  106827. * * radialSegments the number of sides on each tube segments, optional, default 32
  106828. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106829. * * p the number of windings around the z axis, optional, default 2
  106830. * * q the number of windings around the x axis, optional, default 3
  106831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106832. * * 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)
  106833. * * 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)
  106834. * @returns the VertexData of the Torus Knot
  106835. */
  106836. static CreateTorusKnot(options: {
  106837. radius?: number;
  106838. tube?: number;
  106839. radialSegments?: number;
  106840. tubularSegments?: number;
  106841. p?: number;
  106842. q?: number;
  106843. sideOrientation?: number;
  106844. frontUVs?: Vector4;
  106845. backUVs?: Vector4;
  106846. }): VertexData;
  106847. /**
  106848. * Compute normals for given positions and indices
  106849. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106850. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106851. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106852. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106853. * * facetNormals : optional array of facet normals (vector3)
  106854. * * facetPositions : optional array of facet positions (vector3)
  106855. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106856. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106857. * * bInfo : optional bounding info, required for facetPartitioning computation
  106858. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106859. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106860. * * useRightHandedSystem: optional boolean to for right handed system computation
  106861. * * depthSort : optional boolean to enable the facet depth sort computation
  106862. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106863. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106864. */
  106865. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106866. facetNormals?: any;
  106867. facetPositions?: any;
  106868. facetPartitioning?: any;
  106869. ratio?: number;
  106870. bInfo?: any;
  106871. bbSize?: Vector3;
  106872. subDiv?: any;
  106873. useRightHandedSystem?: boolean;
  106874. depthSort?: boolean;
  106875. distanceTo?: Vector3;
  106876. depthSortedFacets?: any;
  106877. }): void;
  106878. /** @hidden */
  106879. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106880. /**
  106881. * Applies VertexData created from the imported parameters to the geometry
  106882. * @param parsedVertexData the parsed data from an imported file
  106883. * @param geometry the geometry to apply the VertexData to
  106884. */
  106885. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106886. }
  106887. }
  106888. declare module BABYLON {
  106889. /**
  106890. * Defines a target to use with MorphTargetManager
  106891. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106892. */
  106893. export class MorphTarget implements IAnimatable {
  106894. /** defines the name of the target */
  106895. name: string;
  106896. /**
  106897. * Gets or sets the list of animations
  106898. */
  106899. animations: Animation[];
  106900. private _scene;
  106901. private _positions;
  106902. private _normals;
  106903. private _tangents;
  106904. private _uvs;
  106905. private _influence;
  106906. private _uniqueId;
  106907. /**
  106908. * Observable raised when the influence changes
  106909. */
  106910. onInfluenceChanged: Observable<boolean>;
  106911. /** @hidden */
  106912. _onDataLayoutChanged: Observable<void>;
  106913. /**
  106914. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106915. */
  106916. get influence(): number;
  106917. set influence(influence: number);
  106918. /**
  106919. * Gets or sets the id of the morph Target
  106920. */
  106921. id: string;
  106922. private _animationPropertiesOverride;
  106923. /**
  106924. * Gets or sets the animation properties override
  106925. */
  106926. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106927. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106928. /**
  106929. * Creates a new MorphTarget
  106930. * @param name defines the name of the target
  106931. * @param influence defines the influence to use
  106932. * @param scene defines the scene the morphtarget belongs to
  106933. */
  106934. constructor(
  106935. /** defines the name of the target */
  106936. name: string, influence?: number, scene?: Nullable<Scene>);
  106937. /**
  106938. * Gets the unique ID of this manager
  106939. */
  106940. get uniqueId(): number;
  106941. /**
  106942. * Gets a boolean defining if the target contains position data
  106943. */
  106944. get hasPositions(): boolean;
  106945. /**
  106946. * Gets a boolean defining if the target contains normal data
  106947. */
  106948. get hasNormals(): boolean;
  106949. /**
  106950. * Gets a boolean defining if the target contains tangent data
  106951. */
  106952. get hasTangents(): boolean;
  106953. /**
  106954. * Gets a boolean defining if the target contains texture coordinates data
  106955. */
  106956. get hasUVs(): boolean;
  106957. /**
  106958. * Affects position data to this target
  106959. * @param data defines the position data to use
  106960. */
  106961. setPositions(data: Nullable<FloatArray>): void;
  106962. /**
  106963. * Gets the position data stored in this target
  106964. * @returns a FloatArray containing the position data (or null if not present)
  106965. */
  106966. getPositions(): Nullable<FloatArray>;
  106967. /**
  106968. * Affects normal data to this target
  106969. * @param data defines the normal data to use
  106970. */
  106971. setNormals(data: Nullable<FloatArray>): void;
  106972. /**
  106973. * Gets the normal data stored in this target
  106974. * @returns a FloatArray containing the normal data (or null if not present)
  106975. */
  106976. getNormals(): Nullable<FloatArray>;
  106977. /**
  106978. * Affects tangent data to this target
  106979. * @param data defines the tangent data to use
  106980. */
  106981. setTangents(data: Nullable<FloatArray>): void;
  106982. /**
  106983. * Gets the tangent data stored in this target
  106984. * @returns a FloatArray containing the tangent data (or null if not present)
  106985. */
  106986. getTangents(): Nullable<FloatArray>;
  106987. /**
  106988. * Affects texture coordinates data to this target
  106989. * @param data defines the texture coordinates data to use
  106990. */
  106991. setUVs(data: Nullable<FloatArray>): void;
  106992. /**
  106993. * Gets the texture coordinates data stored in this target
  106994. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106995. */
  106996. getUVs(): Nullable<FloatArray>;
  106997. /**
  106998. * Clone the current target
  106999. * @returns a new MorphTarget
  107000. */
  107001. clone(): MorphTarget;
  107002. /**
  107003. * Serializes the current target into a Serialization object
  107004. * @returns the serialized object
  107005. */
  107006. serialize(): any;
  107007. /**
  107008. * Returns the string "MorphTarget"
  107009. * @returns "MorphTarget"
  107010. */
  107011. getClassName(): string;
  107012. /**
  107013. * Creates a new target from serialized data
  107014. * @param serializationObject defines the serialized data to use
  107015. * @returns a new MorphTarget
  107016. */
  107017. static Parse(serializationObject: any): MorphTarget;
  107018. /**
  107019. * Creates a MorphTarget from mesh data
  107020. * @param mesh defines the source mesh
  107021. * @param name defines the name to use for the new target
  107022. * @param influence defines the influence to attach to the target
  107023. * @returns a new MorphTarget
  107024. */
  107025. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107026. }
  107027. }
  107028. declare module BABYLON {
  107029. /**
  107030. * This class is used to deform meshes using morphing between different targets
  107031. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107032. */
  107033. export class MorphTargetManager {
  107034. private _targets;
  107035. private _targetInfluenceChangedObservers;
  107036. private _targetDataLayoutChangedObservers;
  107037. private _activeTargets;
  107038. private _scene;
  107039. private _influences;
  107040. private _supportsNormals;
  107041. private _supportsTangents;
  107042. private _supportsUVs;
  107043. private _vertexCount;
  107044. private _uniqueId;
  107045. private _tempInfluences;
  107046. /**
  107047. * Gets or sets a boolean indicating if normals must be morphed
  107048. */
  107049. enableNormalMorphing: boolean;
  107050. /**
  107051. * Gets or sets a boolean indicating if tangents must be morphed
  107052. */
  107053. enableTangentMorphing: boolean;
  107054. /**
  107055. * Gets or sets a boolean indicating if UV must be morphed
  107056. */
  107057. enableUVMorphing: boolean;
  107058. /**
  107059. * Creates a new MorphTargetManager
  107060. * @param scene defines the current scene
  107061. */
  107062. constructor(scene?: Nullable<Scene>);
  107063. /**
  107064. * Gets the unique ID of this manager
  107065. */
  107066. get uniqueId(): number;
  107067. /**
  107068. * Gets the number of vertices handled by this manager
  107069. */
  107070. get vertexCount(): number;
  107071. /**
  107072. * Gets a boolean indicating if this manager supports morphing of normals
  107073. */
  107074. get supportsNormals(): boolean;
  107075. /**
  107076. * Gets a boolean indicating if this manager supports morphing of tangents
  107077. */
  107078. get supportsTangents(): boolean;
  107079. /**
  107080. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107081. */
  107082. get supportsUVs(): boolean;
  107083. /**
  107084. * Gets the number of targets stored in this manager
  107085. */
  107086. get numTargets(): number;
  107087. /**
  107088. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107089. */
  107090. get numInfluencers(): number;
  107091. /**
  107092. * Gets the list of influences (one per target)
  107093. */
  107094. get influences(): Float32Array;
  107095. /**
  107096. * Gets the active target at specified index. An active target is a target with an influence > 0
  107097. * @param index defines the index to check
  107098. * @returns the requested target
  107099. */
  107100. getActiveTarget(index: number): MorphTarget;
  107101. /**
  107102. * Gets the target at specified index
  107103. * @param index defines the index to check
  107104. * @returns the requested target
  107105. */
  107106. getTarget(index: number): MorphTarget;
  107107. /**
  107108. * Add a new target to this manager
  107109. * @param target defines the target to add
  107110. */
  107111. addTarget(target: MorphTarget): void;
  107112. /**
  107113. * Removes a target from the manager
  107114. * @param target defines the target to remove
  107115. */
  107116. removeTarget(target: MorphTarget): void;
  107117. /**
  107118. * Clone the current manager
  107119. * @returns a new MorphTargetManager
  107120. */
  107121. clone(): MorphTargetManager;
  107122. /**
  107123. * Serializes the current manager into a Serialization object
  107124. * @returns the serialized object
  107125. */
  107126. serialize(): any;
  107127. private _syncActiveTargets;
  107128. /**
  107129. * Syncrhonize the targets with all the meshes using this morph target manager
  107130. */
  107131. synchronize(): void;
  107132. /**
  107133. * Creates a new MorphTargetManager from serialized data
  107134. * @param serializationObject defines the serialized data
  107135. * @param scene defines the hosting scene
  107136. * @returns the new MorphTargetManager
  107137. */
  107138. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107139. }
  107140. }
  107141. declare module BABYLON {
  107142. /**
  107143. * Class used to represent a specific level of detail of a mesh
  107144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107145. */
  107146. export class MeshLODLevel {
  107147. /** Defines the distance where this level should start being displayed */
  107148. distance: number;
  107149. /** Defines the mesh to use to render this level */
  107150. mesh: Nullable<Mesh>;
  107151. /**
  107152. * Creates a new LOD level
  107153. * @param distance defines the distance where this level should star being displayed
  107154. * @param mesh defines the mesh to use to render this level
  107155. */
  107156. constructor(
  107157. /** Defines the distance where this level should start being displayed */
  107158. distance: number,
  107159. /** Defines the mesh to use to render this level */
  107160. mesh: Nullable<Mesh>);
  107161. }
  107162. }
  107163. declare module BABYLON {
  107164. /**
  107165. * Helper class used to generate a canvas to manipulate images
  107166. */
  107167. export class CanvasGenerator {
  107168. /**
  107169. * Create a new canvas (or offscreen canvas depending on the context)
  107170. * @param width defines the expected width
  107171. * @param height defines the expected height
  107172. * @return a new canvas or offscreen canvas
  107173. */
  107174. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107175. }
  107176. }
  107177. declare module BABYLON {
  107178. /**
  107179. * Mesh representing the gorund
  107180. */
  107181. export class GroundMesh extends Mesh {
  107182. /** If octree should be generated */
  107183. generateOctree: boolean;
  107184. private _heightQuads;
  107185. /** @hidden */
  107186. _subdivisionsX: number;
  107187. /** @hidden */
  107188. _subdivisionsY: number;
  107189. /** @hidden */
  107190. _width: number;
  107191. /** @hidden */
  107192. _height: number;
  107193. /** @hidden */
  107194. _minX: number;
  107195. /** @hidden */
  107196. _maxX: number;
  107197. /** @hidden */
  107198. _minZ: number;
  107199. /** @hidden */
  107200. _maxZ: number;
  107201. constructor(name: string, scene: Scene);
  107202. /**
  107203. * "GroundMesh"
  107204. * @returns "GroundMesh"
  107205. */
  107206. getClassName(): string;
  107207. /**
  107208. * The minimum of x and y subdivisions
  107209. */
  107210. get subdivisions(): number;
  107211. /**
  107212. * X subdivisions
  107213. */
  107214. get subdivisionsX(): number;
  107215. /**
  107216. * Y subdivisions
  107217. */
  107218. get subdivisionsY(): number;
  107219. /**
  107220. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107221. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107222. * @param chunksCount the number of subdivisions for x and y
  107223. * @param octreeBlocksSize (Default: 32)
  107224. */
  107225. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107226. /**
  107227. * Returns a height (y) value in the Worl system :
  107228. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107229. * @param x x coordinate
  107230. * @param z z coordinate
  107231. * @returns the ground y position if (x, z) are outside the ground surface.
  107232. */
  107233. getHeightAtCoordinates(x: number, z: number): number;
  107234. /**
  107235. * Returns a normalized vector (Vector3) orthogonal to the ground
  107236. * at the ground coordinates (x, z) expressed in the World system.
  107237. * @param x x coordinate
  107238. * @param z z coordinate
  107239. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107240. */
  107241. getNormalAtCoordinates(x: number, z: number): Vector3;
  107242. /**
  107243. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107244. * at the ground coordinates (x, z) expressed in the World system.
  107245. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107246. * @param x x coordinate
  107247. * @param z z coordinate
  107248. * @param ref vector to store the result
  107249. * @returns the GroundMesh.
  107250. */
  107251. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107252. /**
  107253. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107254. * if the ground has been updated.
  107255. * This can be used in the render loop.
  107256. * @returns the GroundMesh.
  107257. */
  107258. updateCoordinateHeights(): GroundMesh;
  107259. private _getFacetAt;
  107260. private _initHeightQuads;
  107261. private _computeHeightQuads;
  107262. /**
  107263. * Serializes this ground mesh
  107264. * @param serializationObject object to write serialization to
  107265. */
  107266. serialize(serializationObject: any): void;
  107267. /**
  107268. * Parses a serialized ground mesh
  107269. * @param parsedMesh the serialized mesh
  107270. * @param scene the scene to create the ground mesh in
  107271. * @returns the created ground mesh
  107272. */
  107273. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107274. }
  107275. }
  107276. declare module BABYLON {
  107277. /**
  107278. * Interface for Physics-Joint data
  107279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107280. */
  107281. export interface PhysicsJointData {
  107282. /**
  107283. * The main pivot of the joint
  107284. */
  107285. mainPivot?: Vector3;
  107286. /**
  107287. * The connected pivot of the joint
  107288. */
  107289. connectedPivot?: Vector3;
  107290. /**
  107291. * The main axis of the joint
  107292. */
  107293. mainAxis?: Vector3;
  107294. /**
  107295. * The connected axis of the joint
  107296. */
  107297. connectedAxis?: Vector3;
  107298. /**
  107299. * The collision of the joint
  107300. */
  107301. collision?: boolean;
  107302. /**
  107303. * Native Oimo/Cannon/Energy data
  107304. */
  107305. nativeParams?: any;
  107306. }
  107307. /**
  107308. * This is a holder class for the physics joint created by the physics plugin
  107309. * It holds a set of functions to control the underlying joint
  107310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107311. */
  107312. export class PhysicsJoint {
  107313. /**
  107314. * The type of the physics joint
  107315. */
  107316. type: number;
  107317. /**
  107318. * The data for the physics joint
  107319. */
  107320. jointData: PhysicsJointData;
  107321. private _physicsJoint;
  107322. protected _physicsPlugin: IPhysicsEnginePlugin;
  107323. /**
  107324. * Initializes the physics joint
  107325. * @param type The type of the physics joint
  107326. * @param jointData The data for the physics joint
  107327. */
  107328. constructor(
  107329. /**
  107330. * The type of the physics joint
  107331. */
  107332. type: number,
  107333. /**
  107334. * The data for the physics joint
  107335. */
  107336. jointData: PhysicsJointData);
  107337. /**
  107338. * Gets the physics joint
  107339. */
  107340. get physicsJoint(): any;
  107341. /**
  107342. * Sets the physics joint
  107343. */
  107344. set physicsJoint(newJoint: any);
  107345. /**
  107346. * Sets the physics plugin
  107347. */
  107348. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107349. /**
  107350. * Execute a function that is physics-plugin specific.
  107351. * @param {Function} func the function that will be executed.
  107352. * It accepts two parameters: the physics world and the physics joint
  107353. */
  107354. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107355. /**
  107356. * Distance-Joint type
  107357. */
  107358. static DistanceJoint: number;
  107359. /**
  107360. * Hinge-Joint type
  107361. */
  107362. static HingeJoint: number;
  107363. /**
  107364. * Ball-and-Socket joint type
  107365. */
  107366. static BallAndSocketJoint: number;
  107367. /**
  107368. * Wheel-Joint type
  107369. */
  107370. static WheelJoint: number;
  107371. /**
  107372. * Slider-Joint type
  107373. */
  107374. static SliderJoint: number;
  107375. /**
  107376. * Prismatic-Joint type
  107377. */
  107378. static PrismaticJoint: number;
  107379. /**
  107380. * Universal-Joint type
  107381. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107382. */
  107383. static UniversalJoint: number;
  107384. /**
  107385. * Hinge-Joint 2 type
  107386. */
  107387. static Hinge2Joint: number;
  107388. /**
  107389. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107390. */
  107391. static PointToPointJoint: number;
  107392. /**
  107393. * Spring-Joint type
  107394. */
  107395. static SpringJoint: number;
  107396. /**
  107397. * Lock-Joint type
  107398. */
  107399. static LockJoint: number;
  107400. }
  107401. /**
  107402. * A class representing a physics distance joint
  107403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107404. */
  107405. export class DistanceJoint extends PhysicsJoint {
  107406. /**
  107407. *
  107408. * @param jointData The data for the Distance-Joint
  107409. */
  107410. constructor(jointData: DistanceJointData);
  107411. /**
  107412. * Update the predefined distance.
  107413. * @param maxDistance The maximum preferred distance
  107414. * @param minDistance The minimum preferred distance
  107415. */
  107416. updateDistance(maxDistance: number, minDistance?: number): void;
  107417. }
  107418. /**
  107419. * Represents a Motor-Enabled Joint
  107420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107421. */
  107422. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107423. /**
  107424. * Initializes the Motor-Enabled Joint
  107425. * @param type The type of the joint
  107426. * @param jointData The physica joint data for the joint
  107427. */
  107428. constructor(type: number, jointData: PhysicsJointData);
  107429. /**
  107430. * Set the motor values.
  107431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107432. * @param force the force to apply
  107433. * @param maxForce max force for this motor.
  107434. */
  107435. setMotor(force?: number, maxForce?: number): void;
  107436. /**
  107437. * Set the motor's limits.
  107438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107439. * @param upperLimit The upper limit of the motor
  107440. * @param lowerLimit The lower limit of the motor
  107441. */
  107442. setLimit(upperLimit: number, lowerLimit?: number): void;
  107443. }
  107444. /**
  107445. * This class represents a single physics Hinge-Joint
  107446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107447. */
  107448. export class HingeJoint extends MotorEnabledJoint {
  107449. /**
  107450. * Initializes the Hinge-Joint
  107451. * @param jointData The joint data for the Hinge-Joint
  107452. */
  107453. constructor(jointData: PhysicsJointData);
  107454. /**
  107455. * Set the motor values.
  107456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107457. * @param {number} force the force to apply
  107458. * @param {number} maxForce max force for this motor.
  107459. */
  107460. setMotor(force?: number, maxForce?: number): void;
  107461. /**
  107462. * Set the motor's limits.
  107463. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107464. * @param upperLimit The upper limit of the motor
  107465. * @param lowerLimit The lower limit of the motor
  107466. */
  107467. setLimit(upperLimit: number, lowerLimit?: number): void;
  107468. }
  107469. /**
  107470. * This class represents a dual hinge physics joint (same as wheel joint)
  107471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107472. */
  107473. export class Hinge2Joint extends MotorEnabledJoint {
  107474. /**
  107475. * Initializes the Hinge2-Joint
  107476. * @param jointData The joint data for the Hinge2-Joint
  107477. */
  107478. constructor(jointData: PhysicsJointData);
  107479. /**
  107480. * Set the motor values.
  107481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107482. * @param {number} targetSpeed the speed the motor is to reach
  107483. * @param {number} maxForce max force for this motor.
  107484. * @param {motorIndex} the motor's index, 0 or 1.
  107485. */
  107486. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107487. /**
  107488. * Set the motor limits.
  107489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107490. * @param {number} upperLimit the upper limit
  107491. * @param {number} lowerLimit lower limit
  107492. * @param {motorIndex} the motor's index, 0 or 1.
  107493. */
  107494. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107495. }
  107496. /**
  107497. * Interface for a motor enabled joint
  107498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107499. */
  107500. export interface IMotorEnabledJoint {
  107501. /**
  107502. * Physics joint
  107503. */
  107504. physicsJoint: any;
  107505. /**
  107506. * Sets the motor of the motor-enabled joint
  107507. * @param force The force of the motor
  107508. * @param maxForce The maximum force of the motor
  107509. * @param motorIndex The index of the motor
  107510. */
  107511. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107512. /**
  107513. * Sets the limit of the motor
  107514. * @param upperLimit The upper limit of the motor
  107515. * @param lowerLimit The lower limit of the motor
  107516. * @param motorIndex The index of the motor
  107517. */
  107518. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107519. }
  107520. /**
  107521. * Joint data for a Distance-Joint
  107522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107523. */
  107524. export interface DistanceJointData extends PhysicsJointData {
  107525. /**
  107526. * Max distance the 2 joint objects can be apart
  107527. */
  107528. maxDistance: number;
  107529. }
  107530. /**
  107531. * Joint data from a spring joint
  107532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107533. */
  107534. export interface SpringJointData extends PhysicsJointData {
  107535. /**
  107536. * Length of the spring
  107537. */
  107538. length: number;
  107539. /**
  107540. * Stiffness of the spring
  107541. */
  107542. stiffness: number;
  107543. /**
  107544. * Damping of the spring
  107545. */
  107546. damping: number;
  107547. /** this callback will be called when applying the force to the impostors. */
  107548. forceApplicationCallback: () => void;
  107549. }
  107550. }
  107551. declare module BABYLON {
  107552. /**
  107553. * Holds the data for the raycast result
  107554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107555. */
  107556. export class PhysicsRaycastResult {
  107557. private _hasHit;
  107558. private _hitDistance;
  107559. private _hitNormalWorld;
  107560. private _hitPointWorld;
  107561. private _rayFromWorld;
  107562. private _rayToWorld;
  107563. /**
  107564. * Gets if there was a hit
  107565. */
  107566. get hasHit(): boolean;
  107567. /**
  107568. * Gets the distance from the hit
  107569. */
  107570. get hitDistance(): number;
  107571. /**
  107572. * Gets the hit normal/direction in the world
  107573. */
  107574. get hitNormalWorld(): Vector3;
  107575. /**
  107576. * Gets the hit point in the world
  107577. */
  107578. get hitPointWorld(): Vector3;
  107579. /**
  107580. * Gets the ray "start point" of the ray in the world
  107581. */
  107582. get rayFromWorld(): Vector3;
  107583. /**
  107584. * Gets the ray "end point" of the ray in the world
  107585. */
  107586. get rayToWorld(): Vector3;
  107587. /**
  107588. * Sets the hit data (normal & point in world space)
  107589. * @param hitNormalWorld defines the normal in world space
  107590. * @param hitPointWorld defines the point in world space
  107591. */
  107592. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107593. /**
  107594. * Sets the distance from the start point to the hit point
  107595. * @param distance
  107596. */
  107597. setHitDistance(distance: number): void;
  107598. /**
  107599. * Calculates the distance manually
  107600. */
  107601. calculateHitDistance(): void;
  107602. /**
  107603. * Resets all the values to default
  107604. * @param from The from point on world space
  107605. * @param to The to point on world space
  107606. */
  107607. reset(from?: Vector3, to?: Vector3): void;
  107608. }
  107609. /**
  107610. * Interface for the size containing width and height
  107611. */
  107612. interface IXYZ {
  107613. /**
  107614. * X
  107615. */
  107616. x: number;
  107617. /**
  107618. * Y
  107619. */
  107620. y: number;
  107621. /**
  107622. * Z
  107623. */
  107624. z: number;
  107625. }
  107626. }
  107627. declare module BABYLON {
  107628. /**
  107629. * Interface used to describe a physics joint
  107630. */
  107631. export interface PhysicsImpostorJoint {
  107632. /** Defines the main impostor to which the joint is linked */
  107633. mainImpostor: PhysicsImpostor;
  107634. /** Defines the impostor that is connected to the main impostor using this joint */
  107635. connectedImpostor: PhysicsImpostor;
  107636. /** Defines the joint itself */
  107637. joint: PhysicsJoint;
  107638. }
  107639. /** @hidden */
  107640. export interface IPhysicsEnginePlugin {
  107641. world: any;
  107642. name: string;
  107643. setGravity(gravity: Vector3): void;
  107644. setTimeStep(timeStep: number): void;
  107645. getTimeStep(): number;
  107646. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107647. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107648. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107649. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107650. removePhysicsBody(impostor: PhysicsImpostor): void;
  107651. generateJoint(joint: PhysicsImpostorJoint): void;
  107652. removeJoint(joint: PhysicsImpostorJoint): void;
  107653. isSupported(): boolean;
  107654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107656. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107657. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107659. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107661. getBodyMass(impostor: PhysicsImpostor): number;
  107662. getBodyFriction(impostor: PhysicsImpostor): number;
  107663. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107664. getBodyRestitution(impostor: PhysicsImpostor): number;
  107665. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107666. getBodyPressure?(impostor: PhysicsImpostor): number;
  107667. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107668. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107669. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107670. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107671. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107672. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107673. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107674. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107675. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107676. sleepBody(impostor: PhysicsImpostor): void;
  107677. wakeUpBody(impostor: PhysicsImpostor): void;
  107678. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107680. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107681. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107682. getRadius(impostor: PhysicsImpostor): number;
  107683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107684. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107685. dispose(): void;
  107686. }
  107687. /**
  107688. * Interface used to define a physics engine
  107689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107690. */
  107691. export interface IPhysicsEngine {
  107692. /**
  107693. * Gets the gravity vector used by the simulation
  107694. */
  107695. gravity: Vector3;
  107696. /**
  107697. * Sets the gravity vector used by the simulation
  107698. * @param gravity defines the gravity vector to use
  107699. */
  107700. setGravity(gravity: Vector3): void;
  107701. /**
  107702. * Set the time step of the physics engine.
  107703. * Default is 1/60.
  107704. * To slow it down, enter 1/600 for example.
  107705. * To speed it up, 1/30
  107706. * @param newTimeStep the new timestep to apply to this world.
  107707. */
  107708. setTimeStep(newTimeStep: number): void;
  107709. /**
  107710. * Get the time step of the physics engine.
  107711. * @returns the current time step
  107712. */
  107713. getTimeStep(): number;
  107714. /**
  107715. * Set the sub time step of the physics engine.
  107716. * Default is 0 meaning there is no sub steps
  107717. * To increase physics resolution precision, set a small value (like 1 ms)
  107718. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107719. */
  107720. setSubTimeStep(subTimeStep: number): void;
  107721. /**
  107722. * Get the sub time step of the physics engine.
  107723. * @returns the current sub time step
  107724. */
  107725. getSubTimeStep(): number;
  107726. /**
  107727. * Release all resources
  107728. */
  107729. dispose(): void;
  107730. /**
  107731. * Gets the name of the current physics plugin
  107732. * @returns the name of the plugin
  107733. */
  107734. getPhysicsPluginName(): string;
  107735. /**
  107736. * Adding a new impostor for the impostor tracking.
  107737. * This will be done by the impostor itself.
  107738. * @param impostor the impostor to add
  107739. */
  107740. addImpostor(impostor: PhysicsImpostor): void;
  107741. /**
  107742. * Remove an impostor from the engine.
  107743. * This impostor and its mesh will not longer be updated by the physics engine.
  107744. * @param impostor the impostor to remove
  107745. */
  107746. removeImpostor(impostor: PhysicsImpostor): void;
  107747. /**
  107748. * Add a joint to the physics engine
  107749. * @param mainImpostor defines the main impostor to which the joint is added.
  107750. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107751. * @param joint defines the joint that will connect both impostors.
  107752. */
  107753. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107754. /**
  107755. * Removes a joint from the simulation
  107756. * @param mainImpostor defines the impostor used with the joint
  107757. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107758. * @param joint defines the joint to remove
  107759. */
  107760. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107761. /**
  107762. * Gets the current plugin used to run the simulation
  107763. * @returns current plugin
  107764. */
  107765. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107766. /**
  107767. * Gets the list of physic impostors
  107768. * @returns an array of PhysicsImpostor
  107769. */
  107770. getImpostors(): Array<PhysicsImpostor>;
  107771. /**
  107772. * Gets the impostor for a physics enabled object
  107773. * @param object defines the object impersonated by the impostor
  107774. * @returns the PhysicsImpostor or null if not found
  107775. */
  107776. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107777. /**
  107778. * Gets the impostor for a physics body object
  107779. * @param body defines physics body used by the impostor
  107780. * @returns the PhysicsImpostor or null if not found
  107781. */
  107782. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107783. /**
  107784. * Does a raycast in the physics world
  107785. * @param from when should the ray start?
  107786. * @param to when should the ray end?
  107787. * @returns PhysicsRaycastResult
  107788. */
  107789. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107790. /**
  107791. * Called by the scene. No need to call it.
  107792. * @param delta defines the timespam between frames
  107793. */
  107794. _step(delta: number): void;
  107795. }
  107796. }
  107797. declare module BABYLON {
  107798. /**
  107799. * The interface for the physics imposter parameters
  107800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107801. */
  107802. export interface PhysicsImpostorParameters {
  107803. /**
  107804. * The mass of the physics imposter
  107805. */
  107806. mass: number;
  107807. /**
  107808. * The friction of the physics imposter
  107809. */
  107810. friction?: number;
  107811. /**
  107812. * The coefficient of restitution of the physics imposter
  107813. */
  107814. restitution?: number;
  107815. /**
  107816. * The native options of the physics imposter
  107817. */
  107818. nativeOptions?: any;
  107819. /**
  107820. * Specifies if the parent should be ignored
  107821. */
  107822. ignoreParent?: boolean;
  107823. /**
  107824. * Specifies if bi-directional transformations should be disabled
  107825. */
  107826. disableBidirectionalTransformation?: boolean;
  107827. /**
  107828. * The pressure inside the physics imposter, soft object only
  107829. */
  107830. pressure?: number;
  107831. /**
  107832. * The stiffness the physics imposter, soft object only
  107833. */
  107834. stiffness?: number;
  107835. /**
  107836. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107837. */
  107838. velocityIterations?: number;
  107839. /**
  107840. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107841. */
  107842. positionIterations?: number;
  107843. /**
  107844. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107845. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107846. * Add to fix multiple points
  107847. */
  107848. fixedPoints?: number;
  107849. /**
  107850. * The collision margin around a soft object
  107851. */
  107852. margin?: number;
  107853. /**
  107854. * The collision margin around a soft object
  107855. */
  107856. damping?: number;
  107857. /**
  107858. * The path for a rope based on an extrusion
  107859. */
  107860. path?: any;
  107861. /**
  107862. * The shape of an extrusion used for a rope based on an extrusion
  107863. */
  107864. shape?: any;
  107865. }
  107866. /**
  107867. * Interface for a physics-enabled object
  107868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107869. */
  107870. export interface IPhysicsEnabledObject {
  107871. /**
  107872. * The position of the physics-enabled object
  107873. */
  107874. position: Vector3;
  107875. /**
  107876. * The rotation of the physics-enabled object
  107877. */
  107878. rotationQuaternion: Nullable<Quaternion>;
  107879. /**
  107880. * The scale of the physics-enabled object
  107881. */
  107882. scaling: Vector3;
  107883. /**
  107884. * The rotation of the physics-enabled object
  107885. */
  107886. rotation?: Vector3;
  107887. /**
  107888. * The parent of the physics-enabled object
  107889. */
  107890. parent?: any;
  107891. /**
  107892. * The bounding info of the physics-enabled object
  107893. * @returns The bounding info of the physics-enabled object
  107894. */
  107895. getBoundingInfo(): BoundingInfo;
  107896. /**
  107897. * Computes the world matrix
  107898. * @param force Specifies if the world matrix should be computed by force
  107899. * @returns A world matrix
  107900. */
  107901. computeWorldMatrix(force: boolean): Matrix;
  107902. /**
  107903. * Gets the world matrix
  107904. * @returns A world matrix
  107905. */
  107906. getWorldMatrix?(): Matrix;
  107907. /**
  107908. * Gets the child meshes
  107909. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107910. * @returns An array of abstract meshes
  107911. */
  107912. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107913. /**
  107914. * Gets the vertex data
  107915. * @param kind The type of vertex data
  107916. * @returns A nullable array of numbers, or a float32 array
  107917. */
  107918. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107919. /**
  107920. * Gets the indices from the mesh
  107921. * @returns A nullable array of index arrays
  107922. */
  107923. getIndices?(): Nullable<IndicesArray>;
  107924. /**
  107925. * Gets the scene from the mesh
  107926. * @returns the indices array or null
  107927. */
  107928. getScene?(): Scene;
  107929. /**
  107930. * Gets the absolute position from the mesh
  107931. * @returns the absolute position
  107932. */
  107933. getAbsolutePosition(): Vector3;
  107934. /**
  107935. * Gets the absolute pivot point from the mesh
  107936. * @returns the absolute pivot point
  107937. */
  107938. getAbsolutePivotPoint(): Vector3;
  107939. /**
  107940. * Rotates the mesh
  107941. * @param axis The axis of rotation
  107942. * @param amount The amount of rotation
  107943. * @param space The space of the rotation
  107944. * @returns The rotation transform node
  107945. */
  107946. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107947. /**
  107948. * Translates the mesh
  107949. * @param axis The axis of translation
  107950. * @param distance The distance of translation
  107951. * @param space The space of the translation
  107952. * @returns The transform node
  107953. */
  107954. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107955. /**
  107956. * Sets the absolute position of the mesh
  107957. * @param absolutePosition The absolute position of the mesh
  107958. * @returns The transform node
  107959. */
  107960. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107961. /**
  107962. * Gets the class name of the mesh
  107963. * @returns The class name
  107964. */
  107965. getClassName(): string;
  107966. }
  107967. /**
  107968. * Represents a physics imposter
  107969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107970. */
  107971. export class PhysicsImpostor {
  107972. /**
  107973. * The physics-enabled object used as the physics imposter
  107974. */
  107975. object: IPhysicsEnabledObject;
  107976. /**
  107977. * The type of the physics imposter
  107978. */
  107979. type: number;
  107980. private _options;
  107981. private _scene?;
  107982. /**
  107983. * The default object size of the imposter
  107984. */
  107985. static DEFAULT_OBJECT_SIZE: Vector3;
  107986. /**
  107987. * The identity quaternion of the imposter
  107988. */
  107989. static IDENTITY_QUATERNION: Quaternion;
  107990. /** @hidden */
  107991. _pluginData: any;
  107992. private _physicsEngine;
  107993. private _physicsBody;
  107994. private _bodyUpdateRequired;
  107995. private _onBeforePhysicsStepCallbacks;
  107996. private _onAfterPhysicsStepCallbacks;
  107997. /** @hidden */
  107998. _onPhysicsCollideCallbacks: Array<{
  107999. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108000. otherImpostors: Array<PhysicsImpostor>;
  108001. }>;
  108002. private _deltaPosition;
  108003. private _deltaRotation;
  108004. private _deltaRotationConjugated;
  108005. /** @hidden */
  108006. _isFromLine: boolean;
  108007. private _parent;
  108008. private _isDisposed;
  108009. private static _tmpVecs;
  108010. private static _tmpQuat;
  108011. /**
  108012. * Specifies if the physics imposter is disposed
  108013. */
  108014. get isDisposed(): boolean;
  108015. /**
  108016. * Gets the mass of the physics imposter
  108017. */
  108018. get mass(): number;
  108019. set mass(value: number);
  108020. /**
  108021. * Gets the coefficient of friction
  108022. */
  108023. get friction(): number;
  108024. /**
  108025. * Sets the coefficient of friction
  108026. */
  108027. set friction(value: number);
  108028. /**
  108029. * Gets the coefficient of restitution
  108030. */
  108031. get restitution(): number;
  108032. /**
  108033. * Sets the coefficient of restitution
  108034. */
  108035. set restitution(value: number);
  108036. /**
  108037. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108038. */
  108039. get pressure(): number;
  108040. /**
  108041. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108042. */
  108043. set pressure(value: number);
  108044. /**
  108045. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108046. */
  108047. get stiffness(): number;
  108048. /**
  108049. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108050. */
  108051. set stiffness(value: number);
  108052. /**
  108053. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108054. */
  108055. get velocityIterations(): number;
  108056. /**
  108057. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108058. */
  108059. set velocityIterations(value: number);
  108060. /**
  108061. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108062. */
  108063. get positionIterations(): number;
  108064. /**
  108065. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108066. */
  108067. set positionIterations(value: number);
  108068. /**
  108069. * The unique id of the physics imposter
  108070. * set by the physics engine when adding this impostor to the array
  108071. */
  108072. uniqueId: number;
  108073. /**
  108074. * @hidden
  108075. */
  108076. soft: boolean;
  108077. /**
  108078. * @hidden
  108079. */
  108080. segments: number;
  108081. private _joints;
  108082. /**
  108083. * Initializes the physics imposter
  108084. * @param object The physics-enabled object used as the physics imposter
  108085. * @param type The type of the physics imposter
  108086. * @param _options The options for the physics imposter
  108087. * @param _scene The Babylon scene
  108088. */
  108089. constructor(
  108090. /**
  108091. * The physics-enabled object used as the physics imposter
  108092. */
  108093. object: IPhysicsEnabledObject,
  108094. /**
  108095. * The type of the physics imposter
  108096. */
  108097. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108098. /**
  108099. * This function will completly initialize this impostor.
  108100. * It will create a new body - but only if this mesh has no parent.
  108101. * If it has, this impostor will not be used other than to define the impostor
  108102. * of the child mesh.
  108103. * @hidden
  108104. */
  108105. _init(): void;
  108106. private _getPhysicsParent;
  108107. /**
  108108. * Should a new body be generated.
  108109. * @returns boolean specifying if body initialization is required
  108110. */
  108111. isBodyInitRequired(): boolean;
  108112. /**
  108113. * Sets the updated scaling
  108114. * @param updated Specifies if the scaling is updated
  108115. */
  108116. setScalingUpdated(): void;
  108117. /**
  108118. * Force a regeneration of this or the parent's impostor's body.
  108119. * Use under cautious - This will remove all joints already implemented.
  108120. */
  108121. forceUpdate(): void;
  108122. /**
  108123. * Gets the body that holds this impostor. Either its own, or its parent.
  108124. */
  108125. get physicsBody(): any;
  108126. /**
  108127. * Get the parent of the physics imposter
  108128. * @returns Physics imposter or null
  108129. */
  108130. get parent(): Nullable<PhysicsImpostor>;
  108131. /**
  108132. * Sets the parent of the physics imposter
  108133. */
  108134. set parent(value: Nullable<PhysicsImpostor>);
  108135. /**
  108136. * Set the physics body. Used mainly by the physics engine/plugin
  108137. */
  108138. set physicsBody(physicsBody: any);
  108139. /**
  108140. * Resets the update flags
  108141. */
  108142. resetUpdateFlags(): void;
  108143. /**
  108144. * Gets the object extend size
  108145. * @returns the object extend size
  108146. */
  108147. getObjectExtendSize(): Vector3;
  108148. /**
  108149. * Gets the object center
  108150. * @returns The object center
  108151. */
  108152. getObjectCenter(): Vector3;
  108153. /**
  108154. * Get a specific parameter from the options parameters
  108155. * @param paramName The object parameter name
  108156. * @returns The object parameter
  108157. */
  108158. getParam(paramName: string): any;
  108159. /**
  108160. * Sets a specific parameter in the options given to the physics plugin
  108161. * @param paramName The parameter name
  108162. * @param value The value of the parameter
  108163. */
  108164. setParam(paramName: string, value: number): void;
  108165. /**
  108166. * Specifically change the body's mass option. Won't recreate the physics body object
  108167. * @param mass The mass of the physics imposter
  108168. */
  108169. setMass(mass: number): void;
  108170. /**
  108171. * Gets the linear velocity
  108172. * @returns linear velocity or null
  108173. */
  108174. getLinearVelocity(): Nullable<Vector3>;
  108175. /**
  108176. * Sets the linear velocity
  108177. * @param velocity linear velocity or null
  108178. */
  108179. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108180. /**
  108181. * Gets the angular velocity
  108182. * @returns angular velocity or null
  108183. */
  108184. getAngularVelocity(): Nullable<Vector3>;
  108185. /**
  108186. * Sets the angular velocity
  108187. * @param velocity The velocity or null
  108188. */
  108189. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108190. /**
  108191. * Execute a function with the physics plugin native code
  108192. * Provide a function the will have two variables - the world object and the physics body object
  108193. * @param func The function to execute with the physics plugin native code
  108194. */
  108195. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108196. /**
  108197. * Register a function that will be executed before the physics world is stepping forward
  108198. * @param func The function to execute before the physics world is stepped forward
  108199. */
  108200. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108201. /**
  108202. * Unregister a function that will be executed before the physics world is stepping forward
  108203. * @param func The function to execute before the physics world is stepped forward
  108204. */
  108205. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108206. /**
  108207. * Register a function that will be executed after the physics step
  108208. * @param func The function to execute after physics step
  108209. */
  108210. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108211. /**
  108212. * Unregisters a function that will be executed after the physics step
  108213. * @param func The function to execute after physics step
  108214. */
  108215. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108216. /**
  108217. * register a function that will be executed when this impostor collides against a different body
  108218. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108219. * @param func Callback that is executed on collision
  108220. */
  108221. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108222. /**
  108223. * Unregisters the physics imposter on contact
  108224. * @param collideAgainst The physics object to collide against
  108225. * @param func Callback to execute on collision
  108226. */
  108227. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108228. private _tmpQuat;
  108229. private _tmpQuat2;
  108230. /**
  108231. * Get the parent rotation
  108232. * @returns The parent rotation
  108233. */
  108234. getParentsRotation(): Quaternion;
  108235. /**
  108236. * this function is executed by the physics engine.
  108237. */
  108238. beforeStep: () => void;
  108239. /**
  108240. * this function is executed by the physics engine
  108241. */
  108242. afterStep: () => void;
  108243. /**
  108244. * Legacy collision detection event support
  108245. */
  108246. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108247. /**
  108248. * event and body object due to cannon's event-based architecture.
  108249. */
  108250. onCollide: (e: {
  108251. body: any;
  108252. }) => void;
  108253. /**
  108254. * Apply a force
  108255. * @param force The force to apply
  108256. * @param contactPoint The contact point for the force
  108257. * @returns The physics imposter
  108258. */
  108259. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108260. /**
  108261. * Apply an impulse
  108262. * @param force The impulse force
  108263. * @param contactPoint The contact point for the impulse force
  108264. * @returns The physics imposter
  108265. */
  108266. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108267. /**
  108268. * A help function to create a joint
  108269. * @param otherImpostor A physics imposter used to create a joint
  108270. * @param jointType The type of joint
  108271. * @param jointData The data for the joint
  108272. * @returns The physics imposter
  108273. */
  108274. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108275. /**
  108276. * Add a joint to this impostor with a different impostor
  108277. * @param otherImpostor A physics imposter used to add a joint
  108278. * @param joint The joint to add
  108279. * @returns The physics imposter
  108280. */
  108281. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108282. /**
  108283. * Add an anchor to a cloth impostor
  108284. * @param otherImpostor rigid impostor to anchor to
  108285. * @param width ratio across width from 0 to 1
  108286. * @param height ratio up height from 0 to 1
  108287. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108288. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108289. * @returns impostor the soft imposter
  108290. */
  108291. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108292. /**
  108293. * Add a hook to a rope impostor
  108294. * @param otherImpostor rigid impostor to anchor to
  108295. * @param length ratio across rope from 0 to 1
  108296. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108297. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108298. * @returns impostor the rope imposter
  108299. */
  108300. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108301. /**
  108302. * Will keep this body still, in a sleep mode.
  108303. * @returns the physics imposter
  108304. */
  108305. sleep(): PhysicsImpostor;
  108306. /**
  108307. * Wake the body up.
  108308. * @returns The physics imposter
  108309. */
  108310. wakeUp(): PhysicsImpostor;
  108311. /**
  108312. * Clones the physics imposter
  108313. * @param newObject The physics imposter clones to this physics-enabled object
  108314. * @returns A nullable physics imposter
  108315. */
  108316. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108317. /**
  108318. * Disposes the physics imposter
  108319. */
  108320. dispose(): void;
  108321. /**
  108322. * Sets the delta position
  108323. * @param position The delta position amount
  108324. */
  108325. setDeltaPosition(position: Vector3): void;
  108326. /**
  108327. * Sets the delta rotation
  108328. * @param rotation The delta rotation amount
  108329. */
  108330. setDeltaRotation(rotation: Quaternion): void;
  108331. /**
  108332. * Gets the box size of the physics imposter and stores the result in the input parameter
  108333. * @param result Stores the box size
  108334. * @returns The physics imposter
  108335. */
  108336. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108337. /**
  108338. * Gets the radius of the physics imposter
  108339. * @returns Radius of the physics imposter
  108340. */
  108341. getRadius(): number;
  108342. /**
  108343. * Sync a bone with this impostor
  108344. * @param bone The bone to sync to the impostor.
  108345. * @param boneMesh The mesh that the bone is influencing.
  108346. * @param jointPivot The pivot of the joint / bone in local space.
  108347. * @param distToJoint Optional distance from the impostor to the joint.
  108348. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108349. */
  108350. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108351. /**
  108352. * Sync impostor to a bone
  108353. * @param bone The bone that the impostor will be synced to.
  108354. * @param boneMesh The mesh that the bone is influencing.
  108355. * @param jointPivot The pivot of the joint / bone in local space.
  108356. * @param distToJoint Optional distance from the impostor to the joint.
  108357. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108358. * @param boneAxis Optional vector3 axis the bone is aligned with
  108359. */
  108360. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108361. /**
  108362. * No-Imposter type
  108363. */
  108364. static NoImpostor: number;
  108365. /**
  108366. * Sphere-Imposter type
  108367. */
  108368. static SphereImpostor: number;
  108369. /**
  108370. * Box-Imposter type
  108371. */
  108372. static BoxImpostor: number;
  108373. /**
  108374. * Plane-Imposter type
  108375. */
  108376. static PlaneImpostor: number;
  108377. /**
  108378. * Mesh-imposter type
  108379. */
  108380. static MeshImpostor: number;
  108381. /**
  108382. * Capsule-Impostor type (Ammo.js plugin only)
  108383. */
  108384. static CapsuleImpostor: number;
  108385. /**
  108386. * Cylinder-Imposter type
  108387. */
  108388. static CylinderImpostor: number;
  108389. /**
  108390. * Particle-Imposter type
  108391. */
  108392. static ParticleImpostor: number;
  108393. /**
  108394. * Heightmap-Imposter type
  108395. */
  108396. static HeightmapImpostor: number;
  108397. /**
  108398. * ConvexHull-Impostor type (Ammo.js plugin only)
  108399. */
  108400. static ConvexHullImpostor: number;
  108401. /**
  108402. * Custom-Imposter type (Ammo.js plugin only)
  108403. */
  108404. static CustomImpostor: number;
  108405. /**
  108406. * Rope-Imposter type
  108407. */
  108408. static RopeImpostor: number;
  108409. /**
  108410. * Cloth-Imposter type
  108411. */
  108412. static ClothImpostor: number;
  108413. /**
  108414. * Softbody-Imposter type
  108415. */
  108416. static SoftbodyImpostor: number;
  108417. }
  108418. }
  108419. declare module BABYLON {
  108420. /**
  108421. * @hidden
  108422. **/
  108423. export class _CreationDataStorage {
  108424. closePath?: boolean;
  108425. closeArray?: boolean;
  108426. idx: number[];
  108427. dashSize: number;
  108428. gapSize: number;
  108429. path3D: Path3D;
  108430. pathArray: Vector3[][];
  108431. arc: number;
  108432. radius: number;
  108433. cap: number;
  108434. tessellation: number;
  108435. }
  108436. /**
  108437. * @hidden
  108438. **/
  108439. class _InstanceDataStorage {
  108440. visibleInstances: any;
  108441. batchCache: _InstancesBatch;
  108442. instancesBufferSize: number;
  108443. instancesBuffer: Nullable<Buffer>;
  108444. instancesData: Float32Array;
  108445. overridenInstanceCount: number;
  108446. isFrozen: boolean;
  108447. previousBatch: Nullable<_InstancesBatch>;
  108448. hardwareInstancedRendering: boolean;
  108449. sideOrientation: number;
  108450. manualUpdate: boolean;
  108451. previousRenderId: number;
  108452. }
  108453. /**
  108454. * @hidden
  108455. **/
  108456. export class _InstancesBatch {
  108457. mustReturn: boolean;
  108458. visibleInstances: Nullable<InstancedMesh[]>[];
  108459. renderSelf: boolean[];
  108460. hardwareInstancedRendering: boolean[];
  108461. }
  108462. /**
  108463. * @hidden
  108464. **/
  108465. class _ThinInstanceDataStorage {
  108466. instancesCount: number;
  108467. matrixBuffer: Nullable<Buffer>;
  108468. matrixBufferSize: number;
  108469. matrixData: Nullable<Float32Array>;
  108470. boundingVectors: Array<Vector3>;
  108471. worldMatrices: Nullable<Matrix[]>;
  108472. }
  108473. /**
  108474. * Class used to represent renderable models
  108475. */
  108476. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108477. /**
  108478. * Mesh side orientation : usually the external or front surface
  108479. */
  108480. static readonly FRONTSIDE: number;
  108481. /**
  108482. * Mesh side orientation : usually the internal or back surface
  108483. */
  108484. static readonly BACKSIDE: number;
  108485. /**
  108486. * Mesh side orientation : both internal and external or front and back surfaces
  108487. */
  108488. static readonly DOUBLESIDE: number;
  108489. /**
  108490. * Mesh side orientation : by default, `FRONTSIDE`
  108491. */
  108492. static readonly DEFAULTSIDE: number;
  108493. /**
  108494. * Mesh cap setting : no cap
  108495. */
  108496. static readonly NO_CAP: number;
  108497. /**
  108498. * Mesh cap setting : one cap at the beginning of the mesh
  108499. */
  108500. static readonly CAP_START: number;
  108501. /**
  108502. * Mesh cap setting : one cap at the end of the mesh
  108503. */
  108504. static readonly CAP_END: number;
  108505. /**
  108506. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108507. */
  108508. static readonly CAP_ALL: number;
  108509. /**
  108510. * Mesh pattern setting : no flip or rotate
  108511. */
  108512. static readonly NO_FLIP: number;
  108513. /**
  108514. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108515. */
  108516. static readonly FLIP_TILE: number;
  108517. /**
  108518. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108519. */
  108520. static readonly ROTATE_TILE: number;
  108521. /**
  108522. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108523. */
  108524. static readonly FLIP_ROW: number;
  108525. /**
  108526. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108527. */
  108528. static readonly ROTATE_ROW: number;
  108529. /**
  108530. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108531. */
  108532. static readonly FLIP_N_ROTATE_TILE: number;
  108533. /**
  108534. * Mesh pattern setting : rotate pattern and rotate
  108535. */
  108536. static readonly FLIP_N_ROTATE_ROW: number;
  108537. /**
  108538. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108539. */
  108540. static readonly CENTER: number;
  108541. /**
  108542. * Mesh tile positioning : part tiles on left
  108543. */
  108544. static readonly LEFT: number;
  108545. /**
  108546. * Mesh tile positioning : part tiles on right
  108547. */
  108548. static readonly RIGHT: number;
  108549. /**
  108550. * Mesh tile positioning : part tiles on top
  108551. */
  108552. static readonly TOP: number;
  108553. /**
  108554. * Mesh tile positioning : part tiles on bottom
  108555. */
  108556. static readonly BOTTOM: number;
  108557. /**
  108558. * Gets the default side orientation.
  108559. * @param orientation the orientation to value to attempt to get
  108560. * @returns the default orientation
  108561. * @hidden
  108562. */
  108563. static _GetDefaultSideOrientation(orientation?: number): number;
  108564. private _internalMeshDataInfo;
  108565. get computeBonesUsingShaders(): boolean;
  108566. set computeBonesUsingShaders(value: boolean);
  108567. /**
  108568. * An event triggered before rendering the mesh
  108569. */
  108570. get onBeforeRenderObservable(): Observable<Mesh>;
  108571. /**
  108572. * An event triggered before binding the mesh
  108573. */
  108574. get onBeforeBindObservable(): Observable<Mesh>;
  108575. /**
  108576. * An event triggered after rendering the mesh
  108577. */
  108578. get onAfterRenderObservable(): Observable<Mesh>;
  108579. /**
  108580. * An event triggered before drawing the mesh
  108581. */
  108582. get onBeforeDrawObservable(): Observable<Mesh>;
  108583. private _onBeforeDrawObserver;
  108584. /**
  108585. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108586. */
  108587. set onBeforeDraw(callback: () => void);
  108588. get hasInstances(): boolean;
  108589. get hasThinInstances(): boolean;
  108590. /**
  108591. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108592. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108593. */
  108594. delayLoadState: number;
  108595. /**
  108596. * Gets the list of instances created from this mesh
  108597. * it is not supposed to be modified manually.
  108598. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108600. */
  108601. instances: InstancedMesh[];
  108602. /**
  108603. * Gets the file containing delay loading data for this mesh
  108604. */
  108605. delayLoadingFile: string;
  108606. /** @hidden */
  108607. _binaryInfo: any;
  108608. /**
  108609. * User defined function used to change how LOD level selection is done
  108610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108611. */
  108612. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108613. /**
  108614. * Gets or sets the morph target manager
  108615. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108616. */
  108617. get morphTargetManager(): Nullable<MorphTargetManager>;
  108618. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108619. /** @hidden */
  108620. _creationDataStorage: Nullable<_CreationDataStorage>;
  108621. /** @hidden */
  108622. _geometry: Nullable<Geometry>;
  108623. /** @hidden */
  108624. _delayInfo: Array<string>;
  108625. /** @hidden */
  108626. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108627. /** @hidden */
  108628. _instanceDataStorage: _InstanceDataStorage;
  108629. /** @hidden */
  108630. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108631. private _effectiveMaterial;
  108632. /** @hidden */
  108633. _shouldGenerateFlatShading: boolean;
  108634. /** @hidden */
  108635. _originalBuilderSideOrientation: number;
  108636. /**
  108637. * Use this property to change the original side orientation defined at construction time
  108638. */
  108639. overrideMaterialSideOrientation: Nullable<number>;
  108640. /**
  108641. * Gets the source mesh (the one used to clone this one from)
  108642. */
  108643. get source(): Nullable<Mesh>;
  108644. /**
  108645. * Gets the list of clones of this mesh
  108646. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108647. * Note that useClonedMeshMap=true is the default setting
  108648. */
  108649. get cloneMeshMap(): Nullable<{
  108650. [id: string]: Mesh | undefined;
  108651. }>;
  108652. /**
  108653. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108654. */
  108655. get isUnIndexed(): boolean;
  108656. set isUnIndexed(value: boolean);
  108657. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108658. get worldMatrixInstancedBuffer(): Float32Array;
  108659. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108660. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108661. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108662. /**
  108663. * @constructor
  108664. * @param name The value used by scene.getMeshByName() to do a lookup.
  108665. * @param scene The scene to add this mesh to.
  108666. * @param parent The parent of this mesh, if it has one
  108667. * @param source An optional Mesh from which geometry is shared, cloned.
  108668. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108669. * When false, achieved by calling a clone(), also passing False.
  108670. * This will make creation of children, recursive.
  108671. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108672. */
  108673. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108674. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108675. doNotInstantiate: boolean;
  108676. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108677. /**
  108678. * Gets the class name
  108679. * @returns the string "Mesh".
  108680. */
  108681. getClassName(): string;
  108682. /** @hidden */
  108683. get _isMesh(): boolean;
  108684. /**
  108685. * Returns a description of this mesh
  108686. * @param fullDetails define if full details about this mesh must be used
  108687. * @returns a descriptive string representing this mesh
  108688. */
  108689. toString(fullDetails?: boolean): string;
  108690. /** @hidden */
  108691. _unBindEffect(): void;
  108692. /**
  108693. * Gets a boolean indicating if this mesh has LOD
  108694. */
  108695. get hasLODLevels(): boolean;
  108696. /**
  108697. * Gets the list of MeshLODLevel associated with the current mesh
  108698. * @returns an array of MeshLODLevel
  108699. */
  108700. getLODLevels(): MeshLODLevel[];
  108701. private _sortLODLevels;
  108702. /**
  108703. * Add a mesh as LOD level triggered at the given distance.
  108704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108705. * @param distance The distance from the center of the object to show this level
  108706. * @param mesh The mesh to be added as LOD level (can be null)
  108707. * @return This mesh (for chaining)
  108708. */
  108709. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108710. /**
  108711. * Returns the LOD level mesh at the passed distance or null if not found.
  108712. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108713. * @param distance The distance from the center of the object to show this level
  108714. * @returns a Mesh or `null`
  108715. */
  108716. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108717. /**
  108718. * Remove a mesh from the LOD array
  108719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108720. * @param mesh defines the mesh to be removed
  108721. * @return This mesh (for chaining)
  108722. */
  108723. removeLODLevel(mesh: Mesh): Mesh;
  108724. /**
  108725. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108727. * @param camera defines the camera to use to compute distance
  108728. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108729. * @return This mesh (for chaining)
  108730. */
  108731. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108732. /**
  108733. * Gets the mesh internal Geometry object
  108734. */
  108735. get geometry(): Nullable<Geometry>;
  108736. /**
  108737. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108738. * @returns the total number of vertices
  108739. */
  108740. getTotalVertices(): number;
  108741. /**
  108742. * Returns the content of an associated vertex buffer
  108743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108744. * - VertexBuffer.PositionKind
  108745. * - VertexBuffer.UVKind
  108746. * - VertexBuffer.UV2Kind
  108747. * - VertexBuffer.UV3Kind
  108748. * - VertexBuffer.UV4Kind
  108749. * - VertexBuffer.UV5Kind
  108750. * - VertexBuffer.UV6Kind
  108751. * - VertexBuffer.ColorKind
  108752. * - VertexBuffer.MatricesIndicesKind
  108753. * - VertexBuffer.MatricesIndicesExtraKind
  108754. * - VertexBuffer.MatricesWeightsKind
  108755. * - VertexBuffer.MatricesWeightsExtraKind
  108756. * @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
  108757. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108758. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108759. */
  108760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108761. /**
  108762. * Returns the mesh VertexBuffer object from the requested `kind`
  108763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108764. * - VertexBuffer.PositionKind
  108765. * - VertexBuffer.NormalKind
  108766. * - VertexBuffer.UVKind
  108767. * - VertexBuffer.UV2Kind
  108768. * - VertexBuffer.UV3Kind
  108769. * - VertexBuffer.UV4Kind
  108770. * - VertexBuffer.UV5Kind
  108771. * - VertexBuffer.UV6Kind
  108772. * - VertexBuffer.ColorKind
  108773. * - VertexBuffer.MatricesIndicesKind
  108774. * - VertexBuffer.MatricesIndicesExtraKind
  108775. * - VertexBuffer.MatricesWeightsKind
  108776. * - VertexBuffer.MatricesWeightsExtraKind
  108777. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108778. */
  108779. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108780. /**
  108781. * Tests if a specific vertex buffer is associated with this mesh
  108782. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108783. * - VertexBuffer.PositionKind
  108784. * - VertexBuffer.NormalKind
  108785. * - VertexBuffer.UVKind
  108786. * - VertexBuffer.UV2Kind
  108787. * - VertexBuffer.UV3Kind
  108788. * - VertexBuffer.UV4Kind
  108789. * - VertexBuffer.UV5Kind
  108790. * - VertexBuffer.UV6Kind
  108791. * - VertexBuffer.ColorKind
  108792. * - VertexBuffer.MatricesIndicesKind
  108793. * - VertexBuffer.MatricesIndicesExtraKind
  108794. * - VertexBuffer.MatricesWeightsKind
  108795. * - VertexBuffer.MatricesWeightsExtraKind
  108796. * @returns a boolean
  108797. */
  108798. isVerticesDataPresent(kind: string): boolean;
  108799. /**
  108800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108801. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108802. * - VertexBuffer.PositionKind
  108803. * - VertexBuffer.UVKind
  108804. * - VertexBuffer.UV2Kind
  108805. * - VertexBuffer.UV3Kind
  108806. * - VertexBuffer.UV4Kind
  108807. * - VertexBuffer.UV5Kind
  108808. * - VertexBuffer.UV6Kind
  108809. * - VertexBuffer.ColorKind
  108810. * - VertexBuffer.MatricesIndicesKind
  108811. * - VertexBuffer.MatricesIndicesExtraKind
  108812. * - VertexBuffer.MatricesWeightsKind
  108813. * - VertexBuffer.MatricesWeightsExtraKind
  108814. * @returns a boolean
  108815. */
  108816. isVertexBufferUpdatable(kind: string): boolean;
  108817. /**
  108818. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108819. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108820. * - VertexBuffer.PositionKind
  108821. * - VertexBuffer.NormalKind
  108822. * - VertexBuffer.UVKind
  108823. * - VertexBuffer.UV2Kind
  108824. * - VertexBuffer.UV3Kind
  108825. * - VertexBuffer.UV4Kind
  108826. * - VertexBuffer.UV5Kind
  108827. * - VertexBuffer.UV6Kind
  108828. * - VertexBuffer.ColorKind
  108829. * - VertexBuffer.MatricesIndicesKind
  108830. * - VertexBuffer.MatricesIndicesExtraKind
  108831. * - VertexBuffer.MatricesWeightsKind
  108832. * - VertexBuffer.MatricesWeightsExtraKind
  108833. * @returns an array of strings
  108834. */
  108835. getVerticesDataKinds(): string[];
  108836. /**
  108837. * Returns a positive integer : the total number of indices in this mesh geometry.
  108838. * @returns the numner of indices or zero if the mesh has no geometry.
  108839. */
  108840. getTotalIndices(): number;
  108841. /**
  108842. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108843. * @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.
  108844. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108845. * @returns the indices array or an empty array if the mesh has no geometry
  108846. */
  108847. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108848. get isBlocked(): boolean;
  108849. /**
  108850. * Determine if the current mesh is ready to be rendered
  108851. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108852. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108853. * @returns true if all associated assets are ready (material, textures, shaders)
  108854. */
  108855. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108856. /**
  108857. * 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.
  108858. */
  108859. get areNormalsFrozen(): boolean;
  108860. /**
  108861. * 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.
  108862. * @returns the current mesh
  108863. */
  108864. freezeNormals(): Mesh;
  108865. /**
  108866. * 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
  108867. * @returns the current mesh
  108868. */
  108869. unfreezeNormals(): Mesh;
  108870. /**
  108871. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108872. */
  108873. set overridenInstanceCount(count: number);
  108874. /** @hidden */
  108875. _preActivate(): Mesh;
  108876. /** @hidden */
  108877. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108878. /** @hidden */
  108879. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108880. protected _afterComputeWorldMatrix(): void;
  108881. /** @hidden */
  108882. _postActivate(): void;
  108883. /**
  108884. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108885. * This means the mesh underlying bounding box and sphere are recomputed.
  108886. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108887. * @returns the current mesh
  108888. */
  108889. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108890. /** @hidden */
  108891. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108892. /**
  108893. * This function will subdivide the mesh into multiple submeshes
  108894. * @param count defines the expected number of submeshes
  108895. */
  108896. subdivide(count: number): void;
  108897. /**
  108898. * Copy a FloatArray into a specific associated vertex buffer
  108899. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108900. * - VertexBuffer.PositionKind
  108901. * - VertexBuffer.UVKind
  108902. * - VertexBuffer.UV2Kind
  108903. * - VertexBuffer.UV3Kind
  108904. * - VertexBuffer.UV4Kind
  108905. * - VertexBuffer.UV5Kind
  108906. * - VertexBuffer.UV6Kind
  108907. * - VertexBuffer.ColorKind
  108908. * - VertexBuffer.MatricesIndicesKind
  108909. * - VertexBuffer.MatricesIndicesExtraKind
  108910. * - VertexBuffer.MatricesWeightsKind
  108911. * - VertexBuffer.MatricesWeightsExtraKind
  108912. * @param data defines the data source
  108913. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108914. * @param stride defines the data stride size (can be null)
  108915. * @returns the current mesh
  108916. */
  108917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108918. /**
  108919. * Delete a vertex buffer associated with this mesh
  108920. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108921. * - VertexBuffer.PositionKind
  108922. * - VertexBuffer.UVKind
  108923. * - VertexBuffer.UV2Kind
  108924. * - VertexBuffer.UV3Kind
  108925. * - VertexBuffer.UV4Kind
  108926. * - VertexBuffer.UV5Kind
  108927. * - VertexBuffer.UV6Kind
  108928. * - VertexBuffer.ColorKind
  108929. * - VertexBuffer.MatricesIndicesKind
  108930. * - VertexBuffer.MatricesIndicesExtraKind
  108931. * - VertexBuffer.MatricesWeightsKind
  108932. * - VertexBuffer.MatricesWeightsExtraKind
  108933. */
  108934. removeVerticesData(kind: string): void;
  108935. /**
  108936. * Flags an associated vertex buffer as updatable
  108937. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108938. * - VertexBuffer.PositionKind
  108939. * - VertexBuffer.UVKind
  108940. * - VertexBuffer.UV2Kind
  108941. * - VertexBuffer.UV3Kind
  108942. * - VertexBuffer.UV4Kind
  108943. * - VertexBuffer.UV5Kind
  108944. * - VertexBuffer.UV6Kind
  108945. * - VertexBuffer.ColorKind
  108946. * - VertexBuffer.MatricesIndicesKind
  108947. * - VertexBuffer.MatricesIndicesExtraKind
  108948. * - VertexBuffer.MatricesWeightsKind
  108949. * - VertexBuffer.MatricesWeightsExtraKind
  108950. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108951. */
  108952. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108953. /**
  108954. * Sets the mesh global Vertex Buffer
  108955. * @param buffer defines the buffer to use
  108956. * @returns the current mesh
  108957. */
  108958. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108959. /**
  108960. * Update a specific associated vertex buffer
  108961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108962. * - VertexBuffer.PositionKind
  108963. * - VertexBuffer.UVKind
  108964. * - VertexBuffer.UV2Kind
  108965. * - VertexBuffer.UV3Kind
  108966. * - VertexBuffer.UV4Kind
  108967. * - VertexBuffer.UV5Kind
  108968. * - VertexBuffer.UV6Kind
  108969. * - VertexBuffer.ColorKind
  108970. * - VertexBuffer.MatricesIndicesKind
  108971. * - VertexBuffer.MatricesIndicesExtraKind
  108972. * - VertexBuffer.MatricesWeightsKind
  108973. * - VertexBuffer.MatricesWeightsExtraKind
  108974. * @param data defines the data source
  108975. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108976. * @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)
  108977. * @returns the current mesh
  108978. */
  108979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108980. /**
  108981. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108982. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108983. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108984. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108985. * @returns the current mesh
  108986. */
  108987. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108988. /**
  108989. * Creates a un-shared specific occurence of the geometry for the mesh.
  108990. * @returns the current mesh
  108991. */
  108992. makeGeometryUnique(): Mesh;
  108993. /**
  108994. * Set the index buffer of this mesh
  108995. * @param indices defines the source data
  108996. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108997. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108998. * @returns the current mesh
  108999. */
  109000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109001. /**
  109002. * Update the current index buffer
  109003. * @param indices defines the source data
  109004. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109005. * @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)
  109006. * @returns the current mesh
  109007. */
  109008. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109009. /**
  109010. * Invert the geometry to move from a right handed system to a left handed one.
  109011. * @returns the current mesh
  109012. */
  109013. toLeftHanded(): Mesh;
  109014. /** @hidden */
  109015. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109016. /** @hidden */
  109017. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109018. /**
  109019. * Registers for this mesh a javascript function called just before the rendering process
  109020. * @param func defines the function to call before rendering this mesh
  109021. * @returns the current mesh
  109022. */
  109023. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109024. /**
  109025. * Disposes a previously registered javascript function called before the rendering
  109026. * @param func defines the function to remove
  109027. * @returns the current mesh
  109028. */
  109029. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109030. /**
  109031. * Registers for this mesh a javascript function called just after the rendering is complete
  109032. * @param func defines the function to call after rendering this mesh
  109033. * @returns the current mesh
  109034. */
  109035. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109036. /**
  109037. * Disposes a previously registered javascript function called after the rendering.
  109038. * @param func defines the function to remove
  109039. * @returns the current mesh
  109040. */
  109041. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109042. /** @hidden */
  109043. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109044. /** @hidden */
  109045. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109046. /** @hidden */
  109047. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109048. /** @hidden */
  109049. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109050. /** @hidden */
  109051. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109052. /** @hidden */
  109053. _rebuild(): void;
  109054. /** @hidden */
  109055. _freeze(): void;
  109056. /** @hidden */
  109057. _unFreeze(): void;
  109058. /**
  109059. * 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
  109060. * @param subMesh defines the subMesh to render
  109061. * @param enableAlphaMode defines if alpha mode can be changed
  109062. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109063. * @returns the current mesh
  109064. */
  109065. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109066. private _onBeforeDraw;
  109067. /**
  109068. * Renormalize the mesh and patch it up if there are no weights
  109069. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109070. * However in the case of zero weights then we set just a single influence to 1.
  109071. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109072. */
  109073. cleanMatrixWeights(): void;
  109074. private normalizeSkinFourWeights;
  109075. private normalizeSkinWeightsAndExtra;
  109076. /**
  109077. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109078. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109079. * the user know there was an issue with importing the mesh
  109080. * @returns a validation object with skinned, valid and report string
  109081. */
  109082. validateSkinning(): {
  109083. skinned: boolean;
  109084. valid: boolean;
  109085. report: string;
  109086. };
  109087. /** @hidden */
  109088. _checkDelayState(): Mesh;
  109089. private _queueLoad;
  109090. /**
  109091. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109092. * A mesh is in the frustum if its bounding box intersects the frustum
  109093. * @param frustumPlanes defines the frustum to test
  109094. * @returns true if the mesh is in the frustum planes
  109095. */
  109096. isInFrustum(frustumPlanes: Plane[]): boolean;
  109097. /**
  109098. * Sets the mesh material by the material or multiMaterial `id` property
  109099. * @param id is a string identifying the material or the multiMaterial
  109100. * @returns the current mesh
  109101. */
  109102. setMaterialByID(id: string): Mesh;
  109103. /**
  109104. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109105. * @returns an array of IAnimatable
  109106. */
  109107. getAnimatables(): IAnimatable[];
  109108. /**
  109109. * Modifies the mesh geometry according to the passed transformation matrix.
  109110. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109111. * The mesh normals are modified using the same transformation.
  109112. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109113. * @param transform defines the transform matrix to use
  109114. * @see https://doc.babylonjs.com/resources/baking_transformations
  109115. * @returns the current mesh
  109116. */
  109117. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109118. /**
  109119. * Modifies the mesh geometry according to its own current World Matrix.
  109120. * The mesh World Matrix is then reset.
  109121. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109122. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109123. * @see https://doc.babylonjs.com/resources/baking_transformations
  109124. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109125. * @returns the current mesh
  109126. */
  109127. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109128. /** @hidden */
  109129. get _positions(): Nullable<Vector3[]>;
  109130. /** @hidden */
  109131. _resetPointsArrayCache(): Mesh;
  109132. /** @hidden */
  109133. _generatePointsArray(): boolean;
  109134. /**
  109135. * Returns a new Mesh object generated from the current mesh properties.
  109136. * This method must not get confused with createInstance()
  109137. * @param name is a string, the name given to the new mesh
  109138. * @param newParent can be any Node object (default `null`)
  109139. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109140. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109141. * @returns a new mesh
  109142. */
  109143. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109144. /**
  109145. * Releases resources associated with this mesh.
  109146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109148. */
  109149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109150. /** @hidden */
  109151. _disposeInstanceSpecificData(): void;
  109152. /** @hidden */
  109153. _disposeThinInstanceSpecificData(): void;
  109154. /**
  109155. * Modifies the mesh geometry according to a displacement map.
  109156. * 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.
  109157. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109158. * @param url is a string, the URL from the image file is to be downloaded.
  109159. * @param minHeight is the lower limit of the displacement.
  109160. * @param maxHeight is the upper limit of the displacement.
  109161. * @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.
  109162. * @param uvOffset is an optional vector2 used to offset UV.
  109163. * @param uvScale is an optional vector2 used to scale UV.
  109164. * @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.
  109165. * @returns the Mesh.
  109166. */
  109167. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109168. /**
  109169. * Modifies the mesh geometry according to a displacementMap buffer.
  109170. * 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.
  109171. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109172. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109173. * @param heightMapWidth is the width of the buffer image.
  109174. * @param heightMapHeight is the height of the buffer image.
  109175. * @param minHeight is the lower limit of the displacement.
  109176. * @param maxHeight is the upper limit of the displacement.
  109177. * @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.
  109178. * @param uvOffset is an optional vector2 used to offset UV.
  109179. * @param uvScale is an optional vector2 used to scale UV.
  109180. * @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.
  109181. * @returns the Mesh.
  109182. */
  109183. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109184. /**
  109185. * Modify the mesh to get a flat shading rendering.
  109186. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109187. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109188. * @returns current mesh
  109189. */
  109190. convertToFlatShadedMesh(): Mesh;
  109191. /**
  109192. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109193. * In other words, more vertices, no more indices and a single bigger VBO.
  109194. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109195. * @returns current mesh
  109196. */
  109197. convertToUnIndexedMesh(): Mesh;
  109198. /**
  109199. * Inverses facet orientations.
  109200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109201. * @param flipNormals will also inverts the normals
  109202. * @returns current mesh
  109203. */
  109204. flipFaces(flipNormals?: boolean): Mesh;
  109205. /**
  109206. * Increase the number of facets and hence vertices in a mesh
  109207. * Vertex normals are interpolated from existing vertex normals
  109208. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109209. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109210. */
  109211. increaseVertices(numberPerEdge: number): void;
  109212. /**
  109213. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109214. * This will undo any application of covertToFlatShadedMesh
  109215. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109216. */
  109217. forceSharedVertices(): void;
  109218. /** @hidden */
  109219. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109220. /** @hidden */
  109221. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109222. /**
  109223. * Creates a new InstancedMesh object from the mesh model.
  109224. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109225. * @param name defines the name of the new instance
  109226. * @returns a new InstancedMesh
  109227. */
  109228. createInstance(name: string): InstancedMesh;
  109229. /**
  109230. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109231. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109232. * @returns the current mesh
  109233. */
  109234. synchronizeInstances(): Mesh;
  109235. /**
  109236. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109237. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109238. * This should be used together with the simplification to avoid disappearing triangles.
  109239. * @param successCallback an optional success callback to be called after the optimization finished.
  109240. * @returns the current mesh
  109241. */
  109242. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109243. /**
  109244. * Serialize current mesh
  109245. * @param serializationObject defines the object which will receive the serialization data
  109246. */
  109247. serialize(serializationObject: any): void;
  109248. /** @hidden */
  109249. _syncGeometryWithMorphTargetManager(): void;
  109250. /** @hidden */
  109251. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109252. /**
  109253. * Returns a new Mesh object parsed from the source provided.
  109254. * @param parsedMesh is the source
  109255. * @param scene defines the hosting scene
  109256. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109257. * @returns a new Mesh
  109258. */
  109259. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109260. /**
  109261. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109263. * @param name defines the name of the mesh to create
  109264. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109265. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109266. * @param closePath creates a seam between the first and the last points of each path of the path array
  109267. * @param offset is taken in account only if the `pathArray` is containing a single path
  109268. * @param scene defines the hosting scene
  109269. * @param updatable defines if the mesh must be flagged as updatable
  109270. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109271. * @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)
  109272. * @returns a new Mesh
  109273. */
  109274. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109275. /**
  109276. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109277. * @param name defines the name of the mesh to create
  109278. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109279. * @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
  109280. * @param scene defines the hosting scene
  109281. * @param updatable defines if the mesh must be flagged as updatable
  109282. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109283. * @returns a new Mesh
  109284. */
  109285. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109286. /**
  109287. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109288. * @param name defines the name of the mesh to create
  109289. * @param size sets the size (float) of each box side (default 1)
  109290. * @param scene defines the hosting scene
  109291. * @param updatable defines if the mesh must be flagged as updatable
  109292. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109293. * @returns a new Mesh
  109294. */
  109295. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109296. /**
  109297. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109298. * @param name defines the name of the mesh to create
  109299. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109300. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109301. * @param scene defines the hosting scene
  109302. * @param updatable defines if the mesh must be flagged as updatable
  109303. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109304. * @returns a new Mesh
  109305. */
  109306. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109307. /**
  109308. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109309. * @param name defines the name of the mesh to create
  109310. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109311. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109312. * @param scene defines the hosting scene
  109313. * @returns a new Mesh
  109314. */
  109315. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109316. /**
  109317. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109318. * @param name defines the name of the mesh to create
  109319. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109320. * @param diameterTop set the top cap diameter (floats, default 1)
  109321. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109322. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109323. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109324. * @param scene defines the hosting scene
  109325. * @param updatable defines if the mesh must be flagged as updatable
  109326. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109327. * @returns a new Mesh
  109328. */
  109329. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109330. /**
  109331. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109332. * @param name defines the name of the mesh to create
  109333. * @param diameter sets the diameter size (float) of the torus (default 1)
  109334. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109335. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109336. * @param scene defines the hosting scene
  109337. * @param updatable defines if the mesh must be flagged as updatable
  109338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109339. * @returns a new Mesh
  109340. */
  109341. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109342. /**
  109343. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109344. * @param name defines the name of the mesh to create
  109345. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109346. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109347. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109348. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109349. * @param p the number of windings on X axis (positive integers, default 2)
  109350. * @param q the number of windings on Y axis (positive integers, default 3)
  109351. * @param scene defines the hosting scene
  109352. * @param updatable defines if the mesh must be flagged as updatable
  109353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109354. * @returns a new Mesh
  109355. */
  109356. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109357. /**
  109358. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109359. * @param name defines the name of the mesh to create
  109360. * @param points is an array successive Vector3
  109361. * @param scene defines the hosting scene
  109362. * @param updatable defines if the mesh must be flagged as updatable
  109363. * @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).
  109364. * @returns a new Mesh
  109365. */
  109366. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109367. /**
  109368. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109369. * @param name defines the name of the mesh to create
  109370. * @param points is an array successive Vector3
  109371. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109372. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109373. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109374. * @param scene defines the hosting scene
  109375. * @param updatable defines if the mesh must be flagged as updatable
  109376. * @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)
  109377. * @returns a new Mesh
  109378. */
  109379. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109380. /**
  109381. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109382. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109383. * 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.
  109384. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109385. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109386. * Remember you can only change the shape positions, not their number when updating a polygon.
  109387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109388. * @param name defines the name of the mesh to create
  109389. * @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
  109390. * @param scene defines the hosting scene
  109391. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109392. * @param updatable defines if the mesh must be flagged as updatable
  109393. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109394. * @param earcutInjection can be used to inject your own earcut reference
  109395. * @returns a new Mesh
  109396. */
  109397. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109398. /**
  109399. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109401. * @param name defines the name of the mesh to create
  109402. * @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
  109403. * @param depth defines the height of extrusion
  109404. * @param scene defines the hosting scene
  109405. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109406. * @param updatable defines if the mesh must be flagged as updatable
  109407. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109408. * @param earcutInjection can be used to inject your own earcut reference
  109409. * @returns a new Mesh
  109410. */
  109411. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109412. /**
  109413. * Creates an extruded shape mesh.
  109414. * 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
  109415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109417. * @param name defines the name of the mesh to create
  109418. * @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
  109419. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109420. * @param scale is the value to scale the shape
  109421. * @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
  109422. * @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
  109423. * @param scene defines the hosting scene
  109424. * @param updatable defines if the mesh must be flagged as updatable
  109425. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109426. * @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)
  109427. * @returns a new Mesh
  109428. */
  109429. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109430. /**
  109431. * Creates an custom extruded shape mesh.
  109432. * The custom extrusion is a parametric shape.
  109433. * It has no predefined shape. Its final shape will depend on the input parameters.
  109434. * Please consider using the same method from the MeshBuilder class instead
  109435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109436. * @param name defines the name of the mesh to create
  109437. * @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
  109438. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109439. * @param scaleFunction is a custom Javascript function called on each path point
  109440. * @param rotationFunction is a custom Javascript function called on each path point
  109441. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109442. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109443. * @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
  109444. * @param scene defines the hosting scene
  109445. * @param updatable defines if the mesh must be flagged as updatable
  109446. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109447. * @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)
  109448. * @returns a new Mesh
  109449. */
  109450. 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;
  109451. /**
  109452. * Creates lathe mesh.
  109453. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109454. * Please consider using the same method from the MeshBuilder class instead
  109455. * @param name defines the name of the mesh to create
  109456. * @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
  109457. * @param radius is the radius value of the lathe
  109458. * @param tessellation is the side number of the lathe.
  109459. * @param scene defines the hosting scene
  109460. * @param updatable defines if the mesh must be flagged as updatable
  109461. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109462. * @returns a new Mesh
  109463. */
  109464. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109465. /**
  109466. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109467. * @param name defines the name of the mesh to create
  109468. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109469. * @param scene defines the hosting scene
  109470. * @param updatable defines if the mesh must be flagged as updatable
  109471. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109472. * @returns a new Mesh
  109473. */
  109474. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109475. /**
  109476. * Creates a ground mesh.
  109477. * Please consider using the same method from the MeshBuilder class instead
  109478. * @param name defines the name of the mesh to create
  109479. * @param width set the width of the ground
  109480. * @param height set the height of the ground
  109481. * @param subdivisions sets the number of subdivisions per side
  109482. * @param scene defines the hosting scene
  109483. * @param updatable defines if the mesh must be flagged as updatable
  109484. * @returns a new Mesh
  109485. */
  109486. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109487. /**
  109488. * Creates a tiled ground mesh.
  109489. * Please consider using the same method from the MeshBuilder class instead
  109490. * @param name defines the name of the mesh to create
  109491. * @param xmin set the ground minimum X coordinate
  109492. * @param zmin set the ground minimum Y coordinate
  109493. * @param xmax set the ground maximum X coordinate
  109494. * @param zmax set the ground maximum Z coordinate
  109495. * @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
  109496. * @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
  109497. * @param scene defines the hosting scene
  109498. * @param updatable defines if the mesh must be flagged as updatable
  109499. * @returns a new Mesh
  109500. */
  109501. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109502. w: number;
  109503. h: number;
  109504. }, precision: {
  109505. w: number;
  109506. h: number;
  109507. }, scene: Scene, updatable?: boolean): Mesh;
  109508. /**
  109509. * Creates a ground mesh from a height map.
  109510. * Please consider using the same method from the MeshBuilder class instead
  109511. * @see https://doc.babylonjs.com/babylon101/height_map
  109512. * @param name defines the name of the mesh to create
  109513. * @param url sets the URL of the height map image resource
  109514. * @param width set the ground width size
  109515. * @param height set the ground height size
  109516. * @param subdivisions sets the number of subdivision per side
  109517. * @param minHeight is the minimum altitude on the ground
  109518. * @param maxHeight is the maximum altitude on the ground
  109519. * @param scene defines the hosting scene
  109520. * @param updatable defines if the mesh must be flagged as updatable
  109521. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109522. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109523. * @returns a new Mesh
  109524. */
  109525. 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;
  109526. /**
  109527. * Creates a tube mesh.
  109528. * The tube is a parametric shape.
  109529. * It has no predefined shape. Its final shape will depend on the input parameters.
  109530. * Please consider using the same method from the MeshBuilder class instead
  109531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109532. * @param name defines the name of the mesh to create
  109533. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109534. * @param radius sets the tube radius size
  109535. * @param tessellation is the number of sides on the tubular surface
  109536. * @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
  109537. * @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
  109538. * @param scene defines the hosting scene
  109539. * @param updatable defines if the mesh must be flagged as updatable
  109540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109541. * @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)
  109542. * @returns a new Mesh
  109543. */
  109544. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109545. (i: number, distance: number): number;
  109546. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109547. /**
  109548. * Creates a polyhedron mesh.
  109549. * Please consider using the same method from the MeshBuilder class instead.
  109550. * * 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
  109551. * * The parameter `size` (positive float, default 1) sets the polygon size
  109552. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109553. * * 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`
  109554. * * 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
  109555. * * 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)`)
  109556. * * 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
  109557. * * 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
  109558. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109561. * @param name defines the name of the mesh to create
  109562. * @param options defines the options used to create the mesh
  109563. * @param scene defines the hosting scene
  109564. * @returns a new Mesh
  109565. */
  109566. static CreatePolyhedron(name: string, options: {
  109567. type?: number;
  109568. size?: number;
  109569. sizeX?: number;
  109570. sizeY?: number;
  109571. sizeZ?: number;
  109572. custom?: any;
  109573. faceUV?: Vector4[];
  109574. faceColors?: Color4[];
  109575. updatable?: boolean;
  109576. sideOrientation?: number;
  109577. }, scene: Scene): Mesh;
  109578. /**
  109579. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109580. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109581. * * 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`)
  109582. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109583. * * 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
  109584. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109587. * @param name defines the name of the mesh
  109588. * @param options defines the options used to create the mesh
  109589. * @param scene defines the hosting scene
  109590. * @returns a new Mesh
  109591. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109592. */
  109593. static CreateIcoSphere(name: string, options: {
  109594. radius?: number;
  109595. flat?: boolean;
  109596. subdivisions?: number;
  109597. sideOrientation?: number;
  109598. updatable?: boolean;
  109599. }, scene: Scene): Mesh;
  109600. /**
  109601. * Creates a decal mesh.
  109602. * Please consider using the same method from the MeshBuilder class instead.
  109603. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109604. * @param name defines the name of the mesh
  109605. * @param sourceMesh defines the mesh receiving the decal
  109606. * @param position sets the position of the decal in world coordinates
  109607. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109608. * @param size sets the decal scaling
  109609. * @param angle sets the angle to rotate the decal
  109610. * @returns a new Mesh
  109611. */
  109612. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109613. /** Creates a Capsule Mesh
  109614. * @param name defines the name of the mesh.
  109615. * @param options the constructors options used to shape the mesh.
  109616. * @param scene defines the scene the mesh is scoped to.
  109617. * @returns the capsule mesh
  109618. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109619. */
  109620. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109621. /**
  109622. * Prepare internal position array for software CPU skinning
  109623. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109624. */
  109625. setPositionsForCPUSkinning(): Float32Array;
  109626. /**
  109627. * Prepare internal normal array for software CPU skinning
  109628. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109629. */
  109630. setNormalsForCPUSkinning(): Float32Array;
  109631. /**
  109632. * Updates the vertex buffer by applying transformation from the bones
  109633. * @param skeleton defines the skeleton to apply to current mesh
  109634. * @returns the current mesh
  109635. */
  109636. applySkeleton(skeleton: Skeleton): Mesh;
  109637. /**
  109638. * 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
  109639. * @param meshes defines the list of meshes to scan
  109640. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109641. */
  109642. static MinMax(meshes: AbstractMesh[]): {
  109643. min: Vector3;
  109644. max: Vector3;
  109645. };
  109646. /**
  109647. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109648. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109649. * @returns a vector3
  109650. */
  109651. static Center(meshesOrMinMaxVector: {
  109652. min: Vector3;
  109653. max: Vector3;
  109654. } | AbstractMesh[]): Vector3;
  109655. /**
  109656. * Merge the array of meshes into a single mesh for performance reasons.
  109657. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109658. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109659. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109660. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109661. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109662. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109663. * @returns a new mesh
  109664. */
  109665. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109666. /** @hidden */
  109667. addInstance(instance: InstancedMesh): void;
  109668. /** @hidden */
  109669. removeInstance(instance: InstancedMesh): void;
  109670. }
  109671. }
  109672. declare module BABYLON {
  109673. /**
  109674. * This is the base class of all the camera used in the application.
  109675. * @see https://doc.babylonjs.com/features/cameras
  109676. */
  109677. export class Camera extends Node {
  109678. /** @hidden */
  109679. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109680. /**
  109681. * This is the default projection mode used by the cameras.
  109682. * It helps recreating a feeling of perspective and better appreciate depth.
  109683. * This is the best way to simulate real life cameras.
  109684. */
  109685. static readonly PERSPECTIVE_CAMERA: number;
  109686. /**
  109687. * This helps creating camera with an orthographic mode.
  109688. * 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.
  109689. */
  109690. static readonly ORTHOGRAPHIC_CAMERA: number;
  109691. /**
  109692. * This is the default FOV mode for perspective cameras.
  109693. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109694. */
  109695. static readonly FOVMODE_VERTICAL_FIXED: number;
  109696. /**
  109697. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109698. */
  109699. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109700. /**
  109701. * This specifies ther is no need for a camera rig.
  109702. * Basically only one eye is rendered corresponding to the camera.
  109703. */
  109704. static readonly RIG_MODE_NONE: number;
  109705. /**
  109706. * Simulates a camera Rig with one blue eye and one red eye.
  109707. * This can be use with 3d blue and red glasses.
  109708. */
  109709. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109710. /**
  109711. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109712. */
  109713. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109714. /**
  109715. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109716. */
  109717. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109718. /**
  109719. * Defines that both eyes of the camera will be rendered over under each other.
  109720. */
  109721. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109722. /**
  109723. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109724. */
  109725. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109726. /**
  109727. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109728. */
  109729. static readonly RIG_MODE_VR: number;
  109730. /**
  109731. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109732. */
  109733. static readonly RIG_MODE_WEBVR: number;
  109734. /**
  109735. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109736. */
  109737. static readonly RIG_MODE_CUSTOM: number;
  109738. /**
  109739. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109740. */
  109741. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109742. /**
  109743. * Define the input manager associated with the camera.
  109744. */
  109745. inputs: CameraInputsManager<Camera>;
  109746. /** @hidden */
  109747. _position: Vector3;
  109748. /**
  109749. * Define the current local position of the camera in the scene
  109750. */
  109751. get position(): Vector3;
  109752. set position(newPosition: Vector3);
  109753. protected _upVector: Vector3;
  109754. /**
  109755. * The vector the camera should consider as up.
  109756. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109757. */
  109758. set upVector(vec: Vector3);
  109759. get upVector(): Vector3;
  109760. /**
  109761. * Define the current limit on the left side for an orthographic camera
  109762. * In scene unit
  109763. */
  109764. orthoLeft: Nullable<number>;
  109765. /**
  109766. * Define the current limit on the right side for an orthographic camera
  109767. * In scene unit
  109768. */
  109769. orthoRight: Nullable<number>;
  109770. /**
  109771. * Define the current limit on the bottom side for an orthographic camera
  109772. * In scene unit
  109773. */
  109774. orthoBottom: Nullable<number>;
  109775. /**
  109776. * Define the current limit on the top side for an orthographic camera
  109777. * In scene unit
  109778. */
  109779. orthoTop: Nullable<number>;
  109780. /**
  109781. * Field Of View is set in Radians. (default is 0.8)
  109782. */
  109783. fov: number;
  109784. /**
  109785. * Define the minimum distance the camera can see from.
  109786. * This is important to note that the depth buffer are not infinite and the closer it starts
  109787. * the more your scene might encounter depth fighting issue.
  109788. */
  109789. minZ: number;
  109790. /**
  109791. * Define the maximum distance the camera can see to.
  109792. * This is important to note that the depth buffer are not infinite and the further it end
  109793. * the more your scene might encounter depth fighting issue.
  109794. */
  109795. maxZ: number;
  109796. /**
  109797. * Define the default inertia of the camera.
  109798. * This helps giving a smooth feeling to the camera movement.
  109799. */
  109800. inertia: number;
  109801. /**
  109802. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109803. */
  109804. mode: number;
  109805. /**
  109806. * Define whether the camera is intermediate.
  109807. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109808. */
  109809. isIntermediate: boolean;
  109810. /**
  109811. * Define the viewport of the camera.
  109812. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109813. */
  109814. viewport: Viewport;
  109815. /**
  109816. * Restricts the camera to viewing objects with the same layerMask.
  109817. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109818. */
  109819. layerMask: number;
  109820. /**
  109821. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109822. */
  109823. fovMode: number;
  109824. /**
  109825. * Rig mode of the camera.
  109826. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109827. * This is normally controlled byt the camera themselves as internal use.
  109828. */
  109829. cameraRigMode: number;
  109830. /**
  109831. * Defines the distance between both "eyes" in case of a RIG
  109832. */
  109833. interaxialDistance: number;
  109834. /**
  109835. * Defines if stereoscopic rendering is done side by side or over under.
  109836. */
  109837. isStereoscopicSideBySide: boolean;
  109838. /**
  109839. * 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
  109840. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109841. * else in the scene. (Eg. security camera)
  109842. *
  109843. * 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)
  109844. */
  109845. customRenderTargets: RenderTargetTexture[];
  109846. /**
  109847. * When set, the camera will render to this render target instead of the default canvas
  109848. *
  109849. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109850. */
  109851. outputRenderTarget: Nullable<RenderTargetTexture>;
  109852. /**
  109853. * Observable triggered when the camera view matrix has changed.
  109854. */
  109855. onViewMatrixChangedObservable: Observable<Camera>;
  109856. /**
  109857. * Observable triggered when the camera Projection matrix has changed.
  109858. */
  109859. onProjectionMatrixChangedObservable: Observable<Camera>;
  109860. /**
  109861. * Observable triggered when the inputs have been processed.
  109862. */
  109863. onAfterCheckInputsObservable: Observable<Camera>;
  109864. /**
  109865. * Observable triggered when reset has been called and applied to the camera.
  109866. */
  109867. onRestoreStateObservable: Observable<Camera>;
  109868. /**
  109869. * Is this camera a part of a rig system?
  109870. */
  109871. isRigCamera: boolean;
  109872. /**
  109873. * If isRigCamera set to true this will be set with the parent camera.
  109874. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109875. */
  109876. rigParent?: Camera;
  109877. /** @hidden */
  109878. _cameraRigParams: any;
  109879. /** @hidden */
  109880. _rigCameras: Camera[];
  109881. /** @hidden */
  109882. _rigPostProcess: Nullable<PostProcess>;
  109883. protected _webvrViewMatrix: Matrix;
  109884. /** @hidden */
  109885. _skipRendering: boolean;
  109886. /** @hidden */
  109887. _projectionMatrix: Matrix;
  109888. /** @hidden */
  109889. _postProcesses: Nullable<PostProcess>[];
  109890. /** @hidden */
  109891. _activeMeshes: SmartArray<AbstractMesh>;
  109892. protected _globalPosition: Vector3;
  109893. /** @hidden */
  109894. _computedViewMatrix: Matrix;
  109895. private _doNotComputeProjectionMatrix;
  109896. private _transformMatrix;
  109897. private _frustumPlanes;
  109898. private _refreshFrustumPlanes;
  109899. private _storedFov;
  109900. private _stateStored;
  109901. /**
  109902. * Instantiates a new camera object.
  109903. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109904. * @see https://doc.babylonjs.com/features/cameras
  109905. * @param name Defines the name of the camera in the scene
  109906. * @param position Defines the position of the camera
  109907. * @param scene Defines the scene the camera belongs too
  109908. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109909. */
  109910. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109911. /**
  109912. * Store current camera state (fov, position, etc..)
  109913. * @returns the camera
  109914. */
  109915. storeState(): Camera;
  109916. /**
  109917. * Restores the camera state values if it has been stored. You must call storeState() first
  109918. */
  109919. protected _restoreStateValues(): boolean;
  109920. /**
  109921. * Restored camera state. You must call storeState() first.
  109922. * @returns true if restored and false otherwise
  109923. */
  109924. restoreState(): boolean;
  109925. /**
  109926. * Gets the class name of the camera.
  109927. * @returns the class name
  109928. */
  109929. getClassName(): string;
  109930. /** @hidden */
  109931. readonly _isCamera: boolean;
  109932. /**
  109933. * Gets a string representation of the camera useful for debug purpose.
  109934. * @param fullDetails Defines that a more verboe level of logging is required
  109935. * @returns the string representation
  109936. */
  109937. toString(fullDetails?: boolean): string;
  109938. /**
  109939. * Gets the current world space position of the camera.
  109940. */
  109941. get globalPosition(): Vector3;
  109942. /**
  109943. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109944. * @returns the active meshe list
  109945. */
  109946. getActiveMeshes(): SmartArray<AbstractMesh>;
  109947. /**
  109948. * Check whether a mesh is part of the current active mesh list of the camera
  109949. * @param mesh Defines the mesh to check
  109950. * @returns true if active, false otherwise
  109951. */
  109952. isActiveMesh(mesh: Mesh): boolean;
  109953. /**
  109954. * Is this camera ready to be used/rendered
  109955. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109956. * @return true if the camera is ready
  109957. */
  109958. isReady(completeCheck?: boolean): boolean;
  109959. /** @hidden */
  109960. _initCache(): void;
  109961. /** @hidden */
  109962. _updateCache(ignoreParentClass?: boolean): void;
  109963. /** @hidden */
  109964. _isSynchronized(): boolean;
  109965. /** @hidden */
  109966. _isSynchronizedViewMatrix(): boolean;
  109967. /** @hidden */
  109968. _isSynchronizedProjectionMatrix(): boolean;
  109969. /**
  109970. * Attach the input controls to a specific dom element to get the input from.
  109971. * @param element Defines the element the controls should be listened from
  109972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109973. */
  109974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109975. /**
  109976. * Detach the current controls from the specified dom element.
  109977. * @param element Defines the element to stop listening the inputs from
  109978. */
  109979. detachControl(element: HTMLElement): void;
  109980. /**
  109981. * Update the camera state according to the different inputs gathered during the frame.
  109982. */
  109983. update(): void;
  109984. /** @hidden */
  109985. _checkInputs(): void;
  109986. /** @hidden */
  109987. get rigCameras(): Camera[];
  109988. /**
  109989. * Gets the post process used by the rig cameras
  109990. */
  109991. get rigPostProcess(): Nullable<PostProcess>;
  109992. /**
  109993. * Internal, gets the first post proces.
  109994. * @returns the first post process to be run on this camera.
  109995. */
  109996. _getFirstPostProcess(): Nullable<PostProcess>;
  109997. private _cascadePostProcessesToRigCams;
  109998. /**
  109999. * Attach a post process to the camera.
  110000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110001. * @param postProcess The post process to attach to the camera
  110002. * @param insertAt The position of the post process in case several of them are in use in the scene
  110003. * @returns the position the post process has been inserted at
  110004. */
  110005. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110006. /**
  110007. * Detach a post process to the camera.
  110008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110009. * @param postProcess The post process to detach from the camera
  110010. */
  110011. detachPostProcess(postProcess: PostProcess): void;
  110012. /**
  110013. * Gets the current world matrix of the camera
  110014. */
  110015. getWorldMatrix(): Matrix;
  110016. /** @hidden */
  110017. _getViewMatrix(): Matrix;
  110018. /**
  110019. * Gets the current view matrix of the camera.
  110020. * @param force forces the camera to recompute the matrix without looking at the cached state
  110021. * @returns the view matrix
  110022. */
  110023. getViewMatrix(force?: boolean): Matrix;
  110024. /**
  110025. * Freeze the projection matrix.
  110026. * It will prevent the cache check of the camera projection compute and can speed up perf
  110027. * if no parameter of the camera are meant to change
  110028. * @param projection Defines manually a projection if necessary
  110029. */
  110030. freezeProjectionMatrix(projection?: Matrix): void;
  110031. /**
  110032. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110033. */
  110034. unfreezeProjectionMatrix(): void;
  110035. /**
  110036. * Gets the current projection matrix of the camera.
  110037. * @param force forces the camera to recompute the matrix without looking at the cached state
  110038. * @returns the projection matrix
  110039. */
  110040. getProjectionMatrix(force?: boolean): Matrix;
  110041. /**
  110042. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110043. * @returns a Matrix
  110044. */
  110045. getTransformationMatrix(): Matrix;
  110046. private _updateFrustumPlanes;
  110047. /**
  110048. * Checks if a cullable object (mesh...) is in the camera frustum
  110049. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110050. * @param target The object to check
  110051. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110052. * @returns true if the object is in frustum otherwise false
  110053. */
  110054. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110055. /**
  110056. * Checks if a cullable object (mesh...) is in the camera frustum
  110057. * Unlike isInFrustum this cheks the full bounding box
  110058. * @param target The object to check
  110059. * @returns true if the object is in frustum otherwise false
  110060. */
  110061. isCompletelyInFrustum(target: ICullable): boolean;
  110062. /**
  110063. * Gets a ray in the forward direction from the camera.
  110064. * @param length Defines the length of the ray to create
  110065. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110066. * @param origin Defines the start point of the ray which defaults to the camera position
  110067. * @returns the forward ray
  110068. */
  110069. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110070. /**
  110071. * Gets a ray in the forward direction from the camera.
  110072. * @param refRay the ray to (re)use when setting the values
  110073. * @param length Defines the length of the ray to create
  110074. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110075. * @param origin Defines the start point of the ray which defaults to the camera position
  110076. * @returns the forward ray
  110077. */
  110078. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110079. /**
  110080. * Releases resources associated with this node.
  110081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110083. */
  110084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110085. /** @hidden */
  110086. _isLeftCamera: boolean;
  110087. /**
  110088. * Gets the left camera of a rig setup in case of Rigged Camera
  110089. */
  110090. get isLeftCamera(): boolean;
  110091. /** @hidden */
  110092. _isRightCamera: boolean;
  110093. /**
  110094. * Gets the right camera of a rig setup in case of Rigged Camera
  110095. */
  110096. get isRightCamera(): boolean;
  110097. /**
  110098. * Gets the left camera of a rig setup in case of Rigged Camera
  110099. */
  110100. get leftCamera(): Nullable<FreeCamera>;
  110101. /**
  110102. * Gets the right camera of a rig setup in case of Rigged Camera
  110103. */
  110104. get rightCamera(): Nullable<FreeCamera>;
  110105. /**
  110106. * Gets the left camera target of a rig setup in case of Rigged Camera
  110107. * @returns the target position
  110108. */
  110109. getLeftTarget(): Nullable<Vector3>;
  110110. /**
  110111. * Gets the right camera target of a rig setup in case of Rigged Camera
  110112. * @returns the target position
  110113. */
  110114. getRightTarget(): Nullable<Vector3>;
  110115. /**
  110116. * @hidden
  110117. */
  110118. setCameraRigMode(mode: number, rigParams: any): void;
  110119. /** @hidden */
  110120. static _setStereoscopicRigMode(camera: Camera): void;
  110121. /** @hidden */
  110122. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110123. /** @hidden */
  110124. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110125. /** @hidden */
  110126. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110127. /** @hidden */
  110128. _getVRProjectionMatrix(): Matrix;
  110129. protected _updateCameraRotationMatrix(): void;
  110130. protected _updateWebVRCameraRotationMatrix(): void;
  110131. /**
  110132. * This function MUST be overwritten by the different WebVR cameras available.
  110133. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110134. * @hidden
  110135. */
  110136. _getWebVRProjectionMatrix(): Matrix;
  110137. /**
  110138. * This function MUST be overwritten by the different WebVR cameras available.
  110139. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110140. * @hidden
  110141. */
  110142. _getWebVRViewMatrix(): Matrix;
  110143. /** @hidden */
  110144. setCameraRigParameter(name: string, value: any): void;
  110145. /**
  110146. * needs to be overridden by children so sub has required properties to be copied
  110147. * @hidden
  110148. */
  110149. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110150. /**
  110151. * May need to be overridden by children
  110152. * @hidden
  110153. */
  110154. _updateRigCameras(): void;
  110155. /** @hidden */
  110156. _setupInputs(): void;
  110157. /**
  110158. * Serialiaze the camera setup to a json represention
  110159. * @returns the JSON representation
  110160. */
  110161. serialize(): any;
  110162. /**
  110163. * Clones the current camera.
  110164. * @param name The cloned camera name
  110165. * @returns the cloned camera
  110166. */
  110167. clone(name: string): Camera;
  110168. /**
  110169. * Gets the direction of the camera relative to a given local axis.
  110170. * @param localAxis Defines the reference axis to provide a relative direction.
  110171. * @return the direction
  110172. */
  110173. getDirection(localAxis: Vector3): Vector3;
  110174. /**
  110175. * Returns the current camera absolute rotation
  110176. */
  110177. get absoluteRotation(): Quaternion;
  110178. /**
  110179. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110180. * @param localAxis Defines the reference axis to provide a relative direction.
  110181. * @param result Defines the vector to store the result in
  110182. */
  110183. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110184. /**
  110185. * Gets a camera constructor for a given camera type
  110186. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110187. * @param name The name of the camera the result will be able to instantiate
  110188. * @param scene The scene the result will construct the camera in
  110189. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110190. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110191. * @returns a factory method to construc the camera
  110192. */
  110193. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110194. /**
  110195. * Compute the world matrix of the camera.
  110196. * @returns the camera world matrix
  110197. */
  110198. computeWorldMatrix(): Matrix;
  110199. /**
  110200. * Parse a JSON and creates the camera from the parsed information
  110201. * @param parsedCamera The JSON to parse
  110202. * @param scene The scene to instantiate the camera in
  110203. * @returns the newly constructed camera
  110204. */
  110205. static Parse(parsedCamera: any, scene: Scene): Camera;
  110206. }
  110207. }
  110208. declare module BABYLON {
  110209. /**
  110210. * Class containing static functions to help procedurally build meshes
  110211. */
  110212. export class DiscBuilder {
  110213. /**
  110214. * Creates a plane polygonal mesh. By default, this is a disc
  110215. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110216. * * 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
  110217. * * 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
  110218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110221. * @param name defines the name of the mesh
  110222. * @param options defines the options used to create the mesh
  110223. * @param scene defines the hosting scene
  110224. * @returns the plane polygonal mesh
  110225. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110226. */
  110227. static CreateDisc(name: string, options: {
  110228. radius?: number;
  110229. tessellation?: number;
  110230. arc?: number;
  110231. updatable?: boolean;
  110232. sideOrientation?: number;
  110233. frontUVs?: Vector4;
  110234. backUVs?: Vector4;
  110235. }, scene?: Nullable<Scene>): Mesh;
  110236. }
  110237. }
  110238. declare module BABYLON {
  110239. /**
  110240. * Options to be used when creating a FresnelParameters.
  110241. */
  110242. export type IFresnelParametersCreationOptions = {
  110243. /**
  110244. * Define the color used on edges (grazing angle)
  110245. */
  110246. leftColor?: Color3;
  110247. /**
  110248. * Define the color used on center
  110249. */
  110250. rightColor?: Color3;
  110251. /**
  110252. * Define bias applied to computed fresnel term
  110253. */
  110254. bias?: number;
  110255. /**
  110256. * Defined the power exponent applied to fresnel term
  110257. */
  110258. power?: number;
  110259. /**
  110260. * Define if the fresnel effect is enable or not.
  110261. */
  110262. isEnabled?: boolean;
  110263. };
  110264. /**
  110265. * Serialized format for FresnelParameters.
  110266. */
  110267. export type IFresnelParametersSerialized = {
  110268. /**
  110269. * Define the color used on edges (grazing angle) [as an array]
  110270. */
  110271. leftColor: number[];
  110272. /**
  110273. * Define the color used on center [as an array]
  110274. */
  110275. rightColor: number[];
  110276. /**
  110277. * Define bias applied to computed fresnel term
  110278. */
  110279. bias: number;
  110280. /**
  110281. * Defined the power exponent applied to fresnel term
  110282. */
  110283. power?: number;
  110284. /**
  110285. * Define if the fresnel effect is enable or not.
  110286. */
  110287. isEnabled: boolean;
  110288. };
  110289. /**
  110290. * This represents all the required information to add a fresnel effect on a material:
  110291. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110292. */
  110293. export class FresnelParameters {
  110294. private _isEnabled;
  110295. /**
  110296. * Define if the fresnel effect is enable or not.
  110297. */
  110298. get isEnabled(): boolean;
  110299. set isEnabled(value: boolean);
  110300. /**
  110301. * Define the color used on edges (grazing angle)
  110302. */
  110303. leftColor: Color3;
  110304. /**
  110305. * Define the color used on center
  110306. */
  110307. rightColor: Color3;
  110308. /**
  110309. * Define bias applied to computed fresnel term
  110310. */
  110311. bias: number;
  110312. /**
  110313. * Defined the power exponent applied to fresnel term
  110314. */
  110315. power: number;
  110316. /**
  110317. * Creates a new FresnelParameters object.
  110318. *
  110319. * @param options provide your own settings to optionally to override defaults
  110320. */
  110321. constructor(options?: IFresnelParametersCreationOptions);
  110322. /**
  110323. * Clones the current fresnel and its valuues
  110324. * @returns a clone fresnel configuration
  110325. */
  110326. clone(): FresnelParameters;
  110327. /**
  110328. * Determines equality between FresnelParameters objects
  110329. * @param otherFresnelParameters defines the second operand
  110330. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110331. */
  110332. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110333. /**
  110334. * Serializes the current fresnel parameters to a JSON representation.
  110335. * @return the JSON serialization
  110336. */
  110337. serialize(): IFresnelParametersSerialized;
  110338. /**
  110339. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110340. * @param parsedFresnelParameters Define the JSON representation
  110341. * @returns the parsed parameters
  110342. */
  110343. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110344. }
  110345. }
  110346. declare module BABYLON {
  110347. /**
  110348. * This groups all the flags used to control the materials channel.
  110349. */
  110350. export class MaterialFlags {
  110351. private static _DiffuseTextureEnabled;
  110352. /**
  110353. * Are diffuse textures enabled in the application.
  110354. */
  110355. static get DiffuseTextureEnabled(): boolean;
  110356. static set DiffuseTextureEnabled(value: boolean);
  110357. private static _DetailTextureEnabled;
  110358. /**
  110359. * Are detail textures enabled in the application.
  110360. */
  110361. static get DetailTextureEnabled(): boolean;
  110362. static set DetailTextureEnabled(value: boolean);
  110363. private static _AmbientTextureEnabled;
  110364. /**
  110365. * Are ambient textures enabled in the application.
  110366. */
  110367. static get AmbientTextureEnabled(): boolean;
  110368. static set AmbientTextureEnabled(value: boolean);
  110369. private static _OpacityTextureEnabled;
  110370. /**
  110371. * Are opacity textures enabled in the application.
  110372. */
  110373. static get OpacityTextureEnabled(): boolean;
  110374. static set OpacityTextureEnabled(value: boolean);
  110375. private static _ReflectionTextureEnabled;
  110376. /**
  110377. * Are reflection textures enabled in the application.
  110378. */
  110379. static get ReflectionTextureEnabled(): boolean;
  110380. static set ReflectionTextureEnabled(value: boolean);
  110381. private static _EmissiveTextureEnabled;
  110382. /**
  110383. * Are emissive textures enabled in the application.
  110384. */
  110385. static get EmissiveTextureEnabled(): boolean;
  110386. static set EmissiveTextureEnabled(value: boolean);
  110387. private static _SpecularTextureEnabled;
  110388. /**
  110389. * Are specular textures enabled in the application.
  110390. */
  110391. static get SpecularTextureEnabled(): boolean;
  110392. static set SpecularTextureEnabled(value: boolean);
  110393. private static _BumpTextureEnabled;
  110394. /**
  110395. * Are bump textures enabled in the application.
  110396. */
  110397. static get BumpTextureEnabled(): boolean;
  110398. static set BumpTextureEnabled(value: boolean);
  110399. private static _LightmapTextureEnabled;
  110400. /**
  110401. * Are lightmap textures enabled in the application.
  110402. */
  110403. static get LightmapTextureEnabled(): boolean;
  110404. static set LightmapTextureEnabled(value: boolean);
  110405. private static _RefractionTextureEnabled;
  110406. /**
  110407. * Are refraction textures enabled in the application.
  110408. */
  110409. static get RefractionTextureEnabled(): boolean;
  110410. static set RefractionTextureEnabled(value: boolean);
  110411. private static _ColorGradingTextureEnabled;
  110412. /**
  110413. * Are color grading textures enabled in the application.
  110414. */
  110415. static get ColorGradingTextureEnabled(): boolean;
  110416. static set ColorGradingTextureEnabled(value: boolean);
  110417. private static _FresnelEnabled;
  110418. /**
  110419. * Are fresnels enabled in the application.
  110420. */
  110421. static get FresnelEnabled(): boolean;
  110422. static set FresnelEnabled(value: boolean);
  110423. private static _ClearCoatTextureEnabled;
  110424. /**
  110425. * Are clear coat textures enabled in the application.
  110426. */
  110427. static get ClearCoatTextureEnabled(): boolean;
  110428. static set ClearCoatTextureEnabled(value: boolean);
  110429. private static _ClearCoatBumpTextureEnabled;
  110430. /**
  110431. * Are clear coat bump textures enabled in the application.
  110432. */
  110433. static get ClearCoatBumpTextureEnabled(): boolean;
  110434. static set ClearCoatBumpTextureEnabled(value: boolean);
  110435. private static _ClearCoatTintTextureEnabled;
  110436. /**
  110437. * Are clear coat tint textures enabled in the application.
  110438. */
  110439. static get ClearCoatTintTextureEnabled(): boolean;
  110440. static set ClearCoatTintTextureEnabled(value: boolean);
  110441. private static _SheenTextureEnabled;
  110442. /**
  110443. * Are sheen textures enabled in the application.
  110444. */
  110445. static get SheenTextureEnabled(): boolean;
  110446. static set SheenTextureEnabled(value: boolean);
  110447. private static _AnisotropicTextureEnabled;
  110448. /**
  110449. * Are anisotropic textures enabled in the application.
  110450. */
  110451. static get AnisotropicTextureEnabled(): boolean;
  110452. static set AnisotropicTextureEnabled(value: boolean);
  110453. private static _ThicknessTextureEnabled;
  110454. /**
  110455. * Are thickness textures enabled in the application.
  110456. */
  110457. static get ThicknessTextureEnabled(): boolean;
  110458. static set ThicknessTextureEnabled(value: boolean);
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. /** @hidden */
  110463. export var defaultFragmentDeclaration: {
  110464. name: string;
  110465. shader: string;
  110466. };
  110467. }
  110468. declare module BABYLON {
  110469. /** @hidden */
  110470. export var defaultUboDeclaration: {
  110471. name: string;
  110472. shader: string;
  110473. };
  110474. }
  110475. declare module BABYLON {
  110476. /** @hidden */
  110477. export var prePassDeclaration: {
  110478. name: string;
  110479. shader: string;
  110480. };
  110481. }
  110482. declare module BABYLON {
  110483. /** @hidden */
  110484. export var lightFragmentDeclaration: {
  110485. name: string;
  110486. shader: string;
  110487. };
  110488. }
  110489. declare module BABYLON {
  110490. /** @hidden */
  110491. export var lightUboDeclaration: {
  110492. name: string;
  110493. shader: string;
  110494. };
  110495. }
  110496. declare module BABYLON {
  110497. /** @hidden */
  110498. export var lightsFragmentFunctions: {
  110499. name: string;
  110500. shader: string;
  110501. };
  110502. }
  110503. declare module BABYLON {
  110504. /** @hidden */
  110505. export var shadowsFragmentFunctions: {
  110506. name: string;
  110507. shader: string;
  110508. };
  110509. }
  110510. declare module BABYLON {
  110511. /** @hidden */
  110512. export var fresnelFunction: {
  110513. name: string;
  110514. shader: string;
  110515. };
  110516. }
  110517. declare module BABYLON {
  110518. /** @hidden */
  110519. export var bumpFragmentMainFunctions: {
  110520. name: string;
  110521. shader: string;
  110522. };
  110523. }
  110524. declare module BABYLON {
  110525. /** @hidden */
  110526. export var bumpFragmentFunctions: {
  110527. name: string;
  110528. shader: string;
  110529. };
  110530. }
  110531. declare module BABYLON {
  110532. /** @hidden */
  110533. export var logDepthDeclaration: {
  110534. name: string;
  110535. shader: string;
  110536. };
  110537. }
  110538. declare module BABYLON {
  110539. /** @hidden */
  110540. export var bumpFragment: {
  110541. name: string;
  110542. shader: string;
  110543. };
  110544. }
  110545. declare module BABYLON {
  110546. /** @hidden */
  110547. export var depthPrePass: {
  110548. name: string;
  110549. shader: string;
  110550. };
  110551. }
  110552. declare module BABYLON {
  110553. /** @hidden */
  110554. export var lightFragment: {
  110555. name: string;
  110556. shader: string;
  110557. };
  110558. }
  110559. declare module BABYLON {
  110560. /** @hidden */
  110561. export var logDepthFragment: {
  110562. name: string;
  110563. shader: string;
  110564. };
  110565. }
  110566. declare module BABYLON {
  110567. /** @hidden */
  110568. export var defaultPixelShader: {
  110569. name: string;
  110570. shader: string;
  110571. };
  110572. }
  110573. declare module BABYLON {
  110574. /** @hidden */
  110575. export var defaultVertexDeclaration: {
  110576. name: string;
  110577. shader: string;
  110578. };
  110579. }
  110580. declare module BABYLON {
  110581. /** @hidden */
  110582. export var bumpVertexDeclaration: {
  110583. name: string;
  110584. shader: string;
  110585. };
  110586. }
  110587. declare module BABYLON {
  110588. /** @hidden */
  110589. export var bumpVertex: {
  110590. name: string;
  110591. shader: string;
  110592. };
  110593. }
  110594. declare module BABYLON {
  110595. /** @hidden */
  110596. export var fogVertex: {
  110597. name: string;
  110598. shader: string;
  110599. };
  110600. }
  110601. declare module BABYLON {
  110602. /** @hidden */
  110603. export var shadowsVertex: {
  110604. name: string;
  110605. shader: string;
  110606. };
  110607. }
  110608. declare module BABYLON {
  110609. /** @hidden */
  110610. export var pointCloudVertex: {
  110611. name: string;
  110612. shader: string;
  110613. };
  110614. }
  110615. declare module BABYLON {
  110616. /** @hidden */
  110617. export var logDepthVertex: {
  110618. name: string;
  110619. shader: string;
  110620. };
  110621. }
  110622. declare module BABYLON {
  110623. /** @hidden */
  110624. export var defaultVertexShader: {
  110625. name: string;
  110626. shader: string;
  110627. };
  110628. }
  110629. declare module BABYLON {
  110630. /**
  110631. * @hidden
  110632. */
  110633. export interface IMaterialDetailMapDefines {
  110634. DETAIL: boolean;
  110635. DETAILDIRECTUV: number;
  110636. DETAIL_NORMALBLENDMETHOD: number;
  110637. /** @hidden */
  110638. _areTexturesDirty: boolean;
  110639. }
  110640. /**
  110641. * Define the code related to the detail map parameters of a material
  110642. *
  110643. * Inspired from:
  110644. * 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
  110645. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110646. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110647. */
  110648. export class DetailMapConfiguration {
  110649. private _texture;
  110650. /**
  110651. * The detail texture of the material.
  110652. */
  110653. texture: Nullable<BaseTexture>;
  110654. /**
  110655. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110656. * Bigger values mean stronger blending
  110657. */
  110658. diffuseBlendLevel: number;
  110659. /**
  110660. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110661. * Bigger values mean stronger blending. Only used with PBR materials
  110662. */
  110663. roughnessBlendLevel: number;
  110664. /**
  110665. * Defines how strong the bump effect from the detail map is
  110666. * Bigger values mean stronger effect
  110667. */
  110668. bumpLevel: number;
  110669. private _normalBlendMethod;
  110670. /**
  110671. * The method used to blend the bump and detail normals together
  110672. */
  110673. normalBlendMethod: number;
  110674. private _isEnabled;
  110675. /**
  110676. * Enable or disable the detail map on this material
  110677. */
  110678. isEnabled: boolean;
  110679. /** @hidden */
  110680. private _internalMarkAllSubMeshesAsTexturesDirty;
  110681. /** @hidden */
  110682. _markAllSubMeshesAsTexturesDirty(): void;
  110683. /**
  110684. * Instantiate a new detail map
  110685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110686. */
  110687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110688. /**
  110689. * Gets whether the submesh is ready to be used or not.
  110690. * @param defines the list of "defines" to update.
  110691. * @param scene defines the scene the material belongs to.
  110692. * @returns - boolean indicating that the submesh is ready or not.
  110693. */
  110694. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110695. /**
  110696. * Update the defines for detail map usage
  110697. * @param defines the list of "defines" to update.
  110698. * @param scene defines the scene the material belongs to.
  110699. */
  110700. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110701. /**
  110702. * Binds the material data.
  110703. * @param uniformBuffer defines the Uniform buffer to fill in.
  110704. * @param scene defines the scene the material belongs to.
  110705. * @param isFrozen defines whether the material is frozen or not.
  110706. */
  110707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110708. /**
  110709. * Checks to see if a texture is used in the material.
  110710. * @param texture - Base texture to use.
  110711. * @returns - Boolean specifying if a texture is used in the material.
  110712. */
  110713. hasTexture(texture: BaseTexture): boolean;
  110714. /**
  110715. * Returns an array of the actively used textures.
  110716. * @param activeTextures Array of BaseTextures
  110717. */
  110718. getActiveTextures(activeTextures: BaseTexture[]): void;
  110719. /**
  110720. * Returns the animatable textures.
  110721. * @param animatables Array of animatable textures.
  110722. */
  110723. getAnimatables(animatables: IAnimatable[]): void;
  110724. /**
  110725. * Disposes the resources of the material.
  110726. * @param forceDisposeTextures - Forces the disposal of all textures.
  110727. */
  110728. dispose(forceDisposeTextures?: boolean): void;
  110729. /**
  110730. * Get the current class name useful for serialization or dynamic coding.
  110731. * @returns "DetailMap"
  110732. */
  110733. getClassName(): string;
  110734. /**
  110735. * Add the required uniforms to the current list.
  110736. * @param uniforms defines the current uniform list.
  110737. */
  110738. static AddUniforms(uniforms: string[]): void;
  110739. /**
  110740. * Add the required samplers to the current list.
  110741. * @param samplers defines the current sampler list.
  110742. */
  110743. static AddSamplers(samplers: string[]): void;
  110744. /**
  110745. * Add the required uniforms to the current buffer.
  110746. * @param uniformBuffer defines the current uniform buffer.
  110747. */
  110748. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110749. /**
  110750. * Makes a duplicate of the current instance into another one.
  110751. * @param detailMap define the instance where to copy the info
  110752. */
  110753. copyTo(detailMap: DetailMapConfiguration): void;
  110754. /**
  110755. * Serializes this detail map instance
  110756. * @returns - An object with the serialized instance.
  110757. */
  110758. serialize(): any;
  110759. /**
  110760. * Parses a detail map setting from a serialized object.
  110761. * @param source - Serialized object.
  110762. * @param scene Defines the scene we are parsing for
  110763. * @param rootUrl Defines the rootUrl to load from
  110764. */
  110765. parse(source: any, scene: Scene, rootUrl: string): void;
  110766. }
  110767. }
  110768. declare module BABYLON {
  110769. /** @hidden */
  110770. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110771. MAINUV1: boolean;
  110772. MAINUV2: boolean;
  110773. DIFFUSE: boolean;
  110774. DIFFUSEDIRECTUV: number;
  110775. DETAIL: boolean;
  110776. DETAILDIRECTUV: number;
  110777. DETAIL_NORMALBLENDMETHOD: number;
  110778. AMBIENT: boolean;
  110779. AMBIENTDIRECTUV: number;
  110780. OPACITY: boolean;
  110781. OPACITYDIRECTUV: number;
  110782. OPACITYRGB: boolean;
  110783. REFLECTION: boolean;
  110784. EMISSIVE: boolean;
  110785. EMISSIVEDIRECTUV: number;
  110786. SPECULAR: boolean;
  110787. SPECULARDIRECTUV: number;
  110788. BUMP: boolean;
  110789. BUMPDIRECTUV: number;
  110790. PARALLAX: boolean;
  110791. PARALLAXOCCLUSION: boolean;
  110792. SPECULAROVERALPHA: boolean;
  110793. CLIPPLANE: boolean;
  110794. CLIPPLANE2: boolean;
  110795. CLIPPLANE3: boolean;
  110796. CLIPPLANE4: boolean;
  110797. CLIPPLANE5: boolean;
  110798. CLIPPLANE6: boolean;
  110799. ALPHATEST: boolean;
  110800. DEPTHPREPASS: boolean;
  110801. ALPHAFROMDIFFUSE: boolean;
  110802. POINTSIZE: boolean;
  110803. FOG: boolean;
  110804. SPECULARTERM: boolean;
  110805. DIFFUSEFRESNEL: boolean;
  110806. OPACITYFRESNEL: boolean;
  110807. REFLECTIONFRESNEL: boolean;
  110808. REFRACTIONFRESNEL: boolean;
  110809. EMISSIVEFRESNEL: boolean;
  110810. FRESNEL: boolean;
  110811. NORMAL: boolean;
  110812. UV1: boolean;
  110813. UV2: boolean;
  110814. VERTEXCOLOR: boolean;
  110815. VERTEXALPHA: boolean;
  110816. NUM_BONE_INFLUENCERS: number;
  110817. BonesPerMesh: number;
  110818. BONETEXTURE: boolean;
  110819. INSTANCES: boolean;
  110820. THIN_INSTANCES: boolean;
  110821. GLOSSINESS: boolean;
  110822. ROUGHNESS: boolean;
  110823. EMISSIVEASILLUMINATION: boolean;
  110824. LINKEMISSIVEWITHDIFFUSE: boolean;
  110825. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110826. LIGHTMAP: boolean;
  110827. LIGHTMAPDIRECTUV: number;
  110828. OBJECTSPACE_NORMALMAP: boolean;
  110829. USELIGHTMAPASSHADOWMAP: boolean;
  110830. REFLECTIONMAP_3D: boolean;
  110831. REFLECTIONMAP_SPHERICAL: boolean;
  110832. REFLECTIONMAP_PLANAR: boolean;
  110833. REFLECTIONMAP_CUBIC: boolean;
  110834. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110835. REFLECTIONMAP_PROJECTION: boolean;
  110836. REFLECTIONMAP_SKYBOX: boolean;
  110837. REFLECTIONMAP_EXPLICIT: boolean;
  110838. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110839. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110840. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110841. INVERTCUBICMAP: boolean;
  110842. LOGARITHMICDEPTH: boolean;
  110843. REFRACTION: boolean;
  110844. REFRACTIONMAP_3D: boolean;
  110845. REFLECTIONOVERALPHA: boolean;
  110846. TWOSIDEDLIGHTING: boolean;
  110847. SHADOWFLOAT: boolean;
  110848. MORPHTARGETS: boolean;
  110849. MORPHTARGETS_NORMAL: boolean;
  110850. MORPHTARGETS_TANGENT: boolean;
  110851. MORPHTARGETS_UV: boolean;
  110852. NUM_MORPH_INFLUENCERS: number;
  110853. NONUNIFORMSCALING: boolean;
  110854. PREMULTIPLYALPHA: boolean;
  110855. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110856. ALPHABLEND: boolean;
  110857. PREPASS: boolean;
  110858. PREPASS_IRRADIANCE: boolean;
  110859. PREPASS_IRRADIANCE_INDEX: number;
  110860. PREPASS_ALBEDO: boolean;
  110861. PREPASS_ALBEDO_INDEX: number;
  110862. PREPASS_DEPTHNORMAL: boolean;
  110863. PREPASS_DEPTHNORMAL_INDEX: number;
  110864. SCENE_MRT_COUNT: number;
  110865. RGBDLIGHTMAP: boolean;
  110866. RGBDREFLECTION: boolean;
  110867. RGBDREFRACTION: boolean;
  110868. IMAGEPROCESSING: boolean;
  110869. VIGNETTE: boolean;
  110870. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110871. VIGNETTEBLENDMODEOPAQUE: boolean;
  110872. TONEMAPPING: boolean;
  110873. TONEMAPPING_ACES: boolean;
  110874. CONTRAST: boolean;
  110875. COLORCURVES: boolean;
  110876. COLORGRADING: boolean;
  110877. COLORGRADING3D: boolean;
  110878. SAMPLER3DGREENDEPTH: boolean;
  110879. SAMPLER3DBGRMAP: boolean;
  110880. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110881. MULTIVIEW: boolean;
  110882. /**
  110883. * If the reflection texture on this material is in linear color space
  110884. * @hidden
  110885. */
  110886. IS_REFLECTION_LINEAR: boolean;
  110887. /**
  110888. * If the refraction texture on this material is in linear color space
  110889. * @hidden
  110890. */
  110891. IS_REFRACTION_LINEAR: boolean;
  110892. EXPOSURE: boolean;
  110893. constructor();
  110894. setReflectionMode(modeToEnable: string): void;
  110895. }
  110896. /**
  110897. * This is the default material used in Babylon. It is the best trade off between quality
  110898. * and performances.
  110899. * @see https://doc.babylonjs.com/babylon101/materials
  110900. */
  110901. export class StandardMaterial extends PushMaterial {
  110902. private _diffuseTexture;
  110903. /**
  110904. * The basic texture of the material as viewed under a light.
  110905. */
  110906. diffuseTexture: Nullable<BaseTexture>;
  110907. private _ambientTexture;
  110908. /**
  110909. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110910. */
  110911. ambientTexture: Nullable<BaseTexture>;
  110912. private _opacityTexture;
  110913. /**
  110914. * Define the transparency of the material from a texture.
  110915. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110916. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110917. */
  110918. opacityTexture: Nullable<BaseTexture>;
  110919. private _reflectionTexture;
  110920. /**
  110921. * Define the texture used to display the reflection.
  110922. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110923. */
  110924. reflectionTexture: Nullable<BaseTexture>;
  110925. private _emissiveTexture;
  110926. /**
  110927. * Define texture of the material as if self lit.
  110928. * This will be mixed in the final result even in the absence of light.
  110929. */
  110930. emissiveTexture: Nullable<BaseTexture>;
  110931. private _specularTexture;
  110932. /**
  110933. * Define how the color and intensity of the highlight given by the light in the material.
  110934. */
  110935. specularTexture: Nullable<BaseTexture>;
  110936. private _bumpTexture;
  110937. /**
  110938. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110939. * 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.
  110940. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110941. */
  110942. bumpTexture: Nullable<BaseTexture>;
  110943. private _lightmapTexture;
  110944. /**
  110945. * Complex lighting can be computationally expensive to compute at runtime.
  110946. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110947. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110948. */
  110949. lightmapTexture: Nullable<BaseTexture>;
  110950. private _refractionTexture;
  110951. /**
  110952. * Define the texture used to display the refraction.
  110953. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110954. */
  110955. refractionTexture: Nullable<BaseTexture>;
  110956. /**
  110957. * The color of the material lit by the environmental background lighting.
  110958. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110959. */
  110960. ambientColor: Color3;
  110961. /**
  110962. * The basic color of the material as viewed under a light.
  110963. */
  110964. diffuseColor: Color3;
  110965. /**
  110966. * Define how the color and intensity of the highlight given by the light in the material.
  110967. */
  110968. specularColor: Color3;
  110969. /**
  110970. * Define the color of the material as if self lit.
  110971. * This will be mixed in the final result even in the absence of light.
  110972. */
  110973. emissiveColor: Color3;
  110974. /**
  110975. * Defines how sharp are the highlights in the material.
  110976. * The bigger the value the sharper giving a more glossy feeling to the result.
  110977. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110978. */
  110979. specularPower: number;
  110980. private _useAlphaFromDiffuseTexture;
  110981. /**
  110982. * Does the transparency come from the diffuse texture alpha channel.
  110983. */
  110984. useAlphaFromDiffuseTexture: boolean;
  110985. private _useEmissiveAsIllumination;
  110986. /**
  110987. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110988. */
  110989. useEmissiveAsIllumination: boolean;
  110990. private _linkEmissiveWithDiffuse;
  110991. /**
  110992. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110993. * the emissive level when the final color is close to one.
  110994. */
  110995. linkEmissiveWithDiffuse: boolean;
  110996. private _useSpecularOverAlpha;
  110997. /**
  110998. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111000. */
  111001. useSpecularOverAlpha: boolean;
  111002. private _useReflectionOverAlpha;
  111003. /**
  111004. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111005. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111006. */
  111007. useReflectionOverAlpha: boolean;
  111008. private _disableLighting;
  111009. /**
  111010. * Does lights from the scene impacts this material.
  111011. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111012. */
  111013. disableLighting: boolean;
  111014. private _useObjectSpaceNormalMap;
  111015. /**
  111016. * Allows using an object space normal map (instead of tangent space).
  111017. */
  111018. useObjectSpaceNormalMap: boolean;
  111019. private _useParallax;
  111020. /**
  111021. * Is parallax enabled or not.
  111022. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111023. */
  111024. useParallax: boolean;
  111025. private _useParallaxOcclusion;
  111026. /**
  111027. * Is parallax occlusion enabled or not.
  111028. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111029. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111030. */
  111031. useParallaxOcclusion: boolean;
  111032. /**
  111033. * 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.
  111034. */
  111035. parallaxScaleBias: number;
  111036. private _roughness;
  111037. /**
  111038. * Helps to define how blurry the reflections should appears in the material.
  111039. */
  111040. roughness: number;
  111041. /**
  111042. * In case of refraction, define the value of the index of refraction.
  111043. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111044. */
  111045. indexOfRefraction: number;
  111046. /**
  111047. * Invert the refraction texture alongside the y axis.
  111048. * It can be useful with procedural textures or probe for instance.
  111049. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111050. */
  111051. invertRefractionY: boolean;
  111052. /**
  111053. * Defines the alpha limits in alpha test mode.
  111054. */
  111055. alphaCutOff: number;
  111056. private _useLightmapAsShadowmap;
  111057. /**
  111058. * In case of light mapping, define whether the map contains light or shadow informations.
  111059. */
  111060. useLightmapAsShadowmap: boolean;
  111061. private _diffuseFresnelParameters;
  111062. /**
  111063. * Define the diffuse fresnel parameters of the material.
  111064. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111065. */
  111066. diffuseFresnelParameters: FresnelParameters;
  111067. private _opacityFresnelParameters;
  111068. /**
  111069. * Define the opacity fresnel parameters of the material.
  111070. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111071. */
  111072. opacityFresnelParameters: FresnelParameters;
  111073. private _reflectionFresnelParameters;
  111074. /**
  111075. * Define the reflection fresnel parameters of the material.
  111076. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111077. */
  111078. reflectionFresnelParameters: FresnelParameters;
  111079. private _refractionFresnelParameters;
  111080. /**
  111081. * Define the refraction fresnel parameters of the material.
  111082. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111083. */
  111084. refractionFresnelParameters: FresnelParameters;
  111085. private _emissiveFresnelParameters;
  111086. /**
  111087. * Define the emissive fresnel parameters of the material.
  111088. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111089. */
  111090. emissiveFresnelParameters: FresnelParameters;
  111091. private _useReflectionFresnelFromSpecular;
  111092. /**
  111093. * If true automatically deducts the fresnels values from the material specularity.
  111094. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111095. */
  111096. useReflectionFresnelFromSpecular: boolean;
  111097. private _useGlossinessFromSpecularMapAlpha;
  111098. /**
  111099. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111100. */
  111101. useGlossinessFromSpecularMapAlpha: boolean;
  111102. private _maxSimultaneousLights;
  111103. /**
  111104. * Defines the maximum number of lights that can be used in the material
  111105. */
  111106. maxSimultaneousLights: number;
  111107. private _invertNormalMapX;
  111108. /**
  111109. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111110. */
  111111. invertNormalMapX: boolean;
  111112. private _invertNormalMapY;
  111113. /**
  111114. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111115. */
  111116. invertNormalMapY: boolean;
  111117. private _twoSidedLighting;
  111118. /**
  111119. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111120. */
  111121. twoSidedLighting: boolean;
  111122. /**
  111123. * Default configuration related to image processing available in the standard Material.
  111124. */
  111125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111126. /**
  111127. * Gets the image processing configuration used either in this material.
  111128. */
  111129. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111130. /**
  111131. * Sets the Default image processing configuration used either in the this material.
  111132. *
  111133. * If sets to null, the scene one is in use.
  111134. */
  111135. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111136. /**
  111137. * Keep track of the image processing observer to allow dispose and replace.
  111138. */
  111139. private _imageProcessingObserver;
  111140. /**
  111141. * Attaches a new image processing configuration to the Standard Material.
  111142. * @param configuration
  111143. */
  111144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111145. /**
  111146. * Gets wether the color curves effect is enabled.
  111147. */
  111148. get cameraColorCurvesEnabled(): boolean;
  111149. /**
  111150. * Sets wether the color curves effect is enabled.
  111151. */
  111152. set cameraColorCurvesEnabled(value: boolean);
  111153. /**
  111154. * Gets wether the color grading effect is enabled.
  111155. */
  111156. get cameraColorGradingEnabled(): boolean;
  111157. /**
  111158. * Gets wether the color grading effect is enabled.
  111159. */
  111160. set cameraColorGradingEnabled(value: boolean);
  111161. /**
  111162. * Gets wether tonemapping is enabled or not.
  111163. */
  111164. get cameraToneMappingEnabled(): boolean;
  111165. /**
  111166. * Sets wether tonemapping is enabled or not
  111167. */
  111168. set cameraToneMappingEnabled(value: boolean);
  111169. /**
  111170. * The camera exposure used on this material.
  111171. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111172. * This corresponds to a photographic exposure.
  111173. */
  111174. get cameraExposure(): number;
  111175. /**
  111176. * The camera exposure used on this material.
  111177. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111178. * This corresponds to a photographic exposure.
  111179. */
  111180. set cameraExposure(value: number);
  111181. /**
  111182. * Gets The camera contrast used on this material.
  111183. */
  111184. get cameraContrast(): number;
  111185. /**
  111186. * Sets The camera contrast used on this material.
  111187. */
  111188. set cameraContrast(value: number);
  111189. /**
  111190. * Gets the Color Grading 2D Lookup Texture.
  111191. */
  111192. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111193. /**
  111194. * Sets the Color Grading 2D Lookup Texture.
  111195. */
  111196. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111197. /**
  111198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111200. * 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;
  111201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111202. */
  111203. get cameraColorCurves(): Nullable<ColorCurves>;
  111204. /**
  111205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111207. * 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;
  111208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111209. */
  111210. set cameraColorCurves(value: Nullable<ColorCurves>);
  111211. /**
  111212. * Can this material render to several textures at once
  111213. */
  111214. get canRenderToMRT(): boolean;
  111215. /**
  111216. * Defines the detail map parameters for the material.
  111217. */
  111218. readonly detailMap: DetailMapConfiguration;
  111219. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111220. protected _worldViewProjectionMatrix: Matrix;
  111221. protected _globalAmbientColor: Color3;
  111222. protected _useLogarithmicDepth: boolean;
  111223. protected _rebuildInParallel: boolean;
  111224. /**
  111225. * Instantiates a new standard material.
  111226. * This is the default material used in Babylon. It is the best trade off between quality
  111227. * and performances.
  111228. * @see https://doc.babylonjs.com/babylon101/materials
  111229. * @param name Define the name of the material in the scene
  111230. * @param scene Define the scene the material belong to
  111231. */
  111232. constructor(name: string, scene: Scene);
  111233. /**
  111234. * Gets a boolean indicating that current material needs to register RTT
  111235. */
  111236. get hasRenderTargetTextures(): boolean;
  111237. /**
  111238. * Gets the current class name of the material e.g. "StandardMaterial"
  111239. * Mainly use in serialization.
  111240. * @returns the class name
  111241. */
  111242. getClassName(): string;
  111243. /**
  111244. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111245. * You can try switching to logarithmic depth.
  111246. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111247. */
  111248. get useLogarithmicDepth(): boolean;
  111249. set useLogarithmicDepth(value: boolean);
  111250. /**
  111251. * Specifies if the material will require alpha blending
  111252. * @returns a boolean specifying if alpha blending is needed
  111253. */
  111254. needAlphaBlending(): boolean;
  111255. /**
  111256. * Specifies if this material should be rendered in alpha test mode
  111257. * @returns a boolean specifying if an alpha test is needed.
  111258. */
  111259. needAlphaTesting(): boolean;
  111260. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111261. /**
  111262. * Get the texture used for alpha test purpose.
  111263. * @returns the diffuse texture in case of the standard material.
  111264. */
  111265. getAlphaTestTexture(): Nullable<BaseTexture>;
  111266. /**
  111267. * Get if the submesh is ready to be used and all its information available.
  111268. * Child classes can use it to update shaders
  111269. * @param mesh defines the mesh to check
  111270. * @param subMesh defines which submesh to check
  111271. * @param useInstances specifies that instances should be used
  111272. * @returns a boolean indicating that the submesh is ready or not
  111273. */
  111274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111275. /**
  111276. * Builds the material UBO layouts.
  111277. * Used internally during the effect preparation.
  111278. */
  111279. buildUniformLayout(): void;
  111280. /**
  111281. * Unbinds the material from the mesh
  111282. */
  111283. unbind(): void;
  111284. /**
  111285. * Binds the submesh to this material by preparing the effect and shader to draw
  111286. * @param world defines the world transformation matrix
  111287. * @param mesh defines the mesh containing the submesh
  111288. * @param subMesh defines the submesh to bind the material to
  111289. */
  111290. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111291. /**
  111292. * Get the list of animatables in the material.
  111293. * @returns the list of animatables object used in the material
  111294. */
  111295. getAnimatables(): IAnimatable[];
  111296. /**
  111297. * Gets the active textures from the material
  111298. * @returns an array of textures
  111299. */
  111300. getActiveTextures(): BaseTexture[];
  111301. /**
  111302. * Specifies if the material uses a texture
  111303. * @param texture defines the texture to check against the material
  111304. * @returns a boolean specifying if the material uses the texture
  111305. */
  111306. hasTexture(texture: BaseTexture): boolean;
  111307. /**
  111308. * Disposes the material
  111309. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111310. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111311. */
  111312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111313. /**
  111314. * Makes a duplicate of the material, and gives it a new name
  111315. * @param name defines the new name for the duplicated material
  111316. * @returns the cloned material
  111317. */
  111318. clone(name: string): StandardMaterial;
  111319. /**
  111320. * Serializes this material in a JSON representation
  111321. * @returns the serialized material object
  111322. */
  111323. serialize(): any;
  111324. /**
  111325. * Creates a standard material from parsed material data
  111326. * @param source defines the JSON representation of the material
  111327. * @param scene defines the hosting scene
  111328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111329. * @returns a new standard material
  111330. */
  111331. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111332. /**
  111333. * Are diffuse textures enabled in the application.
  111334. */
  111335. static get DiffuseTextureEnabled(): boolean;
  111336. static set DiffuseTextureEnabled(value: boolean);
  111337. /**
  111338. * Are detail textures enabled in the application.
  111339. */
  111340. static get DetailTextureEnabled(): boolean;
  111341. static set DetailTextureEnabled(value: boolean);
  111342. /**
  111343. * Are ambient textures enabled in the application.
  111344. */
  111345. static get AmbientTextureEnabled(): boolean;
  111346. static set AmbientTextureEnabled(value: boolean);
  111347. /**
  111348. * Are opacity textures enabled in the application.
  111349. */
  111350. static get OpacityTextureEnabled(): boolean;
  111351. static set OpacityTextureEnabled(value: boolean);
  111352. /**
  111353. * Are reflection textures enabled in the application.
  111354. */
  111355. static get ReflectionTextureEnabled(): boolean;
  111356. static set ReflectionTextureEnabled(value: boolean);
  111357. /**
  111358. * Are emissive textures enabled in the application.
  111359. */
  111360. static get EmissiveTextureEnabled(): boolean;
  111361. static set EmissiveTextureEnabled(value: boolean);
  111362. /**
  111363. * Are specular textures enabled in the application.
  111364. */
  111365. static get SpecularTextureEnabled(): boolean;
  111366. static set SpecularTextureEnabled(value: boolean);
  111367. /**
  111368. * Are bump textures enabled in the application.
  111369. */
  111370. static get BumpTextureEnabled(): boolean;
  111371. static set BumpTextureEnabled(value: boolean);
  111372. /**
  111373. * Are lightmap textures enabled in the application.
  111374. */
  111375. static get LightmapTextureEnabled(): boolean;
  111376. static set LightmapTextureEnabled(value: boolean);
  111377. /**
  111378. * Are refraction textures enabled in the application.
  111379. */
  111380. static get RefractionTextureEnabled(): boolean;
  111381. static set RefractionTextureEnabled(value: boolean);
  111382. /**
  111383. * Are color grading textures enabled in the application.
  111384. */
  111385. static get ColorGradingTextureEnabled(): boolean;
  111386. static set ColorGradingTextureEnabled(value: boolean);
  111387. /**
  111388. * Are fresnels enabled in the application.
  111389. */
  111390. static get FresnelEnabled(): boolean;
  111391. static set FresnelEnabled(value: boolean);
  111392. }
  111393. }
  111394. declare module BABYLON {
  111395. /**
  111396. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111397. *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.
  111398. * The SPS is also a particle system. It provides some methods to manage the particles.
  111399. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111400. *
  111401. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111402. */
  111403. export class SolidParticleSystem implements IDisposable {
  111404. /**
  111405. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111406. * Example : var p = SPS.particles[i];
  111407. */
  111408. particles: SolidParticle[];
  111409. /**
  111410. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111411. */
  111412. nbParticles: number;
  111413. /**
  111414. * If the particles must ever face the camera (default false). Useful for planar particles.
  111415. */
  111416. billboard: boolean;
  111417. /**
  111418. * Recompute normals when adding a shape
  111419. */
  111420. recomputeNormals: boolean;
  111421. /**
  111422. * This a counter ofr your own usage. It's not set by any SPS functions.
  111423. */
  111424. counter: number;
  111425. /**
  111426. * The SPS name. This name is also given to the underlying mesh.
  111427. */
  111428. name: string;
  111429. /**
  111430. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111431. */
  111432. mesh: Mesh;
  111433. /**
  111434. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111435. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111436. */
  111437. vars: any;
  111438. /**
  111439. * This array is populated when the SPS is set as 'pickable'.
  111440. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111441. * Each element of this array is an object `{idx: int, faceId: int}`.
  111442. * `idx` is the picked particle index in the `SPS.particles` array
  111443. * `faceId` is the picked face index counted within this particle.
  111444. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111445. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111446. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111447. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111448. */
  111449. pickedParticles: {
  111450. idx: number;
  111451. faceId: number;
  111452. }[];
  111453. /**
  111454. * This array is populated when the SPS is set as 'pickable'
  111455. * Each key of this array is a submesh index.
  111456. * Each element of this array is a second array defined like this :
  111457. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111458. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111459. * `idx` is the picked particle index in the `SPS.particles` array
  111460. * `faceId` is the picked face index counted within this particle.
  111461. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111462. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111463. */
  111464. pickedBySubMesh: {
  111465. idx: number;
  111466. faceId: number;
  111467. }[][];
  111468. /**
  111469. * This array is populated when `enableDepthSort` is set to true.
  111470. * Each element of this array is an instance of the class DepthSortedParticle.
  111471. */
  111472. depthSortedParticles: DepthSortedParticle[];
  111473. /**
  111474. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111475. * @hidden
  111476. */
  111477. _bSphereOnly: boolean;
  111478. /**
  111479. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111480. * @hidden
  111481. */
  111482. _bSphereRadiusFactor: number;
  111483. private _scene;
  111484. private _positions;
  111485. private _indices;
  111486. private _normals;
  111487. private _colors;
  111488. private _uvs;
  111489. private _indices32;
  111490. private _positions32;
  111491. private _normals32;
  111492. private _fixedNormal32;
  111493. private _colors32;
  111494. private _uvs32;
  111495. private _index;
  111496. private _updatable;
  111497. private _pickable;
  111498. private _isVisibilityBoxLocked;
  111499. private _alwaysVisible;
  111500. private _depthSort;
  111501. private _expandable;
  111502. private _shapeCounter;
  111503. private _copy;
  111504. private _color;
  111505. private _computeParticleColor;
  111506. private _computeParticleTexture;
  111507. private _computeParticleRotation;
  111508. private _computeParticleVertex;
  111509. private _computeBoundingBox;
  111510. private _depthSortParticles;
  111511. private _camera;
  111512. private _mustUnrotateFixedNormals;
  111513. private _particlesIntersect;
  111514. private _needs32Bits;
  111515. private _isNotBuilt;
  111516. private _lastParticleId;
  111517. private _idxOfId;
  111518. private _multimaterialEnabled;
  111519. private _useModelMaterial;
  111520. private _indicesByMaterial;
  111521. private _materialIndexes;
  111522. private _depthSortFunction;
  111523. private _materialSortFunction;
  111524. private _materials;
  111525. private _multimaterial;
  111526. private _materialIndexesById;
  111527. private _defaultMaterial;
  111528. private _autoUpdateSubMeshes;
  111529. private _tmpVertex;
  111530. /**
  111531. * Creates a SPS (Solid Particle System) object.
  111532. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111533. * @param scene (Scene) is the scene in which the SPS is added.
  111534. * @param options defines the options of the sps e.g.
  111535. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111536. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111537. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111538. * * 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.
  111539. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111540. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111541. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111542. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111543. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111544. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111545. */
  111546. constructor(name: string, scene: Scene, options?: {
  111547. updatable?: boolean;
  111548. isPickable?: boolean;
  111549. enableDepthSort?: boolean;
  111550. particleIntersection?: boolean;
  111551. boundingSphereOnly?: boolean;
  111552. bSphereRadiusFactor?: number;
  111553. expandable?: boolean;
  111554. useModelMaterial?: boolean;
  111555. enableMultiMaterial?: boolean;
  111556. });
  111557. /**
  111558. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111559. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111560. * @returns the created mesh
  111561. */
  111562. buildMesh(): Mesh;
  111563. /**
  111564. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111565. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111566. * Thus the particles generated from `digest()` have their property `position` set yet.
  111567. * @param mesh ( Mesh ) is the mesh to be digested
  111568. * @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
  111569. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111570. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111571. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111572. * @returns the current SPS
  111573. */
  111574. digest(mesh: Mesh, options?: {
  111575. facetNb?: number;
  111576. number?: number;
  111577. delta?: number;
  111578. storage?: [];
  111579. }): SolidParticleSystem;
  111580. /**
  111581. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111582. * @hidden
  111583. */
  111584. private _unrotateFixedNormals;
  111585. /**
  111586. * Resets the temporary working copy particle
  111587. * @hidden
  111588. */
  111589. private _resetCopy;
  111590. /**
  111591. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111592. * @param p the current index in the positions array to be updated
  111593. * @param ind the current index in the indices array
  111594. * @param shape a Vector3 array, the shape geometry
  111595. * @param positions the positions array to be updated
  111596. * @param meshInd the shape indices array
  111597. * @param indices the indices array to be updated
  111598. * @param meshUV the shape uv array
  111599. * @param uvs the uv array to be updated
  111600. * @param meshCol the shape color array
  111601. * @param colors the color array to be updated
  111602. * @param meshNor the shape normals array
  111603. * @param normals the normals array to be updated
  111604. * @param idx the particle index
  111605. * @param idxInShape the particle index in its shape
  111606. * @param options the addShape() method passed options
  111607. * @model the particle model
  111608. * @hidden
  111609. */
  111610. private _meshBuilder;
  111611. /**
  111612. * Returns a shape Vector3 array from positions float array
  111613. * @param positions float array
  111614. * @returns a vector3 array
  111615. * @hidden
  111616. */
  111617. private _posToShape;
  111618. /**
  111619. * Returns a shapeUV array from a float uvs (array deep copy)
  111620. * @param uvs as a float array
  111621. * @returns a shapeUV array
  111622. * @hidden
  111623. */
  111624. private _uvsToShapeUV;
  111625. /**
  111626. * Adds a new particle object in the particles array
  111627. * @param idx particle index in particles array
  111628. * @param id particle id
  111629. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111630. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111631. * @param model particle ModelShape object
  111632. * @param shapeId model shape identifier
  111633. * @param idxInShape index of the particle in the current model
  111634. * @param bInfo model bounding info object
  111635. * @param storage target storage array, if any
  111636. * @hidden
  111637. */
  111638. private _addParticle;
  111639. /**
  111640. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111641. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111642. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111643. * @param nb (positive integer) the number of particles to be created from this model
  111644. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111645. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111646. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111647. * @returns the number of shapes in the system
  111648. */
  111649. addShape(mesh: Mesh, nb: number, options?: {
  111650. positionFunction?: any;
  111651. vertexFunction?: any;
  111652. storage?: [];
  111653. }): number;
  111654. /**
  111655. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111656. * @hidden
  111657. */
  111658. private _rebuildParticle;
  111659. /**
  111660. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111661. * @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.
  111662. * @returns the SPS.
  111663. */
  111664. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111665. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111666. * Returns an array with the removed particles.
  111667. * 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.
  111668. * The SPS can't be empty so at least one particle needs to remain in place.
  111669. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111670. * @param start index of the first particle to remove
  111671. * @param end index of the last particle to remove (included)
  111672. * @returns an array populated with the removed particles
  111673. */
  111674. removeParticles(start: number, end: number): SolidParticle[];
  111675. /**
  111676. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111677. * @param solidParticleArray an array populated with Solid Particles objects
  111678. * @returns the SPS
  111679. */
  111680. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111681. /**
  111682. * Creates a new particle and modifies the SPS mesh geometry :
  111683. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111684. * - calls _addParticle() to populate the particle array
  111685. * factorized code from addShape() and insertParticlesFromArray()
  111686. * @param idx particle index in the particles array
  111687. * @param i particle index in its shape
  111688. * @param modelShape particle ModelShape object
  111689. * @param shape shape vertex array
  111690. * @param meshInd shape indices array
  111691. * @param meshUV shape uv array
  111692. * @param meshCol shape color array
  111693. * @param meshNor shape normals array
  111694. * @param bbInfo shape bounding info
  111695. * @param storage target particle storage
  111696. * @options addShape() passed options
  111697. * @hidden
  111698. */
  111699. private _insertNewParticle;
  111700. /**
  111701. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111702. * This method calls `updateParticle()` for each particle of the SPS.
  111703. * For an animated SPS, it is usually called within the render loop.
  111704. * 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.
  111705. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111706. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111707. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111708. * @returns the SPS.
  111709. */
  111710. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111711. /**
  111712. * Disposes the SPS.
  111713. */
  111714. dispose(): void;
  111715. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111716. * idx is the particle index in the SPS
  111717. * faceId is the picked face index counted within this particle.
  111718. * Returns null if the pickInfo can't identify a picked particle.
  111719. * @param pickingInfo (PickingInfo object)
  111720. * @returns {idx: number, faceId: number} or null
  111721. */
  111722. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111723. idx: number;
  111724. faceId: number;
  111725. }>;
  111726. /**
  111727. * Returns a SolidParticle object from its identifier : particle.id
  111728. * @param id (integer) the particle Id
  111729. * @returns the searched particle or null if not found in the SPS.
  111730. */
  111731. getParticleById(id: number): Nullable<SolidParticle>;
  111732. /**
  111733. * Returns a new array populated with the particles having the passed shapeId.
  111734. * @param shapeId (integer) the shape identifier
  111735. * @returns a new solid particle array
  111736. */
  111737. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111738. /**
  111739. * Populates the passed array "ref" with the particles having the passed shapeId.
  111740. * @param shapeId the shape identifier
  111741. * @returns the SPS
  111742. * @param ref
  111743. */
  111744. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111745. /**
  111746. * Computes the required SubMeshes according the materials assigned to the particles.
  111747. * @returns the solid particle system.
  111748. * Does nothing if called before the SPS mesh is built.
  111749. */
  111750. computeSubMeshes(): SolidParticleSystem;
  111751. /**
  111752. * Sorts the solid particles by material when MultiMaterial is enabled.
  111753. * Updates the indices32 array.
  111754. * Updates the indicesByMaterial array.
  111755. * Updates the mesh indices array.
  111756. * @returns the SPS
  111757. * @hidden
  111758. */
  111759. private _sortParticlesByMaterial;
  111760. /**
  111761. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111762. * @hidden
  111763. */
  111764. private _setMaterialIndexesById;
  111765. /**
  111766. * Returns an array with unique values of Materials from the passed array
  111767. * @param array the material array to be checked and filtered
  111768. * @hidden
  111769. */
  111770. private _filterUniqueMaterialId;
  111771. /**
  111772. * Sets a new Standard Material as _defaultMaterial if not already set.
  111773. * @hidden
  111774. */
  111775. private _setDefaultMaterial;
  111776. /**
  111777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111778. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111779. * @returns the SPS.
  111780. */
  111781. refreshVisibleSize(): SolidParticleSystem;
  111782. /**
  111783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111784. * @param size the size (float) of the visibility box
  111785. * note : this doesn't lock the SPS mesh bounding box.
  111786. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111787. */
  111788. setVisibilityBox(size: number): void;
  111789. /**
  111790. * Gets whether the SPS as always visible or not
  111791. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111792. */
  111793. get isAlwaysVisible(): boolean;
  111794. /**
  111795. * Sets the SPS as always visible or not
  111796. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111797. */
  111798. set isAlwaysVisible(val: boolean);
  111799. /**
  111800. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111801. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111802. */
  111803. set isVisibilityBoxLocked(val: boolean);
  111804. /**
  111805. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111806. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111807. */
  111808. get isVisibilityBoxLocked(): boolean;
  111809. /**
  111810. * Tells to `setParticles()` to compute the particle rotations or not.
  111811. * Default value : true. The SPS is faster when it's set to false.
  111812. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111813. */
  111814. set computeParticleRotation(val: boolean);
  111815. /**
  111816. * Tells to `setParticles()` to compute the particle colors or not.
  111817. * Default value : true. The SPS is faster when it's set to false.
  111818. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111819. */
  111820. set computeParticleColor(val: boolean);
  111821. set computeParticleTexture(val: boolean);
  111822. /**
  111823. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111824. * Default value : false. The SPS is faster when it's set to false.
  111825. * Note : the particle custom vertex positions aren't stored values.
  111826. */
  111827. set computeParticleVertex(val: boolean);
  111828. /**
  111829. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111830. */
  111831. set computeBoundingBox(val: boolean);
  111832. /**
  111833. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111834. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111835. * Default : `true`
  111836. */
  111837. set depthSortParticles(val: boolean);
  111838. /**
  111839. * Gets if `setParticles()` computes the particle rotations or not.
  111840. * Default value : true. The SPS is faster when it's set to false.
  111841. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111842. */
  111843. get computeParticleRotation(): boolean;
  111844. /**
  111845. * Gets if `setParticles()` computes the particle colors or not.
  111846. * Default value : true. The SPS is faster when it's set to false.
  111847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111848. */
  111849. get computeParticleColor(): boolean;
  111850. /**
  111851. * Gets if `setParticles()` computes the particle textures or not.
  111852. * Default value : true. The SPS is faster when it's set to false.
  111853. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111854. */
  111855. get computeParticleTexture(): boolean;
  111856. /**
  111857. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111858. * Default value : false. The SPS is faster when it's set to false.
  111859. * Note : the particle custom vertex positions aren't stored values.
  111860. */
  111861. get computeParticleVertex(): boolean;
  111862. /**
  111863. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111864. */
  111865. get computeBoundingBox(): boolean;
  111866. /**
  111867. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111868. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111869. * Default : `true`
  111870. */
  111871. get depthSortParticles(): boolean;
  111872. /**
  111873. * Gets if the SPS is created as expandable at construction time.
  111874. * Default : `false`
  111875. */
  111876. get expandable(): boolean;
  111877. /**
  111878. * Gets if the SPS supports the Multi Materials
  111879. */
  111880. get multimaterialEnabled(): boolean;
  111881. /**
  111882. * Gets if the SPS uses the model materials for its own multimaterial.
  111883. */
  111884. get useModelMaterial(): boolean;
  111885. /**
  111886. * The SPS used material array.
  111887. */
  111888. get materials(): Material[];
  111889. /**
  111890. * Sets the SPS MultiMaterial from the passed materials.
  111891. * Note : the passed array is internally copied and not used then by reference.
  111892. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111893. */
  111894. setMultiMaterial(materials: Material[]): void;
  111895. /**
  111896. * The SPS computed multimaterial object
  111897. */
  111898. get multimaterial(): MultiMaterial;
  111899. set multimaterial(mm: MultiMaterial);
  111900. /**
  111901. * If the subMeshes must be updated on the next call to setParticles()
  111902. */
  111903. get autoUpdateSubMeshes(): boolean;
  111904. set autoUpdateSubMeshes(val: boolean);
  111905. /**
  111906. * This function does nothing. It may be overwritten to set all the particle first values.
  111907. * The SPS doesn't call this function, you may have to call it by your own.
  111908. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111909. */
  111910. initParticles(): void;
  111911. /**
  111912. * This function does nothing. It may be overwritten to recycle a particle.
  111913. * The SPS doesn't call this function, you may have to call it by your own.
  111914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111915. * @param particle The particle to recycle
  111916. * @returns the recycled particle
  111917. */
  111918. recycleParticle(particle: SolidParticle): SolidParticle;
  111919. /**
  111920. * Updates a particle : this function should be overwritten by the user.
  111921. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111922. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111923. * @example : just set a particle position or velocity and recycle conditions
  111924. * @param particle The particle to update
  111925. * @returns the updated particle
  111926. */
  111927. updateParticle(particle: SolidParticle): SolidParticle;
  111928. /**
  111929. * Updates a vertex of a particle : it can be overwritten by the user.
  111930. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111931. * @param particle the current particle
  111932. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111933. * @param pt the index of the current vertex in the particle shape
  111934. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111935. * @example : just set a vertex particle position or color
  111936. * @returns the sps
  111937. */
  111938. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111939. /**
  111940. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111941. * This does nothing and may be overwritten by the user.
  111942. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111943. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111944. * @param update the boolean update value actually passed to setParticles()
  111945. */
  111946. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111947. /**
  111948. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111949. * This will be passed three parameters.
  111950. * This does nothing and may be overwritten by the user.
  111951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111953. * @param update the boolean update value actually passed to setParticles()
  111954. */
  111955. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111956. }
  111957. }
  111958. declare module BABYLON {
  111959. /**
  111960. * Represents one particle of a solid particle system.
  111961. */
  111962. export class SolidParticle {
  111963. /**
  111964. * particle global index
  111965. */
  111966. idx: number;
  111967. /**
  111968. * particle identifier
  111969. */
  111970. id: number;
  111971. /**
  111972. * The color of the particle
  111973. */
  111974. color: Nullable<Color4>;
  111975. /**
  111976. * The world space position of the particle.
  111977. */
  111978. position: Vector3;
  111979. /**
  111980. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111981. */
  111982. rotation: Vector3;
  111983. /**
  111984. * The world space rotation quaternion of the particle.
  111985. */
  111986. rotationQuaternion: Nullable<Quaternion>;
  111987. /**
  111988. * The scaling of the particle.
  111989. */
  111990. scaling: Vector3;
  111991. /**
  111992. * The uvs of the particle.
  111993. */
  111994. uvs: Vector4;
  111995. /**
  111996. * The current speed of the particle.
  111997. */
  111998. velocity: Vector3;
  111999. /**
  112000. * The pivot point in the particle local space.
  112001. */
  112002. pivot: Vector3;
  112003. /**
  112004. * Must the particle be translated from its pivot point in its local space ?
  112005. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112006. * Default : false
  112007. */
  112008. translateFromPivot: boolean;
  112009. /**
  112010. * Is the particle active or not ?
  112011. */
  112012. alive: boolean;
  112013. /**
  112014. * Is the particle visible or not ?
  112015. */
  112016. isVisible: boolean;
  112017. /**
  112018. * Index of this particle in the global "positions" array (Internal use)
  112019. * @hidden
  112020. */
  112021. _pos: number;
  112022. /**
  112023. * @hidden Index of this particle in the global "indices" array (Internal use)
  112024. */
  112025. _ind: number;
  112026. /**
  112027. * @hidden ModelShape of this particle (Internal use)
  112028. */
  112029. _model: ModelShape;
  112030. /**
  112031. * ModelShape id of this particle
  112032. */
  112033. shapeId: number;
  112034. /**
  112035. * Index of the particle in its shape id
  112036. */
  112037. idxInShape: number;
  112038. /**
  112039. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112040. */
  112041. _modelBoundingInfo: BoundingInfo;
  112042. /**
  112043. * @hidden Particle BoundingInfo object (Internal use)
  112044. */
  112045. _boundingInfo: BoundingInfo;
  112046. /**
  112047. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112048. */
  112049. _sps: SolidParticleSystem;
  112050. /**
  112051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112052. */
  112053. _stillInvisible: boolean;
  112054. /**
  112055. * @hidden Last computed particle rotation matrix
  112056. */
  112057. _rotationMatrix: number[];
  112058. /**
  112059. * Parent particle Id, if any.
  112060. * Default null.
  112061. */
  112062. parentId: Nullable<number>;
  112063. /**
  112064. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112065. */
  112066. materialIndex: Nullable<number>;
  112067. /**
  112068. * Custom object or properties.
  112069. */
  112070. props: Nullable<any>;
  112071. /**
  112072. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112073. * The possible values are :
  112074. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112075. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112077. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112078. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112079. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112080. * */
  112081. cullingStrategy: number;
  112082. /**
  112083. * @hidden Internal global position in the SPS.
  112084. */
  112085. _globalPosition: Vector3;
  112086. /**
  112087. * Creates a Solid Particle object.
  112088. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112089. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112090. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112091. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112092. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112093. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112094. * @param shapeId (integer) is the model shape identifier in the SPS.
  112095. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112096. * @param sps defines the sps it is associated to
  112097. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112098. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112099. */
  112100. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112101. /**
  112102. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112103. * @param target the particle target
  112104. * @returns the current particle
  112105. */
  112106. copyToRef(target: SolidParticle): SolidParticle;
  112107. /**
  112108. * Legacy support, changed scale to scaling
  112109. */
  112110. get scale(): Vector3;
  112111. /**
  112112. * Legacy support, changed scale to scaling
  112113. */
  112114. set scale(scale: Vector3);
  112115. /**
  112116. * Legacy support, changed quaternion to rotationQuaternion
  112117. */
  112118. get quaternion(): Nullable<Quaternion>;
  112119. /**
  112120. * Legacy support, changed quaternion to rotationQuaternion
  112121. */
  112122. set quaternion(q: Nullable<Quaternion>);
  112123. /**
  112124. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112125. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112126. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112127. * @returns true if it intersects
  112128. */
  112129. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112130. /**
  112131. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112132. * A particle is in the frustum if its bounding box intersects the frustum
  112133. * @param frustumPlanes defines the frustum to test
  112134. * @returns true if the particle is in the frustum planes
  112135. */
  112136. isInFrustum(frustumPlanes: Plane[]): boolean;
  112137. /**
  112138. * get the rotation matrix of the particle
  112139. * @hidden
  112140. */
  112141. getRotationMatrix(m: Matrix): void;
  112142. }
  112143. /**
  112144. * Represents the shape of the model used by one particle of a solid particle system.
  112145. * SPS internal tool, don't use it manually.
  112146. */
  112147. export class ModelShape {
  112148. /**
  112149. * The shape id
  112150. * @hidden
  112151. */
  112152. shapeID: number;
  112153. /**
  112154. * flat array of model positions (internal use)
  112155. * @hidden
  112156. */
  112157. _shape: Vector3[];
  112158. /**
  112159. * flat array of model UVs (internal use)
  112160. * @hidden
  112161. */
  112162. _shapeUV: number[];
  112163. /**
  112164. * color array of the model
  112165. * @hidden
  112166. */
  112167. _shapeColors: number[];
  112168. /**
  112169. * indices array of the model
  112170. * @hidden
  112171. */
  112172. _indices: number[];
  112173. /**
  112174. * normals array of the model
  112175. * @hidden
  112176. */
  112177. _normals: number[];
  112178. /**
  112179. * length of the shape in the model indices array (internal use)
  112180. * @hidden
  112181. */
  112182. _indicesLength: number;
  112183. /**
  112184. * Custom position function (internal use)
  112185. * @hidden
  112186. */
  112187. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112188. /**
  112189. * Custom vertex function (internal use)
  112190. * @hidden
  112191. */
  112192. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112193. /**
  112194. * Model material (internal use)
  112195. * @hidden
  112196. */
  112197. _material: Nullable<Material>;
  112198. /**
  112199. * 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.
  112200. * SPS internal tool, don't use it manually.
  112201. * @hidden
  112202. */
  112203. 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>);
  112204. }
  112205. /**
  112206. * Represents a Depth Sorted Particle in the solid particle system.
  112207. * @hidden
  112208. */
  112209. export class DepthSortedParticle {
  112210. /**
  112211. * Particle index
  112212. */
  112213. idx: number;
  112214. /**
  112215. * Index of the particle in the "indices" array
  112216. */
  112217. ind: number;
  112218. /**
  112219. * Length of the particle shape in the "indices" array
  112220. */
  112221. indicesLength: number;
  112222. /**
  112223. * Squared distance from the particle to the camera
  112224. */
  112225. sqDistance: number;
  112226. /**
  112227. * Material index when used with MultiMaterials
  112228. */
  112229. materialIndex: number;
  112230. /**
  112231. * Creates a new sorted particle
  112232. * @param materialIndex
  112233. */
  112234. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112235. }
  112236. /**
  112237. * Represents a solid particle vertex
  112238. */
  112239. export class SolidParticleVertex {
  112240. /**
  112241. * Vertex position
  112242. */
  112243. position: Vector3;
  112244. /**
  112245. * Vertex color
  112246. */
  112247. color: Color4;
  112248. /**
  112249. * Vertex UV
  112250. */
  112251. uv: Vector2;
  112252. /**
  112253. * Creates a new solid particle vertex
  112254. */
  112255. constructor();
  112256. /** Vertex x coordinate */
  112257. get x(): number;
  112258. set x(val: number);
  112259. /** Vertex y coordinate */
  112260. get y(): number;
  112261. set y(val: number);
  112262. /** Vertex z coordinate */
  112263. get z(): number;
  112264. set z(val: number);
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. /**
  112269. * @hidden
  112270. */
  112271. export class _MeshCollisionData {
  112272. _checkCollisions: boolean;
  112273. _collisionMask: number;
  112274. _collisionGroup: number;
  112275. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112276. _collider: Nullable<Collider>;
  112277. _oldPositionForCollisions: Vector3;
  112278. _diffPositionForCollisions: Vector3;
  112279. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112280. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112281. _collisionResponse: boolean;
  112282. }
  112283. }
  112284. declare module BABYLON {
  112285. /** @hidden */
  112286. class _FacetDataStorage {
  112287. facetPositions: Vector3[];
  112288. facetNormals: Vector3[];
  112289. facetPartitioning: number[][];
  112290. facetNb: number;
  112291. partitioningSubdivisions: number;
  112292. partitioningBBoxRatio: number;
  112293. facetDataEnabled: boolean;
  112294. facetParameters: any;
  112295. bbSize: Vector3;
  112296. subDiv: {
  112297. max: number;
  112298. X: number;
  112299. Y: number;
  112300. Z: number;
  112301. };
  112302. facetDepthSort: boolean;
  112303. facetDepthSortEnabled: boolean;
  112304. depthSortedIndices: IndicesArray;
  112305. depthSortedFacets: {
  112306. ind: number;
  112307. sqDistance: number;
  112308. }[];
  112309. facetDepthSortFunction: (f1: {
  112310. ind: number;
  112311. sqDistance: number;
  112312. }, f2: {
  112313. ind: number;
  112314. sqDistance: number;
  112315. }) => number;
  112316. facetDepthSortFrom: Vector3;
  112317. facetDepthSortOrigin: Vector3;
  112318. invertedMatrix: Matrix;
  112319. }
  112320. /**
  112321. * @hidden
  112322. **/
  112323. class _InternalAbstractMeshDataInfo {
  112324. _hasVertexAlpha: boolean;
  112325. _useVertexColors: boolean;
  112326. _numBoneInfluencers: number;
  112327. _applyFog: boolean;
  112328. _receiveShadows: boolean;
  112329. _facetData: _FacetDataStorage;
  112330. _visibility: number;
  112331. _skeleton: Nullable<Skeleton>;
  112332. _layerMask: number;
  112333. _computeBonesUsingShaders: boolean;
  112334. _isActive: boolean;
  112335. _onlyForInstances: boolean;
  112336. _isActiveIntermediate: boolean;
  112337. _onlyForInstancesIntermediate: boolean;
  112338. _actAsRegularMesh: boolean;
  112339. }
  112340. /**
  112341. * Class used to store all common mesh properties
  112342. */
  112343. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112344. /** No occlusion */
  112345. static OCCLUSION_TYPE_NONE: number;
  112346. /** Occlusion set to optimisitic */
  112347. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112348. /** Occlusion set to strict */
  112349. static OCCLUSION_TYPE_STRICT: number;
  112350. /** Use an accurante occlusion algorithm */
  112351. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112352. /** Use a conservative occlusion algorithm */
  112353. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112354. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112355. * Test order :
  112356. * Is the bounding sphere outside the frustum ?
  112357. * If not, are the bounding box vertices outside the frustum ?
  112358. * It not, then the cullable object is in the frustum.
  112359. */
  112360. static readonly CULLINGSTRATEGY_STANDARD: number;
  112361. /** Culling strategy : Bounding Sphere Only.
  112362. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112363. * It's also less accurate than the standard because some not visible objects can still be selected.
  112364. * Test : is the bounding sphere outside the frustum ?
  112365. * If not, then the cullable object is in the frustum.
  112366. */
  112367. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112368. /** Culling strategy : Optimistic Inclusion.
  112369. * This in an inclusion test first, then the standard exclusion test.
  112370. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112371. * 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.
  112372. * Anyway, it's as accurate as the standard strategy.
  112373. * Test :
  112374. * Is the cullable object bounding sphere center in the frustum ?
  112375. * If not, apply the default culling strategy.
  112376. */
  112377. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112378. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112379. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112380. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112381. * 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.
  112382. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112383. * Test :
  112384. * Is the cullable object bounding sphere center in the frustum ?
  112385. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112386. */
  112387. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112388. /**
  112389. * No billboard
  112390. */
  112391. static get BILLBOARDMODE_NONE(): number;
  112392. /** Billboard on X axis */
  112393. static get BILLBOARDMODE_X(): number;
  112394. /** Billboard on Y axis */
  112395. static get BILLBOARDMODE_Y(): number;
  112396. /** Billboard on Z axis */
  112397. static get BILLBOARDMODE_Z(): number;
  112398. /** Billboard on all axes */
  112399. static get BILLBOARDMODE_ALL(): number;
  112400. /** Billboard on using position instead of orientation */
  112401. static get BILLBOARDMODE_USE_POSITION(): number;
  112402. /** @hidden */
  112403. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112404. /**
  112405. * The culling strategy to use to check whether the mesh must be rendered or not.
  112406. * This value can be changed at any time and will be used on the next render mesh selection.
  112407. * The possible values are :
  112408. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112409. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112410. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112411. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112412. * Please read each static variable documentation to get details about the culling process.
  112413. * */
  112414. cullingStrategy: number;
  112415. /**
  112416. * Gets the number of facets in the mesh
  112417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112418. */
  112419. get facetNb(): number;
  112420. /**
  112421. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112422. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112423. */
  112424. get partitioningSubdivisions(): number;
  112425. set partitioningSubdivisions(nb: number);
  112426. /**
  112427. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112428. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112429. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112430. */
  112431. get partitioningBBoxRatio(): number;
  112432. set partitioningBBoxRatio(ratio: number);
  112433. /**
  112434. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112435. * Works only for updatable meshes.
  112436. * Doesn't work with multi-materials
  112437. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112438. */
  112439. get mustDepthSortFacets(): boolean;
  112440. set mustDepthSortFacets(sort: boolean);
  112441. /**
  112442. * The location (Vector3) where the facet depth sort must be computed from.
  112443. * By default, the active camera position.
  112444. * Used only when facet depth sort is enabled
  112445. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112446. */
  112447. get facetDepthSortFrom(): Vector3;
  112448. set facetDepthSortFrom(location: Vector3);
  112449. /**
  112450. * gets a boolean indicating if facetData is enabled
  112451. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112452. */
  112453. get isFacetDataEnabled(): boolean;
  112454. /** @hidden */
  112455. _updateNonUniformScalingState(value: boolean): boolean;
  112456. /**
  112457. * An event triggered when this mesh collides with another one
  112458. */
  112459. onCollideObservable: Observable<AbstractMesh>;
  112460. /** Set a function to call when this mesh collides with another one */
  112461. set onCollide(callback: () => void);
  112462. /**
  112463. * An event triggered when the collision's position changes
  112464. */
  112465. onCollisionPositionChangeObservable: Observable<Vector3>;
  112466. /** Set a function to call when the collision's position changes */
  112467. set onCollisionPositionChange(callback: () => void);
  112468. /**
  112469. * An event triggered when material is changed
  112470. */
  112471. onMaterialChangedObservable: Observable<AbstractMesh>;
  112472. /**
  112473. * Gets or sets the orientation for POV movement & rotation
  112474. */
  112475. definedFacingForward: boolean;
  112476. /** @hidden */
  112477. _occlusionQuery: Nullable<WebGLQuery>;
  112478. /** @hidden */
  112479. _renderingGroup: Nullable<RenderingGroup>;
  112480. /**
  112481. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112482. */
  112483. get visibility(): number;
  112484. /**
  112485. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112486. */
  112487. set visibility(value: number);
  112488. /** Gets or sets the alpha index used to sort transparent meshes
  112489. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112490. */
  112491. alphaIndex: number;
  112492. /**
  112493. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112494. */
  112495. isVisible: boolean;
  112496. /**
  112497. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112498. */
  112499. isPickable: boolean;
  112500. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112501. showSubMeshesBoundingBox: boolean;
  112502. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112503. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112504. */
  112505. isBlocker: boolean;
  112506. /**
  112507. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112508. */
  112509. enablePointerMoveEvents: boolean;
  112510. private _renderingGroupId;
  112511. /**
  112512. * Specifies the rendering group id for this mesh (0 by default)
  112513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112514. */
  112515. get renderingGroupId(): number;
  112516. set renderingGroupId(value: number);
  112517. private _material;
  112518. /** Gets or sets current material */
  112519. get material(): Nullable<Material>;
  112520. set material(value: Nullable<Material>);
  112521. /**
  112522. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112523. * @see https://doc.babylonjs.com/babylon101/shadows
  112524. */
  112525. get receiveShadows(): boolean;
  112526. set receiveShadows(value: boolean);
  112527. /** Defines color to use when rendering outline */
  112528. outlineColor: Color3;
  112529. /** Define width to use when rendering outline */
  112530. outlineWidth: number;
  112531. /** Defines color to use when rendering overlay */
  112532. overlayColor: Color3;
  112533. /** Defines alpha to use when rendering overlay */
  112534. overlayAlpha: number;
  112535. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112536. get hasVertexAlpha(): boolean;
  112537. set hasVertexAlpha(value: boolean);
  112538. /** 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) */
  112539. get useVertexColors(): boolean;
  112540. set useVertexColors(value: boolean);
  112541. /**
  112542. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112543. */
  112544. get computeBonesUsingShaders(): boolean;
  112545. set computeBonesUsingShaders(value: boolean);
  112546. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112547. get numBoneInfluencers(): number;
  112548. set numBoneInfluencers(value: number);
  112549. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112550. get applyFog(): boolean;
  112551. set applyFog(value: boolean);
  112552. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112553. useOctreeForRenderingSelection: boolean;
  112554. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112555. useOctreeForPicking: boolean;
  112556. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112557. useOctreeForCollisions: boolean;
  112558. /**
  112559. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112560. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112561. */
  112562. get layerMask(): number;
  112563. set layerMask(value: number);
  112564. /**
  112565. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112566. */
  112567. alwaysSelectAsActiveMesh: boolean;
  112568. /**
  112569. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112570. */
  112571. doNotSyncBoundingInfo: boolean;
  112572. /**
  112573. * Gets or sets the current action manager
  112574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112575. */
  112576. actionManager: Nullable<AbstractActionManager>;
  112577. private _meshCollisionData;
  112578. /**
  112579. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112580. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112581. */
  112582. ellipsoid: Vector3;
  112583. /**
  112584. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112585. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112586. */
  112587. ellipsoidOffset: Vector3;
  112588. /**
  112589. * Gets or sets a collision mask used to mask collisions (default is -1).
  112590. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112591. */
  112592. get collisionMask(): number;
  112593. set collisionMask(mask: number);
  112594. /**
  112595. * Gets or sets a collision response flag (default is true).
  112596. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112597. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112598. * to respond to the collision.
  112599. */
  112600. get collisionResponse(): boolean;
  112601. set collisionResponse(response: boolean);
  112602. /**
  112603. * Gets or sets the current collision group mask (-1 by default).
  112604. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112605. */
  112606. get collisionGroup(): number;
  112607. set collisionGroup(mask: number);
  112608. /**
  112609. * Gets or sets current surrounding meshes (null by default).
  112610. *
  112611. * By default collision detection is tested against every mesh in the scene.
  112612. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112613. * meshes will be tested for the collision.
  112614. *
  112615. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112616. */
  112617. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112618. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112619. /**
  112620. * Defines edge width used when edgesRenderer is enabled
  112621. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112622. */
  112623. edgesWidth: number;
  112624. /**
  112625. * Defines edge color used when edgesRenderer is enabled
  112626. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112627. */
  112628. edgesColor: Color4;
  112629. /** @hidden */
  112630. _edgesRenderer: Nullable<IEdgesRenderer>;
  112631. /** @hidden */
  112632. _masterMesh: Nullable<AbstractMesh>;
  112633. /** @hidden */
  112634. _boundingInfo: Nullable<BoundingInfo>;
  112635. /** @hidden */
  112636. _renderId: number;
  112637. /**
  112638. * Gets or sets the list of subMeshes
  112639. * @see https://doc.babylonjs.com/how_to/multi_materials
  112640. */
  112641. subMeshes: SubMesh[];
  112642. /** @hidden */
  112643. _intersectionsInProgress: AbstractMesh[];
  112644. /** @hidden */
  112645. _unIndexed: boolean;
  112646. /** @hidden */
  112647. _lightSources: Light[];
  112648. /** Gets the list of lights affecting that mesh */
  112649. get lightSources(): Light[];
  112650. /** @hidden */
  112651. get _positions(): Nullable<Vector3[]>;
  112652. /** @hidden */
  112653. _waitingData: {
  112654. lods: Nullable<any>;
  112655. actions: Nullable<any>;
  112656. freezeWorldMatrix: Nullable<boolean>;
  112657. };
  112658. /** @hidden */
  112659. _bonesTransformMatrices: Nullable<Float32Array>;
  112660. /** @hidden */
  112661. _transformMatrixTexture: Nullable<RawTexture>;
  112662. /**
  112663. * Gets or sets a skeleton to apply skining transformations
  112664. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112665. */
  112666. set skeleton(value: Nullable<Skeleton>);
  112667. get skeleton(): Nullable<Skeleton>;
  112668. /**
  112669. * An event triggered when the mesh is rebuilt.
  112670. */
  112671. onRebuildObservable: Observable<AbstractMesh>;
  112672. /**
  112673. * Creates a new AbstractMesh
  112674. * @param name defines the name of the mesh
  112675. * @param scene defines the hosting scene
  112676. */
  112677. constructor(name: string, scene?: Nullable<Scene>);
  112678. /**
  112679. * Returns the string "AbstractMesh"
  112680. * @returns "AbstractMesh"
  112681. */
  112682. getClassName(): string;
  112683. /**
  112684. * Gets a string representation of the current mesh
  112685. * @param fullDetails defines a boolean indicating if full details must be included
  112686. * @returns a string representation of the current mesh
  112687. */
  112688. toString(fullDetails?: boolean): string;
  112689. /**
  112690. * @hidden
  112691. */
  112692. protected _getEffectiveParent(): Nullable<Node>;
  112693. /** @hidden */
  112694. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112695. /** @hidden */
  112696. _rebuild(): void;
  112697. /** @hidden */
  112698. _resyncLightSources(): void;
  112699. /** @hidden */
  112700. _resyncLightSource(light: Light): void;
  112701. /** @hidden */
  112702. _unBindEffect(): void;
  112703. /** @hidden */
  112704. _removeLightSource(light: Light, dispose: boolean): void;
  112705. private _markSubMeshesAsDirty;
  112706. /** @hidden */
  112707. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112708. /** @hidden */
  112709. _markSubMeshesAsAttributesDirty(): void;
  112710. /** @hidden */
  112711. _markSubMeshesAsMiscDirty(): void;
  112712. /**
  112713. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112714. */
  112715. get scaling(): Vector3;
  112716. set scaling(newScaling: Vector3);
  112717. /**
  112718. * Returns true if the mesh is blocked. Implemented by child classes
  112719. */
  112720. get isBlocked(): boolean;
  112721. /**
  112722. * Returns the mesh itself by default. Implemented by child classes
  112723. * @param camera defines the camera to use to pick the right LOD level
  112724. * @returns the currentAbstractMesh
  112725. */
  112726. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112727. /**
  112728. * Returns 0 by default. Implemented by child classes
  112729. * @returns an integer
  112730. */
  112731. getTotalVertices(): number;
  112732. /**
  112733. * Returns a positive integer : the total number of indices in this mesh geometry.
  112734. * @returns the numner of indices or zero if the mesh has no geometry.
  112735. */
  112736. getTotalIndices(): number;
  112737. /**
  112738. * Returns null by default. Implemented by child classes
  112739. * @returns null
  112740. */
  112741. getIndices(): Nullable<IndicesArray>;
  112742. /**
  112743. * Returns the array of the requested vertex data kind. Implemented by child classes
  112744. * @param kind defines the vertex data kind to use
  112745. * @returns null
  112746. */
  112747. getVerticesData(kind: string): Nullable<FloatArray>;
  112748. /**
  112749. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112750. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112751. * Note that a new underlying VertexBuffer object is created each call.
  112752. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112753. * @param kind defines vertex data kind:
  112754. * * VertexBuffer.PositionKind
  112755. * * VertexBuffer.UVKind
  112756. * * VertexBuffer.UV2Kind
  112757. * * VertexBuffer.UV3Kind
  112758. * * VertexBuffer.UV4Kind
  112759. * * VertexBuffer.UV5Kind
  112760. * * VertexBuffer.UV6Kind
  112761. * * VertexBuffer.ColorKind
  112762. * * VertexBuffer.MatricesIndicesKind
  112763. * * VertexBuffer.MatricesIndicesExtraKind
  112764. * * VertexBuffer.MatricesWeightsKind
  112765. * * VertexBuffer.MatricesWeightsExtraKind
  112766. * @param data defines the data source
  112767. * @param updatable defines if the data must be flagged as updatable (or static)
  112768. * @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
  112769. * @returns the current mesh
  112770. */
  112771. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112772. /**
  112773. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112774. * If the mesh has no geometry, it is simply returned as it is.
  112775. * @param kind defines vertex data kind:
  112776. * * VertexBuffer.PositionKind
  112777. * * VertexBuffer.UVKind
  112778. * * VertexBuffer.UV2Kind
  112779. * * VertexBuffer.UV3Kind
  112780. * * VertexBuffer.UV4Kind
  112781. * * VertexBuffer.UV5Kind
  112782. * * VertexBuffer.UV6Kind
  112783. * * VertexBuffer.ColorKind
  112784. * * VertexBuffer.MatricesIndicesKind
  112785. * * VertexBuffer.MatricesIndicesExtraKind
  112786. * * VertexBuffer.MatricesWeightsKind
  112787. * * VertexBuffer.MatricesWeightsExtraKind
  112788. * @param data defines the data source
  112789. * @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
  112790. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112791. * @returns the current mesh
  112792. */
  112793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112794. /**
  112795. * Sets the mesh indices,
  112796. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112797. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112798. * @param totalVertices Defines the total number of vertices
  112799. * @returns the current mesh
  112800. */
  112801. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112802. /**
  112803. * Gets a boolean indicating if specific vertex data is present
  112804. * @param kind defines the vertex data kind to use
  112805. * @returns true is data kind is present
  112806. */
  112807. isVerticesDataPresent(kind: string): boolean;
  112808. /**
  112809. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112810. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112811. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112812. * @returns a BoundingInfo
  112813. */
  112814. getBoundingInfo(): BoundingInfo;
  112815. /**
  112816. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112817. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112818. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112819. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112820. * @returns the current mesh
  112821. */
  112822. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112823. /**
  112824. * Overwrite the current bounding info
  112825. * @param boundingInfo defines the new bounding info
  112826. * @returns the current mesh
  112827. */
  112828. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112829. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112830. get useBones(): boolean;
  112831. /** @hidden */
  112832. _preActivate(): void;
  112833. /** @hidden */
  112834. _preActivateForIntermediateRendering(renderId: number): void;
  112835. /** @hidden */
  112836. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112837. /** @hidden */
  112838. _postActivate(): void;
  112839. /** @hidden */
  112840. _freeze(): void;
  112841. /** @hidden */
  112842. _unFreeze(): void;
  112843. /**
  112844. * Gets the current world matrix
  112845. * @returns a Matrix
  112846. */
  112847. getWorldMatrix(): Matrix;
  112848. /** @hidden */
  112849. _getWorldMatrixDeterminant(): number;
  112850. /**
  112851. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112852. */
  112853. get isAnInstance(): boolean;
  112854. /**
  112855. * Gets a boolean indicating if this mesh has instances
  112856. */
  112857. get hasInstances(): boolean;
  112858. /**
  112859. * Gets a boolean indicating if this mesh has thin instances
  112860. */
  112861. get hasThinInstances(): boolean;
  112862. /**
  112863. * Perform relative position change from the point of view of behind the front of the mesh.
  112864. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112865. * Supports definition of mesh facing forward or backward
  112866. * @param amountRight defines the distance on the right axis
  112867. * @param amountUp defines the distance on the up axis
  112868. * @param amountForward defines the distance on the forward axis
  112869. * @returns the current mesh
  112870. */
  112871. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112872. /**
  112873. * Calculate relative position change from the point of view of behind the front of the mesh.
  112874. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112875. * Supports definition of mesh facing forward or backward
  112876. * @param amountRight defines the distance on the right axis
  112877. * @param amountUp defines the distance on the up axis
  112878. * @param amountForward defines the distance on the forward axis
  112879. * @returns the new displacement vector
  112880. */
  112881. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112882. /**
  112883. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112884. * Supports definition of mesh facing forward or backward
  112885. * @param flipBack defines the flip
  112886. * @param twirlClockwise defines the twirl
  112887. * @param tiltRight defines the tilt
  112888. * @returns the current mesh
  112889. */
  112890. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112891. /**
  112892. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112893. * Supports definition of mesh facing forward or backward.
  112894. * @param flipBack defines the flip
  112895. * @param twirlClockwise defines the twirl
  112896. * @param tiltRight defines the tilt
  112897. * @returns the new rotation vector
  112898. */
  112899. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112900. /**
  112901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112902. * This means the mesh underlying bounding box and sphere are recomputed.
  112903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112904. * @returns the current mesh
  112905. */
  112906. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112907. /** @hidden */
  112908. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112909. /** @hidden */
  112910. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112911. /** @hidden */
  112912. _updateBoundingInfo(): AbstractMesh;
  112913. /** @hidden */
  112914. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112915. /** @hidden */
  112916. protected _afterComputeWorldMatrix(): void;
  112917. /** @hidden */
  112918. get _effectiveMesh(): AbstractMesh;
  112919. /**
  112920. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112921. * A mesh is in the frustum if its bounding box intersects the frustum
  112922. * @param frustumPlanes defines the frustum to test
  112923. * @returns true if the mesh is in the frustum planes
  112924. */
  112925. isInFrustum(frustumPlanes: Plane[]): boolean;
  112926. /**
  112927. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112928. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112929. * @param frustumPlanes defines the frustum to test
  112930. * @returns true if the mesh is completely in the frustum planes
  112931. */
  112932. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112933. /**
  112934. * True if the mesh intersects another mesh or a SolidParticle object
  112935. * @param mesh defines a target mesh or SolidParticle to test
  112936. * @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)
  112937. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112938. * @returns true if there is an intersection
  112939. */
  112940. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112941. /**
  112942. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112943. * @param point defines the point to test
  112944. * @returns true if there is an intersection
  112945. */
  112946. intersectsPoint(point: Vector3): boolean;
  112947. /**
  112948. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112949. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112950. */
  112951. get checkCollisions(): boolean;
  112952. set checkCollisions(collisionEnabled: boolean);
  112953. /**
  112954. * Gets Collider object used to compute collisions (not physics)
  112955. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112956. */
  112957. get collider(): Nullable<Collider>;
  112958. /**
  112959. * Move the mesh using collision engine
  112960. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112961. * @param displacement defines the requested displacement vector
  112962. * @returns the current mesh
  112963. */
  112964. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112965. private _onCollisionPositionChange;
  112966. /** @hidden */
  112967. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112968. /** @hidden */
  112969. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112970. /** @hidden */
  112971. _checkCollision(collider: Collider): AbstractMesh;
  112972. /** @hidden */
  112973. _generatePointsArray(): boolean;
  112974. /**
  112975. * Checks if the passed Ray intersects with the mesh
  112976. * @param ray defines the ray to use
  112977. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112978. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112979. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112980. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112981. * @returns the picking info
  112982. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112983. */
  112984. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112985. /**
  112986. * Clones the current mesh
  112987. * @param name defines the mesh name
  112988. * @param newParent defines the new mesh parent
  112989. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112990. * @returns the new mesh
  112991. */
  112992. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112993. /**
  112994. * Disposes all the submeshes of the current meshnp
  112995. * @returns the current mesh
  112996. */
  112997. releaseSubMeshes(): AbstractMesh;
  112998. /**
  112999. * Releases resources associated with this abstract mesh.
  113000. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113001. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113002. */
  113003. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113004. /**
  113005. * Adds the passed mesh as a child to the current mesh
  113006. * @param mesh defines the child mesh
  113007. * @returns the current mesh
  113008. */
  113009. addChild(mesh: AbstractMesh): AbstractMesh;
  113010. /**
  113011. * Removes the passed mesh from the current mesh children list
  113012. * @param mesh defines the child mesh
  113013. * @returns the current mesh
  113014. */
  113015. removeChild(mesh: AbstractMesh): AbstractMesh;
  113016. /** @hidden */
  113017. private _initFacetData;
  113018. /**
  113019. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113020. * This method can be called within the render loop.
  113021. * 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
  113022. * @returns the current mesh
  113023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113024. */
  113025. updateFacetData(): AbstractMesh;
  113026. /**
  113027. * Returns the facetLocalNormals array.
  113028. * The normals are expressed in the mesh local spac
  113029. * @returns an array of Vector3
  113030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113031. */
  113032. getFacetLocalNormals(): Vector3[];
  113033. /**
  113034. * Returns the facetLocalPositions array.
  113035. * The facet positions are expressed in the mesh local space
  113036. * @returns an array of Vector3
  113037. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113038. */
  113039. getFacetLocalPositions(): Vector3[];
  113040. /**
  113041. * Returns the facetLocalPartioning array
  113042. * @returns an array of array of numbers
  113043. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113044. */
  113045. getFacetLocalPartitioning(): number[][];
  113046. /**
  113047. * Returns the i-th facet position in the world system.
  113048. * This method allocates a new Vector3 per call
  113049. * @param i defines the facet index
  113050. * @returns a new Vector3
  113051. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113052. */
  113053. getFacetPosition(i: number): Vector3;
  113054. /**
  113055. * Sets the reference Vector3 with the i-th facet position in the world system
  113056. * @param i defines the facet index
  113057. * @param ref defines the target vector
  113058. * @returns the current mesh
  113059. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113060. */
  113061. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113062. /**
  113063. * Returns the i-th facet normal in the world system.
  113064. * This method allocates a new Vector3 per call
  113065. * @param i defines the facet index
  113066. * @returns a new Vector3
  113067. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113068. */
  113069. getFacetNormal(i: number): Vector3;
  113070. /**
  113071. * Sets the reference Vector3 with the i-th facet normal in the world system
  113072. * @param i defines the facet index
  113073. * @param ref defines the target vector
  113074. * @returns the current mesh
  113075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113076. */
  113077. getFacetNormalToRef(i: number, ref: Vector3): this;
  113078. /**
  113079. * 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)
  113080. * @param x defines x coordinate
  113081. * @param y defines y coordinate
  113082. * @param z defines z coordinate
  113083. * @returns the array of facet indexes
  113084. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113085. */
  113086. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113087. /**
  113088. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113089. * @param projected sets as the (x,y,z) world projection on the facet
  113090. * @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
  113091. * @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
  113092. * @param x defines x coordinate
  113093. * @param y defines y coordinate
  113094. * @param z defines z coordinate
  113095. * @returns the face index if found (or null instead)
  113096. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113097. */
  113098. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113099. /**
  113100. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113101. * @param projected sets as the (x,y,z) local projection on the facet
  113102. * @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
  113103. * @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
  113104. * @param x defines x coordinate
  113105. * @param y defines y coordinate
  113106. * @param z defines z coordinate
  113107. * @returns the face index if found (or null instead)
  113108. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113109. */
  113110. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113111. /**
  113112. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113113. * @returns the parameters
  113114. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113115. */
  113116. getFacetDataParameters(): any;
  113117. /**
  113118. * Disables the feature FacetData and frees the related memory
  113119. * @returns the current mesh
  113120. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113121. */
  113122. disableFacetData(): AbstractMesh;
  113123. /**
  113124. * Updates the AbstractMesh indices array
  113125. * @param indices defines the data source
  113126. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113127. * @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)
  113128. * @returns the current mesh
  113129. */
  113130. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113131. /**
  113132. * Creates new normals data for the mesh
  113133. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113134. * @returns the current mesh
  113135. */
  113136. createNormals(updatable: boolean): AbstractMesh;
  113137. /**
  113138. * Align the mesh with a normal
  113139. * @param normal defines the normal to use
  113140. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113141. * @returns the current mesh
  113142. */
  113143. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113144. /** @hidden */
  113145. _checkOcclusionQuery(): boolean;
  113146. /**
  113147. * Disables the mesh edge rendering mode
  113148. * @returns the currentAbstractMesh
  113149. */
  113150. disableEdgesRendering(): AbstractMesh;
  113151. /**
  113152. * Enables the edge rendering mode on the mesh.
  113153. * This mode makes the mesh edges visible
  113154. * @param epsilon defines the maximal distance between two angles to detect a face
  113155. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113156. * @returns the currentAbstractMesh
  113157. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113158. */
  113159. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113160. /**
  113161. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113162. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113163. */
  113164. getConnectedParticleSystems(): IParticleSystem[];
  113165. }
  113166. }
  113167. declare module BABYLON {
  113168. /**
  113169. * Interface used to define ActionEvent
  113170. */
  113171. export interface IActionEvent {
  113172. /** The mesh or sprite that triggered the action */
  113173. source: any;
  113174. /** The X mouse cursor position at the time of the event */
  113175. pointerX: number;
  113176. /** The Y mouse cursor position at the time of the event */
  113177. pointerY: number;
  113178. /** The mesh that is currently pointed at (can be null) */
  113179. meshUnderPointer: Nullable<AbstractMesh>;
  113180. /** the original (browser) event that triggered the ActionEvent */
  113181. sourceEvent?: any;
  113182. /** additional data for the event */
  113183. additionalData?: any;
  113184. }
  113185. /**
  113186. * ActionEvent is the event being sent when an action is triggered.
  113187. */
  113188. export class ActionEvent implements IActionEvent {
  113189. /** The mesh or sprite that triggered the action */
  113190. source: any;
  113191. /** The X mouse cursor position at the time of the event */
  113192. pointerX: number;
  113193. /** The Y mouse cursor position at the time of the event */
  113194. pointerY: number;
  113195. /** The mesh that is currently pointed at (can be null) */
  113196. meshUnderPointer: Nullable<AbstractMesh>;
  113197. /** the original (browser) event that triggered the ActionEvent */
  113198. sourceEvent?: any;
  113199. /** additional data for the event */
  113200. additionalData?: any;
  113201. /**
  113202. * Creates a new ActionEvent
  113203. * @param source The mesh or sprite that triggered the action
  113204. * @param pointerX The X mouse cursor position at the time of the event
  113205. * @param pointerY The Y mouse cursor position at the time of the event
  113206. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113207. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113208. * @param additionalData additional data for the event
  113209. */
  113210. constructor(
  113211. /** The mesh or sprite that triggered the action */
  113212. source: any,
  113213. /** The X mouse cursor position at the time of the event */
  113214. pointerX: number,
  113215. /** The Y mouse cursor position at the time of the event */
  113216. pointerY: number,
  113217. /** The mesh that is currently pointed at (can be null) */
  113218. meshUnderPointer: Nullable<AbstractMesh>,
  113219. /** the original (browser) event that triggered the ActionEvent */
  113220. sourceEvent?: any,
  113221. /** additional data for the event */
  113222. additionalData?: any);
  113223. /**
  113224. * Helper function to auto-create an ActionEvent from a source mesh.
  113225. * @param source The source mesh that triggered the event
  113226. * @param evt The original (browser) event
  113227. * @param additionalData additional data for the event
  113228. * @returns the new ActionEvent
  113229. */
  113230. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113231. /**
  113232. * Helper function to auto-create an ActionEvent from a source sprite
  113233. * @param source The source sprite that triggered the event
  113234. * @param scene Scene associated with the sprite
  113235. * @param evt The original (browser) event
  113236. * @param additionalData additional data for the event
  113237. * @returns the new ActionEvent
  113238. */
  113239. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113240. /**
  113241. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113242. * @param scene the scene where the event occurred
  113243. * @param evt The original (browser) event
  113244. * @returns the new ActionEvent
  113245. */
  113246. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113247. /**
  113248. * Helper function to auto-create an ActionEvent from a primitive
  113249. * @param prim defines the target primitive
  113250. * @param pointerPos defines the pointer position
  113251. * @param evt The original (browser) event
  113252. * @param additionalData additional data for the event
  113253. * @returns the new ActionEvent
  113254. */
  113255. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113256. }
  113257. }
  113258. declare module BABYLON {
  113259. /**
  113260. * Abstract class used to decouple action Manager from scene and meshes.
  113261. * Do not instantiate.
  113262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113263. */
  113264. export abstract class AbstractActionManager implements IDisposable {
  113265. /** Gets the list of active triggers */
  113266. static Triggers: {
  113267. [key: string]: number;
  113268. };
  113269. /** Gets the cursor to use when hovering items */
  113270. hoverCursor: string;
  113271. /** Gets the list of actions */
  113272. actions: IAction[];
  113273. /**
  113274. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113275. */
  113276. isRecursive: boolean;
  113277. /**
  113278. * Releases all associated resources
  113279. */
  113280. abstract dispose(): void;
  113281. /**
  113282. * Does this action manager has pointer triggers
  113283. */
  113284. abstract get hasPointerTriggers(): boolean;
  113285. /**
  113286. * Does this action manager has pick triggers
  113287. */
  113288. abstract get hasPickTriggers(): boolean;
  113289. /**
  113290. * Process a specific trigger
  113291. * @param trigger defines the trigger to process
  113292. * @param evt defines the event details to be processed
  113293. */
  113294. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113295. /**
  113296. * Does this action manager handles actions of any of the given triggers
  113297. * @param triggers defines the triggers to be tested
  113298. * @return a boolean indicating whether one (or more) of the triggers is handled
  113299. */
  113300. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113301. /**
  113302. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113303. * speed.
  113304. * @param triggerA defines the trigger to be tested
  113305. * @param triggerB defines the trigger to be tested
  113306. * @return a boolean indicating whether one (or more) of the triggers is handled
  113307. */
  113308. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113309. /**
  113310. * Does this action manager handles actions of a given trigger
  113311. * @param trigger defines the trigger to be tested
  113312. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113313. * @return whether the trigger is handled
  113314. */
  113315. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113316. /**
  113317. * Serialize this manager to a JSON object
  113318. * @param name defines the property name to store this manager
  113319. * @returns a JSON representation of this manager
  113320. */
  113321. abstract serialize(name: string): any;
  113322. /**
  113323. * Registers an action to this action manager
  113324. * @param action defines the action to be registered
  113325. * @return the action amended (prepared) after registration
  113326. */
  113327. abstract registerAction(action: IAction): Nullable<IAction>;
  113328. /**
  113329. * Unregisters an action to this action manager
  113330. * @param action defines the action to be unregistered
  113331. * @return a boolean indicating whether the action has been unregistered
  113332. */
  113333. abstract unregisterAction(action: IAction): Boolean;
  113334. /**
  113335. * Does exist one action manager with at least one trigger
  113336. **/
  113337. static get HasTriggers(): boolean;
  113338. /**
  113339. * Does exist one action manager with at least one pick trigger
  113340. **/
  113341. static get HasPickTriggers(): boolean;
  113342. /**
  113343. * Does exist one action manager that handles actions of a given trigger
  113344. * @param trigger defines the trigger to be tested
  113345. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113346. **/
  113347. static HasSpecificTrigger(trigger: number): boolean;
  113348. }
  113349. }
  113350. declare module BABYLON {
  113351. /**
  113352. * Defines how a node can be built from a string name.
  113353. */
  113354. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113355. /**
  113356. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113357. */
  113358. export class Node implements IBehaviorAware<Node> {
  113359. /** @hidden */
  113360. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113361. private static _NodeConstructors;
  113362. /**
  113363. * Add a new node constructor
  113364. * @param type defines the type name of the node to construct
  113365. * @param constructorFunc defines the constructor function
  113366. */
  113367. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113368. /**
  113369. * Returns a node constructor based on type name
  113370. * @param type defines the type name
  113371. * @param name defines the new node name
  113372. * @param scene defines the hosting scene
  113373. * @param options defines optional options to transmit to constructors
  113374. * @returns the new constructor or null
  113375. */
  113376. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113377. /**
  113378. * Gets or sets the name of the node
  113379. */
  113380. name: string;
  113381. /**
  113382. * Gets or sets the id of the node
  113383. */
  113384. id: string;
  113385. /**
  113386. * Gets or sets the unique id of the node
  113387. */
  113388. uniqueId: number;
  113389. /**
  113390. * Gets or sets a string used to store user defined state for the node
  113391. */
  113392. state: string;
  113393. /**
  113394. * Gets or sets an object used to store user defined information for the node
  113395. */
  113396. metadata: any;
  113397. /**
  113398. * For internal use only. Please do not use.
  113399. */
  113400. reservedDataStore: any;
  113401. /**
  113402. * List of inspectable custom properties (used by the Inspector)
  113403. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113404. */
  113405. inspectableCustomProperties: IInspectable[];
  113406. private _doNotSerialize;
  113407. /**
  113408. * Gets or sets a boolean used to define if the node must be serialized
  113409. */
  113410. get doNotSerialize(): boolean;
  113411. set doNotSerialize(value: boolean);
  113412. /** @hidden */
  113413. _isDisposed: boolean;
  113414. /**
  113415. * Gets a list of Animations associated with the node
  113416. */
  113417. animations: Animation[];
  113418. protected _ranges: {
  113419. [name: string]: Nullable<AnimationRange>;
  113420. };
  113421. /**
  113422. * Callback raised when the node is ready to be used
  113423. */
  113424. onReady: Nullable<(node: Node) => void>;
  113425. private _isEnabled;
  113426. private _isParentEnabled;
  113427. private _isReady;
  113428. /** @hidden */
  113429. _currentRenderId: number;
  113430. private _parentUpdateId;
  113431. /** @hidden */
  113432. _childUpdateId: number;
  113433. /** @hidden */
  113434. _waitingParentId: Nullable<string>;
  113435. /** @hidden */
  113436. _scene: Scene;
  113437. /** @hidden */
  113438. _cache: any;
  113439. private _parentNode;
  113440. private _children;
  113441. /** @hidden */
  113442. _worldMatrix: Matrix;
  113443. /** @hidden */
  113444. _worldMatrixDeterminant: number;
  113445. /** @hidden */
  113446. _worldMatrixDeterminantIsDirty: boolean;
  113447. /** @hidden */
  113448. private _sceneRootNodesIndex;
  113449. /**
  113450. * Gets a boolean indicating if the node has been disposed
  113451. * @returns true if the node was disposed
  113452. */
  113453. isDisposed(): boolean;
  113454. /**
  113455. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113456. * @see https://doc.babylonjs.com/how_to/parenting
  113457. */
  113458. set parent(parent: Nullable<Node>);
  113459. get parent(): Nullable<Node>;
  113460. /** @hidden */
  113461. _addToSceneRootNodes(): void;
  113462. /** @hidden */
  113463. _removeFromSceneRootNodes(): void;
  113464. private _animationPropertiesOverride;
  113465. /**
  113466. * Gets or sets the animation properties override
  113467. */
  113468. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113469. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113470. /**
  113471. * Gets a string identifying the name of the class
  113472. * @returns "Node" string
  113473. */
  113474. getClassName(): string;
  113475. /** @hidden */
  113476. readonly _isNode: boolean;
  113477. /**
  113478. * An event triggered when the mesh is disposed
  113479. */
  113480. onDisposeObservable: Observable<Node>;
  113481. private _onDisposeObserver;
  113482. /**
  113483. * Sets a callback that will be raised when the node will be disposed
  113484. */
  113485. set onDispose(callback: () => void);
  113486. /**
  113487. * Creates a new Node
  113488. * @param name the name and id to be given to this node
  113489. * @param scene the scene this node will be added to
  113490. */
  113491. constructor(name: string, scene?: Nullable<Scene>);
  113492. /**
  113493. * Gets the scene of the node
  113494. * @returns a scene
  113495. */
  113496. getScene(): Scene;
  113497. /**
  113498. * Gets the engine of the node
  113499. * @returns a Engine
  113500. */
  113501. getEngine(): Engine;
  113502. private _behaviors;
  113503. /**
  113504. * Attach a behavior to the node
  113505. * @see https://doc.babylonjs.com/features/behaviour
  113506. * @param behavior defines the behavior to attach
  113507. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113508. * @returns the current Node
  113509. */
  113510. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113511. /**
  113512. * Remove an attached behavior
  113513. * @see https://doc.babylonjs.com/features/behaviour
  113514. * @param behavior defines the behavior to attach
  113515. * @returns the current Node
  113516. */
  113517. removeBehavior(behavior: Behavior<Node>): Node;
  113518. /**
  113519. * Gets the list of attached behaviors
  113520. * @see https://doc.babylonjs.com/features/behaviour
  113521. */
  113522. get behaviors(): Behavior<Node>[];
  113523. /**
  113524. * Gets an attached behavior by name
  113525. * @param name defines the name of the behavior to look for
  113526. * @see https://doc.babylonjs.com/features/behaviour
  113527. * @returns null if behavior was not found else the requested behavior
  113528. */
  113529. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113530. /**
  113531. * Returns the latest update of the World matrix
  113532. * @returns a Matrix
  113533. */
  113534. getWorldMatrix(): Matrix;
  113535. /** @hidden */
  113536. _getWorldMatrixDeterminant(): number;
  113537. /**
  113538. * Returns directly the latest state of the mesh World matrix.
  113539. * A Matrix is returned.
  113540. */
  113541. get worldMatrixFromCache(): Matrix;
  113542. /** @hidden */
  113543. _initCache(): void;
  113544. /** @hidden */
  113545. updateCache(force?: boolean): void;
  113546. /** @hidden */
  113547. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113548. /** @hidden */
  113549. _updateCache(ignoreParentClass?: boolean): void;
  113550. /** @hidden */
  113551. _isSynchronized(): boolean;
  113552. /** @hidden */
  113553. _markSyncedWithParent(): void;
  113554. /** @hidden */
  113555. isSynchronizedWithParent(): boolean;
  113556. /** @hidden */
  113557. isSynchronized(): boolean;
  113558. /**
  113559. * Is this node ready to be used/rendered
  113560. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113561. * @return true if the node is ready
  113562. */
  113563. isReady(completeCheck?: boolean): boolean;
  113564. /**
  113565. * Is this node enabled?
  113566. * 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
  113567. * @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
  113568. * @return whether this node (and its parent) is enabled
  113569. */
  113570. isEnabled(checkAncestors?: boolean): boolean;
  113571. /** @hidden */
  113572. protected _syncParentEnabledState(): void;
  113573. /**
  113574. * Set the enabled state of this node
  113575. * @param value defines the new enabled state
  113576. */
  113577. setEnabled(value: boolean): void;
  113578. /**
  113579. * Is this node a descendant of the given node?
  113580. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113581. * @param ancestor defines the parent node to inspect
  113582. * @returns a boolean indicating if this node is a descendant of the given node
  113583. */
  113584. isDescendantOf(ancestor: Node): boolean;
  113585. /** @hidden */
  113586. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113587. /**
  113588. * Will return all nodes that have this node as ascendant
  113589. * @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
  113590. * @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
  113591. * @return all children nodes of all types
  113592. */
  113593. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113594. /**
  113595. * Get all child-meshes of this node
  113596. * @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)
  113597. * @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
  113598. * @returns an array of AbstractMesh
  113599. */
  113600. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113601. /**
  113602. * Get all direct children of this node
  113603. * @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
  113604. * @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)
  113605. * @returns an array of Node
  113606. */
  113607. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113608. /** @hidden */
  113609. _setReady(state: boolean): void;
  113610. /**
  113611. * Get an animation by name
  113612. * @param name defines the name of the animation to look for
  113613. * @returns null if not found else the requested animation
  113614. */
  113615. getAnimationByName(name: string): Nullable<Animation>;
  113616. /**
  113617. * Creates an animation range for this node
  113618. * @param name defines the name of the range
  113619. * @param from defines the starting key
  113620. * @param to defines the end key
  113621. */
  113622. createAnimationRange(name: string, from: number, to: number): void;
  113623. /**
  113624. * Delete a specific animation range
  113625. * @param name defines the name of the range to delete
  113626. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113627. */
  113628. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113629. /**
  113630. * Get an animation range by name
  113631. * @param name defines the name of the animation range to look for
  113632. * @returns null if not found else the requested animation range
  113633. */
  113634. getAnimationRange(name: string): Nullable<AnimationRange>;
  113635. /**
  113636. * Gets the list of all animation ranges defined on this node
  113637. * @returns an array
  113638. */
  113639. getAnimationRanges(): Nullable<AnimationRange>[];
  113640. /**
  113641. * Will start the animation sequence
  113642. * @param name defines the range frames for animation sequence
  113643. * @param loop defines if the animation should loop (false by default)
  113644. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113645. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113646. * @returns the object created for this animation. If range does not exist, it will return null
  113647. */
  113648. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113649. /**
  113650. * Serialize animation ranges into a JSON compatible object
  113651. * @returns serialization object
  113652. */
  113653. serializeAnimationRanges(): any;
  113654. /**
  113655. * Computes the world matrix of the node
  113656. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113657. * @returns the world matrix
  113658. */
  113659. computeWorldMatrix(force?: boolean): Matrix;
  113660. /**
  113661. * Releases resources associated with this node.
  113662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113664. */
  113665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113666. /**
  113667. * Parse animation range data from a serialization object and store them into a given node
  113668. * @param node defines where to store the animation ranges
  113669. * @param parsedNode defines the serialization object to read data from
  113670. * @param scene defines the hosting scene
  113671. */
  113672. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113673. /**
  113674. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113675. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113676. * @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
  113677. * @returns the new bounding vectors
  113678. */
  113679. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113680. min: Vector3;
  113681. max: Vector3;
  113682. };
  113683. }
  113684. }
  113685. declare module BABYLON {
  113686. /**
  113687. * @hidden
  113688. */
  113689. export class _IAnimationState {
  113690. key: number;
  113691. repeatCount: number;
  113692. workValue?: any;
  113693. loopMode?: number;
  113694. offsetValue?: any;
  113695. highLimitValue?: any;
  113696. }
  113697. /**
  113698. * Class used to store any kind of animation
  113699. */
  113700. export class Animation {
  113701. /**Name of the animation */
  113702. name: string;
  113703. /**Property to animate */
  113704. targetProperty: string;
  113705. /**The frames per second of the animation */
  113706. framePerSecond: number;
  113707. /**The data type of the animation */
  113708. dataType: number;
  113709. /**The loop mode of the animation */
  113710. loopMode?: number | undefined;
  113711. /**Specifies if blending should be enabled */
  113712. enableBlending?: boolean | undefined;
  113713. /**
  113714. * Use matrix interpolation instead of using direct key value when animating matrices
  113715. */
  113716. static AllowMatricesInterpolation: boolean;
  113717. /**
  113718. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113719. */
  113720. static AllowMatrixDecomposeForInterpolation: boolean;
  113721. /** Define the Url to load snippets */
  113722. static SnippetUrl: string;
  113723. /** Snippet ID if the animation was created from the snippet server */
  113724. snippetId: string;
  113725. /**
  113726. * Stores the key frames of the animation
  113727. */
  113728. private _keys;
  113729. /**
  113730. * Stores the easing function of the animation
  113731. */
  113732. private _easingFunction;
  113733. /**
  113734. * @hidden Internal use only
  113735. */
  113736. _runtimeAnimations: RuntimeAnimation[];
  113737. /**
  113738. * The set of event that will be linked to this animation
  113739. */
  113740. private _events;
  113741. /**
  113742. * Stores an array of target property paths
  113743. */
  113744. targetPropertyPath: string[];
  113745. /**
  113746. * Stores the blending speed of the animation
  113747. */
  113748. blendingSpeed: number;
  113749. /**
  113750. * Stores the animation ranges for the animation
  113751. */
  113752. private _ranges;
  113753. /**
  113754. * @hidden Internal use
  113755. */
  113756. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113757. /**
  113758. * Sets up an animation
  113759. * @param property The property to animate
  113760. * @param animationType The animation type to apply
  113761. * @param framePerSecond The frames per second of the animation
  113762. * @param easingFunction The easing function used in the animation
  113763. * @returns The created animation
  113764. */
  113765. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113766. /**
  113767. * Create and start an animation on a node
  113768. * @param name defines the name of the global animation that will be run on all nodes
  113769. * @param node defines the root node where the animation will take place
  113770. * @param targetProperty defines property to animate
  113771. * @param framePerSecond defines the number of frame per second yo use
  113772. * @param totalFrame defines the number of frames in total
  113773. * @param from defines the initial value
  113774. * @param to defines the final value
  113775. * @param loopMode defines which loop mode you want to use (off by default)
  113776. * @param easingFunction defines the easing function to use (linear by default)
  113777. * @param onAnimationEnd defines the callback to call when animation end
  113778. * @returns the animatable created for this animation
  113779. */
  113780. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113781. /**
  113782. * Create and start an animation on a node and its descendants
  113783. * @param name defines the name of the global animation that will be run on all nodes
  113784. * @param node defines the root node where the animation will take place
  113785. * @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
  113786. * @param targetProperty defines property to animate
  113787. * @param framePerSecond defines the number of frame per second to use
  113788. * @param totalFrame defines the number of frames in total
  113789. * @param from defines the initial value
  113790. * @param to defines the final value
  113791. * @param loopMode defines which loop mode you want to use (off by default)
  113792. * @param easingFunction defines the easing function to use (linear by default)
  113793. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113794. * @returns the list of animatables created for all nodes
  113795. * @example https://www.babylonjs-playground.com/#MH0VLI
  113796. */
  113797. 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[]>;
  113798. /**
  113799. * Creates a new animation, merges it with the existing animations and starts it
  113800. * @param name Name of the animation
  113801. * @param node Node which contains the scene that begins the animations
  113802. * @param targetProperty Specifies which property to animate
  113803. * @param framePerSecond The frames per second of the animation
  113804. * @param totalFrame The total number of frames
  113805. * @param from The frame at the beginning of the animation
  113806. * @param to The frame at the end of the animation
  113807. * @param loopMode Specifies the loop mode of the animation
  113808. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113809. * @param onAnimationEnd Callback to run once the animation is complete
  113810. * @returns Nullable animation
  113811. */
  113812. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113813. /**
  113814. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113815. * @param sourceAnimation defines the Animation containing keyframes to convert
  113816. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113817. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113818. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113819. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113820. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113821. */
  113822. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113823. /**
  113824. * Transition property of an host to the target Value
  113825. * @param property The property to transition
  113826. * @param targetValue The target Value of the property
  113827. * @param host The object where the property to animate belongs
  113828. * @param scene Scene used to run the animation
  113829. * @param frameRate Framerate (in frame/s) to use
  113830. * @param transition The transition type we want to use
  113831. * @param duration The duration of the animation, in milliseconds
  113832. * @param onAnimationEnd Callback trigger at the end of the animation
  113833. * @returns Nullable animation
  113834. */
  113835. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113836. /**
  113837. * Return the array of runtime animations currently using this animation
  113838. */
  113839. get runtimeAnimations(): RuntimeAnimation[];
  113840. /**
  113841. * Specifies if any of the runtime animations are currently running
  113842. */
  113843. get hasRunningRuntimeAnimations(): boolean;
  113844. /**
  113845. * Initializes the animation
  113846. * @param name Name of the animation
  113847. * @param targetProperty Property to animate
  113848. * @param framePerSecond The frames per second of the animation
  113849. * @param dataType The data type of the animation
  113850. * @param loopMode The loop mode of the animation
  113851. * @param enableBlending Specifies if blending should be enabled
  113852. */
  113853. constructor(
  113854. /**Name of the animation */
  113855. name: string,
  113856. /**Property to animate */
  113857. targetProperty: string,
  113858. /**The frames per second of the animation */
  113859. framePerSecond: number,
  113860. /**The data type of the animation */
  113861. dataType: number,
  113862. /**The loop mode of the animation */
  113863. loopMode?: number | undefined,
  113864. /**Specifies if blending should be enabled */
  113865. enableBlending?: boolean | undefined);
  113866. /**
  113867. * Converts the animation to a string
  113868. * @param fullDetails support for multiple levels of logging within scene loading
  113869. * @returns String form of the animation
  113870. */
  113871. toString(fullDetails?: boolean): string;
  113872. /**
  113873. * Add an event to this animation
  113874. * @param event Event to add
  113875. */
  113876. addEvent(event: AnimationEvent): void;
  113877. /**
  113878. * Remove all events found at the given frame
  113879. * @param frame The frame to remove events from
  113880. */
  113881. removeEvents(frame: number): void;
  113882. /**
  113883. * Retrieves all the events from the animation
  113884. * @returns Events from the animation
  113885. */
  113886. getEvents(): AnimationEvent[];
  113887. /**
  113888. * Creates an animation range
  113889. * @param name Name of the animation range
  113890. * @param from Starting frame of the animation range
  113891. * @param to Ending frame of the animation
  113892. */
  113893. createRange(name: string, from: number, to: number): void;
  113894. /**
  113895. * Deletes an animation range by name
  113896. * @param name Name of the animation range to delete
  113897. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113898. */
  113899. deleteRange(name: string, deleteFrames?: boolean): void;
  113900. /**
  113901. * Gets the animation range by name, or null if not defined
  113902. * @param name Name of the animation range
  113903. * @returns Nullable animation range
  113904. */
  113905. getRange(name: string): Nullable<AnimationRange>;
  113906. /**
  113907. * Gets the key frames from the animation
  113908. * @returns The key frames of the animation
  113909. */
  113910. getKeys(): Array<IAnimationKey>;
  113911. /**
  113912. * Gets the highest frame rate of the animation
  113913. * @returns Highest frame rate of the animation
  113914. */
  113915. getHighestFrame(): number;
  113916. /**
  113917. * Gets the easing function of the animation
  113918. * @returns Easing function of the animation
  113919. */
  113920. getEasingFunction(): IEasingFunction;
  113921. /**
  113922. * Sets the easing function of the animation
  113923. * @param easingFunction A custom mathematical formula for animation
  113924. */
  113925. setEasingFunction(easingFunction: EasingFunction): void;
  113926. /**
  113927. * Interpolates a scalar linearly
  113928. * @param startValue Start value of the animation curve
  113929. * @param endValue End value of the animation curve
  113930. * @param gradient Scalar amount to interpolate
  113931. * @returns Interpolated scalar value
  113932. */
  113933. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113934. /**
  113935. * Interpolates a scalar cubically
  113936. * @param startValue Start value of the animation curve
  113937. * @param outTangent End tangent of the animation
  113938. * @param endValue End value of the animation curve
  113939. * @param inTangent Start tangent of the animation curve
  113940. * @param gradient Scalar amount to interpolate
  113941. * @returns Interpolated scalar value
  113942. */
  113943. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113944. /**
  113945. * Interpolates a quaternion using a spherical linear interpolation
  113946. * @param startValue Start value of the animation curve
  113947. * @param endValue End value of the animation curve
  113948. * @param gradient Scalar amount to interpolate
  113949. * @returns Interpolated quaternion value
  113950. */
  113951. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113952. /**
  113953. * Interpolates a quaternion cubically
  113954. * @param startValue Start value of the animation curve
  113955. * @param outTangent End tangent of the animation curve
  113956. * @param endValue End value of the animation curve
  113957. * @param inTangent Start tangent of the animation curve
  113958. * @param gradient Scalar amount to interpolate
  113959. * @returns Interpolated quaternion value
  113960. */
  113961. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113962. /**
  113963. * Interpolates a Vector3 linearl
  113964. * @param startValue Start value of the animation curve
  113965. * @param endValue End value of the animation curve
  113966. * @param gradient Scalar amount to interpolate
  113967. * @returns Interpolated scalar value
  113968. */
  113969. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113970. /**
  113971. * Interpolates a Vector3 cubically
  113972. * @param startValue Start value of the animation curve
  113973. * @param outTangent End tangent of the animation
  113974. * @param endValue End value of the animation curve
  113975. * @param inTangent Start tangent of the animation curve
  113976. * @param gradient Scalar amount to interpolate
  113977. * @returns InterpolatedVector3 value
  113978. */
  113979. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113980. /**
  113981. * Interpolates a Vector2 linearly
  113982. * @param startValue Start value of the animation curve
  113983. * @param endValue End value of the animation curve
  113984. * @param gradient Scalar amount to interpolate
  113985. * @returns Interpolated Vector2 value
  113986. */
  113987. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113988. /**
  113989. * Interpolates a Vector2 cubically
  113990. * @param startValue Start value of the animation curve
  113991. * @param outTangent End tangent of the animation
  113992. * @param endValue End value of the animation curve
  113993. * @param inTangent Start tangent of the animation curve
  113994. * @param gradient Scalar amount to interpolate
  113995. * @returns Interpolated Vector2 value
  113996. */
  113997. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113998. /**
  113999. * Interpolates a size linearly
  114000. * @param startValue Start value of the animation curve
  114001. * @param endValue End value of the animation curve
  114002. * @param gradient Scalar amount to interpolate
  114003. * @returns Interpolated Size value
  114004. */
  114005. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114006. /**
  114007. * Interpolates a Color3 linearly
  114008. * @param startValue Start value of the animation curve
  114009. * @param endValue End value of the animation curve
  114010. * @param gradient Scalar amount to interpolate
  114011. * @returns Interpolated Color3 value
  114012. */
  114013. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114014. /**
  114015. * Interpolates a Color4 linearly
  114016. * @param startValue Start value of the animation curve
  114017. * @param endValue End value of the animation curve
  114018. * @param gradient Scalar amount to interpolate
  114019. * @returns Interpolated Color3 value
  114020. */
  114021. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114022. /**
  114023. * @hidden Internal use only
  114024. */
  114025. _getKeyValue(value: any): any;
  114026. /**
  114027. * @hidden Internal use only
  114028. */
  114029. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114030. /**
  114031. * Defines the function to use to interpolate matrices
  114032. * @param startValue defines the start matrix
  114033. * @param endValue defines the end matrix
  114034. * @param gradient defines the gradient between both matrices
  114035. * @param result defines an optional target matrix where to store the interpolation
  114036. * @returns the interpolated matrix
  114037. */
  114038. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114039. /**
  114040. * Makes a copy of the animation
  114041. * @returns Cloned animation
  114042. */
  114043. clone(): Animation;
  114044. /**
  114045. * Sets the key frames of the animation
  114046. * @param values The animation key frames to set
  114047. */
  114048. setKeys(values: Array<IAnimationKey>): void;
  114049. /**
  114050. * Serializes the animation to an object
  114051. * @returns Serialized object
  114052. */
  114053. serialize(): any;
  114054. /**
  114055. * Float animation type
  114056. */
  114057. static readonly ANIMATIONTYPE_FLOAT: number;
  114058. /**
  114059. * Vector3 animation type
  114060. */
  114061. static readonly ANIMATIONTYPE_VECTOR3: number;
  114062. /**
  114063. * Quaternion animation type
  114064. */
  114065. static readonly ANIMATIONTYPE_QUATERNION: number;
  114066. /**
  114067. * Matrix animation type
  114068. */
  114069. static readonly ANIMATIONTYPE_MATRIX: number;
  114070. /**
  114071. * Color3 animation type
  114072. */
  114073. static readonly ANIMATIONTYPE_COLOR3: number;
  114074. /**
  114075. * Color3 animation type
  114076. */
  114077. static readonly ANIMATIONTYPE_COLOR4: number;
  114078. /**
  114079. * Vector2 animation type
  114080. */
  114081. static readonly ANIMATIONTYPE_VECTOR2: number;
  114082. /**
  114083. * Size animation type
  114084. */
  114085. static readonly ANIMATIONTYPE_SIZE: number;
  114086. /**
  114087. * Relative Loop Mode
  114088. */
  114089. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114090. /**
  114091. * Cycle Loop Mode
  114092. */
  114093. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114094. /**
  114095. * Constant Loop Mode
  114096. */
  114097. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114098. /** @hidden */
  114099. static _UniversalLerp(left: any, right: any, amount: number): any;
  114100. /**
  114101. * Parses an animation object and creates an animation
  114102. * @param parsedAnimation Parsed animation object
  114103. * @returns Animation object
  114104. */
  114105. static Parse(parsedAnimation: any): Animation;
  114106. /**
  114107. * Appends the serialized animations from the source animations
  114108. * @param source Source containing the animations
  114109. * @param destination Target to store the animations
  114110. */
  114111. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114112. /**
  114113. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114114. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114115. * @param url defines the url to load from
  114116. * @returns a promise that will resolve to the new animation or an array of animations
  114117. */
  114118. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114119. /**
  114120. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114121. * @param snippetId defines the snippet to load
  114122. * @returns a promise that will resolve to the new animation or a new array of animations
  114123. */
  114124. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /**
  114129. * Interface containing an array of animations
  114130. */
  114131. export interface IAnimatable {
  114132. /**
  114133. * Array of animations
  114134. */
  114135. animations: Nullable<Array<Animation>>;
  114136. }
  114137. }
  114138. declare module BABYLON {
  114139. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114140. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114141. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114142. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114143. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114144. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114145. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114146. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114147. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114148. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114149. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114150. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114151. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114152. /**
  114153. * Decorator used to define property that can be serialized as reference to a camera
  114154. * @param sourceName defines the name of the property to decorate
  114155. */
  114156. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114157. /**
  114158. * Class used to help serialization objects
  114159. */
  114160. export class SerializationHelper {
  114161. /** @hidden */
  114162. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114163. /** @hidden */
  114164. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114165. /** @hidden */
  114166. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114167. /** @hidden */
  114168. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114169. /**
  114170. * Appends the serialized animations from the source animations
  114171. * @param source Source containing the animations
  114172. * @param destination Target to store the animations
  114173. */
  114174. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114175. /**
  114176. * Static function used to serialized a specific entity
  114177. * @param entity defines the entity to serialize
  114178. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114179. * @returns a JSON compatible object representing the serialization of the entity
  114180. */
  114181. static Serialize<T>(entity: T, serializationObject?: any): any;
  114182. /**
  114183. * Creates a new entity from a serialization data object
  114184. * @param creationFunction defines a function used to instanciated the new entity
  114185. * @param source defines the source serialization data
  114186. * @param scene defines the hosting scene
  114187. * @param rootUrl defines the root url for resources
  114188. * @returns a new entity
  114189. */
  114190. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114191. /**
  114192. * Clones an object
  114193. * @param creationFunction defines the function used to instanciate the new object
  114194. * @param source defines the source object
  114195. * @returns the cloned object
  114196. */
  114197. static Clone<T>(creationFunction: () => T, source: T): T;
  114198. /**
  114199. * Instanciates a new object based on a source one (some data will be shared between both object)
  114200. * @param creationFunction defines the function used to instanciate the new object
  114201. * @param source defines the source object
  114202. * @returns the new object
  114203. */
  114204. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114205. }
  114206. }
  114207. declare module BABYLON {
  114208. /**
  114209. * Base class of all the textures in babylon.
  114210. * It groups all the common properties the materials, post process, lights... might need
  114211. * in order to make a correct use of the texture.
  114212. */
  114213. export class BaseTexture implements IAnimatable {
  114214. /**
  114215. * Default anisotropic filtering level for the application.
  114216. * It is set to 4 as a good tradeoff between perf and quality.
  114217. */
  114218. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114219. /**
  114220. * Gets or sets the unique id of the texture
  114221. */
  114222. uniqueId: number;
  114223. /**
  114224. * Define the name of the texture.
  114225. */
  114226. name: string;
  114227. /**
  114228. * Gets or sets an object used to store user defined information.
  114229. */
  114230. metadata: any;
  114231. /**
  114232. * For internal use only. Please do not use.
  114233. */
  114234. reservedDataStore: any;
  114235. private _hasAlpha;
  114236. /**
  114237. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114238. */
  114239. set hasAlpha(value: boolean);
  114240. get hasAlpha(): boolean;
  114241. /**
  114242. * Defines if the alpha value should be determined via the rgb values.
  114243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114244. */
  114245. getAlphaFromRGB: boolean;
  114246. /**
  114247. * Intensity or strength of the texture.
  114248. * It is commonly used by materials to fine tune the intensity of the texture
  114249. */
  114250. level: number;
  114251. /**
  114252. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114253. * This is part of the texture as textures usually maps to one uv set.
  114254. */
  114255. coordinatesIndex: number;
  114256. protected _coordinatesMode: number;
  114257. /**
  114258. * How a texture is mapped.
  114259. *
  114260. * | Value | Type | Description |
  114261. * | ----- | ----------------------------------- | ----------- |
  114262. * | 0 | EXPLICIT_MODE | |
  114263. * | 1 | SPHERICAL_MODE | |
  114264. * | 2 | PLANAR_MODE | |
  114265. * | 3 | CUBIC_MODE | |
  114266. * | 4 | PROJECTION_MODE | |
  114267. * | 5 | SKYBOX_MODE | |
  114268. * | 6 | INVCUBIC_MODE | |
  114269. * | 7 | EQUIRECTANGULAR_MODE | |
  114270. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114271. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114272. */
  114273. set coordinatesMode(value: number);
  114274. get coordinatesMode(): number;
  114275. private _wrapU;
  114276. /**
  114277. * | Value | Type | Description |
  114278. * | ----- | ------------------ | ----------- |
  114279. * | 0 | CLAMP_ADDRESSMODE | |
  114280. * | 1 | WRAP_ADDRESSMODE | |
  114281. * | 2 | MIRROR_ADDRESSMODE | |
  114282. */
  114283. get wrapU(): number;
  114284. set wrapU(value: number);
  114285. private _wrapV;
  114286. /**
  114287. * | Value | Type | Description |
  114288. * | ----- | ------------------ | ----------- |
  114289. * | 0 | CLAMP_ADDRESSMODE | |
  114290. * | 1 | WRAP_ADDRESSMODE | |
  114291. * | 2 | MIRROR_ADDRESSMODE | |
  114292. */
  114293. get wrapV(): number;
  114294. set wrapV(value: number);
  114295. /**
  114296. * | Value | Type | Description |
  114297. * | ----- | ------------------ | ----------- |
  114298. * | 0 | CLAMP_ADDRESSMODE | |
  114299. * | 1 | WRAP_ADDRESSMODE | |
  114300. * | 2 | MIRROR_ADDRESSMODE | |
  114301. */
  114302. wrapR: number;
  114303. /**
  114304. * With compliant hardware and browser (supporting anisotropic filtering)
  114305. * this defines the level of anisotropic filtering in the texture.
  114306. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114307. */
  114308. anisotropicFilteringLevel: number;
  114309. /**
  114310. * Define if the texture is a cube texture or if false a 2d texture.
  114311. */
  114312. get isCube(): boolean;
  114313. set isCube(value: boolean);
  114314. /**
  114315. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114316. */
  114317. get is3D(): boolean;
  114318. set is3D(value: boolean);
  114319. /**
  114320. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114321. */
  114322. get is2DArray(): boolean;
  114323. set is2DArray(value: boolean);
  114324. private _gammaSpace;
  114325. /**
  114326. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114327. * HDR texture are usually stored in linear space.
  114328. * This only impacts the PBR and Background materials
  114329. */
  114330. get gammaSpace(): boolean;
  114331. set gammaSpace(gamma: boolean);
  114332. /**
  114333. * Gets or sets whether or not the texture contains RGBD data.
  114334. */
  114335. get isRGBD(): boolean;
  114336. set isRGBD(value: boolean);
  114337. /**
  114338. * Is Z inverted in the texture (useful in a cube texture).
  114339. */
  114340. invertZ: boolean;
  114341. /**
  114342. * Are mip maps generated for this texture or not.
  114343. */
  114344. get noMipmap(): boolean;
  114345. /**
  114346. * @hidden
  114347. */
  114348. lodLevelInAlpha: boolean;
  114349. /**
  114350. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114351. */
  114352. get lodGenerationOffset(): number;
  114353. set lodGenerationOffset(value: number);
  114354. /**
  114355. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114356. */
  114357. get lodGenerationScale(): number;
  114358. set lodGenerationScale(value: number);
  114359. /**
  114360. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114361. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114362. * average roughness values.
  114363. */
  114364. get linearSpecularLOD(): boolean;
  114365. set linearSpecularLOD(value: boolean);
  114366. /**
  114367. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114368. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114369. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114370. */
  114371. get irradianceTexture(): Nullable<BaseTexture>;
  114372. set irradianceTexture(value: Nullable<BaseTexture>);
  114373. /**
  114374. * Define if the texture is a render target.
  114375. */
  114376. isRenderTarget: boolean;
  114377. /**
  114378. * Define the unique id of the texture in the scene.
  114379. */
  114380. get uid(): string;
  114381. /** @hidden */
  114382. _prefiltered: boolean;
  114383. /**
  114384. * Return a string representation of the texture.
  114385. * @returns the texture as a string
  114386. */
  114387. toString(): string;
  114388. /**
  114389. * Get the class name of the texture.
  114390. * @returns "BaseTexture"
  114391. */
  114392. getClassName(): string;
  114393. /**
  114394. * Define the list of animation attached to the texture.
  114395. */
  114396. animations: Animation[];
  114397. /**
  114398. * An event triggered when the texture is disposed.
  114399. */
  114400. onDisposeObservable: Observable<BaseTexture>;
  114401. private _onDisposeObserver;
  114402. /**
  114403. * Callback triggered when the texture has been disposed.
  114404. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114405. */
  114406. set onDispose(callback: () => void);
  114407. /**
  114408. * Define the current state of the loading sequence when in delayed load mode.
  114409. */
  114410. delayLoadState: number;
  114411. protected _scene: Nullable<Scene>;
  114412. protected _engine: Nullable<ThinEngine>;
  114413. /** @hidden */
  114414. _texture: Nullable<InternalTexture>;
  114415. private _uid;
  114416. /**
  114417. * Define if the texture is preventinga material to render or not.
  114418. * If not and the texture is not ready, the engine will use a default black texture instead.
  114419. */
  114420. get isBlocking(): boolean;
  114421. /**
  114422. * Instantiates a new BaseTexture.
  114423. * Base class of all the textures in babylon.
  114424. * It groups all the common properties the materials, post process, lights... might need
  114425. * in order to make a correct use of the texture.
  114426. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114427. */
  114428. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114429. /**
  114430. * Get the scene the texture belongs to.
  114431. * @returns the scene or null if undefined
  114432. */
  114433. getScene(): Nullable<Scene>;
  114434. /** @hidden */
  114435. protected _getEngine(): Nullable<ThinEngine>;
  114436. /**
  114437. * Get the texture transform matrix used to offset tile the texture for istance.
  114438. * @returns the transformation matrix
  114439. */
  114440. getTextureMatrix(): Matrix;
  114441. /**
  114442. * Get the texture reflection matrix used to rotate/transform the reflection.
  114443. * @returns the reflection matrix
  114444. */
  114445. getReflectionTextureMatrix(): Matrix;
  114446. /**
  114447. * Get the underlying lower level texture from Babylon.
  114448. * @returns the insternal texture
  114449. */
  114450. getInternalTexture(): Nullable<InternalTexture>;
  114451. /**
  114452. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114453. * @returns true if ready or not blocking
  114454. */
  114455. isReadyOrNotBlocking(): boolean;
  114456. /**
  114457. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114458. * @returns true if fully ready
  114459. */
  114460. isReady(): boolean;
  114461. private _cachedSize;
  114462. /**
  114463. * Get the size of the texture.
  114464. * @returns the texture size.
  114465. */
  114466. getSize(): ISize;
  114467. /**
  114468. * Get the base size of the texture.
  114469. * It can be different from the size if the texture has been resized for POT for instance
  114470. * @returns the base size
  114471. */
  114472. getBaseSize(): ISize;
  114473. /**
  114474. * Update the sampling mode of the texture.
  114475. * Default is Trilinear mode.
  114476. *
  114477. * | Value | Type | Description |
  114478. * | ----- | ------------------ | ----------- |
  114479. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114480. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114481. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114482. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114483. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114484. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114485. * | 7 | NEAREST_LINEAR | |
  114486. * | 8 | NEAREST_NEAREST | |
  114487. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114488. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114489. * | 11 | LINEAR_LINEAR | |
  114490. * | 12 | LINEAR_NEAREST | |
  114491. *
  114492. * > _mag_: magnification filter (close to the viewer)
  114493. * > _min_: minification filter (far from the viewer)
  114494. * > _mip_: filter used between mip map levels
  114495. *@param samplingMode Define the new sampling mode of the texture
  114496. */
  114497. updateSamplingMode(samplingMode: number): void;
  114498. /**
  114499. * Scales the texture if is `canRescale()`
  114500. * @param ratio the resize factor we want to use to rescale
  114501. */
  114502. scale(ratio: number): void;
  114503. /**
  114504. * Get if the texture can rescale.
  114505. */
  114506. get canRescale(): boolean;
  114507. /** @hidden */
  114508. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114509. /** @hidden */
  114510. _rebuild(): void;
  114511. /**
  114512. * Triggers the load sequence in delayed load mode.
  114513. */
  114514. delayLoad(): void;
  114515. /**
  114516. * Clones the texture.
  114517. * @returns the cloned texture
  114518. */
  114519. clone(): Nullable<BaseTexture>;
  114520. /**
  114521. * Get the texture underlying type (INT, FLOAT...)
  114522. */
  114523. get textureType(): number;
  114524. /**
  114525. * Get the texture underlying format (RGB, RGBA...)
  114526. */
  114527. get textureFormat(): number;
  114528. /**
  114529. * Indicates that textures need to be re-calculated for all materials
  114530. */
  114531. protected _markAllSubMeshesAsTexturesDirty(): void;
  114532. /**
  114533. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114534. * This will returns an RGBA array buffer containing either in values (0-255) or
  114535. * float values (0-1) depending of the underlying buffer type.
  114536. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114537. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114538. * @param buffer defines a user defined buffer to fill with data (can be null)
  114539. * @returns The Array buffer containing the pixels data.
  114540. */
  114541. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114542. /**
  114543. * Release and destroy the underlying lower level texture aka internalTexture.
  114544. */
  114545. releaseInternalTexture(): void;
  114546. /** @hidden */
  114547. get _lodTextureHigh(): Nullable<BaseTexture>;
  114548. /** @hidden */
  114549. get _lodTextureMid(): Nullable<BaseTexture>;
  114550. /** @hidden */
  114551. get _lodTextureLow(): Nullable<BaseTexture>;
  114552. /**
  114553. * Dispose the texture and release its associated resources.
  114554. */
  114555. dispose(): void;
  114556. /**
  114557. * Serialize the texture into a JSON representation that can be parsed later on.
  114558. * @returns the JSON representation of the texture
  114559. */
  114560. serialize(): any;
  114561. /**
  114562. * Helper function to be called back once a list of texture contains only ready textures.
  114563. * @param textures Define the list of textures to wait for
  114564. * @param callback Define the callback triggered once the entire list will be ready
  114565. */
  114566. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114567. private static _isScene;
  114568. }
  114569. }
  114570. declare module BABYLON {
  114571. /**
  114572. * Options to be used when creating an effect.
  114573. */
  114574. export interface IEffectCreationOptions {
  114575. /**
  114576. * Atrributes that will be used in the shader.
  114577. */
  114578. attributes: string[];
  114579. /**
  114580. * Uniform varible names that will be set in the shader.
  114581. */
  114582. uniformsNames: string[];
  114583. /**
  114584. * Uniform buffer variable names that will be set in the shader.
  114585. */
  114586. uniformBuffersNames: string[];
  114587. /**
  114588. * Sampler texture variable names that will be set in the shader.
  114589. */
  114590. samplers: string[];
  114591. /**
  114592. * Define statements that will be set in the shader.
  114593. */
  114594. defines: any;
  114595. /**
  114596. * Possible fallbacks for this effect to improve performance when needed.
  114597. */
  114598. fallbacks: Nullable<IEffectFallbacks>;
  114599. /**
  114600. * Callback that will be called when the shader is compiled.
  114601. */
  114602. onCompiled: Nullable<(effect: Effect) => void>;
  114603. /**
  114604. * Callback that will be called if an error occurs during shader compilation.
  114605. */
  114606. onError: Nullable<(effect: Effect, errors: string) => void>;
  114607. /**
  114608. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114609. */
  114610. indexParameters?: any;
  114611. /**
  114612. * Max number of lights that can be used in the shader.
  114613. */
  114614. maxSimultaneousLights?: number;
  114615. /**
  114616. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114617. */
  114618. transformFeedbackVaryings?: Nullable<string[]>;
  114619. /**
  114620. * 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
  114621. */
  114622. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114623. /**
  114624. * Is this effect rendering to several color attachments ?
  114625. */
  114626. multiTarget?: boolean;
  114627. }
  114628. /**
  114629. * Effect containing vertex and fragment shader that can be executed on an object.
  114630. */
  114631. export class Effect implements IDisposable {
  114632. /**
  114633. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114634. */
  114635. static ShadersRepository: string;
  114636. /**
  114637. * Enable logging of the shader code when a compilation error occurs
  114638. */
  114639. static LogShaderCodeOnCompilationError: boolean;
  114640. /**
  114641. * Name of the effect.
  114642. */
  114643. name: any;
  114644. /**
  114645. * String container all the define statements that should be set on the shader.
  114646. */
  114647. defines: string;
  114648. /**
  114649. * Callback that will be called when the shader is compiled.
  114650. */
  114651. onCompiled: Nullable<(effect: Effect) => void>;
  114652. /**
  114653. * Callback that will be called if an error occurs during shader compilation.
  114654. */
  114655. onError: Nullable<(effect: Effect, errors: string) => void>;
  114656. /**
  114657. * Callback that will be called when effect is bound.
  114658. */
  114659. onBind: Nullable<(effect: Effect) => void>;
  114660. /**
  114661. * Unique ID of the effect.
  114662. */
  114663. uniqueId: number;
  114664. /**
  114665. * Observable that will be called when the shader is compiled.
  114666. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114667. */
  114668. onCompileObservable: Observable<Effect>;
  114669. /**
  114670. * Observable that will be called if an error occurs during shader compilation.
  114671. */
  114672. onErrorObservable: Observable<Effect>;
  114673. /** @hidden */
  114674. _onBindObservable: Nullable<Observable<Effect>>;
  114675. /**
  114676. * @hidden
  114677. * Specifies if the effect was previously ready
  114678. */
  114679. _wasPreviouslyReady: boolean;
  114680. /**
  114681. * Observable that will be called when effect is bound.
  114682. */
  114683. get onBindObservable(): Observable<Effect>;
  114684. /** @hidden */
  114685. _bonesComputationForcedToCPU: boolean;
  114686. /** @hidden */
  114687. _multiTarget: boolean;
  114688. private static _uniqueIdSeed;
  114689. private _engine;
  114690. private _uniformBuffersNames;
  114691. private _uniformBuffersNamesList;
  114692. private _uniformsNames;
  114693. private _samplerList;
  114694. private _samplers;
  114695. private _isReady;
  114696. private _compilationError;
  114697. private _allFallbacksProcessed;
  114698. private _attributesNames;
  114699. private _attributes;
  114700. private _attributeLocationByName;
  114701. private _uniforms;
  114702. /**
  114703. * Key for the effect.
  114704. * @hidden
  114705. */
  114706. _key: string;
  114707. private _indexParameters;
  114708. private _fallbacks;
  114709. private _vertexSourceCode;
  114710. private _fragmentSourceCode;
  114711. private _vertexSourceCodeOverride;
  114712. private _fragmentSourceCodeOverride;
  114713. private _transformFeedbackVaryings;
  114714. /**
  114715. * Compiled shader to webGL program.
  114716. * @hidden
  114717. */
  114718. _pipelineContext: Nullable<IPipelineContext>;
  114719. private _valueCache;
  114720. private static _baseCache;
  114721. /**
  114722. * Instantiates an effect.
  114723. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114724. * @param baseName Name of the effect.
  114725. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114726. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114727. * @param samplers List of sampler variables that will be passed to the shader.
  114728. * @param engine Engine to be used to render the effect
  114729. * @param defines Define statements to be added to the shader.
  114730. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114731. * @param onCompiled Callback that will be called when the shader is compiled.
  114732. * @param onError Callback that will be called if an error occurs during shader compilation.
  114733. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114734. */
  114735. 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);
  114736. private _useFinalCode;
  114737. /**
  114738. * Unique key for this effect
  114739. */
  114740. get key(): string;
  114741. /**
  114742. * If the effect has been compiled and prepared.
  114743. * @returns if the effect is compiled and prepared.
  114744. */
  114745. isReady(): boolean;
  114746. private _isReadyInternal;
  114747. /**
  114748. * The engine the effect was initialized with.
  114749. * @returns the engine.
  114750. */
  114751. getEngine(): Engine;
  114752. /**
  114753. * The pipeline context for this effect
  114754. * @returns the associated pipeline context
  114755. */
  114756. getPipelineContext(): Nullable<IPipelineContext>;
  114757. /**
  114758. * The set of names of attribute variables for the shader.
  114759. * @returns An array of attribute names.
  114760. */
  114761. getAttributesNames(): string[];
  114762. /**
  114763. * Returns the attribute at the given index.
  114764. * @param index The index of the attribute.
  114765. * @returns The location of the attribute.
  114766. */
  114767. getAttributeLocation(index: number): number;
  114768. /**
  114769. * Returns the attribute based on the name of the variable.
  114770. * @param name of the attribute to look up.
  114771. * @returns the attribute location.
  114772. */
  114773. getAttributeLocationByName(name: string): number;
  114774. /**
  114775. * The number of attributes.
  114776. * @returns the numnber of attributes.
  114777. */
  114778. getAttributesCount(): number;
  114779. /**
  114780. * Gets the index of a uniform variable.
  114781. * @param uniformName of the uniform to look up.
  114782. * @returns the index.
  114783. */
  114784. getUniformIndex(uniformName: string): number;
  114785. /**
  114786. * Returns the attribute based on the name of the variable.
  114787. * @param uniformName of the uniform to look up.
  114788. * @returns the location of the uniform.
  114789. */
  114790. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114791. /**
  114792. * Returns an array of sampler variable names
  114793. * @returns The array of sampler variable names.
  114794. */
  114795. getSamplers(): string[];
  114796. /**
  114797. * Returns an array of uniform variable names
  114798. * @returns The array of uniform variable names.
  114799. */
  114800. getUniformNames(): string[];
  114801. /**
  114802. * Returns an array of uniform buffer variable names
  114803. * @returns The array of uniform buffer variable names.
  114804. */
  114805. getUniformBuffersNames(): string[];
  114806. /**
  114807. * Returns the index parameters used to create the effect
  114808. * @returns The index parameters object
  114809. */
  114810. getIndexParameters(): any;
  114811. /**
  114812. * The error from the last compilation.
  114813. * @returns the error string.
  114814. */
  114815. getCompilationError(): string;
  114816. /**
  114817. * Gets a boolean indicating that all fallbacks were used during compilation
  114818. * @returns true if all fallbacks were used
  114819. */
  114820. allFallbacksProcessed(): boolean;
  114821. /**
  114822. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114823. * @param func The callback to be used.
  114824. */
  114825. executeWhenCompiled(func: (effect: Effect) => void): void;
  114826. private _checkIsReady;
  114827. private _loadShader;
  114828. /**
  114829. * Gets the vertex shader source code of this effect
  114830. */
  114831. get vertexSourceCode(): string;
  114832. /**
  114833. * Gets the fragment shader source code of this effect
  114834. */
  114835. get fragmentSourceCode(): string;
  114836. /**
  114837. * Recompiles the webGL program
  114838. * @param vertexSourceCode The source code for the vertex shader.
  114839. * @param fragmentSourceCode The source code for the fragment shader.
  114840. * @param onCompiled Callback called when completed.
  114841. * @param onError Callback called on error.
  114842. * @hidden
  114843. */
  114844. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114845. /**
  114846. * Prepares the effect
  114847. * @hidden
  114848. */
  114849. _prepareEffect(): void;
  114850. private _getShaderCodeAndErrorLine;
  114851. private _processCompilationErrors;
  114852. /**
  114853. * Checks if the effect is supported. (Must be called after compilation)
  114854. */
  114855. get isSupported(): boolean;
  114856. /**
  114857. * Binds a texture to the engine to be used as output of the shader.
  114858. * @param channel Name of the output variable.
  114859. * @param texture Texture to bind.
  114860. * @hidden
  114861. */
  114862. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114863. /**
  114864. * Sets a texture on the engine to be used in the shader.
  114865. * @param channel Name of the sampler variable.
  114866. * @param texture Texture to set.
  114867. */
  114868. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114869. /**
  114870. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114871. * @param channel Name of the sampler variable.
  114872. * @param texture Texture to set.
  114873. */
  114874. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114875. /**
  114876. * Sets an array of textures on the engine to be used in the shader.
  114877. * @param channel Name of the variable.
  114878. * @param textures Textures to set.
  114879. */
  114880. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114881. /**
  114882. * 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)
  114883. * @param channel Name of the sampler variable.
  114884. * @param postProcess Post process to get the input texture from.
  114885. */
  114886. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114887. /**
  114888. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114889. * 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)
  114890. * @param channel Name of the sampler variable.
  114891. * @param postProcess Post process to get the output texture from.
  114892. */
  114893. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114894. /** @hidden */
  114895. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114896. /** @hidden */
  114897. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114898. /** @hidden */
  114899. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114900. /** @hidden */
  114901. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114902. /**
  114903. * Binds a buffer to a uniform.
  114904. * @param buffer Buffer to bind.
  114905. * @param name Name of the uniform variable to bind to.
  114906. */
  114907. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114908. /**
  114909. * Binds block to a uniform.
  114910. * @param blockName Name of the block to bind.
  114911. * @param index Index to bind.
  114912. */
  114913. bindUniformBlock(blockName: string, index: number): void;
  114914. /**
  114915. * Sets an interger value on a uniform variable.
  114916. * @param uniformName Name of the variable.
  114917. * @param value Value to be set.
  114918. * @returns this effect.
  114919. */
  114920. setInt(uniformName: string, value: number): Effect;
  114921. /**
  114922. * Sets an int array on a uniform variable.
  114923. * @param uniformName Name of the variable.
  114924. * @param array array to be set.
  114925. * @returns this effect.
  114926. */
  114927. setIntArray(uniformName: string, array: Int32Array): Effect;
  114928. /**
  114929. * 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)
  114930. * @param uniformName Name of the variable.
  114931. * @param array array to be set.
  114932. * @returns this effect.
  114933. */
  114934. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114935. /**
  114936. * 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)
  114937. * @param uniformName Name of the variable.
  114938. * @param array array to be set.
  114939. * @returns this effect.
  114940. */
  114941. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114942. /**
  114943. * 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)
  114944. * @param uniformName Name of the variable.
  114945. * @param array array to be set.
  114946. * @returns this effect.
  114947. */
  114948. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114949. /**
  114950. * Sets an float array on a uniform variable.
  114951. * @param uniformName Name of the variable.
  114952. * @param array array to be set.
  114953. * @returns this effect.
  114954. */
  114955. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114956. /**
  114957. * 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)
  114958. * @param uniformName Name of the variable.
  114959. * @param array array to be set.
  114960. * @returns this effect.
  114961. */
  114962. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114963. /**
  114964. * 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)
  114965. * @param uniformName Name of the variable.
  114966. * @param array array to be set.
  114967. * @returns this effect.
  114968. */
  114969. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114970. /**
  114971. * 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)
  114972. * @param uniformName Name of the variable.
  114973. * @param array array to be set.
  114974. * @returns this effect.
  114975. */
  114976. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114977. /**
  114978. * Sets an array on a uniform variable.
  114979. * @param uniformName Name of the variable.
  114980. * @param array array to be set.
  114981. * @returns this effect.
  114982. */
  114983. setArray(uniformName: string, array: number[]): Effect;
  114984. /**
  114985. * 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)
  114986. * @param uniformName Name of the variable.
  114987. * @param array array to be set.
  114988. * @returns this effect.
  114989. */
  114990. setArray2(uniformName: string, array: number[]): Effect;
  114991. /**
  114992. * 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)
  114993. * @param uniformName Name of the variable.
  114994. * @param array array to be set.
  114995. * @returns this effect.
  114996. */
  114997. setArray3(uniformName: string, array: number[]): Effect;
  114998. /**
  114999. * 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)
  115000. * @param uniformName Name of the variable.
  115001. * @param array array to be set.
  115002. * @returns this effect.
  115003. */
  115004. setArray4(uniformName: string, array: number[]): Effect;
  115005. /**
  115006. * Sets matrices on a uniform variable.
  115007. * @param uniformName Name of the variable.
  115008. * @param matrices matrices to be set.
  115009. * @returns this effect.
  115010. */
  115011. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115012. /**
  115013. * Sets matrix on a uniform variable.
  115014. * @param uniformName Name of the variable.
  115015. * @param matrix matrix to be set.
  115016. * @returns this effect.
  115017. */
  115018. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115019. /**
  115020. * 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)
  115021. * @param uniformName Name of the variable.
  115022. * @param matrix matrix to be set.
  115023. * @returns this effect.
  115024. */
  115025. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115026. /**
  115027. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115028. * @param uniformName Name of the variable.
  115029. * @param matrix matrix to be set.
  115030. * @returns this effect.
  115031. */
  115032. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115033. /**
  115034. * Sets a float on a uniform variable.
  115035. * @param uniformName Name of the variable.
  115036. * @param value value to be set.
  115037. * @returns this effect.
  115038. */
  115039. setFloat(uniformName: string, value: number): Effect;
  115040. /**
  115041. * Sets a boolean on a uniform variable.
  115042. * @param uniformName Name of the variable.
  115043. * @param bool value to be set.
  115044. * @returns this effect.
  115045. */
  115046. setBool(uniformName: string, bool: boolean): Effect;
  115047. /**
  115048. * Sets a Vector2 on a uniform variable.
  115049. * @param uniformName Name of the variable.
  115050. * @param vector2 vector2 to be set.
  115051. * @returns this effect.
  115052. */
  115053. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115054. /**
  115055. * Sets a float2 on a uniform variable.
  115056. * @param uniformName Name of the variable.
  115057. * @param x First float in float2.
  115058. * @param y Second float in float2.
  115059. * @returns this effect.
  115060. */
  115061. setFloat2(uniformName: string, x: number, y: number): Effect;
  115062. /**
  115063. * Sets a Vector3 on a uniform variable.
  115064. * @param uniformName Name of the variable.
  115065. * @param vector3 Value to be set.
  115066. * @returns this effect.
  115067. */
  115068. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115069. /**
  115070. * Sets a float3 on a uniform variable.
  115071. * @param uniformName Name of the variable.
  115072. * @param x First float in float3.
  115073. * @param y Second float in float3.
  115074. * @param z Third float in float3.
  115075. * @returns this effect.
  115076. */
  115077. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115078. /**
  115079. * Sets a Vector4 on a uniform variable.
  115080. * @param uniformName Name of the variable.
  115081. * @param vector4 Value to be set.
  115082. * @returns this effect.
  115083. */
  115084. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115085. /**
  115086. * Sets a float4 on a uniform variable.
  115087. * @param uniformName Name of the variable.
  115088. * @param x First float in float4.
  115089. * @param y Second float in float4.
  115090. * @param z Third float in float4.
  115091. * @param w Fourth float in float4.
  115092. * @returns this effect.
  115093. */
  115094. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115095. /**
  115096. * Sets a Color3 on a uniform variable.
  115097. * @param uniformName Name of the variable.
  115098. * @param color3 Value to be set.
  115099. * @returns this effect.
  115100. */
  115101. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115102. /**
  115103. * Sets a Color4 on a uniform variable.
  115104. * @param uniformName Name of the variable.
  115105. * @param color3 Value to be set.
  115106. * @param alpha Alpha value to be set.
  115107. * @returns this effect.
  115108. */
  115109. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115110. /**
  115111. * Sets a Color4 on a uniform variable
  115112. * @param uniformName defines the name of the variable
  115113. * @param color4 defines the value to be set
  115114. * @returns this effect.
  115115. */
  115116. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115117. /** Release all associated resources */
  115118. dispose(): void;
  115119. /**
  115120. * This function will add a new shader to the shader store
  115121. * @param name the name of the shader
  115122. * @param pixelShader optional pixel shader content
  115123. * @param vertexShader optional vertex shader content
  115124. */
  115125. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115126. /**
  115127. * Store of each shader (The can be looked up using effect.key)
  115128. */
  115129. static ShadersStore: {
  115130. [key: string]: string;
  115131. };
  115132. /**
  115133. * Store of each included file for a shader (The can be looked up using effect.key)
  115134. */
  115135. static IncludesShadersStore: {
  115136. [key: string]: string;
  115137. };
  115138. /**
  115139. * Resets the cache of effects.
  115140. */
  115141. static ResetCache(): void;
  115142. }
  115143. }
  115144. declare module BABYLON {
  115145. /**
  115146. * Interface used to describe the capabilities of the engine relatively to the current browser
  115147. */
  115148. export interface EngineCapabilities {
  115149. /** Maximum textures units per fragment shader */
  115150. maxTexturesImageUnits: number;
  115151. /** Maximum texture units per vertex shader */
  115152. maxVertexTextureImageUnits: number;
  115153. /** Maximum textures units in the entire pipeline */
  115154. maxCombinedTexturesImageUnits: number;
  115155. /** Maximum texture size */
  115156. maxTextureSize: number;
  115157. /** Maximum texture samples */
  115158. maxSamples?: number;
  115159. /** Maximum cube texture size */
  115160. maxCubemapTextureSize: number;
  115161. /** Maximum render texture size */
  115162. maxRenderTextureSize: number;
  115163. /** Maximum number of vertex attributes */
  115164. maxVertexAttribs: number;
  115165. /** Maximum number of varyings */
  115166. maxVaryingVectors: number;
  115167. /** Maximum number of uniforms per vertex shader */
  115168. maxVertexUniformVectors: number;
  115169. /** Maximum number of uniforms per fragment shader */
  115170. maxFragmentUniformVectors: number;
  115171. /** Defines if standard derivates (dx/dy) are supported */
  115172. standardDerivatives: boolean;
  115173. /** Defines if s3tc texture compression is supported */
  115174. s3tc?: WEBGL_compressed_texture_s3tc;
  115175. /** Defines if pvrtc texture compression is supported */
  115176. pvrtc: any;
  115177. /** Defines if etc1 texture compression is supported */
  115178. etc1: any;
  115179. /** Defines if etc2 texture compression is supported */
  115180. etc2: any;
  115181. /** Defines if astc texture compression is supported */
  115182. astc: any;
  115183. /** Defines if bptc texture compression is supported */
  115184. bptc: any;
  115185. /** Defines if float textures are supported */
  115186. textureFloat: boolean;
  115187. /** Defines if vertex array objects are supported */
  115188. vertexArrayObject: boolean;
  115189. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115190. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115191. /** Gets the maximum level of anisotropy supported */
  115192. maxAnisotropy: number;
  115193. /** Defines if instancing is supported */
  115194. instancedArrays: boolean;
  115195. /** Defines if 32 bits indices are supported */
  115196. uintIndices: boolean;
  115197. /** Defines if high precision shaders are supported */
  115198. highPrecisionShaderSupported: boolean;
  115199. /** Defines if depth reading in the fragment shader is supported */
  115200. fragmentDepthSupported: boolean;
  115201. /** Defines if float texture linear filtering is supported*/
  115202. textureFloatLinearFiltering: boolean;
  115203. /** Defines if rendering to float textures is supported */
  115204. textureFloatRender: boolean;
  115205. /** Defines if half float textures are supported*/
  115206. textureHalfFloat: boolean;
  115207. /** Defines if half float texture linear filtering is supported*/
  115208. textureHalfFloatLinearFiltering: boolean;
  115209. /** Defines if rendering to half float textures is supported */
  115210. textureHalfFloatRender: boolean;
  115211. /** Defines if textureLOD shader command is supported */
  115212. textureLOD: boolean;
  115213. /** Defines if draw buffers extension is supported */
  115214. drawBuffersExtension: boolean;
  115215. /** Defines if depth textures are supported */
  115216. depthTextureExtension: boolean;
  115217. /** Defines if float color buffer are supported */
  115218. colorBufferFloat: boolean;
  115219. /** Gets disjoint timer query extension (null if not supported) */
  115220. timerQuery?: EXT_disjoint_timer_query;
  115221. /** Defines if timestamp can be used with timer query */
  115222. canUseTimestampForTimerQuery: boolean;
  115223. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115224. multiview?: any;
  115225. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115226. oculusMultiview?: any;
  115227. /** Function used to let the system compiles shaders in background */
  115228. parallelShaderCompile?: {
  115229. COMPLETION_STATUS_KHR: number;
  115230. };
  115231. /** Max number of texture samples for MSAA */
  115232. maxMSAASamples: number;
  115233. /** Defines if the blend min max extension is supported */
  115234. blendMinMax: boolean;
  115235. }
  115236. }
  115237. declare module BABYLON {
  115238. /**
  115239. * @hidden
  115240. **/
  115241. export class DepthCullingState {
  115242. private _isDepthTestDirty;
  115243. private _isDepthMaskDirty;
  115244. private _isDepthFuncDirty;
  115245. private _isCullFaceDirty;
  115246. private _isCullDirty;
  115247. private _isZOffsetDirty;
  115248. private _isFrontFaceDirty;
  115249. private _depthTest;
  115250. private _depthMask;
  115251. private _depthFunc;
  115252. private _cull;
  115253. private _cullFace;
  115254. private _zOffset;
  115255. private _frontFace;
  115256. /**
  115257. * Initializes the state.
  115258. */
  115259. constructor();
  115260. get isDirty(): boolean;
  115261. get zOffset(): number;
  115262. set zOffset(value: number);
  115263. get cullFace(): Nullable<number>;
  115264. set cullFace(value: Nullable<number>);
  115265. get cull(): Nullable<boolean>;
  115266. set cull(value: Nullable<boolean>);
  115267. get depthFunc(): Nullable<number>;
  115268. set depthFunc(value: Nullable<number>);
  115269. get depthMask(): boolean;
  115270. set depthMask(value: boolean);
  115271. get depthTest(): boolean;
  115272. set depthTest(value: boolean);
  115273. get frontFace(): Nullable<number>;
  115274. set frontFace(value: Nullable<number>);
  115275. reset(): void;
  115276. apply(gl: WebGLRenderingContext): void;
  115277. }
  115278. }
  115279. declare module BABYLON {
  115280. /**
  115281. * @hidden
  115282. **/
  115283. export class StencilState {
  115284. /** 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 */
  115285. static readonly ALWAYS: number;
  115286. /** Passed to stencilOperation to specify that stencil value must be kept */
  115287. static readonly KEEP: number;
  115288. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115289. static readonly REPLACE: number;
  115290. private _isStencilTestDirty;
  115291. private _isStencilMaskDirty;
  115292. private _isStencilFuncDirty;
  115293. private _isStencilOpDirty;
  115294. private _stencilTest;
  115295. private _stencilMask;
  115296. private _stencilFunc;
  115297. private _stencilFuncRef;
  115298. private _stencilFuncMask;
  115299. private _stencilOpStencilFail;
  115300. private _stencilOpDepthFail;
  115301. private _stencilOpStencilDepthPass;
  115302. get isDirty(): boolean;
  115303. get stencilFunc(): number;
  115304. set stencilFunc(value: number);
  115305. get stencilFuncRef(): number;
  115306. set stencilFuncRef(value: number);
  115307. get stencilFuncMask(): number;
  115308. set stencilFuncMask(value: number);
  115309. get stencilOpStencilFail(): number;
  115310. set stencilOpStencilFail(value: number);
  115311. get stencilOpDepthFail(): number;
  115312. set stencilOpDepthFail(value: number);
  115313. get stencilOpStencilDepthPass(): number;
  115314. set stencilOpStencilDepthPass(value: number);
  115315. get stencilMask(): number;
  115316. set stencilMask(value: number);
  115317. get stencilTest(): boolean;
  115318. set stencilTest(value: boolean);
  115319. constructor();
  115320. reset(): void;
  115321. apply(gl: WebGLRenderingContext): void;
  115322. }
  115323. }
  115324. declare module BABYLON {
  115325. /**
  115326. * @hidden
  115327. **/
  115328. export class AlphaState {
  115329. private _isAlphaBlendDirty;
  115330. private _isBlendFunctionParametersDirty;
  115331. private _isBlendEquationParametersDirty;
  115332. private _isBlendConstantsDirty;
  115333. private _alphaBlend;
  115334. private _blendFunctionParameters;
  115335. private _blendEquationParameters;
  115336. private _blendConstants;
  115337. /**
  115338. * Initializes the state.
  115339. */
  115340. constructor();
  115341. get isDirty(): boolean;
  115342. get alphaBlend(): boolean;
  115343. set alphaBlend(value: boolean);
  115344. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115345. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115346. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115347. reset(): void;
  115348. apply(gl: WebGLRenderingContext): void;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. /** @hidden */
  115353. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115354. attributeProcessor(attribute: string): string;
  115355. varyingProcessor(varying: string, isFragment: boolean): string;
  115356. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115357. }
  115358. }
  115359. declare module BABYLON {
  115360. /**
  115361. * Interface for attribute information associated with buffer instanciation
  115362. */
  115363. export interface InstancingAttributeInfo {
  115364. /**
  115365. * Name of the GLSL attribute
  115366. * if attribute index is not specified, this is used to retrieve the index from the effect
  115367. */
  115368. attributeName: string;
  115369. /**
  115370. * Index/offset of the attribute in the vertex shader
  115371. * if not specified, this will be computes from the name.
  115372. */
  115373. index?: number;
  115374. /**
  115375. * size of the attribute, 1, 2, 3 or 4
  115376. */
  115377. attributeSize: number;
  115378. /**
  115379. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115380. */
  115381. offset: number;
  115382. /**
  115383. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115384. * default to 1
  115385. */
  115386. divisor?: number;
  115387. /**
  115388. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115389. * default is FLOAT
  115390. */
  115391. attributeType?: number;
  115392. /**
  115393. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115394. */
  115395. normalized?: boolean;
  115396. }
  115397. }
  115398. declare module BABYLON {
  115399. interface ThinEngine {
  115400. /**
  115401. * Update a video texture
  115402. * @param texture defines the texture to update
  115403. * @param video defines the video element to use
  115404. * @param invertY defines if data must be stored with Y axis inverted
  115405. */
  115406. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115407. }
  115408. }
  115409. declare module BABYLON {
  115410. interface ThinEngine {
  115411. /**
  115412. * Creates a dynamic texture
  115413. * @param width defines the width of the texture
  115414. * @param height defines the height of the texture
  115415. * @param generateMipMaps defines if the engine should generate the mip levels
  115416. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115417. * @returns the dynamic texture inside an InternalTexture
  115418. */
  115419. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115420. /**
  115421. * Update the content of a dynamic texture
  115422. * @param texture defines the texture to update
  115423. * @param canvas defines the canvas containing the source
  115424. * @param invertY defines if data must be stored with Y axis inverted
  115425. * @param premulAlpha defines if alpha is stored as premultiplied
  115426. * @param format defines the format of the data
  115427. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115428. */
  115429. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115430. }
  115431. }
  115432. declare module BABYLON {
  115433. /**
  115434. * Settings for finer control over video usage
  115435. */
  115436. export interface VideoTextureSettings {
  115437. /**
  115438. * Applies `autoplay` to video, if specified
  115439. */
  115440. autoPlay?: boolean;
  115441. /**
  115442. * Applies `loop` to video, if specified
  115443. */
  115444. loop?: boolean;
  115445. /**
  115446. * Automatically updates internal texture from video at every frame in the render loop
  115447. */
  115448. autoUpdateTexture: boolean;
  115449. /**
  115450. * Image src displayed during the video loading or until the user interacts with the video.
  115451. */
  115452. poster?: string;
  115453. }
  115454. /**
  115455. * If you want to display a video in your scene, this is the special texture for that.
  115456. * This special texture works similar to other textures, with the exception of a few parameters.
  115457. * @see https://doc.babylonjs.com/how_to/video_texture
  115458. */
  115459. export class VideoTexture extends Texture {
  115460. /**
  115461. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115462. */
  115463. readonly autoUpdateTexture: boolean;
  115464. /**
  115465. * The video instance used by the texture internally
  115466. */
  115467. readonly video: HTMLVideoElement;
  115468. private _onUserActionRequestedObservable;
  115469. /**
  115470. * Event triggerd when a dom action is required by the user to play the video.
  115471. * This happens due to recent changes in browser policies preventing video to auto start.
  115472. */
  115473. get onUserActionRequestedObservable(): Observable<Texture>;
  115474. private _generateMipMaps;
  115475. private _stillImageCaptured;
  115476. private _displayingPosterTexture;
  115477. private _settings;
  115478. private _createInternalTextureOnEvent;
  115479. private _frameId;
  115480. private _currentSrc;
  115481. /**
  115482. * Creates a video texture.
  115483. * If you want to display a video in your scene, this is the special texture for that.
  115484. * This special texture works similar to other textures, with the exception of a few parameters.
  115485. * @see https://doc.babylonjs.com/how_to/video_texture
  115486. * @param name optional name, will detect from video source, if not defined
  115487. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115488. * @param scene is obviously the current scene.
  115489. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115490. * @param invertY is false by default but can be used to invert video on Y axis
  115491. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115492. * @param settings allows finer control over video usage
  115493. */
  115494. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115495. private _getName;
  115496. private _getVideo;
  115497. private _createInternalTexture;
  115498. private reset;
  115499. /**
  115500. * @hidden Internal method to initiate `update`.
  115501. */
  115502. _rebuild(): void;
  115503. /**
  115504. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115505. */
  115506. update(): void;
  115507. /**
  115508. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115509. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115510. */
  115511. updateTexture(isVisible: boolean): void;
  115512. protected _updateInternalTexture: () => void;
  115513. /**
  115514. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115515. * @param url New url.
  115516. */
  115517. updateURL(url: string): void;
  115518. /**
  115519. * Clones the texture.
  115520. * @returns the cloned texture
  115521. */
  115522. clone(): VideoTexture;
  115523. /**
  115524. * Dispose the texture and release its associated resources.
  115525. */
  115526. dispose(): void;
  115527. /**
  115528. * Creates a video texture straight from a stream.
  115529. * @param scene Define the scene the texture should be created in
  115530. * @param stream Define the stream the texture should be created from
  115531. * @returns The created video texture as a promise
  115532. */
  115533. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115534. /**
  115535. * Creates a video texture straight from your WebCam video feed.
  115536. * @param scene Define the scene the texture should be created in
  115537. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115538. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115539. * @returns The created video texture as a promise
  115540. */
  115541. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115542. minWidth: number;
  115543. maxWidth: number;
  115544. minHeight: number;
  115545. maxHeight: number;
  115546. deviceId: string;
  115547. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115548. /**
  115549. * Creates a video texture straight from your WebCam video feed.
  115550. * @param scene Define the scene the texture should be created in
  115551. * @param onReady Define a callback to triggered once the texture will be ready
  115552. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115553. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115554. */
  115555. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115556. minWidth: number;
  115557. maxWidth: number;
  115558. minHeight: number;
  115559. maxHeight: number;
  115560. deviceId: string;
  115561. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115562. }
  115563. }
  115564. declare module BABYLON {
  115565. /**
  115566. * Defines the interface used by objects working like Scene
  115567. * @hidden
  115568. */
  115569. export interface ISceneLike {
  115570. _addPendingData(data: any): void;
  115571. _removePendingData(data: any): void;
  115572. offlineProvider: IOfflineProvider;
  115573. }
  115574. /**
  115575. * Information about the current host
  115576. */
  115577. export interface HostInformation {
  115578. /**
  115579. * Defines if the current host is a mobile
  115580. */
  115581. isMobile: boolean;
  115582. }
  115583. /** Interface defining initialization parameters for Engine class */
  115584. export interface EngineOptions extends WebGLContextAttributes {
  115585. /**
  115586. * Defines if the engine should no exceed a specified device ratio
  115587. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115588. */
  115589. limitDeviceRatio?: number;
  115590. /**
  115591. * Defines if webvr should be enabled automatically
  115592. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115593. */
  115594. autoEnableWebVR?: boolean;
  115595. /**
  115596. * Defines if webgl2 should be turned off even if supported
  115597. * @see https://doc.babylonjs.com/features/webgl2
  115598. */
  115599. disableWebGL2Support?: boolean;
  115600. /**
  115601. * Defines if webaudio should be initialized as well
  115602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115603. */
  115604. audioEngine?: boolean;
  115605. /**
  115606. * Defines if animations should run using a deterministic lock step
  115607. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115608. */
  115609. deterministicLockstep?: boolean;
  115610. /** Defines the maximum steps to use with deterministic lock step mode */
  115611. lockstepMaxSteps?: number;
  115612. /** Defines the seconds between each deterministic lock step */
  115613. timeStep?: number;
  115614. /**
  115615. * Defines that engine should ignore context lost events
  115616. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115617. */
  115618. doNotHandleContextLost?: boolean;
  115619. /**
  115620. * Defines that engine should ignore modifying touch action attribute and style
  115621. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115622. */
  115623. doNotHandleTouchAction?: boolean;
  115624. /**
  115625. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115626. */
  115627. useHighPrecisionFloats?: boolean;
  115628. /**
  115629. * Make the canvas XR Compatible for XR sessions
  115630. */
  115631. xrCompatible?: boolean;
  115632. /**
  115633. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115634. */
  115635. useHighPrecisionMatrix?: boolean;
  115636. }
  115637. /**
  115638. * The base engine class (root of all engines)
  115639. */
  115640. export class ThinEngine {
  115641. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115642. static ExceptionList: ({
  115643. key: string;
  115644. capture: string;
  115645. captureConstraint: number;
  115646. targets: string[];
  115647. } | {
  115648. key: string;
  115649. capture: null;
  115650. captureConstraint: null;
  115651. targets: string[];
  115652. })[];
  115653. /** @hidden */
  115654. static _TextureLoaders: IInternalTextureLoader[];
  115655. /**
  115656. * Returns the current npm package of the sdk
  115657. */
  115658. static get NpmPackage(): string;
  115659. /**
  115660. * Returns the current version of the framework
  115661. */
  115662. static get Version(): string;
  115663. /**
  115664. * Returns a string describing the current engine
  115665. */
  115666. get description(): string;
  115667. /**
  115668. * Gets or sets the epsilon value used by collision engine
  115669. */
  115670. static CollisionsEpsilon: number;
  115671. /**
  115672. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115673. */
  115674. static get ShadersRepository(): string;
  115675. static set ShadersRepository(value: string);
  115676. /** @hidden */
  115677. _shaderProcessor: IShaderProcessor;
  115678. /**
  115679. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115680. */
  115681. forcePOTTextures: boolean;
  115682. /**
  115683. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115684. */
  115685. isFullscreen: boolean;
  115686. /**
  115687. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115688. */
  115689. cullBackFaces: boolean;
  115690. /**
  115691. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115692. */
  115693. renderEvenInBackground: boolean;
  115694. /**
  115695. * Gets or sets a boolean indicating that cache can be kept between frames
  115696. */
  115697. preventCacheWipeBetweenFrames: boolean;
  115698. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115699. validateShaderPrograms: boolean;
  115700. /**
  115701. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115702. * This can provide greater z depth for distant objects.
  115703. */
  115704. useReverseDepthBuffer: boolean;
  115705. /**
  115706. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115707. */
  115708. disableUniformBuffers: boolean;
  115709. /** @hidden */
  115710. _uniformBuffers: UniformBuffer[];
  115711. /**
  115712. * Gets a boolean indicating that the engine supports uniform buffers
  115713. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115714. */
  115715. get supportsUniformBuffers(): boolean;
  115716. /** @hidden */
  115717. _gl: WebGLRenderingContext;
  115718. /** @hidden */
  115719. _webGLVersion: number;
  115720. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115721. protected _windowIsBackground: boolean;
  115722. protected _creationOptions: EngineOptions;
  115723. protected _highPrecisionShadersAllowed: boolean;
  115724. /** @hidden */
  115725. get _shouldUseHighPrecisionShader(): boolean;
  115726. /**
  115727. * Gets a boolean indicating that only power of 2 textures are supported
  115728. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115729. */
  115730. get needPOTTextures(): boolean;
  115731. /** @hidden */
  115732. _badOS: boolean;
  115733. /** @hidden */
  115734. _badDesktopOS: boolean;
  115735. private _hardwareScalingLevel;
  115736. /** @hidden */
  115737. _caps: EngineCapabilities;
  115738. private _isStencilEnable;
  115739. private _glVersion;
  115740. private _glRenderer;
  115741. private _glVendor;
  115742. /** @hidden */
  115743. _videoTextureSupported: boolean;
  115744. protected _renderingQueueLaunched: boolean;
  115745. protected _activeRenderLoops: (() => void)[];
  115746. /**
  115747. * Observable signaled when a context lost event is raised
  115748. */
  115749. onContextLostObservable: Observable<ThinEngine>;
  115750. /**
  115751. * Observable signaled when a context restored event is raised
  115752. */
  115753. onContextRestoredObservable: Observable<ThinEngine>;
  115754. private _onContextLost;
  115755. private _onContextRestored;
  115756. protected _contextWasLost: boolean;
  115757. /** @hidden */
  115758. _doNotHandleContextLost: boolean;
  115759. /**
  115760. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115761. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115762. */
  115763. get doNotHandleContextLost(): boolean;
  115764. set doNotHandleContextLost(value: boolean);
  115765. /**
  115766. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115767. */
  115768. disableVertexArrayObjects: boolean;
  115769. /** @hidden */
  115770. protected _colorWrite: boolean;
  115771. /** @hidden */
  115772. protected _colorWriteChanged: boolean;
  115773. /** @hidden */
  115774. protected _depthCullingState: DepthCullingState;
  115775. /** @hidden */
  115776. protected _stencilState: StencilState;
  115777. /** @hidden */
  115778. _alphaState: AlphaState;
  115779. /** @hidden */
  115780. _alphaMode: number;
  115781. /** @hidden */
  115782. _alphaEquation: number;
  115783. /** @hidden */
  115784. _internalTexturesCache: InternalTexture[];
  115785. /** @hidden */
  115786. protected _activeChannel: number;
  115787. private _currentTextureChannel;
  115788. /** @hidden */
  115789. protected _boundTexturesCache: {
  115790. [key: string]: Nullable<InternalTexture>;
  115791. };
  115792. /** @hidden */
  115793. protected _currentEffect: Nullable<Effect>;
  115794. /** @hidden */
  115795. protected _currentProgram: Nullable<WebGLProgram>;
  115796. private _compiledEffects;
  115797. private _vertexAttribArraysEnabled;
  115798. /** @hidden */
  115799. protected _cachedViewport: Nullable<IViewportLike>;
  115800. private _cachedVertexArrayObject;
  115801. /** @hidden */
  115802. protected _cachedVertexBuffers: any;
  115803. /** @hidden */
  115804. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115805. /** @hidden */
  115806. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115807. /** @hidden */
  115808. _currentRenderTarget: Nullable<InternalTexture>;
  115809. private _uintIndicesCurrentlySet;
  115810. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115811. /** @hidden */
  115812. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115813. /** @hidden */
  115814. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115815. private _currentBufferPointers;
  115816. private _currentInstanceLocations;
  115817. private _currentInstanceBuffers;
  115818. private _textureUnits;
  115819. /** @hidden */
  115820. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115821. /** @hidden */
  115822. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115823. /** @hidden */
  115824. _boundRenderFunction: any;
  115825. private _vaoRecordInProgress;
  115826. private _mustWipeVertexAttributes;
  115827. private _emptyTexture;
  115828. private _emptyCubeTexture;
  115829. private _emptyTexture3D;
  115830. private _emptyTexture2DArray;
  115831. /** @hidden */
  115832. _frameHandler: number;
  115833. private _nextFreeTextureSlots;
  115834. private _maxSimultaneousTextures;
  115835. private _activeRequests;
  115836. /** @hidden */
  115837. _transformTextureUrl: Nullable<(url: string) => string>;
  115838. /**
  115839. * Gets information about the current host
  115840. */
  115841. hostInformation: HostInformation;
  115842. protected get _supportsHardwareTextureRescaling(): boolean;
  115843. private _framebufferDimensionsObject;
  115844. /**
  115845. * sets the object from which width and height will be taken from when getting render width and height
  115846. * Will fallback to the gl object
  115847. * @param dimensions the framebuffer width and height that will be used.
  115848. */
  115849. set framebufferDimensionsObject(dimensions: Nullable<{
  115850. framebufferWidth: number;
  115851. framebufferHeight: number;
  115852. }>);
  115853. /**
  115854. * Gets the current viewport
  115855. */
  115856. get currentViewport(): Nullable<IViewportLike>;
  115857. /**
  115858. * Gets the default empty texture
  115859. */
  115860. get emptyTexture(): InternalTexture;
  115861. /**
  115862. * Gets the default empty 3D texture
  115863. */
  115864. get emptyTexture3D(): InternalTexture;
  115865. /**
  115866. * Gets the default empty 2D array texture
  115867. */
  115868. get emptyTexture2DArray(): InternalTexture;
  115869. /**
  115870. * Gets the default empty cube texture
  115871. */
  115872. get emptyCubeTexture(): InternalTexture;
  115873. /**
  115874. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115875. */
  115876. readonly premultipliedAlpha: boolean;
  115877. /**
  115878. * Observable event triggered before each texture is initialized
  115879. */
  115880. onBeforeTextureInitObservable: Observable<Texture>;
  115881. /**
  115882. * Creates a new engine
  115883. * @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
  115884. * @param antialias defines enable antialiasing (default: false)
  115885. * @param options defines further options to be sent to the getContext() function
  115886. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115887. */
  115888. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115889. private _rebuildInternalTextures;
  115890. private _rebuildEffects;
  115891. /**
  115892. * Gets a boolean indicating if all created effects are ready
  115893. * @returns true if all effects are ready
  115894. */
  115895. areAllEffectsReady(): boolean;
  115896. protected _rebuildBuffers(): void;
  115897. protected _initGLContext(): void;
  115898. /**
  115899. * Gets version of the current webGL context
  115900. */
  115901. get webGLVersion(): number;
  115902. /**
  115903. * Gets a string identifying the name of the class
  115904. * @returns "Engine" string
  115905. */
  115906. getClassName(): string;
  115907. /**
  115908. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115909. */
  115910. get isStencilEnable(): boolean;
  115911. /** @hidden */
  115912. _prepareWorkingCanvas(): void;
  115913. /**
  115914. * Reset the texture cache to empty state
  115915. */
  115916. resetTextureCache(): void;
  115917. /**
  115918. * Gets an object containing information about the current webGL context
  115919. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115920. */
  115921. getGlInfo(): {
  115922. vendor: string;
  115923. renderer: string;
  115924. version: string;
  115925. };
  115926. /**
  115927. * Defines the hardware scaling level.
  115928. * By default the hardware scaling level is computed from the window device ratio.
  115929. * 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.
  115930. * @param level defines the level to use
  115931. */
  115932. setHardwareScalingLevel(level: number): void;
  115933. /**
  115934. * Gets the current hardware scaling level.
  115935. * By default the hardware scaling level is computed from the window device ratio.
  115936. * 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.
  115937. * @returns a number indicating the current hardware scaling level
  115938. */
  115939. getHardwareScalingLevel(): number;
  115940. /**
  115941. * Gets the list of loaded textures
  115942. * @returns an array containing all loaded textures
  115943. */
  115944. getLoadedTexturesCache(): InternalTexture[];
  115945. /**
  115946. * Gets the object containing all engine capabilities
  115947. * @returns the EngineCapabilities object
  115948. */
  115949. getCaps(): EngineCapabilities;
  115950. /**
  115951. * stop executing a render loop function and remove it from the execution array
  115952. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115953. */
  115954. stopRenderLoop(renderFunction?: () => void): void;
  115955. /** @hidden */
  115956. _renderLoop(): void;
  115957. /**
  115958. * Gets the HTML canvas attached with the current webGL context
  115959. * @returns a HTML canvas
  115960. */
  115961. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115962. /**
  115963. * Gets host window
  115964. * @returns the host window object
  115965. */
  115966. getHostWindow(): Nullable<Window>;
  115967. /**
  115968. * Gets the current render width
  115969. * @param useScreen defines if screen size must be used (or the current render target if any)
  115970. * @returns a number defining the current render width
  115971. */
  115972. getRenderWidth(useScreen?: boolean): number;
  115973. /**
  115974. * Gets the current render height
  115975. * @param useScreen defines if screen size must be used (or the current render target if any)
  115976. * @returns a number defining the current render height
  115977. */
  115978. getRenderHeight(useScreen?: boolean): number;
  115979. /**
  115980. * Can be used to override the current requestAnimationFrame requester.
  115981. * @hidden
  115982. */
  115983. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115984. /**
  115985. * Register and execute a render loop. The engine can have more than one render function
  115986. * @param renderFunction defines the function to continuously execute
  115987. */
  115988. runRenderLoop(renderFunction: () => void): void;
  115989. /**
  115990. * Clear the current render buffer or the current render target (if any is set up)
  115991. * @param color defines the color to use
  115992. * @param backBuffer defines if the back buffer must be cleared
  115993. * @param depth defines if the depth buffer must be cleared
  115994. * @param stencil defines if the stencil buffer must be cleared
  115995. */
  115996. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115997. private _viewportCached;
  115998. /** @hidden */
  115999. _viewport(x: number, y: number, width: number, height: number): void;
  116000. /**
  116001. * Set the WebGL's viewport
  116002. * @param viewport defines the viewport element to be used
  116003. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116004. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116005. */
  116006. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116007. /**
  116008. * Begin a new frame
  116009. */
  116010. beginFrame(): void;
  116011. /**
  116012. * Enf the current frame
  116013. */
  116014. endFrame(): void;
  116015. /**
  116016. * Resize the view according to the canvas' size
  116017. */
  116018. resize(): void;
  116019. /**
  116020. * Force a specific size of the canvas
  116021. * @param width defines the new canvas' width
  116022. * @param height defines the new canvas' height
  116023. * @returns true if the size was changed
  116024. */
  116025. setSize(width: number, height: number): boolean;
  116026. /**
  116027. * Binds the frame buffer to the specified texture.
  116028. * @param texture The texture to render to or null for the default canvas
  116029. * @param faceIndex The face of the texture to render to in case of cube texture
  116030. * @param requiredWidth The width of the target to render to
  116031. * @param requiredHeight The height of the target to render to
  116032. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116033. * @param lodLevel defines the lod level to bind to the frame buffer
  116034. * @param layer defines the 2d array index to bind to frame buffer to
  116035. */
  116036. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116037. /** @hidden */
  116038. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116039. /**
  116040. * Unbind the current render target texture from the webGL context
  116041. * @param texture defines the render target texture to unbind
  116042. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116043. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116044. */
  116045. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116046. /**
  116047. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116048. */
  116049. flushFramebuffer(): void;
  116050. /**
  116051. * Unbind the current render target and bind the default framebuffer
  116052. */
  116053. restoreDefaultFramebuffer(): void;
  116054. /** @hidden */
  116055. protected _resetVertexBufferBinding(): void;
  116056. /**
  116057. * Creates a vertex buffer
  116058. * @param data the data for the vertex buffer
  116059. * @returns the new WebGL static buffer
  116060. */
  116061. createVertexBuffer(data: DataArray): DataBuffer;
  116062. private _createVertexBuffer;
  116063. /**
  116064. * Creates a dynamic vertex buffer
  116065. * @param data the data for the dynamic vertex buffer
  116066. * @returns the new WebGL dynamic buffer
  116067. */
  116068. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116069. protected _resetIndexBufferBinding(): void;
  116070. /**
  116071. * Creates a new index buffer
  116072. * @param indices defines the content of the index buffer
  116073. * @param updatable defines if the index buffer must be updatable
  116074. * @returns a new webGL buffer
  116075. */
  116076. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116077. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116078. /**
  116079. * Bind a webGL buffer to the webGL context
  116080. * @param buffer defines the buffer to bind
  116081. */
  116082. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116083. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116084. private bindBuffer;
  116085. /**
  116086. * update the bound buffer with the given data
  116087. * @param data defines the data to update
  116088. */
  116089. updateArrayBuffer(data: Float32Array): void;
  116090. private _vertexAttribPointer;
  116091. /** @hidden */
  116092. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116093. private _bindVertexBuffersAttributes;
  116094. /**
  116095. * Records a vertex array object
  116096. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116097. * @param vertexBuffers defines the list of vertex buffers to store
  116098. * @param indexBuffer defines the index buffer to store
  116099. * @param effect defines the effect to store
  116100. * @returns the new vertex array object
  116101. */
  116102. recordVertexArrayObject(vertexBuffers: {
  116103. [key: string]: VertexBuffer;
  116104. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116105. /**
  116106. * Bind a specific vertex array object
  116107. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116108. * @param vertexArrayObject defines the vertex array object to bind
  116109. * @param indexBuffer defines the index buffer to bind
  116110. */
  116111. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116112. /**
  116113. * Bind webGl buffers directly to the webGL context
  116114. * @param vertexBuffer defines the vertex buffer to bind
  116115. * @param indexBuffer defines the index buffer to bind
  116116. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116117. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116118. * @param effect defines the effect associated with the vertex buffer
  116119. */
  116120. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116121. private _unbindVertexArrayObject;
  116122. /**
  116123. * Bind a list of vertex buffers to the webGL context
  116124. * @param vertexBuffers defines the list of vertex buffers to bind
  116125. * @param indexBuffer defines the index buffer to bind
  116126. * @param effect defines the effect associated with the vertex buffers
  116127. */
  116128. bindBuffers(vertexBuffers: {
  116129. [key: string]: Nullable<VertexBuffer>;
  116130. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116131. /**
  116132. * Unbind all instance attributes
  116133. */
  116134. unbindInstanceAttributes(): void;
  116135. /**
  116136. * Release and free the memory of a vertex array object
  116137. * @param vao defines the vertex array object to delete
  116138. */
  116139. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116140. /** @hidden */
  116141. _releaseBuffer(buffer: DataBuffer): boolean;
  116142. protected _deleteBuffer(buffer: DataBuffer): void;
  116143. /**
  116144. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116145. * @param instancesBuffer defines the webGL buffer to update and bind
  116146. * @param data defines the data to store in the buffer
  116147. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116148. */
  116149. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116150. /**
  116151. * Bind the content of a webGL buffer used with instantiation
  116152. * @param instancesBuffer defines the webGL buffer to bind
  116153. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116154. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116155. */
  116156. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116157. /**
  116158. * Disable the instance attribute corresponding to the name in parameter
  116159. * @param name defines the name of the attribute to disable
  116160. */
  116161. disableInstanceAttributeByName(name: string): void;
  116162. /**
  116163. * Disable the instance attribute corresponding to the location in parameter
  116164. * @param attributeLocation defines the attribute location of the attribute to disable
  116165. */
  116166. disableInstanceAttribute(attributeLocation: number): void;
  116167. /**
  116168. * Disable the attribute corresponding to the location in parameter
  116169. * @param attributeLocation defines the attribute location of the attribute to disable
  116170. */
  116171. disableAttributeByIndex(attributeLocation: number): void;
  116172. /**
  116173. * Send a draw order
  116174. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116175. * @param indexStart defines the starting index
  116176. * @param indexCount defines the number of index to draw
  116177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116178. */
  116179. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116180. /**
  116181. * Draw a list of points
  116182. * @param verticesStart defines the index of first vertex to draw
  116183. * @param verticesCount defines the count of vertices to draw
  116184. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116185. */
  116186. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116187. /**
  116188. * Draw a list of unindexed primitives
  116189. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116190. * @param verticesStart defines the index of first vertex to draw
  116191. * @param verticesCount defines the count of vertices to draw
  116192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116193. */
  116194. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116195. /**
  116196. * Draw a list of indexed primitives
  116197. * @param fillMode defines the primitive to use
  116198. * @param indexStart defines the starting index
  116199. * @param indexCount defines the number of index to draw
  116200. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116201. */
  116202. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116203. /**
  116204. * Draw a list of unindexed primitives
  116205. * @param fillMode defines the primitive to use
  116206. * @param verticesStart defines the index of first vertex to draw
  116207. * @param verticesCount defines the count of vertices to draw
  116208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116209. */
  116210. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116211. private _drawMode;
  116212. /** @hidden */
  116213. protected _reportDrawCall(): void;
  116214. /** @hidden */
  116215. _releaseEffect(effect: Effect): void;
  116216. /** @hidden */
  116217. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116218. /**
  116219. * Create a new effect (used to store vertex/fragment shaders)
  116220. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116221. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116222. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116223. * @param samplers defines an array of string used to represent textures
  116224. * @param defines defines the string containing the defines to use to compile the shaders
  116225. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116226. * @param onCompiled defines a function to call when the effect creation is successful
  116227. * @param onError defines a function to call when the effect creation has failed
  116228. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116229. * @returns the new Effect
  116230. */
  116231. 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;
  116232. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116233. private _compileShader;
  116234. private _compileRawShader;
  116235. /** @hidden */
  116236. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116237. /**
  116238. * Directly creates a webGL program
  116239. * @param pipelineContext defines the pipeline context to attach to
  116240. * @param vertexCode defines the vertex shader code to use
  116241. * @param fragmentCode defines the fragment shader code to use
  116242. * @param context defines the webGL context to use (if not set, the current one will be used)
  116243. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116244. * @returns the new webGL program
  116245. */
  116246. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116247. /**
  116248. * Creates a webGL program
  116249. * @param pipelineContext defines the pipeline context to attach to
  116250. * @param vertexCode defines the vertex shader code to use
  116251. * @param fragmentCode defines the fragment shader code to use
  116252. * @param defines defines the string containing the defines to use to compile the shaders
  116253. * @param context defines the webGL context to use (if not set, the current one will be used)
  116254. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116255. * @returns the new webGL program
  116256. */
  116257. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116258. /**
  116259. * Creates a new pipeline context
  116260. * @returns the new pipeline
  116261. */
  116262. createPipelineContext(): IPipelineContext;
  116263. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116264. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116265. /** @hidden */
  116266. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116267. /** @hidden */
  116268. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116269. /** @hidden */
  116270. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116271. /**
  116272. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116273. * @param pipelineContext defines the pipeline context to use
  116274. * @param uniformsNames defines the list of uniform names
  116275. * @returns an array of webGL uniform locations
  116276. */
  116277. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116278. /**
  116279. * Gets the lsit of active attributes for a given webGL program
  116280. * @param pipelineContext defines the pipeline context to use
  116281. * @param attributesNames defines the list of attribute names to get
  116282. * @returns an array of indices indicating the offset of each attribute
  116283. */
  116284. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116285. /**
  116286. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116287. * @param effect defines the effect to activate
  116288. */
  116289. enableEffect(effect: Nullable<Effect>): void;
  116290. /**
  116291. * Set the value of an uniform to a number (int)
  116292. * @param uniform defines the webGL uniform location where to store the value
  116293. * @param value defines the int number to store
  116294. * @returns true if the value was set
  116295. */
  116296. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116297. /**
  116298. * Set the value of an uniform to an array of int32
  116299. * @param uniform defines the webGL uniform location where to store the value
  116300. * @param array defines the array of int32 to store
  116301. * @returns true if the value was set
  116302. */
  116303. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116304. /**
  116305. * Set the value of an uniform to an array of int32 (stored as vec2)
  116306. * @param uniform defines the webGL uniform location where to store the value
  116307. * @param array defines the array of int32 to store
  116308. * @returns true if the value was set
  116309. */
  116310. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116311. /**
  116312. * Set the value of an uniform to an array of int32 (stored as vec3)
  116313. * @param uniform defines the webGL uniform location where to store the value
  116314. * @param array defines the array of int32 to store
  116315. * @returns true if the value was set
  116316. */
  116317. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116318. /**
  116319. * Set the value of an uniform to an array of int32 (stored as vec4)
  116320. * @param uniform defines the webGL uniform location where to store the value
  116321. * @param array defines the array of int32 to store
  116322. * @returns true if the value was set
  116323. */
  116324. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116325. /**
  116326. * Set the value of an uniform to an array of number
  116327. * @param uniform defines the webGL uniform location where to store the value
  116328. * @param array defines the array of number to store
  116329. * @returns true if the value was set
  116330. */
  116331. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116332. /**
  116333. * Set the value of an uniform to an array of number (stored as vec2)
  116334. * @param uniform defines the webGL uniform location where to store the value
  116335. * @param array defines the array of number to store
  116336. * @returns true if the value was set
  116337. */
  116338. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116339. /**
  116340. * Set the value of an uniform to an array of number (stored as vec3)
  116341. * @param uniform defines the webGL uniform location where to store the value
  116342. * @param array defines the array of number to store
  116343. * @returns true if the value was set
  116344. */
  116345. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116346. /**
  116347. * Set the value of an uniform to an array of number (stored as vec4)
  116348. * @param uniform defines the webGL uniform location where to store the value
  116349. * @param array defines the array of number to store
  116350. * @returns true if the value was set
  116351. */
  116352. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116353. /**
  116354. * Set the value of an uniform to an array of float32 (stored as matrices)
  116355. * @param uniform defines the webGL uniform location where to store the value
  116356. * @param matrices defines the array of float32 to store
  116357. * @returns true if the value was set
  116358. */
  116359. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116360. /**
  116361. * Set the value of an uniform to a matrix (3x3)
  116362. * @param uniform defines the webGL uniform location where to store the value
  116363. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116364. * @returns true if the value was set
  116365. */
  116366. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116367. /**
  116368. * Set the value of an uniform to a matrix (2x2)
  116369. * @param uniform defines the webGL uniform location where to store the value
  116370. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116371. * @returns true if the value was set
  116372. */
  116373. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116374. /**
  116375. * Set the value of an uniform to a number (float)
  116376. * @param uniform defines the webGL uniform location where to store the value
  116377. * @param value defines the float number to store
  116378. * @returns true if the value was transfered
  116379. */
  116380. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116381. /**
  116382. * Set the value of an uniform to a vec2
  116383. * @param uniform defines the webGL uniform location where to store the value
  116384. * @param x defines the 1st component of the value
  116385. * @param y defines the 2nd component of the value
  116386. * @returns true if the value was set
  116387. */
  116388. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116389. /**
  116390. * Set the value of an uniform to a vec3
  116391. * @param uniform defines the webGL uniform location where to store the value
  116392. * @param x defines the 1st component of the value
  116393. * @param y defines the 2nd component of the value
  116394. * @param z defines the 3rd component of the value
  116395. * @returns true if the value was set
  116396. */
  116397. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116398. /**
  116399. * Set the value of an uniform to a vec4
  116400. * @param uniform defines the webGL uniform location where to store the value
  116401. * @param x defines the 1st component of the value
  116402. * @param y defines the 2nd component of the value
  116403. * @param z defines the 3rd component of the value
  116404. * @param w defines the 4th component of the value
  116405. * @returns true if the value was set
  116406. */
  116407. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116408. /**
  116409. * Apply all cached states (depth, culling, stencil and alpha)
  116410. */
  116411. applyStates(): void;
  116412. /**
  116413. * Enable or disable color writing
  116414. * @param enable defines the state to set
  116415. */
  116416. setColorWrite(enable: boolean): void;
  116417. /**
  116418. * Gets a boolean indicating if color writing is enabled
  116419. * @returns the current color writing state
  116420. */
  116421. getColorWrite(): boolean;
  116422. /**
  116423. * Gets the depth culling state manager
  116424. */
  116425. get depthCullingState(): DepthCullingState;
  116426. /**
  116427. * Gets the alpha state manager
  116428. */
  116429. get alphaState(): AlphaState;
  116430. /**
  116431. * Gets the stencil state manager
  116432. */
  116433. get stencilState(): StencilState;
  116434. /**
  116435. * Clears the list of texture accessible through engine.
  116436. * This can help preventing texture load conflict due to name collision.
  116437. */
  116438. clearInternalTexturesCache(): void;
  116439. /**
  116440. * Force the entire cache to be cleared
  116441. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116442. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116443. */
  116444. wipeCaches(bruteForce?: boolean): void;
  116445. /** @hidden */
  116446. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116447. min: number;
  116448. mag: number;
  116449. };
  116450. /** @hidden */
  116451. _createTexture(): WebGLTexture;
  116452. /**
  116453. * Usually called from Texture.ts.
  116454. * Passed information to create a WebGLTexture
  116455. * @param url defines a value which contains one of the following:
  116456. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116457. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116458. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116460. * @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)
  116461. * @param scene needed for loading to the correct scene
  116462. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116463. * @param onLoad optional callback to be called upon successful completion
  116464. * @param onError optional callback to be called upon failure
  116465. * @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
  116466. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116467. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116468. * @param forcedExtension defines the extension to use to pick the right loader
  116469. * @param mimeType defines an optional mime type
  116470. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116471. */
  116472. 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;
  116473. /**
  116474. * Loads an image as an HTMLImageElement.
  116475. * @param input url string, ArrayBuffer, or Blob to load
  116476. * @param onLoad callback called when the image successfully loads
  116477. * @param onError callback called when the image fails to load
  116478. * @param offlineProvider offline provider for caching
  116479. * @param mimeType optional mime type
  116480. * @returns the HTMLImageElement of the loaded image
  116481. * @hidden
  116482. */
  116483. 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>;
  116484. /**
  116485. * @hidden
  116486. */
  116487. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116488. private _unpackFlipYCached;
  116489. /**
  116490. * In case you are sharing the context with other applications, it might
  116491. * be interested to not cache the unpack flip y state to ensure a consistent
  116492. * value would be set.
  116493. */
  116494. enableUnpackFlipYCached: boolean;
  116495. /** @hidden */
  116496. _unpackFlipY(value: boolean): void;
  116497. /** @hidden */
  116498. _getUnpackAlignement(): number;
  116499. private _getTextureTarget;
  116500. /**
  116501. * Update the sampling mode of a given texture
  116502. * @param samplingMode defines the required sampling mode
  116503. * @param texture defines the texture to update
  116504. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116505. */
  116506. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116507. /**
  116508. * Update the sampling mode of a given texture
  116509. * @param texture defines the texture to update
  116510. * @param wrapU defines the texture wrap mode of the u coordinates
  116511. * @param wrapV defines the texture wrap mode of the v coordinates
  116512. * @param wrapR defines the texture wrap mode of the r coordinates
  116513. */
  116514. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116515. /** @hidden */
  116516. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116517. width: number;
  116518. height: number;
  116519. layers?: number;
  116520. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116521. /** @hidden */
  116522. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116523. /** @hidden */
  116524. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116525. /**
  116526. * Update a portion of an internal texture
  116527. * @param texture defines the texture to update
  116528. * @param imageData defines the data to store into the texture
  116529. * @param xOffset defines the x coordinates of the update rectangle
  116530. * @param yOffset defines the y coordinates of the update rectangle
  116531. * @param width defines the width of the update rectangle
  116532. * @param height defines the height of the update rectangle
  116533. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116534. * @param lod defines the lod level to update (0 by default)
  116535. */
  116536. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116537. /** @hidden */
  116538. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116539. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116540. private _prepareWebGLTexture;
  116541. /** @hidden */
  116542. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116543. private _getDepthStencilBuffer;
  116544. /** @hidden */
  116545. _releaseFramebufferObjects(texture: InternalTexture): void;
  116546. /** @hidden */
  116547. _releaseTexture(texture: InternalTexture): void;
  116548. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116549. protected _setProgram(program: WebGLProgram): void;
  116550. protected _boundUniforms: {
  116551. [key: number]: WebGLUniformLocation;
  116552. };
  116553. /**
  116554. * Binds an effect to the webGL context
  116555. * @param effect defines the effect to bind
  116556. */
  116557. bindSamplers(effect: Effect): void;
  116558. private _activateCurrentTexture;
  116559. /** @hidden */
  116560. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116561. /** @hidden */
  116562. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116563. /**
  116564. * Unbind all textures from the webGL context
  116565. */
  116566. unbindAllTextures(): void;
  116567. /**
  116568. * Sets a texture to the according uniform.
  116569. * @param channel The texture channel
  116570. * @param uniform The uniform to set
  116571. * @param texture The texture to apply
  116572. */
  116573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116574. private _bindSamplerUniformToChannel;
  116575. private _getTextureWrapMode;
  116576. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116577. /**
  116578. * Sets an array of texture to the webGL context
  116579. * @param channel defines the channel where the texture array must be set
  116580. * @param uniform defines the associated uniform location
  116581. * @param textures defines the array of textures to bind
  116582. */
  116583. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116584. /** @hidden */
  116585. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116586. private _setTextureParameterFloat;
  116587. private _setTextureParameterInteger;
  116588. /**
  116589. * Unbind all vertex attributes from the webGL context
  116590. */
  116591. unbindAllAttributes(): void;
  116592. /**
  116593. * 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
  116594. */
  116595. releaseEffects(): void;
  116596. /**
  116597. * Dispose and release all associated resources
  116598. */
  116599. dispose(): void;
  116600. /**
  116601. * Attach a new callback raised when context lost event is fired
  116602. * @param callback defines the callback to call
  116603. */
  116604. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116605. /**
  116606. * Attach a new callback raised when context restored event is fired
  116607. * @param callback defines the callback to call
  116608. */
  116609. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116610. /**
  116611. * Get the current error code of the webGL context
  116612. * @returns the error code
  116613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116614. */
  116615. getError(): number;
  116616. private _canRenderToFloatFramebuffer;
  116617. private _canRenderToHalfFloatFramebuffer;
  116618. private _canRenderToFramebuffer;
  116619. /** @hidden */
  116620. _getWebGLTextureType(type: number): number;
  116621. /** @hidden */
  116622. _getInternalFormat(format: number): number;
  116623. /** @hidden */
  116624. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116625. /** @hidden */
  116626. _getRGBAMultiSampleBufferFormat(type: number): number;
  116627. /** @hidden */
  116628. _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;
  116629. /**
  116630. * Loads a file from a url
  116631. * @param url url to load
  116632. * @param onSuccess callback called when the file successfully loads
  116633. * @param onProgress callback called while file is loading (if the server supports this mode)
  116634. * @param offlineProvider defines the offline provider for caching
  116635. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116636. * @param onError callback called when the file fails to load
  116637. * @returns a file request object
  116638. * @hidden
  116639. */
  116640. 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;
  116641. /**
  116642. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116643. * @param x defines the x coordinate of the rectangle where pixels must be read
  116644. * @param y defines the y coordinate of the rectangle where pixels must be read
  116645. * @param width defines the width of the rectangle where pixels must be read
  116646. * @param height defines the height of the rectangle where pixels must be read
  116647. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116648. * @returns a Uint8Array containing RGBA colors
  116649. */
  116650. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116651. private static _isSupported;
  116652. /**
  116653. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116654. * @returns true if the engine can be created
  116655. * @ignorenaming
  116656. */
  116657. static isSupported(): boolean;
  116658. /**
  116659. * Find the next highest power of two.
  116660. * @param x Number to start search from.
  116661. * @return Next highest power of two.
  116662. */
  116663. static CeilingPOT(x: number): number;
  116664. /**
  116665. * Find the next lowest power of two.
  116666. * @param x Number to start search from.
  116667. * @return Next lowest power of two.
  116668. */
  116669. static FloorPOT(x: number): number;
  116670. /**
  116671. * Find the nearest power of two.
  116672. * @param x Number to start search from.
  116673. * @return Next nearest power of two.
  116674. */
  116675. static NearestPOT(x: number): number;
  116676. /**
  116677. * Get the closest exponent of two
  116678. * @param value defines the value to approximate
  116679. * @param max defines the maximum value to return
  116680. * @param mode defines how to define the closest value
  116681. * @returns closest exponent of two of the given value
  116682. */
  116683. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116684. /**
  116685. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116686. * @param func - the function to be called
  116687. * @param requester - the object that will request the next frame. Falls back to window.
  116688. * @returns frame number
  116689. */
  116690. static QueueNewFrame(func: () => void, requester?: any): number;
  116691. /**
  116692. * Gets host document
  116693. * @returns the host document object
  116694. */
  116695. getHostDocument(): Nullable<Document>;
  116696. }
  116697. }
  116698. declare module BABYLON {
  116699. /**
  116700. * Class representing spherical harmonics coefficients to the 3rd degree
  116701. */
  116702. export class SphericalHarmonics {
  116703. /**
  116704. * Defines whether or not the harmonics have been prescaled for rendering.
  116705. */
  116706. preScaled: boolean;
  116707. /**
  116708. * The l0,0 coefficients of the spherical harmonics
  116709. */
  116710. l00: Vector3;
  116711. /**
  116712. * The l1,-1 coefficients of the spherical harmonics
  116713. */
  116714. l1_1: Vector3;
  116715. /**
  116716. * The l1,0 coefficients of the spherical harmonics
  116717. */
  116718. l10: Vector3;
  116719. /**
  116720. * The l1,1 coefficients of the spherical harmonics
  116721. */
  116722. l11: Vector3;
  116723. /**
  116724. * The l2,-2 coefficients of the spherical harmonics
  116725. */
  116726. l2_2: Vector3;
  116727. /**
  116728. * The l2,-1 coefficients of the spherical harmonics
  116729. */
  116730. l2_1: Vector3;
  116731. /**
  116732. * The l2,0 coefficients of the spherical harmonics
  116733. */
  116734. l20: Vector3;
  116735. /**
  116736. * The l2,1 coefficients of the spherical harmonics
  116737. */
  116738. l21: Vector3;
  116739. /**
  116740. * The l2,2 coefficients of the spherical harmonics
  116741. */
  116742. l22: Vector3;
  116743. /**
  116744. * Adds a light to the spherical harmonics
  116745. * @param direction the direction of the light
  116746. * @param color the color of the light
  116747. * @param deltaSolidAngle the delta solid angle of the light
  116748. */
  116749. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116750. /**
  116751. * Scales the spherical harmonics by the given amount
  116752. * @param scale the amount to scale
  116753. */
  116754. scaleInPlace(scale: number): void;
  116755. /**
  116756. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116757. *
  116758. * ```
  116759. * E_lm = A_l * L_lm
  116760. * ```
  116761. *
  116762. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116763. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116764. * the scaling factors are given in equation 9.
  116765. */
  116766. convertIncidentRadianceToIrradiance(): void;
  116767. /**
  116768. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116769. *
  116770. * ```
  116771. * L = (1/pi) * E * rho
  116772. * ```
  116773. *
  116774. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116775. */
  116776. convertIrradianceToLambertianRadiance(): void;
  116777. /**
  116778. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116779. * required operations at run time.
  116780. *
  116781. * This is simply done by scaling back the SH with Ylm constants parameter.
  116782. * The trigonometric part being applied by the shader at run time.
  116783. */
  116784. preScaleForRendering(): void;
  116785. /**
  116786. * Constructs a spherical harmonics from an array.
  116787. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116788. * @returns the spherical harmonics
  116789. */
  116790. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116791. /**
  116792. * Gets the spherical harmonics from polynomial
  116793. * @param polynomial the spherical polynomial
  116794. * @returns the spherical harmonics
  116795. */
  116796. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116797. }
  116798. /**
  116799. * Class representing spherical polynomial coefficients to the 3rd degree
  116800. */
  116801. export class SphericalPolynomial {
  116802. private _harmonics;
  116803. /**
  116804. * The spherical harmonics used to create the polynomials.
  116805. */
  116806. get preScaledHarmonics(): SphericalHarmonics;
  116807. /**
  116808. * The x coefficients of the spherical polynomial
  116809. */
  116810. x: Vector3;
  116811. /**
  116812. * The y coefficients of the spherical polynomial
  116813. */
  116814. y: Vector3;
  116815. /**
  116816. * The z coefficients of the spherical polynomial
  116817. */
  116818. z: Vector3;
  116819. /**
  116820. * The xx coefficients of the spherical polynomial
  116821. */
  116822. xx: Vector3;
  116823. /**
  116824. * The yy coefficients of the spherical polynomial
  116825. */
  116826. yy: Vector3;
  116827. /**
  116828. * The zz coefficients of the spherical polynomial
  116829. */
  116830. zz: Vector3;
  116831. /**
  116832. * The xy coefficients of the spherical polynomial
  116833. */
  116834. xy: Vector3;
  116835. /**
  116836. * The yz coefficients of the spherical polynomial
  116837. */
  116838. yz: Vector3;
  116839. /**
  116840. * The zx coefficients of the spherical polynomial
  116841. */
  116842. zx: Vector3;
  116843. /**
  116844. * Adds an ambient color to the spherical polynomial
  116845. * @param color the color to add
  116846. */
  116847. addAmbient(color: Color3): void;
  116848. /**
  116849. * Scales the spherical polynomial by the given amount
  116850. * @param scale the amount to scale
  116851. */
  116852. scaleInPlace(scale: number): void;
  116853. /**
  116854. * Gets the spherical polynomial from harmonics
  116855. * @param harmonics the spherical harmonics
  116856. * @returns the spherical polynomial
  116857. */
  116858. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116859. /**
  116860. * Constructs a spherical polynomial from an array.
  116861. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116862. * @returns the spherical polynomial
  116863. */
  116864. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116865. }
  116866. }
  116867. declare module BABYLON {
  116868. /**
  116869. * Defines the source of the internal texture
  116870. */
  116871. export enum InternalTextureSource {
  116872. /**
  116873. * The source of the texture data is unknown
  116874. */
  116875. Unknown = 0,
  116876. /**
  116877. * Texture data comes from an URL
  116878. */
  116879. Url = 1,
  116880. /**
  116881. * Texture data is only used for temporary storage
  116882. */
  116883. Temp = 2,
  116884. /**
  116885. * Texture data comes from raw data (ArrayBuffer)
  116886. */
  116887. Raw = 3,
  116888. /**
  116889. * Texture content is dynamic (video or dynamic texture)
  116890. */
  116891. Dynamic = 4,
  116892. /**
  116893. * Texture content is generated by rendering to it
  116894. */
  116895. RenderTarget = 5,
  116896. /**
  116897. * Texture content is part of a multi render target process
  116898. */
  116899. MultiRenderTarget = 6,
  116900. /**
  116901. * Texture data comes from a cube data file
  116902. */
  116903. Cube = 7,
  116904. /**
  116905. * Texture data comes from a raw cube data
  116906. */
  116907. CubeRaw = 8,
  116908. /**
  116909. * Texture data come from a prefiltered cube data file
  116910. */
  116911. CubePrefiltered = 9,
  116912. /**
  116913. * Texture content is raw 3D data
  116914. */
  116915. Raw3D = 10,
  116916. /**
  116917. * Texture content is raw 2D array data
  116918. */
  116919. Raw2DArray = 11,
  116920. /**
  116921. * Texture content is a depth texture
  116922. */
  116923. Depth = 12,
  116924. /**
  116925. * Texture data comes from a raw cube data encoded with RGBD
  116926. */
  116927. CubeRawRGBD = 13
  116928. }
  116929. /**
  116930. * Class used to store data associated with WebGL texture data for the engine
  116931. * This class should not be used directly
  116932. */
  116933. export class InternalTexture {
  116934. /** @hidden */
  116935. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116936. /**
  116937. * Defines if the texture is ready
  116938. */
  116939. isReady: boolean;
  116940. /**
  116941. * Defines if the texture is a cube texture
  116942. */
  116943. isCube: boolean;
  116944. /**
  116945. * Defines if the texture contains 3D data
  116946. */
  116947. is3D: boolean;
  116948. /**
  116949. * Defines if the texture contains 2D array data
  116950. */
  116951. is2DArray: boolean;
  116952. /**
  116953. * Defines if the texture contains multiview data
  116954. */
  116955. isMultiview: boolean;
  116956. /**
  116957. * Gets the URL used to load this texture
  116958. */
  116959. url: string;
  116960. /**
  116961. * Gets the sampling mode of the texture
  116962. */
  116963. samplingMode: number;
  116964. /**
  116965. * Gets a boolean indicating if the texture needs mipmaps generation
  116966. */
  116967. generateMipMaps: boolean;
  116968. /**
  116969. * Gets the number of samples used by the texture (WebGL2+ only)
  116970. */
  116971. samples: number;
  116972. /**
  116973. * Gets the type of the texture (int, float...)
  116974. */
  116975. type: number;
  116976. /**
  116977. * Gets the format of the texture (RGB, RGBA...)
  116978. */
  116979. format: number;
  116980. /**
  116981. * Observable called when the texture is loaded
  116982. */
  116983. onLoadedObservable: Observable<InternalTexture>;
  116984. /**
  116985. * Gets the width of the texture
  116986. */
  116987. width: number;
  116988. /**
  116989. * Gets the height of the texture
  116990. */
  116991. height: number;
  116992. /**
  116993. * Gets the depth of the texture
  116994. */
  116995. depth: number;
  116996. /**
  116997. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116998. */
  116999. baseWidth: number;
  117000. /**
  117001. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117002. */
  117003. baseHeight: number;
  117004. /**
  117005. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117006. */
  117007. baseDepth: number;
  117008. /**
  117009. * Gets a boolean indicating if the texture is inverted on Y axis
  117010. */
  117011. invertY: boolean;
  117012. /** @hidden */
  117013. _invertVScale: boolean;
  117014. /** @hidden */
  117015. _associatedChannel: number;
  117016. /** @hidden */
  117017. _source: InternalTextureSource;
  117018. /** @hidden */
  117019. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117020. /** @hidden */
  117021. _bufferView: Nullable<ArrayBufferView>;
  117022. /** @hidden */
  117023. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117024. /** @hidden */
  117025. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117026. /** @hidden */
  117027. _size: number;
  117028. /** @hidden */
  117029. _extension: string;
  117030. /** @hidden */
  117031. _files: Nullable<string[]>;
  117032. /** @hidden */
  117033. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117034. /** @hidden */
  117035. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117036. /** @hidden */
  117037. _framebuffer: Nullable<WebGLFramebuffer>;
  117038. /** @hidden */
  117039. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117040. /** @hidden */
  117041. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117042. /** @hidden */
  117043. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117044. /** @hidden */
  117045. _attachments: Nullable<number[]>;
  117046. /** @hidden */
  117047. _textureArray: Nullable<InternalTexture[]>;
  117048. /** @hidden */
  117049. _cachedCoordinatesMode: Nullable<number>;
  117050. /** @hidden */
  117051. _cachedWrapU: Nullable<number>;
  117052. /** @hidden */
  117053. _cachedWrapV: Nullable<number>;
  117054. /** @hidden */
  117055. _cachedWrapR: Nullable<number>;
  117056. /** @hidden */
  117057. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117058. /** @hidden */
  117059. _isDisabled: boolean;
  117060. /** @hidden */
  117061. _compression: Nullable<string>;
  117062. /** @hidden */
  117063. _generateStencilBuffer: boolean;
  117064. /** @hidden */
  117065. _generateDepthBuffer: boolean;
  117066. /** @hidden */
  117067. _comparisonFunction: number;
  117068. /** @hidden */
  117069. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117070. /** @hidden */
  117071. _lodGenerationScale: number;
  117072. /** @hidden */
  117073. _lodGenerationOffset: number;
  117074. /** @hidden */
  117075. _depthStencilTexture: Nullable<InternalTexture>;
  117076. /** @hidden */
  117077. _colorTextureArray: Nullable<WebGLTexture>;
  117078. /** @hidden */
  117079. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117080. /** @hidden */
  117081. _lodTextureHigh: Nullable<BaseTexture>;
  117082. /** @hidden */
  117083. _lodTextureMid: Nullable<BaseTexture>;
  117084. /** @hidden */
  117085. _lodTextureLow: Nullable<BaseTexture>;
  117086. /** @hidden */
  117087. _isRGBD: boolean;
  117088. /** @hidden */
  117089. _linearSpecularLOD: boolean;
  117090. /** @hidden */
  117091. _irradianceTexture: Nullable<BaseTexture>;
  117092. /** @hidden */
  117093. _webGLTexture: Nullable<WebGLTexture>;
  117094. /** @hidden */
  117095. _references: number;
  117096. /** @hidden */
  117097. _gammaSpace: Nullable<boolean>;
  117098. private _engine;
  117099. /**
  117100. * Gets the Engine the texture belongs to.
  117101. * @returns The babylon engine
  117102. */
  117103. getEngine(): ThinEngine;
  117104. /**
  117105. * Gets the data source type of the texture
  117106. */
  117107. get source(): InternalTextureSource;
  117108. /**
  117109. * Creates a new InternalTexture
  117110. * @param engine defines the engine to use
  117111. * @param source defines the type of data that will be used
  117112. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117113. */
  117114. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117115. /**
  117116. * Increments the number of references (ie. the number of Texture that point to it)
  117117. */
  117118. incrementReferences(): void;
  117119. /**
  117120. * Change the size of the texture (not the size of the content)
  117121. * @param width defines the new width
  117122. * @param height defines the new height
  117123. * @param depth defines the new depth (1 by default)
  117124. */
  117125. updateSize(width: int, height: int, depth?: int): void;
  117126. /** @hidden */
  117127. _rebuild(): void;
  117128. /** @hidden */
  117129. _swapAndDie(target: InternalTexture): void;
  117130. /**
  117131. * Dispose the current allocated resources
  117132. */
  117133. dispose(): void;
  117134. }
  117135. }
  117136. declare module BABYLON {
  117137. /**
  117138. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117139. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117140. */
  117141. export class Analyser {
  117142. /**
  117143. * Gets or sets the smoothing
  117144. * @ignorenaming
  117145. */
  117146. SMOOTHING: number;
  117147. /**
  117148. * Gets or sets the FFT table size
  117149. * @ignorenaming
  117150. */
  117151. FFT_SIZE: number;
  117152. /**
  117153. * Gets or sets the bar graph amplitude
  117154. * @ignorenaming
  117155. */
  117156. BARGRAPHAMPLITUDE: number;
  117157. /**
  117158. * Gets or sets the position of the debug canvas
  117159. * @ignorenaming
  117160. */
  117161. DEBUGCANVASPOS: {
  117162. x: number;
  117163. y: number;
  117164. };
  117165. /**
  117166. * Gets or sets the debug canvas size
  117167. * @ignorenaming
  117168. */
  117169. DEBUGCANVASSIZE: {
  117170. width: number;
  117171. height: number;
  117172. };
  117173. private _byteFreqs;
  117174. private _byteTime;
  117175. private _floatFreqs;
  117176. private _webAudioAnalyser;
  117177. private _debugCanvas;
  117178. private _debugCanvasContext;
  117179. private _scene;
  117180. private _registerFunc;
  117181. private _audioEngine;
  117182. /**
  117183. * Creates a new analyser
  117184. * @param scene defines hosting scene
  117185. */
  117186. constructor(scene: Scene);
  117187. /**
  117188. * Get the number of data values you will have to play with for the visualization
  117189. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117190. * @returns a number
  117191. */
  117192. getFrequencyBinCount(): number;
  117193. /**
  117194. * Gets the current frequency data as a byte array
  117195. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117196. * @returns a Uint8Array
  117197. */
  117198. getByteFrequencyData(): Uint8Array;
  117199. /**
  117200. * Gets the current waveform as a byte array
  117201. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117202. * @returns a Uint8Array
  117203. */
  117204. getByteTimeDomainData(): Uint8Array;
  117205. /**
  117206. * Gets the current frequency data as a float array
  117207. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117208. * @returns a Float32Array
  117209. */
  117210. getFloatFrequencyData(): Float32Array;
  117211. /**
  117212. * Renders the debug canvas
  117213. */
  117214. drawDebugCanvas(): void;
  117215. /**
  117216. * Stops rendering the debug canvas and removes it
  117217. */
  117218. stopDebugCanvas(): void;
  117219. /**
  117220. * Connects two audio nodes
  117221. * @param inputAudioNode defines first node to connect
  117222. * @param outputAudioNode defines second node to connect
  117223. */
  117224. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117225. /**
  117226. * Releases all associated resources
  117227. */
  117228. dispose(): void;
  117229. }
  117230. }
  117231. declare module BABYLON {
  117232. /**
  117233. * This represents an audio engine and it is responsible
  117234. * to play, synchronize and analyse sounds throughout the application.
  117235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117236. */
  117237. export interface IAudioEngine extends IDisposable {
  117238. /**
  117239. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117240. */
  117241. readonly canUseWebAudio: boolean;
  117242. /**
  117243. * Gets the current AudioContext if available.
  117244. */
  117245. readonly audioContext: Nullable<AudioContext>;
  117246. /**
  117247. * The master gain node defines the global audio volume of your audio engine.
  117248. */
  117249. readonly masterGain: GainNode;
  117250. /**
  117251. * Gets whether or not mp3 are supported by your browser.
  117252. */
  117253. readonly isMP3supported: boolean;
  117254. /**
  117255. * Gets whether or not ogg are supported by your browser.
  117256. */
  117257. readonly isOGGsupported: boolean;
  117258. /**
  117259. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117260. * @ignoreNaming
  117261. */
  117262. WarnedWebAudioUnsupported: boolean;
  117263. /**
  117264. * Defines if the audio engine relies on a custom unlocked button.
  117265. * In this case, the embedded button will not be displayed.
  117266. */
  117267. useCustomUnlockedButton: boolean;
  117268. /**
  117269. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117270. */
  117271. readonly unlocked: boolean;
  117272. /**
  117273. * Event raised when audio has been unlocked on the browser.
  117274. */
  117275. onAudioUnlockedObservable: Observable<AudioEngine>;
  117276. /**
  117277. * Event raised when audio has been locked on the browser.
  117278. */
  117279. onAudioLockedObservable: Observable<AudioEngine>;
  117280. /**
  117281. * Flags the audio engine in Locked state.
  117282. * This happens due to new browser policies preventing audio to autoplay.
  117283. */
  117284. lock(): void;
  117285. /**
  117286. * Unlocks the audio engine once a user action has been done on the dom.
  117287. * This is helpful to resume play once browser policies have been satisfied.
  117288. */
  117289. unlock(): void;
  117290. /**
  117291. * Gets the global volume sets on the master gain.
  117292. * @returns the global volume if set or -1 otherwise
  117293. */
  117294. getGlobalVolume(): number;
  117295. /**
  117296. * Sets the global volume of your experience (sets on the master gain).
  117297. * @param newVolume Defines the new global volume of the application
  117298. */
  117299. setGlobalVolume(newVolume: number): void;
  117300. /**
  117301. * Connect the audio engine to an audio analyser allowing some amazing
  117302. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117303. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117304. * @param analyser The analyser to connect to the engine
  117305. */
  117306. connectToAnalyser(analyser: Analyser): void;
  117307. }
  117308. /**
  117309. * This represents the default audio engine used in babylon.
  117310. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117312. */
  117313. export class AudioEngine implements IAudioEngine {
  117314. private _audioContext;
  117315. private _audioContextInitialized;
  117316. private _muteButton;
  117317. private _hostElement;
  117318. /**
  117319. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117320. */
  117321. canUseWebAudio: boolean;
  117322. /**
  117323. * The master gain node defines the global audio volume of your audio engine.
  117324. */
  117325. masterGain: GainNode;
  117326. /**
  117327. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117328. * @ignoreNaming
  117329. */
  117330. WarnedWebAudioUnsupported: boolean;
  117331. /**
  117332. * Gets whether or not mp3 are supported by your browser.
  117333. */
  117334. isMP3supported: boolean;
  117335. /**
  117336. * Gets whether or not ogg are supported by your browser.
  117337. */
  117338. isOGGsupported: boolean;
  117339. /**
  117340. * Gets whether audio has been unlocked on the device.
  117341. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117342. * a user interaction has happened.
  117343. */
  117344. unlocked: boolean;
  117345. /**
  117346. * Defines if the audio engine relies on a custom unlocked button.
  117347. * In this case, the embedded button will not be displayed.
  117348. */
  117349. useCustomUnlockedButton: boolean;
  117350. /**
  117351. * Event raised when audio has been unlocked on the browser.
  117352. */
  117353. onAudioUnlockedObservable: Observable<AudioEngine>;
  117354. /**
  117355. * Event raised when audio has been locked on the browser.
  117356. */
  117357. onAudioLockedObservable: Observable<AudioEngine>;
  117358. /**
  117359. * Gets the current AudioContext if available.
  117360. */
  117361. get audioContext(): Nullable<AudioContext>;
  117362. private _connectedAnalyser;
  117363. /**
  117364. * Instantiates a new audio engine.
  117365. *
  117366. * There should be only one per page as some browsers restrict the number
  117367. * of audio contexts you can create.
  117368. * @param hostElement defines the host element where to display the mute icon if necessary
  117369. */
  117370. constructor(hostElement?: Nullable<HTMLElement>);
  117371. /**
  117372. * Flags the audio engine in Locked state.
  117373. * This happens due to new browser policies preventing audio to autoplay.
  117374. */
  117375. lock(): void;
  117376. /**
  117377. * Unlocks the audio engine once a user action has been done on the dom.
  117378. * This is helpful to resume play once browser policies have been satisfied.
  117379. */
  117380. unlock(): void;
  117381. private _resumeAudioContext;
  117382. private _initializeAudioContext;
  117383. private _tryToRun;
  117384. private _triggerRunningState;
  117385. private _triggerSuspendedState;
  117386. private _displayMuteButton;
  117387. private _moveButtonToTopLeft;
  117388. private _onResize;
  117389. private _hideMuteButton;
  117390. /**
  117391. * Destroy and release the resources associated with the audio ccontext.
  117392. */
  117393. dispose(): void;
  117394. /**
  117395. * Gets the global volume sets on the master gain.
  117396. * @returns the global volume if set or -1 otherwise
  117397. */
  117398. getGlobalVolume(): number;
  117399. /**
  117400. * Sets the global volume of your experience (sets on the master gain).
  117401. * @param newVolume Defines the new global volume of the application
  117402. */
  117403. setGlobalVolume(newVolume: number): void;
  117404. /**
  117405. * Connect the audio engine to an audio analyser allowing some amazing
  117406. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117408. * @param analyser The analyser to connect to the engine
  117409. */
  117410. connectToAnalyser(analyser: Analyser): void;
  117411. }
  117412. }
  117413. declare module BABYLON {
  117414. /**
  117415. * Interface used to present a loading screen while loading a scene
  117416. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117417. */
  117418. export interface ILoadingScreen {
  117419. /**
  117420. * Function called to display the loading screen
  117421. */
  117422. displayLoadingUI: () => void;
  117423. /**
  117424. * Function called to hide the loading screen
  117425. */
  117426. hideLoadingUI: () => void;
  117427. /**
  117428. * Gets or sets the color to use for the background
  117429. */
  117430. loadingUIBackgroundColor: string;
  117431. /**
  117432. * Gets or sets the text to display while loading
  117433. */
  117434. loadingUIText: string;
  117435. }
  117436. /**
  117437. * Class used for the default loading screen
  117438. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117439. */
  117440. export class DefaultLoadingScreen implements ILoadingScreen {
  117441. private _renderingCanvas;
  117442. private _loadingText;
  117443. private _loadingDivBackgroundColor;
  117444. private _loadingDiv;
  117445. private _loadingTextDiv;
  117446. /** Gets or sets the logo url to use for the default loading screen */
  117447. static DefaultLogoUrl: string;
  117448. /** Gets or sets the spinner url to use for the default loading screen */
  117449. static DefaultSpinnerUrl: string;
  117450. /**
  117451. * Creates a new default loading screen
  117452. * @param _renderingCanvas defines the canvas used to render the scene
  117453. * @param _loadingText defines the default text to display
  117454. * @param _loadingDivBackgroundColor defines the default background color
  117455. */
  117456. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117457. /**
  117458. * Function called to display the loading screen
  117459. */
  117460. displayLoadingUI(): void;
  117461. /**
  117462. * Function called to hide the loading screen
  117463. */
  117464. hideLoadingUI(): void;
  117465. /**
  117466. * Gets or sets the text to display while loading
  117467. */
  117468. set loadingUIText(text: string);
  117469. get loadingUIText(): string;
  117470. /**
  117471. * Gets or sets the color to use for the background
  117472. */
  117473. get loadingUIBackgroundColor(): string;
  117474. set loadingUIBackgroundColor(color: string);
  117475. private _resizeLoadingUI;
  117476. }
  117477. }
  117478. declare module BABYLON {
  117479. /**
  117480. * Interface for any object that can request an animation frame
  117481. */
  117482. export interface ICustomAnimationFrameRequester {
  117483. /**
  117484. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117485. */
  117486. renderFunction?: Function;
  117487. /**
  117488. * Called to request the next frame to render to
  117489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117490. */
  117491. requestAnimationFrame: Function;
  117492. /**
  117493. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117494. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117495. */
  117496. requestID?: number;
  117497. }
  117498. }
  117499. declare module BABYLON {
  117500. /**
  117501. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117502. */
  117503. export class PerformanceMonitor {
  117504. private _enabled;
  117505. private _rollingFrameTime;
  117506. private _lastFrameTimeMs;
  117507. /**
  117508. * constructor
  117509. * @param frameSampleSize The number of samples required to saturate the sliding window
  117510. */
  117511. constructor(frameSampleSize?: number);
  117512. /**
  117513. * Samples current frame
  117514. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117515. */
  117516. sampleFrame(timeMs?: number): void;
  117517. /**
  117518. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117519. */
  117520. get averageFrameTime(): number;
  117521. /**
  117522. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117523. */
  117524. get averageFrameTimeVariance(): number;
  117525. /**
  117526. * Returns the frame time of the most recent frame
  117527. */
  117528. get instantaneousFrameTime(): number;
  117529. /**
  117530. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117531. */
  117532. get averageFPS(): number;
  117533. /**
  117534. * Returns the average framerate in frames per second using the most recent frame time
  117535. */
  117536. get instantaneousFPS(): number;
  117537. /**
  117538. * Returns true if enough samples have been taken to completely fill the sliding window
  117539. */
  117540. get isSaturated(): boolean;
  117541. /**
  117542. * Enables contributions to the sliding window sample set
  117543. */
  117544. enable(): void;
  117545. /**
  117546. * Disables contributions to the sliding window sample set
  117547. * Samples will not be interpolated over the disabled period
  117548. */
  117549. disable(): void;
  117550. /**
  117551. * Returns true if sampling is enabled
  117552. */
  117553. get isEnabled(): boolean;
  117554. /**
  117555. * Resets performance monitor
  117556. */
  117557. reset(): void;
  117558. }
  117559. /**
  117560. * RollingAverage
  117561. *
  117562. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117563. */
  117564. export class RollingAverage {
  117565. /**
  117566. * Current average
  117567. */
  117568. average: number;
  117569. /**
  117570. * Current variance
  117571. */
  117572. variance: number;
  117573. protected _samples: Array<number>;
  117574. protected _sampleCount: number;
  117575. protected _pos: number;
  117576. protected _m2: number;
  117577. /**
  117578. * constructor
  117579. * @param length The number of samples required to saturate the sliding window
  117580. */
  117581. constructor(length: number);
  117582. /**
  117583. * Adds a sample to the sample set
  117584. * @param v The sample value
  117585. */
  117586. add(v: number): void;
  117587. /**
  117588. * Returns previously added values or null if outside of history or outside the sliding window domain
  117589. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117590. * @return Value previously recorded with add() or null if outside of range
  117591. */
  117592. history(i: number): number;
  117593. /**
  117594. * Returns true if enough samples have been taken to completely fill the sliding window
  117595. * @return true if sample-set saturated
  117596. */
  117597. isSaturated(): boolean;
  117598. /**
  117599. * Resets the rolling average (equivalent to 0 samples taken so far)
  117600. */
  117601. reset(): void;
  117602. /**
  117603. * Wraps a value around the sample range boundaries
  117604. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117605. * @return Wrapped position in sample range
  117606. */
  117607. protected _wrapPosition(i: number): number;
  117608. }
  117609. }
  117610. declare module BABYLON {
  117611. /**
  117612. * This class is used to track a performance counter which is number based.
  117613. * The user has access to many properties which give statistics of different nature.
  117614. *
  117615. * The implementer can track two kinds of Performance Counter: time and count.
  117616. * 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.
  117617. * 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.
  117618. */
  117619. export class PerfCounter {
  117620. /**
  117621. * Gets or sets a global boolean to turn on and off all the counters
  117622. */
  117623. static Enabled: boolean;
  117624. /**
  117625. * Returns the smallest value ever
  117626. */
  117627. get min(): number;
  117628. /**
  117629. * Returns the biggest value ever
  117630. */
  117631. get max(): number;
  117632. /**
  117633. * Returns the average value since the performance counter is running
  117634. */
  117635. get average(): number;
  117636. /**
  117637. * Returns the average value of the last second the counter was monitored
  117638. */
  117639. get lastSecAverage(): number;
  117640. /**
  117641. * Returns the current value
  117642. */
  117643. get current(): number;
  117644. /**
  117645. * Gets the accumulated total
  117646. */
  117647. get total(): number;
  117648. /**
  117649. * Gets the total value count
  117650. */
  117651. get count(): number;
  117652. /**
  117653. * Creates a new counter
  117654. */
  117655. constructor();
  117656. /**
  117657. * Call this method to start monitoring a new frame.
  117658. * 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.
  117659. */
  117660. fetchNewFrame(): void;
  117661. /**
  117662. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117663. * @param newCount the count value to add to the monitored count
  117664. * @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.
  117665. */
  117666. addCount(newCount: number, fetchResult: boolean): void;
  117667. /**
  117668. * Start monitoring this performance counter
  117669. */
  117670. beginMonitoring(): void;
  117671. /**
  117672. * Compute the time lapsed since the previous beginMonitoring() call.
  117673. * @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
  117674. */
  117675. endMonitoring(newFrame?: boolean): void;
  117676. private _fetchResult;
  117677. private _startMonitoringTime;
  117678. private _min;
  117679. private _max;
  117680. private _average;
  117681. private _current;
  117682. private _totalValueCount;
  117683. private _totalAccumulated;
  117684. private _lastSecAverage;
  117685. private _lastSecAccumulated;
  117686. private _lastSecTime;
  117687. private _lastSecValueCount;
  117688. }
  117689. }
  117690. declare module BABYLON {
  117691. interface ThinEngine {
  117692. /** @hidden */
  117693. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117694. }
  117695. }
  117696. declare module BABYLON {
  117697. /**
  117698. * Defines the interface used by display changed events
  117699. */
  117700. export interface IDisplayChangedEventArgs {
  117701. /** Gets the vrDisplay object (if any) */
  117702. vrDisplay: Nullable<any>;
  117703. /** Gets a boolean indicating if webVR is supported */
  117704. vrSupported: boolean;
  117705. }
  117706. /**
  117707. * Defines the interface used by objects containing a viewport (like a camera)
  117708. */
  117709. interface IViewportOwnerLike {
  117710. /**
  117711. * Gets or sets the viewport
  117712. */
  117713. viewport: IViewportLike;
  117714. }
  117715. /**
  117716. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117717. */
  117718. export class Engine extends ThinEngine {
  117719. /** Defines that alpha blending is disabled */
  117720. static readonly ALPHA_DISABLE: number;
  117721. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117722. static readonly ALPHA_ADD: number;
  117723. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117724. static readonly ALPHA_COMBINE: number;
  117725. /** Defines that alpha blending to DEST - SRC * DEST */
  117726. static readonly ALPHA_SUBTRACT: number;
  117727. /** Defines that alpha blending to SRC * DEST */
  117728. static readonly ALPHA_MULTIPLY: number;
  117729. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117730. static readonly ALPHA_MAXIMIZED: number;
  117731. /** Defines that alpha blending to SRC + DEST */
  117732. static readonly ALPHA_ONEONE: number;
  117733. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117734. static readonly ALPHA_PREMULTIPLIED: number;
  117735. /**
  117736. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117737. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117738. */
  117739. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117740. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117741. static readonly ALPHA_INTERPOLATE: number;
  117742. /**
  117743. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117744. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117745. */
  117746. static readonly ALPHA_SCREENMODE: number;
  117747. /** Defines that the ressource is not delayed*/
  117748. static readonly DELAYLOADSTATE_NONE: number;
  117749. /** Defines that the ressource was successfully delay loaded */
  117750. static readonly DELAYLOADSTATE_LOADED: number;
  117751. /** Defines that the ressource is currently delay loading */
  117752. static readonly DELAYLOADSTATE_LOADING: number;
  117753. /** Defines that the ressource is delayed and has not started loading */
  117754. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117755. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117756. static readonly NEVER: number;
  117757. /** 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 */
  117758. static readonly ALWAYS: number;
  117759. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117760. static readonly LESS: number;
  117761. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117762. static readonly EQUAL: number;
  117763. /** 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 */
  117764. static readonly LEQUAL: number;
  117765. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117766. static readonly GREATER: number;
  117767. /** 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 */
  117768. static readonly GEQUAL: number;
  117769. /** 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 */
  117770. static readonly NOTEQUAL: number;
  117771. /** Passed to stencilOperation to specify that stencil value must be kept */
  117772. static readonly KEEP: number;
  117773. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117774. static readonly REPLACE: number;
  117775. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117776. static readonly INCR: number;
  117777. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117778. static readonly DECR: number;
  117779. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117780. static readonly INVERT: number;
  117781. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117782. static readonly INCR_WRAP: number;
  117783. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117784. static readonly DECR_WRAP: number;
  117785. /** Texture is not repeating outside of 0..1 UVs */
  117786. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117787. /** Texture is repeating outside of 0..1 UVs */
  117788. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117789. /** Texture is repeating and mirrored */
  117790. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117791. /** ALPHA */
  117792. static readonly TEXTUREFORMAT_ALPHA: number;
  117793. /** LUMINANCE */
  117794. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117795. /** LUMINANCE_ALPHA */
  117796. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117797. /** RGB */
  117798. static readonly TEXTUREFORMAT_RGB: number;
  117799. /** RGBA */
  117800. static readonly TEXTUREFORMAT_RGBA: number;
  117801. /** RED */
  117802. static readonly TEXTUREFORMAT_RED: number;
  117803. /** RED (2nd reference) */
  117804. static readonly TEXTUREFORMAT_R: number;
  117805. /** RG */
  117806. static readonly TEXTUREFORMAT_RG: number;
  117807. /** RED_INTEGER */
  117808. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117809. /** RED_INTEGER (2nd reference) */
  117810. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117811. /** RG_INTEGER */
  117812. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117813. /** RGB_INTEGER */
  117814. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117815. /** RGBA_INTEGER */
  117816. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117817. /** UNSIGNED_BYTE */
  117818. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117819. /** UNSIGNED_BYTE (2nd reference) */
  117820. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117821. /** FLOAT */
  117822. static readonly TEXTURETYPE_FLOAT: number;
  117823. /** HALF_FLOAT */
  117824. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117825. /** BYTE */
  117826. static readonly TEXTURETYPE_BYTE: number;
  117827. /** SHORT */
  117828. static readonly TEXTURETYPE_SHORT: number;
  117829. /** UNSIGNED_SHORT */
  117830. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117831. /** INT */
  117832. static readonly TEXTURETYPE_INT: number;
  117833. /** UNSIGNED_INT */
  117834. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117835. /** UNSIGNED_SHORT_4_4_4_4 */
  117836. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117837. /** UNSIGNED_SHORT_5_5_5_1 */
  117838. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117839. /** UNSIGNED_SHORT_5_6_5 */
  117840. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117841. /** UNSIGNED_INT_2_10_10_10_REV */
  117842. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117843. /** UNSIGNED_INT_24_8 */
  117844. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117845. /** UNSIGNED_INT_10F_11F_11F_REV */
  117846. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117847. /** UNSIGNED_INT_5_9_9_9_REV */
  117848. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117849. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117850. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117851. /** nearest is mag = nearest and min = nearest and mip = linear */
  117852. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117853. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117854. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117855. /** Trilinear is mag = linear and min = linear and mip = linear */
  117856. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117857. /** nearest is mag = nearest and min = nearest and mip = linear */
  117858. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117860. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117861. /** Trilinear is mag = linear and min = linear and mip = linear */
  117862. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117863. /** mag = nearest and min = nearest and mip = nearest */
  117864. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117865. /** mag = nearest and min = linear and mip = nearest */
  117866. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117867. /** mag = nearest and min = linear and mip = linear */
  117868. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117869. /** mag = nearest and min = linear and mip = none */
  117870. static readonly TEXTURE_NEAREST_LINEAR: number;
  117871. /** mag = nearest and min = nearest and mip = none */
  117872. static readonly TEXTURE_NEAREST_NEAREST: number;
  117873. /** mag = linear and min = nearest and mip = nearest */
  117874. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117875. /** mag = linear and min = nearest and mip = linear */
  117876. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117877. /** mag = linear and min = linear and mip = none */
  117878. static readonly TEXTURE_LINEAR_LINEAR: number;
  117879. /** mag = linear and min = nearest and mip = none */
  117880. static readonly TEXTURE_LINEAR_NEAREST: number;
  117881. /** Explicit coordinates mode */
  117882. static readonly TEXTURE_EXPLICIT_MODE: number;
  117883. /** Spherical coordinates mode */
  117884. static readonly TEXTURE_SPHERICAL_MODE: number;
  117885. /** Planar coordinates mode */
  117886. static readonly TEXTURE_PLANAR_MODE: number;
  117887. /** Cubic coordinates mode */
  117888. static readonly TEXTURE_CUBIC_MODE: number;
  117889. /** Projection coordinates mode */
  117890. static readonly TEXTURE_PROJECTION_MODE: number;
  117891. /** Skybox coordinates mode */
  117892. static readonly TEXTURE_SKYBOX_MODE: number;
  117893. /** Inverse Cubic coordinates mode */
  117894. static readonly TEXTURE_INVCUBIC_MODE: number;
  117895. /** Equirectangular coordinates mode */
  117896. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117897. /** Equirectangular Fixed coordinates mode */
  117898. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117899. /** Equirectangular Fixed Mirrored coordinates mode */
  117900. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117901. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117902. static readonly SCALEMODE_FLOOR: number;
  117903. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117904. static readonly SCALEMODE_NEAREST: number;
  117905. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117906. static readonly SCALEMODE_CEILING: number;
  117907. /**
  117908. * Returns the current npm package of the sdk
  117909. */
  117910. static get NpmPackage(): string;
  117911. /**
  117912. * Returns the current version of the framework
  117913. */
  117914. static get Version(): string;
  117915. /** Gets the list of created engines */
  117916. static get Instances(): Engine[];
  117917. /**
  117918. * Gets the latest created engine
  117919. */
  117920. static get LastCreatedEngine(): Nullable<Engine>;
  117921. /**
  117922. * Gets the latest created scene
  117923. */
  117924. static get LastCreatedScene(): Nullable<Scene>;
  117925. /**
  117926. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117927. * @param flag defines which part of the materials must be marked as dirty
  117928. * @param predicate defines a predicate used to filter which materials should be affected
  117929. */
  117930. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117931. /**
  117932. * Method called to create the default loading screen.
  117933. * This can be overriden in your own app.
  117934. * @param canvas The rendering canvas element
  117935. * @returns The loading screen
  117936. */
  117937. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117938. /**
  117939. * Method called to create the default rescale post process on each engine.
  117940. */
  117941. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117942. /**
  117943. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117944. **/
  117945. enableOfflineSupport: boolean;
  117946. /**
  117947. * 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)
  117948. **/
  117949. disableManifestCheck: boolean;
  117950. /**
  117951. * Gets the list of created scenes
  117952. */
  117953. scenes: Scene[];
  117954. /**
  117955. * Event raised when a new scene is created
  117956. */
  117957. onNewSceneAddedObservable: Observable<Scene>;
  117958. /**
  117959. * Gets the list of created postprocesses
  117960. */
  117961. postProcesses: PostProcess[];
  117962. /**
  117963. * Gets a boolean indicating if the pointer is currently locked
  117964. */
  117965. isPointerLock: boolean;
  117966. /**
  117967. * Observable event triggered each time the rendering canvas is resized
  117968. */
  117969. onResizeObservable: Observable<Engine>;
  117970. /**
  117971. * Observable event triggered each time the canvas loses focus
  117972. */
  117973. onCanvasBlurObservable: Observable<Engine>;
  117974. /**
  117975. * Observable event triggered each time the canvas gains focus
  117976. */
  117977. onCanvasFocusObservable: Observable<Engine>;
  117978. /**
  117979. * Observable event triggered each time the canvas receives pointerout event
  117980. */
  117981. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117982. /**
  117983. * Observable raised when the engine begins a new frame
  117984. */
  117985. onBeginFrameObservable: Observable<Engine>;
  117986. /**
  117987. * If set, will be used to request the next animation frame for the render loop
  117988. */
  117989. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117990. /**
  117991. * Observable raised when the engine ends the current frame
  117992. */
  117993. onEndFrameObservable: Observable<Engine>;
  117994. /**
  117995. * Observable raised when the engine is about to compile a shader
  117996. */
  117997. onBeforeShaderCompilationObservable: Observable<Engine>;
  117998. /**
  117999. * Observable raised when the engine has jsut compiled a shader
  118000. */
  118001. onAfterShaderCompilationObservable: Observable<Engine>;
  118002. /**
  118003. * Gets the audio engine
  118004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118005. * @ignorenaming
  118006. */
  118007. static audioEngine: IAudioEngine;
  118008. /**
  118009. * Default AudioEngine factory responsible of creating the Audio Engine.
  118010. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118011. */
  118012. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118013. /**
  118014. * Default offline support factory responsible of creating a tool used to store data locally.
  118015. * By default, this will create a Database object if the workload has been embedded.
  118016. */
  118017. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118018. private _loadingScreen;
  118019. private _pointerLockRequested;
  118020. private _rescalePostProcess;
  118021. private _deterministicLockstep;
  118022. private _lockstepMaxSteps;
  118023. private _timeStep;
  118024. protected get _supportsHardwareTextureRescaling(): boolean;
  118025. private _fps;
  118026. private _deltaTime;
  118027. /** @hidden */
  118028. _drawCalls: PerfCounter;
  118029. /** 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 */
  118030. canvasTabIndex: number;
  118031. /**
  118032. * Turn this value on if you want to pause FPS computation when in background
  118033. */
  118034. disablePerformanceMonitorInBackground: boolean;
  118035. private _performanceMonitor;
  118036. /**
  118037. * Gets the performance monitor attached to this engine
  118038. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118039. */
  118040. get performanceMonitor(): PerformanceMonitor;
  118041. private _onFocus;
  118042. private _onBlur;
  118043. private _onCanvasPointerOut;
  118044. private _onCanvasBlur;
  118045. private _onCanvasFocus;
  118046. private _onFullscreenChange;
  118047. private _onPointerLockChange;
  118048. /**
  118049. * Gets the HTML element used to attach event listeners
  118050. * @returns a HTML element
  118051. */
  118052. getInputElement(): Nullable<HTMLElement>;
  118053. /**
  118054. * Creates a new engine
  118055. * @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
  118056. * @param antialias defines enable antialiasing (default: false)
  118057. * @param options defines further options to be sent to the getContext() function
  118058. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118059. */
  118060. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118061. /**
  118062. * Gets current aspect ratio
  118063. * @param viewportOwner defines the camera to use to get the aspect ratio
  118064. * @param useScreen defines if screen size must be used (or the current render target if any)
  118065. * @returns a number defining the aspect ratio
  118066. */
  118067. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118068. /**
  118069. * Gets current screen aspect ratio
  118070. * @returns a number defining the aspect ratio
  118071. */
  118072. getScreenAspectRatio(): number;
  118073. /**
  118074. * Gets the client rect of the HTML canvas attached with the current webGL context
  118075. * @returns a client rectanglee
  118076. */
  118077. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118078. /**
  118079. * Gets the client rect of the HTML element used for events
  118080. * @returns a client rectanglee
  118081. */
  118082. getInputElementClientRect(): Nullable<ClientRect>;
  118083. /**
  118084. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118085. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118086. * @returns true if engine is in deterministic lock step mode
  118087. */
  118088. isDeterministicLockStep(): boolean;
  118089. /**
  118090. * Gets the max steps when engine is running in deterministic lock step
  118091. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118092. * @returns the max steps
  118093. */
  118094. getLockstepMaxSteps(): number;
  118095. /**
  118096. * Returns the time in ms between steps when using deterministic lock step.
  118097. * @returns time step in (ms)
  118098. */
  118099. getTimeStep(): number;
  118100. /**
  118101. * Force the mipmap generation for the given render target texture
  118102. * @param texture defines the render target texture to use
  118103. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118104. */
  118105. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118106. /** States */
  118107. /**
  118108. * Set various states to the webGL context
  118109. * @param culling defines backface culling state
  118110. * @param zOffset defines the value to apply to zOffset (0 by default)
  118111. * @param force defines if states must be applied even if cache is up to date
  118112. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118113. */
  118114. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118115. /**
  118116. * Set the z offset to apply to current rendering
  118117. * @param value defines the offset to apply
  118118. */
  118119. setZOffset(value: number): void;
  118120. /**
  118121. * Gets the current value of the zOffset
  118122. * @returns the current zOffset state
  118123. */
  118124. getZOffset(): number;
  118125. /**
  118126. * Enable or disable depth buffering
  118127. * @param enable defines the state to set
  118128. */
  118129. setDepthBuffer(enable: boolean): void;
  118130. /**
  118131. * Gets a boolean indicating if depth writing is enabled
  118132. * @returns the current depth writing state
  118133. */
  118134. getDepthWrite(): boolean;
  118135. /**
  118136. * Enable or disable depth writing
  118137. * @param enable defines the state to set
  118138. */
  118139. setDepthWrite(enable: boolean): void;
  118140. /**
  118141. * Gets a boolean indicating if stencil buffer is enabled
  118142. * @returns the current stencil buffer state
  118143. */
  118144. getStencilBuffer(): boolean;
  118145. /**
  118146. * Enable or disable the stencil buffer
  118147. * @param enable defines if the stencil buffer must be enabled or disabled
  118148. */
  118149. setStencilBuffer(enable: boolean): void;
  118150. /**
  118151. * Gets the current stencil mask
  118152. * @returns a number defining the new stencil mask to use
  118153. */
  118154. getStencilMask(): number;
  118155. /**
  118156. * Sets the current stencil mask
  118157. * @param mask defines the new stencil mask to use
  118158. */
  118159. setStencilMask(mask: number): void;
  118160. /**
  118161. * Gets the current stencil function
  118162. * @returns a number defining the stencil function to use
  118163. */
  118164. getStencilFunction(): number;
  118165. /**
  118166. * Gets the current stencil reference value
  118167. * @returns a number defining the stencil reference value to use
  118168. */
  118169. getStencilFunctionReference(): number;
  118170. /**
  118171. * Gets the current stencil mask
  118172. * @returns a number defining the stencil mask to use
  118173. */
  118174. getStencilFunctionMask(): number;
  118175. /**
  118176. * Sets the current stencil function
  118177. * @param stencilFunc defines the new stencil function to use
  118178. */
  118179. setStencilFunction(stencilFunc: number): void;
  118180. /**
  118181. * Sets the current stencil reference
  118182. * @param reference defines the new stencil reference to use
  118183. */
  118184. setStencilFunctionReference(reference: number): void;
  118185. /**
  118186. * Sets the current stencil mask
  118187. * @param mask defines the new stencil mask to use
  118188. */
  118189. setStencilFunctionMask(mask: number): void;
  118190. /**
  118191. * Gets the current stencil operation when stencil fails
  118192. * @returns a number defining stencil operation to use when stencil fails
  118193. */
  118194. getStencilOperationFail(): number;
  118195. /**
  118196. * Gets the current stencil operation when depth fails
  118197. * @returns a number defining stencil operation to use when depth fails
  118198. */
  118199. getStencilOperationDepthFail(): number;
  118200. /**
  118201. * Gets the current stencil operation when stencil passes
  118202. * @returns a number defining stencil operation to use when stencil passes
  118203. */
  118204. getStencilOperationPass(): number;
  118205. /**
  118206. * Sets the stencil operation to use when stencil fails
  118207. * @param operation defines the stencil operation to use when stencil fails
  118208. */
  118209. setStencilOperationFail(operation: number): void;
  118210. /**
  118211. * Sets the stencil operation to use when depth fails
  118212. * @param operation defines the stencil operation to use when depth fails
  118213. */
  118214. setStencilOperationDepthFail(operation: number): void;
  118215. /**
  118216. * Sets the stencil operation to use when stencil passes
  118217. * @param operation defines the stencil operation to use when stencil passes
  118218. */
  118219. setStencilOperationPass(operation: number): void;
  118220. /**
  118221. * Sets a boolean indicating if the dithering state is enabled or disabled
  118222. * @param value defines the dithering state
  118223. */
  118224. setDitheringState(value: boolean): void;
  118225. /**
  118226. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118227. * @param value defines the rasterizer state
  118228. */
  118229. setRasterizerState(value: boolean): void;
  118230. /**
  118231. * Gets the current depth function
  118232. * @returns a number defining the depth function
  118233. */
  118234. getDepthFunction(): Nullable<number>;
  118235. /**
  118236. * Sets the current depth function
  118237. * @param depthFunc defines the function to use
  118238. */
  118239. setDepthFunction(depthFunc: number): void;
  118240. /**
  118241. * Sets the current depth function to GREATER
  118242. */
  118243. setDepthFunctionToGreater(): void;
  118244. /**
  118245. * Sets the current depth function to GEQUAL
  118246. */
  118247. setDepthFunctionToGreaterOrEqual(): void;
  118248. /**
  118249. * Sets the current depth function to LESS
  118250. */
  118251. setDepthFunctionToLess(): void;
  118252. /**
  118253. * Sets the current depth function to LEQUAL
  118254. */
  118255. setDepthFunctionToLessOrEqual(): void;
  118256. private _cachedStencilBuffer;
  118257. private _cachedStencilFunction;
  118258. private _cachedStencilMask;
  118259. private _cachedStencilOperationPass;
  118260. private _cachedStencilOperationFail;
  118261. private _cachedStencilOperationDepthFail;
  118262. private _cachedStencilReference;
  118263. /**
  118264. * Caches the the state of the stencil buffer
  118265. */
  118266. cacheStencilState(): void;
  118267. /**
  118268. * Restores the state of the stencil buffer
  118269. */
  118270. restoreStencilState(): void;
  118271. /**
  118272. * Directly set the WebGL Viewport
  118273. * @param x defines the x coordinate of the viewport (in screen space)
  118274. * @param y defines the y coordinate of the viewport (in screen space)
  118275. * @param width defines the width of the viewport (in screen space)
  118276. * @param height defines the height of the viewport (in screen space)
  118277. * @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
  118278. */
  118279. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118280. /**
  118281. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118282. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118283. * @param y defines the y-coordinate of the corner of the clear rectangle
  118284. * @param width defines the width of the clear rectangle
  118285. * @param height defines the height of the clear rectangle
  118286. * @param clearColor defines the clear color
  118287. */
  118288. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118289. /**
  118290. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118291. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118292. * @param y defines the y-coordinate of the corner of the clear rectangle
  118293. * @param width defines the width of the clear rectangle
  118294. * @param height defines the height of the clear rectangle
  118295. */
  118296. enableScissor(x: number, y: number, width: number, height: number): void;
  118297. /**
  118298. * Disable previously set scissor test rectangle
  118299. */
  118300. disableScissor(): void;
  118301. protected _reportDrawCall(): void;
  118302. /**
  118303. * Initializes a webVR display and starts listening to display change events
  118304. * The onVRDisplayChangedObservable will be notified upon these changes
  118305. * @returns The onVRDisplayChangedObservable
  118306. */
  118307. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118308. /** @hidden */
  118309. _prepareVRComponent(): void;
  118310. /** @hidden */
  118311. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118312. /** @hidden */
  118313. _submitVRFrame(): void;
  118314. /**
  118315. * Call this function to leave webVR mode
  118316. * Will do nothing if webVR is not supported or if there is no webVR device
  118317. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118318. */
  118319. disableVR(): void;
  118320. /**
  118321. * Gets a boolean indicating that the system is in VR mode and is presenting
  118322. * @returns true if VR mode is engaged
  118323. */
  118324. isVRPresenting(): boolean;
  118325. /** @hidden */
  118326. _requestVRFrame(): void;
  118327. /** @hidden */
  118328. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118329. /**
  118330. * Gets the source code of the vertex shader associated with a specific webGL program
  118331. * @param program defines the program to use
  118332. * @returns a string containing the source code of the vertex shader associated with the program
  118333. */
  118334. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118335. /**
  118336. * Gets the source code of the fragment shader associated with a specific webGL program
  118337. * @param program defines the program to use
  118338. * @returns a string containing the source code of the fragment shader associated with the program
  118339. */
  118340. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118341. /**
  118342. * Sets a depth stencil texture from a render target to the according uniform.
  118343. * @param channel The texture channel
  118344. * @param uniform The uniform to set
  118345. * @param texture The render target texture containing the depth stencil texture to apply
  118346. */
  118347. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118348. /**
  118349. * Sets a texture to the webGL context from a postprocess
  118350. * @param channel defines the channel to use
  118351. * @param postProcess defines the source postprocess
  118352. */
  118353. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118354. /**
  118355. * Binds the output of the passed in post process to the texture channel specified
  118356. * @param channel The channel the texture should be bound to
  118357. * @param postProcess The post process which's output should be bound
  118358. */
  118359. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118360. protected _rebuildBuffers(): void;
  118361. /** @hidden */
  118362. _renderFrame(): void;
  118363. _renderLoop(): void;
  118364. /** @hidden */
  118365. _renderViews(): boolean;
  118366. /**
  118367. * Toggle full screen mode
  118368. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118369. */
  118370. switchFullscreen(requestPointerLock: boolean): void;
  118371. /**
  118372. * Enters full screen mode
  118373. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118374. */
  118375. enterFullscreen(requestPointerLock: boolean): void;
  118376. /**
  118377. * Exits full screen mode
  118378. */
  118379. exitFullscreen(): void;
  118380. /**
  118381. * Enters Pointerlock mode
  118382. */
  118383. enterPointerlock(): void;
  118384. /**
  118385. * Exits Pointerlock mode
  118386. */
  118387. exitPointerlock(): void;
  118388. /**
  118389. * Begin a new frame
  118390. */
  118391. beginFrame(): void;
  118392. /**
  118393. * Enf the current frame
  118394. */
  118395. endFrame(): void;
  118396. resize(): void;
  118397. /**
  118398. * Force a specific size of the canvas
  118399. * @param width defines the new canvas' width
  118400. * @param height defines the new canvas' height
  118401. * @returns true if the size was changed
  118402. */
  118403. setSize(width: number, height: number): boolean;
  118404. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118406. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118407. _releaseTexture(texture: InternalTexture): void;
  118408. /**
  118409. * @hidden
  118410. * Rescales a texture
  118411. * @param source input texutre
  118412. * @param destination destination texture
  118413. * @param scene scene to use to render the resize
  118414. * @param internalFormat format to use when resizing
  118415. * @param onComplete callback to be called when resize has completed
  118416. */
  118417. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118418. /**
  118419. * Gets the current framerate
  118420. * @returns a number representing the framerate
  118421. */
  118422. getFps(): number;
  118423. /**
  118424. * Gets the time spent between current and previous frame
  118425. * @returns a number representing the delta time in ms
  118426. */
  118427. getDeltaTime(): number;
  118428. private _measureFps;
  118429. /** @hidden */
  118430. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118431. /**
  118432. * Updates the sample count of a render target texture
  118433. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118434. * @param texture defines the texture to update
  118435. * @param samples defines the sample count to set
  118436. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118437. */
  118438. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118439. /**
  118440. * Updates a depth texture Comparison Mode and Function.
  118441. * If the comparison Function is equal to 0, the mode will be set to none.
  118442. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118443. * @param texture The texture to set the comparison function for
  118444. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118445. */
  118446. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118447. /**
  118448. * Creates a webGL buffer to use with instanciation
  118449. * @param capacity defines the size of the buffer
  118450. * @returns the webGL buffer
  118451. */
  118452. createInstancesBuffer(capacity: number): DataBuffer;
  118453. /**
  118454. * Delete a webGL buffer used with instanciation
  118455. * @param buffer defines the webGL buffer to delete
  118456. */
  118457. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118458. private _clientWaitAsync;
  118459. /** @hidden */
  118460. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118461. dispose(): void;
  118462. private _disableTouchAction;
  118463. /**
  118464. * Display the loading screen
  118465. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118466. */
  118467. displayLoadingUI(): void;
  118468. /**
  118469. * Hide the loading screen
  118470. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118471. */
  118472. hideLoadingUI(): void;
  118473. /**
  118474. * Gets the current loading screen object
  118475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118476. */
  118477. get loadingScreen(): ILoadingScreen;
  118478. /**
  118479. * Sets the current loading screen object
  118480. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118481. */
  118482. set loadingScreen(loadingScreen: ILoadingScreen);
  118483. /**
  118484. * Sets the current loading screen text
  118485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118486. */
  118487. set loadingUIText(text: string);
  118488. /**
  118489. * Sets the current loading screen background color
  118490. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118491. */
  118492. set loadingUIBackgroundColor(color: string);
  118493. /** Pointerlock and fullscreen */
  118494. /**
  118495. * Ask the browser to promote the current element to pointerlock mode
  118496. * @param element defines the DOM element to promote
  118497. */
  118498. static _RequestPointerlock(element: HTMLElement): void;
  118499. /**
  118500. * Asks the browser to exit pointerlock mode
  118501. */
  118502. static _ExitPointerlock(): void;
  118503. /**
  118504. * Ask the browser to promote the current element to fullscreen rendering mode
  118505. * @param element defines the DOM element to promote
  118506. */
  118507. static _RequestFullscreen(element: HTMLElement): void;
  118508. /**
  118509. * Asks the browser to exit fullscreen mode
  118510. */
  118511. static _ExitFullscreen(): void;
  118512. }
  118513. }
  118514. declare module BABYLON {
  118515. /**
  118516. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118517. * during the life time of the application.
  118518. */
  118519. export class EngineStore {
  118520. /** Gets the list of created engines */
  118521. static Instances: Engine[];
  118522. /** @hidden */
  118523. static _LastCreatedScene: Nullable<Scene>;
  118524. /**
  118525. * Gets the latest created engine
  118526. */
  118527. static get LastCreatedEngine(): Nullable<Engine>;
  118528. /**
  118529. * Gets the latest created scene
  118530. */
  118531. static get LastCreatedScene(): Nullable<Scene>;
  118532. /**
  118533. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118534. * @ignorenaming
  118535. */
  118536. static UseFallbackTexture: boolean;
  118537. /**
  118538. * Texture content used if a texture cannot loaded
  118539. * @ignorenaming
  118540. */
  118541. static FallbackTexture: string;
  118542. }
  118543. }
  118544. declare module BABYLON {
  118545. /**
  118546. * Helper class that provides a small promise polyfill
  118547. */
  118548. export class PromisePolyfill {
  118549. /**
  118550. * Static function used to check if the polyfill is required
  118551. * If this is the case then the function will inject the polyfill to window.Promise
  118552. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118553. */
  118554. static Apply(force?: boolean): void;
  118555. }
  118556. }
  118557. declare module BABYLON {
  118558. /**
  118559. * Interface for screenshot methods with describe argument called `size` as object with options
  118560. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118561. */
  118562. export interface IScreenshotSize {
  118563. /**
  118564. * number in pixels for canvas height
  118565. */
  118566. height?: number;
  118567. /**
  118568. * multiplier allowing render at a higher or lower resolution
  118569. * If value is defined then height and width will be ignored and taken from camera
  118570. */
  118571. precision?: number;
  118572. /**
  118573. * number in pixels for canvas width
  118574. */
  118575. width?: number;
  118576. }
  118577. }
  118578. declare module BABYLON {
  118579. interface IColor4Like {
  118580. r: float;
  118581. g: float;
  118582. b: float;
  118583. a: float;
  118584. }
  118585. /**
  118586. * Class containing a set of static utilities functions
  118587. */
  118588. export class Tools {
  118589. /**
  118590. * Gets or sets the base URL to use to load assets
  118591. */
  118592. static get BaseUrl(): string;
  118593. static set BaseUrl(value: string);
  118594. /**
  118595. * Enable/Disable Custom HTTP Request Headers globally.
  118596. * default = false
  118597. * @see CustomRequestHeaders
  118598. */
  118599. static UseCustomRequestHeaders: boolean;
  118600. /**
  118601. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118602. * i.e. when loading files, where the server/service expects an Authorization header
  118603. */
  118604. static CustomRequestHeaders: {
  118605. [key: string]: string;
  118606. };
  118607. /**
  118608. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118609. */
  118610. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118611. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118612. /**
  118613. * Default behaviour for cors in the application.
  118614. * It can be a string if the expected behavior is identical in the entire app.
  118615. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118616. */
  118617. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118618. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118619. /**
  118620. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118621. * @ignorenaming
  118622. */
  118623. static get UseFallbackTexture(): boolean;
  118624. static set UseFallbackTexture(value: boolean);
  118625. /**
  118626. * Use this object to register external classes like custom textures or material
  118627. * to allow the laoders to instantiate them
  118628. */
  118629. static get RegisteredExternalClasses(): {
  118630. [key: string]: Object;
  118631. };
  118632. static set RegisteredExternalClasses(classes: {
  118633. [key: string]: Object;
  118634. });
  118635. /**
  118636. * Texture content used if a texture cannot loaded
  118637. * @ignorenaming
  118638. */
  118639. static get fallbackTexture(): string;
  118640. static set fallbackTexture(value: string);
  118641. /**
  118642. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118643. * @param u defines the coordinate on X axis
  118644. * @param v defines the coordinate on Y axis
  118645. * @param width defines the width of the source data
  118646. * @param height defines the height of the source data
  118647. * @param pixels defines the source byte array
  118648. * @param color defines the output color
  118649. */
  118650. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118651. /**
  118652. * Interpolates between a and b via alpha
  118653. * @param a The lower value (returned when alpha = 0)
  118654. * @param b The upper value (returned when alpha = 1)
  118655. * @param alpha The interpolation-factor
  118656. * @return The mixed value
  118657. */
  118658. static Mix(a: number, b: number, alpha: number): number;
  118659. /**
  118660. * Tries to instantiate a new object from a given class name
  118661. * @param className defines the class name to instantiate
  118662. * @returns the new object or null if the system was not able to do the instantiation
  118663. */
  118664. static Instantiate(className: string): any;
  118665. /**
  118666. * Provides a slice function that will work even on IE
  118667. * @param data defines the array to slice
  118668. * @param start defines the start of the data (optional)
  118669. * @param end defines the end of the data (optional)
  118670. * @returns the new sliced array
  118671. */
  118672. static Slice<T>(data: T, start?: number, end?: number): T;
  118673. /**
  118674. * Polyfill for setImmediate
  118675. * @param action defines the action to execute after the current execution block
  118676. */
  118677. static SetImmediate(action: () => void): void;
  118678. /**
  118679. * Function indicating if a number is an exponent of 2
  118680. * @param value defines the value to test
  118681. * @returns true if the value is an exponent of 2
  118682. */
  118683. static IsExponentOfTwo(value: number): boolean;
  118684. private static _tmpFloatArray;
  118685. /**
  118686. * Returns the nearest 32-bit single precision float representation of a Number
  118687. * @param value A Number. If the parameter is of a different type, it will get converted
  118688. * to a number or to NaN if it cannot be converted
  118689. * @returns number
  118690. */
  118691. static FloatRound(value: number): number;
  118692. /**
  118693. * Extracts the filename from a path
  118694. * @param path defines the path to use
  118695. * @returns the filename
  118696. */
  118697. static GetFilename(path: string): string;
  118698. /**
  118699. * Extracts the "folder" part of a path (everything before the filename).
  118700. * @param uri The URI to extract the info from
  118701. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118702. * @returns The "folder" part of the path
  118703. */
  118704. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118705. /**
  118706. * Extracts text content from a DOM element hierarchy
  118707. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118708. */
  118709. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118710. /**
  118711. * Convert an angle in radians to degrees
  118712. * @param angle defines the angle to convert
  118713. * @returns the angle in degrees
  118714. */
  118715. static ToDegrees(angle: number): number;
  118716. /**
  118717. * Convert an angle in degrees to radians
  118718. * @param angle defines the angle to convert
  118719. * @returns the angle in radians
  118720. */
  118721. static ToRadians(angle: number): number;
  118722. /**
  118723. * Returns an array if obj is not an array
  118724. * @param obj defines the object to evaluate as an array
  118725. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118726. * @returns either obj directly if obj is an array or a new array containing obj
  118727. */
  118728. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118729. /**
  118730. * Gets the pointer prefix to use
  118731. * @param engine defines the engine we are finding the prefix for
  118732. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118733. */
  118734. static GetPointerPrefix(engine: Engine): string;
  118735. /**
  118736. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118737. * @param url define the url we are trying
  118738. * @param element define the dom element where to configure the cors policy
  118739. */
  118740. static SetCorsBehavior(url: string | string[], element: {
  118741. crossOrigin: string | null;
  118742. }): void;
  118743. /**
  118744. * Removes unwanted characters from an url
  118745. * @param url defines the url to clean
  118746. * @returns the cleaned url
  118747. */
  118748. static CleanUrl(url: string): string;
  118749. /**
  118750. * Gets or sets a function used to pre-process url before using them to load assets
  118751. */
  118752. static get PreprocessUrl(): (url: string) => string;
  118753. static set PreprocessUrl(processor: (url: string) => string);
  118754. /**
  118755. * Loads an image as an HTMLImageElement.
  118756. * @param input url string, ArrayBuffer, or Blob to load
  118757. * @param onLoad callback called when the image successfully loads
  118758. * @param onError callback called when the image fails to load
  118759. * @param offlineProvider offline provider for caching
  118760. * @param mimeType optional mime type
  118761. * @returns the HTMLImageElement of the loaded image
  118762. */
  118763. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118764. /**
  118765. * Loads a file from a url
  118766. * @param url url string, ArrayBuffer, or Blob to load
  118767. * @param onSuccess callback called when the file successfully loads
  118768. * @param onProgress callback called while file is loading (if the server supports this mode)
  118769. * @param offlineProvider defines the offline provider for caching
  118770. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118771. * @param onError callback called when the file fails to load
  118772. * @returns a file request object
  118773. */
  118774. 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;
  118775. /**
  118776. * Loads a file from a url
  118777. * @param url the file url to load
  118778. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118779. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118780. */
  118781. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118782. /**
  118783. * Load a script (identified by an url). When the url returns, the
  118784. * content of this file is added into a new script element, attached to the DOM (body element)
  118785. * @param scriptUrl defines the url of the script to laod
  118786. * @param onSuccess defines the callback called when the script is loaded
  118787. * @param onError defines the callback to call if an error occurs
  118788. * @param scriptId defines the id of the script element
  118789. */
  118790. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118791. /**
  118792. * Load an asynchronous script (identified by an url). When the url returns, the
  118793. * content of this file is added into a new script element, attached to the DOM (body element)
  118794. * @param scriptUrl defines the url of the script to laod
  118795. * @param scriptId defines the id of the script element
  118796. * @returns a promise request object
  118797. */
  118798. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118799. /**
  118800. * Loads a file from a blob
  118801. * @param fileToLoad defines the blob to use
  118802. * @param callback defines the callback to call when data is loaded
  118803. * @param progressCallback defines the callback to call during loading process
  118804. * @returns a file request object
  118805. */
  118806. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118807. /**
  118808. * Reads a file from a File object
  118809. * @param file defines the file to load
  118810. * @param onSuccess defines the callback to call when data is loaded
  118811. * @param onProgress defines the callback to call during loading process
  118812. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118813. * @param onError defines the callback to call when an error occurs
  118814. * @returns a file request object
  118815. */
  118816. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118817. /**
  118818. * Creates a data url from a given string content
  118819. * @param content defines the content to convert
  118820. * @returns the new data url link
  118821. */
  118822. static FileAsURL(content: string): string;
  118823. /**
  118824. * Format the given number to a specific decimal format
  118825. * @param value defines the number to format
  118826. * @param decimals defines the number of decimals to use
  118827. * @returns the formatted string
  118828. */
  118829. static Format(value: number, decimals?: number): string;
  118830. /**
  118831. * Tries to copy an object by duplicating every property
  118832. * @param source defines the source object
  118833. * @param destination defines the target object
  118834. * @param doNotCopyList defines a list of properties to avoid
  118835. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118836. */
  118837. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118838. /**
  118839. * Gets a boolean indicating if the given object has no own property
  118840. * @param obj defines the object to test
  118841. * @returns true if object has no own property
  118842. */
  118843. static IsEmpty(obj: any): boolean;
  118844. /**
  118845. * Function used to register events at window level
  118846. * @param windowElement defines the Window object to use
  118847. * @param events defines the events to register
  118848. */
  118849. static RegisterTopRootEvents(windowElement: Window, events: {
  118850. name: string;
  118851. handler: Nullable<(e: FocusEvent) => any>;
  118852. }[]): void;
  118853. /**
  118854. * Function used to unregister events from window level
  118855. * @param windowElement defines the Window object to use
  118856. * @param events defines the events to unregister
  118857. */
  118858. static UnregisterTopRootEvents(windowElement: Window, events: {
  118859. name: string;
  118860. handler: Nullable<(e: FocusEvent) => any>;
  118861. }[]): void;
  118862. /**
  118863. * @ignore
  118864. */
  118865. static _ScreenshotCanvas: HTMLCanvasElement;
  118866. /**
  118867. * Dumps the current bound framebuffer
  118868. * @param width defines the rendering width
  118869. * @param height defines the rendering height
  118870. * @param engine defines the hosting engine
  118871. * @param successCallback defines the callback triggered once the data are available
  118872. * @param mimeType defines the mime type of the result
  118873. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118874. */
  118875. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118876. /**
  118877. * Converts the canvas data to blob.
  118878. * This acts as a polyfill for browsers not supporting the to blob function.
  118879. * @param canvas Defines the canvas to extract the data from
  118880. * @param successCallback Defines the callback triggered once the data are available
  118881. * @param mimeType Defines the mime type of the result
  118882. */
  118883. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118884. /**
  118885. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118886. * @param successCallback defines the callback triggered once the data are available
  118887. * @param mimeType defines the mime type of the result
  118888. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118889. */
  118890. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118891. /**
  118892. * Downloads a blob in the browser
  118893. * @param blob defines the blob to download
  118894. * @param fileName defines the name of the downloaded file
  118895. */
  118896. static Download(blob: Blob, fileName: string): void;
  118897. /**
  118898. * Captures a screenshot of the current rendering
  118899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118900. * @param engine defines the rendering engine
  118901. * @param camera defines the source camera
  118902. * @param size This parameter can be set to a single number or to an object with the
  118903. * following (optional) properties: precision, width, height. If a single number is passed,
  118904. * it will be used for both width and height. If an object is passed, the screenshot size
  118905. * will be derived from the parameters. The precision property is a multiplier allowing
  118906. * rendering at a higher or lower resolution
  118907. * @param successCallback defines the callback receives a single parameter which contains the
  118908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118909. * src parameter of an <img> to display it
  118910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118911. * Check your browser for supported MIME types
  118912. */
  118913. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118914. /**
  118915. * Captures a screenshot of the current rendering
  118916. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118917. * @param engine defines the rendering engine
  118918. * @param camera defines the source camera
  118919. * @param size This parameter can be set to a single number or to an object with the
  118920. * following (optional) properties: precision, width, height. If a single number is passed,
  118921. * it will be used for both width and height. If an object is passed, the screenshot size
  118922. * will be derived from the parameters. The precision property is a multiplier allowing
  118923. * rendering at a higher or lower resolution
  118924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118925. * Check your browser for supported MIME types
  118926. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118927. * to the src parameter of an <img> to display it
  118928. */
  118929. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118930. /**
  118931. * Generates an image screenshot from the specified camera.
  118932. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118933. * @param engine The engine to use for rendering
  118934. * @param camera The camera to use for rendering
  118935. * @param size This parameter can be set to a single number or to an object with the
  118936. * following (optional) properties: precision, width, height. If a single number is passed,
  118937. * it will be used for both width and height. If an object is passed, the screenshot size
  118938. * will be derived from the parameters. The precision property is a multiplier allowing
  118939. * rendering at a higher or lower resolution
  118940. * @param successCallback The callback receives a single parameter which contains the
  118941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118942. * src parameter of an <img> to display it
  118943. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118944. * Check your browser for supported MIME types
  118945. * @param samples Texture samples (default: 1)
  118946. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118947. * @param fileName A name for for the downloaded file.
  118948. */
  118949. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118950. /**
  118951. * Generates an image screenshot from the specified camera.
  118952. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118953. * @param engine The engine to use for rendering
  118954. * @param camera The camera to use for rendering
  118955. * @param size This parameter can be set to a single number or to an object with the
  118956. * following (optional) properties: precision, width, height. If a single number is passed,
  118957. * it will be used for both width and height. If an object is passed, the screenshot size
  118958. * will be derived from the parameters. The precision property is a multiplier allowing
  118959. * rendering at a higher or lower resolution
  118960. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118961. * Check your browser for supported MIME types
  118962. * @param samples Texture samples (default: 1)
  118963. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118964. * @param fileName A name for for the downloaded file.
  118965. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118966. * to the src parameter of an <img> to display it
  118967. */
  118968. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118969. /**
  118970. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118971. * Be aware Math.random() could cause collisions, but:
  118972. * "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"
  118973. * @returns a pseudo random id
  118974. */
  118975. static RandomId(): string;
  118976. /**
  118977. * Test if the given uri is a base64 string
  118978. * @param uri The uri to test
  118979. * @return True if the uri is a base64 string or false otherwise
  118980. */
  118981. static IsBase64(uri: string): boolean;
  118982. /**
  118983. * Decode the given base64 uri.
  118984. * @param uri The uri to decode
  118985. * @return The decoded base64 data.
  118986. */
  118987. static DecodeBase64(uri: string): ArrayBuffer;
  118988. /**
  118989. * Gets the absolute url.
  118990. * @param url the input url
  118991. * @return the absolute url
  118992. */
  118993. static GetAbsoluteUrl(url: string): string;
  118994. /**
  118995. * No log
  118996. */
  118997. static readonly NoneLogLevel: number;
  118998. /**
  118999. * Only message logs
  119000. */
  119001. static readonly MessageLogLevel: number;
  119002. /**
  119003. * Only warning logs
  119004. */
  119005. static readonly WarningLogLevel: number;
  119006. /**
  119007. * Only error logs
  119008. */
  119009. static readonly ErrorLogLevel: number;
  119010. /**
  119011. * All logs
  119012. */
  119013. static readonly AllLogLevel: number;
  119014. /**
  119015. * Gets a value indicating the number of loading errors
  119016. * @ignorenaming
  119017. */
  119018. static get errorsCount(): number;
  119019. /**
  119020. * Callback called when a new log is added
  119021. */
  119022. static OnNewCacheEntry: (entry: string) => void;
  119023. /**
  119024. * Log a message to the console
  119025. * @param message defines the message to log
  119026. */
  119027. static Log(message: string): void;
  119028. /**
  119029. * Write a warning message to the console
  119030. * @param message defines the message to log
  119031. */
  119032. static Warn(message: string): void;
  119033. /**
  119034. * Write an error message to the console
  119035. * @param message defines the message to log
  119036. */
  119037. static Error(message: string): void;
  119038. /**
  119039. * Gets current log cache (list of logs)
  119040. */
  119041. static get LogCache(): string;
  119042. /**
  119043. * Clears the log cache
  119044. */
  119045. static ClearLogCache(): void;
  119046. /**
  119047. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119048. */
  119049. static set LogLevels(level: number);
  119050. /**
  119051. * Checks if the window object exists
  119052. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119053. */
  119054. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119055. /**
  119056. * No performance log
  119057. */
  119058. static readonly PerformanceNoneLogLevel: number;
  119059. /**
  119060. * Use user marks to log performance
  119061. */
  119062. static readonly PerformanceUserMarkLogLevel: number;
  119063. /**
  119064. * Log performance to the console
  119065. */
  119066. static readonly PerformanceConsoleLogLevel: number;
  119067. private static _performance;
  119068. /**
  119069. * Sets the current performance log level
  119070. */
  119071. static set PerformanceLogLevel(level: number);
  119072. private static _StartPerformanceCounterDisabled;
  119073. private static _EndPerformanceCounterDisabled;
  119074. private static _StartUserMark;
  119075. private static _EndUserMark;
  119076. private static _StartPerformanceConsole;
  119077. private static _EndPerformanceConsole;
  119078. /**
  119079. * Starts a performance counter
  119080. */
  119081. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119082. /**
  119083. * Ends a specific performance coutner
  119084. */
  119085. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119086. /**
  119087. * Gets either window.performance.now() if supported or Date.now() else
  119088. */
  119089. static get Now(): number;
  119090. /**
  119091. * This method will return the name of the class used to create the instance of the given object.
  119092. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119093. * @param object the object to get the class name from
  119094. * @param isType defines if the object is actually a type
  119095. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119096. */
  119097. static GetClassName(object: any, isType?: boolean): string;
  119098. /**
  119099. * Gets the first element of an array satisfying a given predicate
  119100. * @param array defines the array to browse
  119101. * @param predicate defines the predicate to use
  119102. * @returns null if not found or the element
  119103. */
  119104. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119105. /**
  119106. * This method will return the name of the full name of the class, including its owning module (if any).
  119107. * 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).
  119108. * @param object the object to get the class name from
  119109. * @param isType defines if the object is actually a type
  119110. * @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.
  119111. * @ignorenaming
  119112. */
  119113. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119114. /**
  119115. * Returns a promise that resolves after the given amount of time.
  119116. * @param delay Number of milliseconds to delay
  119117. * @returns Promise that resolves after the given amount of time
  119118. */
  119119. static DelayAsync(delay: number): Promise<void>;
  119120. /**
  119121. * Utility function to detect if the current user agent is Safari
  119122. * @returns whether or not the current user agent is safari
  119123. */
  119124. static IsSafari(): boolean;
  119125. }
  119126. /**
  119127. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119128. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119129. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119130. * @param name The name of the class, case should be preserved
  119131. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119132. */
  119133. export function className(name: string, module?: string): (target: Object) => void;
  119134. /**
  119135. * An implementation of a loop for asynchronous functions.
  119136. */
  119137. export class AsyncLoop {
  119138. /**
  119139. * Defines the number of iterations for the loop
  119140. */
  119141. iterations: number;
  119142. /**
  119143. * Defines the current index of the loop.
  119144. */
  119145. index: number;
  119146. private _done;
  119147. private _fn;
  119148. private _successCallback;
  119149. /**
  119150. * Constructor.
  119151. * @param iterations the number of iterations.
  119152. * @param func the function to run each iteration
  119153. * @param successCallback the callback that will be called upon succesful execution
  119154. * @param offset starting offset.
  119155. */
  119156. constructor(
  119157. /**
  119158. * Defines the number of iterations for the loop
  119159. */
  119160. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119161. /**
  119162. * Execute the next iteration. Must be called after the last iteration was finished.
  119163. */
  119164. executeNext(): void;
  119165. /**
  119166. * Break the loop and run the success callback.
  119167. */
  119168. breakLoop(): void;
  119169. /**
  119170. * Create and run an async loop.
  119171. * @param iterations the number of iterations.
  119172. * @param fn the function to run each iteration
  119173. * @param successCallback the callback that will be called upon succesful execution
  119174. * @param offset starting offset.
  119175. * @returns the created async loop object
  119176. */
  119177. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119178. /**
  119179. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119180. * @param iterations total number of iterations
  119181. * @param syncedIterations number of synchronous iterations in each async iteration.
  119182. * @param fn the function to call each iteration.
  119183. * @param callback a success call back that will be called when iterating stops.
  119184. * @param breakFunction a break condition (optional)
  119185. * @param timeout timeout settings for the setTimeout function. default - 0.
  119186. * @returns the created async loop object
  119187. */
  119188. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119189. }
  119190. }
  119191. declare module BABYLON {
  119192. /**
  119193. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119194. * The underlying implementation relies on an associative array to ensure the best performances.
  119195. * The value can be anything including 'null' but except 'undefined'
  119196. */
  119197. export class StringDictionary<T> {
  119198. /**
  119199. * This will clear this dictionary and copy the content from the 'source' one.
  119200. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119201. * @param source the dictionary to take the content from and copy to this dictionary
  119202. */
  119203. copyFrom(source: StringDictionary<T>): void;
  119204. /**
  119205. * Get a value based from its key
  119206. * @param key the given key to get the matching value from
  119207. * @return the value if found, otherwise undefined is returned
  119208. */
  119209. get(key: string): T | undefined;
  119210. /**
  119211. * Get a value from its key or add it if it doesn't exist.
  119212. * This method will ensure you that a given key/data will be present in the dictionary.
  119213. * @param key the given key to get the matching value from
  119214. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119215. * The factory will only be invoked if there's no data for the given key.
  119216. * @return the value corresponding to the key.
  119217. */
  119218. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119219. /**
  119220. * Get a value from its key if present in the dictionary otherwise add it
  119221. * @param key the key to get the value from
  119222. * @param val if there's no such key/value pair in the dictionary add it with this value
  119223. * @return the value corresponding to the key
  119224. */
  119225. getOrAdd(key: string, val: T): T;
  119226. /**
  119227. * Check if there's a given key in the dictionary
  119228. * @param key the key to check for
  119229. * @return true if the key is present, false otherwise
  119230. */
  119231. contains(key: string): boolean;
  119232. /**
  119233. * Add a new key and its corresponding value
  119234. * @param key the key to add
  119235. * @param value the value corresponding to the key
  119236. * @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
  119237. */
  119238. add(key: string, value: T): boolean;
  119239. /**
  119240. * Update a specific value associated to a key
  119241. * @param key defines the key to use
  119242. * @param value defines the value to store
  119243. * @returns true if the value was updated (or false if the key was not found)
  119244. */
  119245. set(key: string, value: T): boolean;
  119246. /**
  119247. * Get the element of the given key and remove it from the dictionary
  119248. * @param key defines the key to search
  119249. * @returns the value associated with the key or null if not found
  119250. */
  119251. getAndRemove(key: string): Nullable<T>;
  119252. /**
  119253. * Remove a key/value from the dictionary.
  119254. * @param key the key to remove
  119255. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119256. */
  119257. remove(key: string): boolean;
  119258. /**
  119259. * Clear the whole content of the dictionary
  119260. */
  119261. clear(): void;
  119262. /**
  119263. * Gets the current count
  119264. */
  119265. get count(): number;
  119266. /**
  119267. * Execute a callback on each key/val of the dictionary.
  119268. * Note that you can remove any element in this dictionary in the callback implementation
  119269. * @param callback the callback to execute on a given key/value pair
  119270. */
  119271. forEach(callback: (key: string, val: T) => void): void;
  119272. /**
  119273. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119274. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119275. * Note that you can remove any element in this dictionary in the callback implementation
  119276. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119277. * @returns the first item
  119278. */
  119279. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119280. private _count;
  119281. private _data;
  119282. }
  119283. }
  119284. declare module BABYLON {
  119285. /** @hidden */
  119286. export interface ICollisionCoordinator {
  119287. createCollider(): Collider;
  119288. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119289. init(scene: Scene): void;
  119290. }
  119291. /** @hidden */
  119292. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119293. private _scene;
  119294. private _scaledPosition;
  119295. private _scaledVelocity;
  119296. private _finalPosition;
  119297. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119298. createCollider(): Collider;
  119299. init(scene: Scene): void;
  119300. private _collideWithWorld;
  119301. }
  119302. }
  119303. declare module BABYLON {
  119304. /**
  119305. * Class used to manage all inputs for the scene.
  119306. */
  119307. export class InputManager {
  119308. /** The distance in pixel that you have to move to prevent some events */
  119309. static DragMovementThreshold: number;
  119310. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119311. static LongPressDelay: number;
  119312. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119313. static DoubleClickDelay: number;
  119314. /** If you need to check double click without raising a single click at first click, enable this flag */
  119315. static ExclusiveDoubleClickMode: boolean;
  119316. /** 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. */
  119317. private _alreadyAttached;
  119318. private _wheelEventName;
  119319. private _onPointerMove;
  119320. private _onPointerDown;
  119321. private _onPointerUp;
  119322. private _initClickEvent;
  119323. private _initActionManager;
  119324. private _delayedSimpleClick;
  119325. private _delayedSimpleClickTimeout;
  119326. private _previousDelayedSimpleClickTimeout;
  119327. private _meshPickProceed;
  119328. private _previousButtonPressed;
  119329. private _currentPickResult;
  119330. private _previousPickResult;
  119331. private _totalPointersPressed;
  119332. private _doubleClickOccured;
  119333. private _pointerOverMesh;
  119334. private _pickedDownMesh;
  119335. private _pickedUpMesh;
  119336. private _pointerX;
  119337. private _pointerY;
  119338. private _unTranslatedPointerX;
  119339. private _unTranslatedPointerY;
  119340. private _startingPointerPosition;
  119341. private _previousStartingPointerPosition;
  119342. private _startingPointerTime;
  119343. private _previousStartingPointerTime;
  119344. private _pointerCaptures;
  119345. private _meshUnderPointerId;
  119346. private _onKeyDown;
  119347. private _onKeyUp;
  119348. private _onCanvasFocusObserver;
  119349. private _onCanvasBlurObserver;
  119350. private _scene;
  119351. /**
  119352. * Creates a new InputManager
  119353. * @param scene defines the hosting scene
  119354. */
  119355. constructor(scene: Scene);
  119356. /**
  119357. * Gets the mesh that is currently under the pointer
  119358. */
  119359. get meshUnderPointer(): Nullable<AbstractMesh>;
  119360. /**
  119361. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119362. * @param pointerId the pointer id to use
  119363. * @returns The mesh under this pointer id or null if not found
  119364. */
  119365. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119366. /**
  119367. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119368. */
  119369. get unTranslatedPointer(): Vector2;
  119370. /**
  119371. * Gets or sets the current on-screen X position of the pointer
  119372. */
  119373. get pointerX(): number;
  119374. set pointerX(value: number);
  119375. /**
  119376. * Gets or sets the current on-screen Y position of the pointer
  119377. */
  119378. get pointerY(): number;
  119379. set pointerY(value: number);
  119380. private _updatePointerPosition;
  119381. private _processPointerMove;
  119382. private _setRayOnPointerInfo;
  119383. private _checkPrePointerObservable;
  119384. /**
  119385. * Use this method to simulate a pointer move on a mesh
  119386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119389. */
  119390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119391. /**
  119392. * Use this method to simulate a pointer down on a mesh
  119393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119396. */
  119397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119398. private _processPointerDown;
  119399. /** @hidden */
  119400. _isPointerSwiping(): boolean;
  119401. /**
  119402. * Use this method to simulate a pointer up on a mesh
  119403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119407. */
  119408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119409. private _processPointerUp;
  119410. /**
  119411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119413. * @returns true if the pointer was captured
  119414. */
  119415. isPointerCaptured(pointerId?: number): boolean;
  119416. /**
  119417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119418. * @param attachUp defines if you want to attach events to pointerup
  119419. * @param attachDown defines if you want to attach events to pointerdown
  119420. * @param attachMove defines if you want to attach events to pointermove
  119421. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119422. */
  119423. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119424. /**
  119425. * Detaches all event handlers
  119426. */
  119427. detachControl(): void;
  119428. /**
  119429. * Force the value of meshUnderPointer
  119430. * @param mesh defines the mesh to use
  119431. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119432. */
  119433. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119434. /**
  119435. * Gets the mesh under the pointer
  119436. * @returns a Mesh or null if no mesh is under the pointer
  119437. */
  119438. getPointerOverMesh(): Nullable<AbstractMesh>;
  119439. }
  119440. }
  119441. declare module BABYLON {
  119442. /**
  119443. * This class defines the direct association between an animation and a target
  119444. */
  119445. export class TargetedAnimation {
  119446. /**
  119447. * Animation to perform
  119448. */
  119449. animation: Animation;
  119450. /**
  119451. * Target to animate
  119452. */
  119453. target: any;
  119454. /**
  119455. * Returns the string "TargetedAnimation"
  119456. * @returns "TargetedAnimation"
  119457. */
  119458. getClassName(): string;
  119459. /**
  119460. * Serialize the object
  119461. * @returns the JSON object representing the current entity
  119462. */
  119463. serialize(): any;
  119464. }
  119465. /**
  119466. * Use this class to create coordinated animations on multiple targets
  119467. */
  119468. export class AnimationGroup implements IDisposable {
  119469. /** The name of the animation group */
  119470. name: string;
  119471. private _scene;
  119472. private _targetedAnimations;
  119473. private _animatables;
  119474. private _from;
  119475. private _to;
  119476. private _isStarted;
  119477. private _isPaused;
  119478. private _speedRatio;
  119479. private _loopAnimation;
  119480. private _isAdditive;
  119481. /**
  119482. * Gets or sets the unique id of the node
  119483. */
  119484. uniqueId: number;
  119485. /**
  119486. * This observable will notify when one animation have ended
  119487. */
  119488. onAnimationEndObservable: Observable<TargetedAnimation>;
  119489. /**
  119490. * Observer raised when one animation loops
  119491. */
  119492. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119493. /**
  119494. * Observer raised when all animations have looped
  119495. */
  119496. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119497. /**
  119498. * This observable will notify when all animations have ended.
  119499. */
  119500. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119501. /**
  119502. * This observable will notify when all animations have paused.
  119503. */
  119504. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119505. /**
  119506. * This observable will notify when all animations are playing.
  119507. */
  119508. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119509. /**
  119510. * Gets the first frame
  119511. */
  119512. get from(): number;
  119513. /**
  119514. * Gets the last frame
  119515. */
  119516. get to(): number;
  119517. /**
  119518. * Define if the animations are started
  119519. */
  119520. get isStarted(): boolean;
  119521. /**
  119522. * Gets a value indicating that the current group is playing
  119523. */
  119524. get isPlaying(): boolean;
  119525. /**
  119526. * Gets or sets the speed ratio to use for all animations
  119527. */
  119528. get speedRatio(): number;
  119529. /**
  119530. * Gets or sets the speed ratio to use for all animations
  119531. */
  119532. set speedRatio(value: number);
  119533. /**
  119534. * Gets or sets if all animations should loop or not
  119535. */
  119536. get loopAnimation(): boolean;
  119537. set loopAnimation(value: boolean);
  119538. /**
  119539. * Gets or sets if all animations should be evaluated additively
  119540. */
  119541. get isAdditive(): boolean;
  119542. set isAdditive(value: boolean);
  119543. /**
  119544. * Gets the targeted animations for this animation group
  119545. */
  119546. get targetedAnimations(): Array<TargetedAnimation>;
  119547. /**
  119548. * returning the list of animatables controlled by this animation group.
  119549. */
  119550. get animatables(): Array<Animatable>;
  119551. /**
  119552. * Gets the list of target animations
  119553. */
  119554. get children(): TargetedAnimation[];
  119555. /**
  119556. * Instantiates a new Animation Group.
  119557. * This helps managing several animations at once.
  119558. * @see https://doc.babylonjs.com/how_to/group
  119559. * @param name Defines the name of the group
  119560. * @param scene Defines the scene the group belongs to
  119561. */
  119562. constructor(
  119563. /** The name of the animation group */
  119564. name: string, scene?: Nullable<Scene>);
  119565. /**
  119566. * Add an animation (with its target) in the group
  119567. * @param animation defines the animation we want to add
  119568. * @param target defines the target of the animation
  119569. * @returns the TargetedAnimation object
  119570. */
  119571. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119572. /**
  119573. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119574. * It can add constant keys at begin or end
  119575. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119576. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119577. * @returns the animation group
  119578. */
  119579. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119580. private _animationLoopCount;
  119581. private _animationLoopFlags;
  119582. private _processLoop;
  119583. /**
  119584. * Start all animations on given targets
  119585. * @param loop defines if animations must loop
  119586. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119587. * @param from defines the from key (optional)
  119588. * @param to defines the to key (optional)
  119589. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119590. * @returns the current animation group
  119591. */
  119592. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119593. /**
  119594. * Pause all animations
  119595. * @returns the animation group
  119596. */
  119597. pause(): AnimationGroup;
  119598. /**
  119599. * Play all animations to initial state
  119600. * This function will start() the animations if they were not started or will restart() them if they were paused
  119601. * @param loop defines if animations must loop
  119602. * @returns the animation group
  119603. */
  119604. play(loop?: boolean): AnimationGroup;
  119605. /**
  119606. * Reset all animations to initial state
  119607. * @returns the animation group
  119608. */
  119609. reset(): AnimationGroup;
  119610. /**
  119611. * Restart animations from key 0
  119612. * @returns the animation group
  119613. */
  119614. restart(): AnimationGroup;
  119615. /**
  119616. * Stop all animations
  119617. * @returns the animation group
  119618. */
  119619. stop(): AnimationGroup;
  119620. /**
  119621. * Set animation weight for all animatables
  119622. * @param weight defines the weight to use
  119623. * @return the animationGroup
  119624. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119625. */
  119626. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119627. /**
  119628. * Synchronize and normalize all animatables with a source animatable
  119629. * @param root defines the root animatable to synchronize with
  119630. * @return the animationGroup
  119631. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119632. */
  119633. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119634. /**
  119635. * Goes to a specific frame in this animation group
  119636. * @param frame the frame number to go to
  119637. * @return the animationGroup
  119638. */
  119639. goToFrame(frame: number): AnimationGroup;
  119640. /**
  119641. * Dispose all associated resources
  119642. */
  119643. dispose(): void;
  119644. private _checkAnimationGroupEnded;
  119645. /**
  119646. * Clone the current animation group and returns a copy
  119647. * @param newName defines the name of the new group
  119648. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119649. * @returns the new aniamtion group
  119650. */
  119651. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119652. /**
  119653. * Serializes the animationGroup to an object
  119654. * @returns Serialized object
  119655. */
  119656. serialize(): any;
  119657. /**
  119658. * Returns a new AnimationGroup object parsed from the source provided.
  119659. * @param parsedAnimationGroup defines the source
  119660. * @param scene defines the scene that will receive the animationGroup
  119661. * @returns a new AnimationGroup
  119662. */
  119663. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119664. /**
  119665. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119666. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119667. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119668. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119669. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119670. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119671. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119672. */
  119673. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119674. /**
  119675. * Returns the string "AnimationGroup"
  119676. * @returns "AnimationGroup"
  119677. */
  119678. getClassName(): string;
  119679. /**
  119680. * Creates a detailled string about the object
  119681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119682. * @returns a string representing the object
  119683. */
  119684. toString(fullDetails?: boolean): string;
  119685. }
  119686. }
  119687. declare module BABYLON {
  119688. /**
  119689. * Define an interface for all classes that will hold resources
  119690. */
  119691. export interface IDisposable {
  119692. /**
  119693. * Releases all held resources
  119694. */
  119695. dispose(): void;
  119696. }
  119697. /** Interface defining initialization parameters for Scene class */
  119698. export interface SceneOptions {
  119699. /**
  119700. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119701. * It will improve performance when the number of geometries becomes important.
  119702. */
  119703. useGeometryUniqueIdsMap?: boolean;
  119704. /**
  119705. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119707. */
  119708. useMaterialMeshMap?: boolean;
  119709. /**
  119710. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119711. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119712. */
  119713. useClonedMeshMap?: boolean;
  119714. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119715. virtual?: boolean;
  119716. }
  119717. /**
  119718. * Represents a scene to be rendered by the engine.
  119719. * @see https://doc.babylonjs.com/features/scene
  119720. */
  119721. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119722. /** The fog is deactivated */
  119723. static readonly FOGMODE_NONE: number;
  119724. /** The fog density is following an exponential function */
  119725. static readonly FOGMODE_EXP: number;
  119726. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119727. static readonly FOGMODE_EXP2: number;
  119728. /** The fog density is following a linear function. */
  119729. static readonly FOGMODE_LINEAR: number;
  119730. /**
  119731. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119733. */
  119734. static MinDeltaTime: number;
  119735. /**
  119736. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119737. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119738. */
  119739. static MaxDeltaTime: number;
  119740. /**
  119741. * Factory used to create the default material.
  119742. * @param name The name of the material to create
  119743. * @param scene The scene to create the material for
  119744. * @returns The default material
  119745. */
  119746. static DefaultMaterialFactory(scene: Scene): Material;
  119747. /**
  119748. * Factory used to create the a collision coordinator.
  119749. * @returns The collision coordinator
  119750. */
  119751. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119752. /** @hidden */
  119753. _inputManager: InputManager;
  119754. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119755. cameraToUseForPointers: Nullable<Camera>;
  119756. /** @hidden */
  119757. readonly _isScene: boolean;
  119758. /** @hidden */
  119759. _blockEntityCollection: boolean;
  119760. /**
  119761. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119762. */
  119763. autoClear: boolean;
  119764. /**
  119765. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119766. */
  119767. autoClearDepthAndStencil: boolean;
  119768. /**
  119769. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119770. */
  119771. clearColor: Color4;
  119772. /**
  119773. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119774. */
  119775. ambientColor: Color3;
  119776. /**
  119777. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119778. * It should only be one of the following (if not the default embedded one):
  119779. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119780. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119781. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119782. * The material properties need to be setup according to the type of texture in use.
  119783. */
  119784. environmentBRDFTexture: BaseTexture;
  119785. /**
  119786. * Texture used in all pbr material as the reflection texture.
  119787. * As in the majority of the scene they are the same (exception for multi room and so on),
  119788. * this is easier to reference from here than from all the materials.
  119789. */
  119790. get environmentTexture(): Nullable<BaseTexture>;
  119791. /**
  119792. * Texture used in all pbr material as the reflection texture.
  119793. * As in the majority of the scene they are the same (exception for multi room and so on),
  119794. * this is easier to set here than in all the materials.
  119795. */
  119796. set environmentTexture(value: Nullable<BaseTexture>);
  119797. /** @hidden */
  119798. protected _environmentIntensity: number;
  119799. /**
  119800. * Intensity of the environment in all pbr material.
  119801. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119802. * As in the majority of the scene they are the same (exception for multi room and so on),
  119803. * this is easier to reference from here than from all the materials.
  119804. */
  119805. get environmentIntensity(): number;
  119806. /**
  119807. * Intensity of the environment in all pbr material.
  119808. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119809. * As in the majority of the scene they are the same (exception for multi room and so on),
  119810. * this is easier to set here than in all the materials.
  119811. */
  119812. set environmentIntensity(value: number);
  119813. /** @hidden */
  119814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119815. /**
  119816. * Default image processing configuration used either in the rendering
  119817. * Forward main pass or through the imageProcessingPostProcess if present.
  119818. * As in the majority of the scene they are the same (exception for multi camera),
  119819. * this is easier to reference from here than from all the materials and post process.
  119820. *
  119821. * No setter as we it is a shared configuration, you can set the values instead.
  119822. */
  119823. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119824. private _forceWireframe;
  119825. /**
  119826. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119827. */
  119828. set forceWireframe(value: boolean);
  119829. get forceWireframe(): boolean;
  119830. private _skipFrustumClipping;
  119831. /**
  119832. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119833. */
  119834. set skipFrustumClipping(value: boolean);
  119835. get skipFrustumClipping(): boolean;
  119836. private _forcePointsCloud;
  119837. /**
  119838. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119839. */
  119840. set forcePointsCloud(value: boolean);
  119841. get forcePointsCloud(): boolean;
  119842. /**
  119843. * Gets or sets the active clipplane 1
  119844. */
  119845. clipPlane: Nullable<Plane>;
  119846. /**
  119847. * Gets or sets the active clipplane 2
  119848. */
  119849. clipPlane2: Nullable<Plane>;
  119850. /**
  119851. * Gets or sets the active clipplane 3
  119852. */
  119853. clipPlane3: Nullable<Plane>;
  119854. /**
  119855. * Gets or sets the active clipplane 4
  119856. */
  119857. clipPlane4: Nullable<Plane>;
  119858. /**
  119859. * Gets or sets the active clipplane 5
  119860. */
  119861. clipPlane5: Nullable<Plane>;
  119862. /**
  119863. * Gets or sets the active clipplane 6
  119864. */
  119865. clipPlane6: Nullable<Plane>;
  119866. /**
  119867. * Gets or sets a boolean indicating if animations are enabled
  119868. */
  119869. animationsEnabled: boolean;
  119870. private _animationPropertiesOverride;
  119871. /**
  119872. * Gets or sets the animation properties override
  119873. */
  119874. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119875. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119876. /**
  119877. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119878. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119879. */
  119880. useConstantAnimationDeltaTime: boolean;
  119881. /**
  119882. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119883. * Please note that it requires to run a ray cast through the scene on every frame
  119884. */
  119885. constantlyUpdateMeshUnderPointer: boolean;
  119886. /**
  119887. * Defines the HTML cursor to use when hovering over interactive elements
  119888. */
  119889. hoverCursor: string;
  119890. /**
  119891. * Defines the HTML default cursor to use (empty by default)
  119892. */
  119893. defaultCursor: string;
  119894. /**
  119895. * Defines whether cursors are handled by the scene.
  119896. */
  119897. doNotHandleCursors: boolean;
  119898. /**
  119899. * This is used to call preventDefault() on pointer down
  119900. * in order to block unwanted artifacts like system double clicks
  119901. */
  119902. preventDefaultOnPointerDown: boolean;
  119903. /**
  119904. * This is used to call preventDefault() on pointer up
  119905. * in order to block unwanted artifacts like system double clicks
  119906. */
  119907. preventDefaultOnPointerUp: boolean;
  119908. /**
  119909. * Gets or sets user defined metadata
  119910. */
  119911. metadata: any;
  119912. /**
  119913. * For internal use only. Please do not use.
  119914. */
  119915. reservedDataStore: any;
  119916. /**
  119917. * Gets the name of the plugin used to load this scene (null by default)
  119918. */
  119919. loadingPluginName: string;
  119920. /**
  119921. * Use this array to add regular expressions used to disable offline support for specific urls
  119922. */
  119923. disableOfflineSupportExceptionRules: RegExp[];
  119924. /**
  119925. * An event triggered when the scene is disposed.
  119926. */
  119927. onDisposeObservable: Observable<Scene>;
  119928. private _onDisposeObserver;
  119929. /** Sets a function to be executed when this scene is disposed. */
  119930. set onDispose(callback: () => void);
  119931. /**
  119932. * An event triggered before rendering the scene (right after animations and physics)
  119933. */
  119934. onBeforeRenderObservable: Observable<Scene>;
  119935. private _onBeforeRenderObserver;
  119936. /** Sets a function to be executed before rendering this scene */
  119937. set beforeRender(callback: Nullable<() => void>);
  119938. /**
  119939. * An event triggered after rendering the scene
  119940. */
  119941. onAfterRenderObservable: Observable<Scene>;
  119942. /**
  119943. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119944. */
  119945. onAfterRenderCameraObservable: Observable<Camera>;
  119946. private _onAfterRenderObserver;
  119947. /** Sets a function to be executed after rendering this scene */
  119948. set afterRender(callback: Nullable<() => void>);
  119949. /**
  119950. * An event triggered before animating the scene
  119951. */
  119952. onBeforeAnimationsObservable: Observable<Scene>;
  119953. /**
  119954. * An event triggered after animations processing
  119955. */
  119956. onAfterAnimationsObservable: Observable<Scene>;
  119957. /**
  119958. * An event triggered before draw calls are ready to be sent
  119959. */
  119960. onBeforeDrawPhaseObservable: Observable<Scene>;
  119961. /**
  119962. * An event triggered after draw calls have been sent
  119963. */
  119964. onAfterDrawPhaseObservable: Observable<Scene>;
  119965. /**
  119966. * An event triggered when the scene is ready
  119967. */
  119968. onReadyObservable: Observable<Scene>;
  119969. /**
  119970. * An event triggered before rendering a camera
  119971. */
  119972. onBeforeCameraRenderObservable: Observable<Camera>;
  119973. private _onBeforeCameraRenderObserver;
  119974. /** Sets a function to be executed before rendering a camera*/
  119975. set beforeCameraRender(callback: () => void);
  119976. /**
  119977. * An event triggered after rendering a camera
  119978. */
  119979. onAfterCameraRenderObservable: Observable<Camera>;
  119980. private _onAfterCameraRenderObserver;
  119981. /** Sets a function to be executed after rendering a camera*/
  119982. set afterCameraRender(callback: () => void);
  119983. /**
  119984. * An event triggered when active meshes evaluation is about to start
  119985. */
  119986. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119987. /**
  119988. * An event triggered when active meshes evaluation is done
  119989. */
  119990. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119991. /**
  119992. * An event triggered when particles rendering is about to start
  119993. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119994. */
  119995. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119996. /**
  119997. * An event triggered when particles rendering is done
  119998. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119999. */
  120000. onAfterParticlesRenderingObservable: Observable<Scene>;
  120001. /**
  120002. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120003. */
  120004. onDataLoadedObservable: Observable<Scene>;
  120005. /**
  120006. * An event triggered when a camera is created
  120007. */
  120008. onNewCameraAddedObservable: Observable<Camera>;
  120009. /**
  120010. * An event triggered when a camera is removed
  120011. */
  120012. onCameraRemovedObservable: Observable<Camera>;
  120013. /**
  120014. * An event triggered when a light is created
  120015. */
  120016. onNewLightAddedObservable: Observable<Light>;
  120017. /**
  120018. * An event triggered when a light is removed
  120019. */
  120020. onLightRemovedObservable: Observable<Light>;
  120021. /**
  120022. * An event triggered when a geometry is created
  120023. */
  120024. onNewGeometryAddedObservable: Observable<Geometry>;
  120025. /**
  120026. * An event triggered when a geometry is removed
  120027. */
  120028. onGeometryRemovedObservable: Observable<Geometry>;
  120029. /**
  120030. * An event triggered when a transform node is created
  120031. */
  120032. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120033. /**
  120034. * An event triggered when a transform node is removed
  120035. */
  120036. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120037. /**
  120038. * An event triggered when a mesh is created
  120039. */
  120040. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120041. /**
  120042. * An event triggered when a mesh is removed
  120043. */
  120044. onMeshRemovedObservable: Observable<AbstractMesh>;
  120045. /**
  120046. * An event triggered when a skeleton is created
  120047. */
  120048. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120049. /**
  120050. * An event triggered when a skeleton is removed
  120051. */
  120052. onSkeletonRemovedObservable: Observable<Skeleton>;
  120053. /**
  120054. * An event triggered when a material is created
  120055. */
  120056. onNewMaterialAddedObservable: Observable<Material>;
  120057. /**
  120058. * An event triggered when a material is removed
  120059. */
  120060. onMaterialRemovedObservable: Observable<Material>;
  120061. /**
  120062. * An event triggered when a texture is created
  120063. */
  120064. onNewTextureAddedObservable: Observable<BaseTexture>;
  120065. /**
  120066. * An event triggered when a texture is removed
  120067. */
  120068. onTextureRemovedObservable: Observable<BaseTexture>;
  120069. /**
  120070. * An event triggered when render targets are about to be rendered
  120071. * Can happen multiple times per frame.
  120072. */
  120073. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120074. /**
  120075. * An event triggered when render targets were rendered.
  120076. * Can happen multiple times per frame.
  120077. */
  120078. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120079. /**
  120080. * An event triggered before calculating deterministic simulation step
  120081. */
  120082. onBeforeStepObservable: Observable<Scene>;
  120083. /**
  120084. * An event triggered after calculating deterministic simulation step
  120085. */
  120086. onAfterStepObservable: Observable<Scene>;
  120087. /**
  120088. * An event triggered when the activeCamera property is updated
  120089. */
  120090. onActiveCameraChanged: Observable<Scene>;
  120091. /**
  120092. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120093. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120094. * 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)
  120095. */
  120096. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120097. /**
  120098. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120099. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120100. * 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)
  120101. */
  120102. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120103. /**
  120104. * This Observable will when a mesh has been imported into the scene.
  120105. */
  120106. onMeshImportedObservable: Observable<AbstractMesh>;
  120107. /**
  120108. * This Observable will when an animation file has been imported into the scene.
  120109. */
  120110. onAnimationFileImportedObservable: Observable<Scene>;
  120111. /**
  120112. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120113. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120114. */
  120115. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120116. /** @hidden */
  120117. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120118. /**
  120119. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120120. */
  120121. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120122. /**
  120123. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120124. */
  120125. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120126. /**
  120127. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120128. */
  120129. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120130. /** Callback called when a pointer move is detected */
  120131. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120132. /** Callback called when a pointer down is detected */
  120133. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120134. /** Callback called when a pointer up is detected */
  120135. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120136. /** Callback called when a pointer pick is detected */
  120137. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120138. /**
  120139. * 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).
  120140. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120141. */
  120142. onPrePointerObservable: Observable<PointerInfoPre>;
  120143. /**
  120144. * Observable event triggered each time an input event is received from the rendering canvas
  120145. */
  120146. onPointerObservable: Observable<PointerInfo>;
  120147. /**
  120148. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120149. */
  120150. get unTranslatedPointer(): Vector2;
  120151. /**
  120152. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120153. */
  120154. static get DragMovementThreshold(): number;
  120155. static set DragMovementThreshold(value: number);
  120156. /**
  120157. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120158. */
  120159. static get LongPressDelay(): number;
  120160. static set LongPressDelay(value: number);
  120161. /**
  120162. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120163. */
  120164. static get DoubleClickDelay(): number;
  120165. static set DoubleClickDelay(value: number);
  120166. /** If you need to check double click without raising a single click at first click, enable this flag */
  120167. static get ExclusiveDoubleClickMode(): boolean;
  120168. static set ExclusiveDoubleClickMode(value: boolean);
  120169. /** @hidden */
  120170. _mirroredCameraPosition: Nullable<Vector3>;
  120171. /**
  120172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120174. */
  120175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120176. /**
  120177. * Observable event triggered each time an keyboard event is received from the hosting window
  120178. */
  120179. onKeyboardObservable: Observable<KeyboardInfo>;
  120180. private _useRightHandedSystem;
  120181. /**
  120182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120183. */
  120184. set useRightHandedSystem(value: boolean);
  120185. get useRightHandedSystem(): boolean;
  120186. private _timeAccumulator;
  120187. private _currentStepId;
  120188. private _currentInternalStep;
  120189. /**
  120190. * Sets the step Id used by deterministic lock step
  120191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120192. * @param newStepId defines the step Id
  120193. */
  120194. setStepId(newStepId: number): void;
  120195. /**
  120196. * Gets the step Id used by deterministic lock step
  120197. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120198. * @returns the step Id
  120199. */
  120200. getStepId(): number;
  120201. /**
  120202. * Gets the internal step used by deterministic lock step
  120203. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120204. * @returns the internal step
  120205. */
  120206. getInternalStep(): number;
  120207. private _fogEnabled;
  120208. /**
  120209. * Gets or sets a boolean indicating if fog is enabled on this scene
  120210. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120211. * (Default is true)
  120212. */
  120213. set fogEnabled(value: boolean);
  120214. get fogEnabled(): boolean;
  120215. private _fogMode;
  120216. /**
  120217. * Gets or sets the fog mode to use
  120218. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120219. * | mode | value |
  120220. * | --- | --- |
  120221. * | FOGMODE_NONE | 0 |
  120222. * | FOGMODE_EXP | 1 |
  120223. * | FOGMODE_EXP2 | 2 |
  120224. * | FOGMODE_LINEAR | 3 |
  120225. */
  120226. set fogMode(value: number);
  120227. get fogMode(): number;
  120228. /**
  120229. * Gets or sets the fog color to use
  120230. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120231. * (Default is Color3(0.2, 0.2, 0.3))
  120232. */
  120233. fogColor: Color3;
  120234. /**
  120235. * Gets or sets the fog density to use
  120236. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120237. * (Default is 0.1)
  120238. */
  120239. fogDensity: number;
  120240. /**
  120241. * Gets or sets the fog start distance to use
  120242. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120243. * (Default is 0)
  120244. */
  120245. fogStart: number;
  120246. /**
  120247. * Gets or sets the fog end distance to use
  120248. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120249. * (Default is 1000)
  120250. */
  120251. fogEnd: number;
  120252. /**
  120253. * Flag indicating that the frame buffer binding is handled by another component
  120254. */
  120255. prePass: boolean;
  120256. private _shadowsEnabled;
  120257. /**
  120258. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120259. */
  120260. set shadowsEnabled(value: boolean);
  120261. get shadowsEnabled(): boolean;
  120262. private _lightsEnabled;
  120263. /**
  120264. * Gets or sets a boolean indicating if lights are enabled on this scene
  120265. */
  120266. set lightsEnabled(value: boolean);
  120267. get lightsEnabled(): boolean;
  120268. /** All of the active cameras added to this scene. */
  120269. activeCameras: Camera[];
  120270. /** @hidden */
  120271. _activeCamera: Nullable<Camera>;
  120272. /** Gets or sets the current active camera */
  120273. get activeCamera(): Nullable<Camera>;
  120274. set activeCamera(value: Nullable<Camera>);
  120275. private _defaultMaterial;
  120276. /** The default material used on meshes when no material is affected */
  120277. get defaultMaterial(): Material;
  120278. /** The default material used on meshes when no material is affected */
  120279. set defaultMaterial(value: Material);
  120280. private _texturesEnabled;
  120281. /**
  120282. * Gets or sets a boolean indicating if textures are enabled on this scene
  120283. */
  120284. set texturesEnabled(value: boolean);
  120285. get texturesEnabled(): boolean;
  120286. /**
  120287. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120288. */
  120289. physicsEnabled: boolean;
  120290. /**
  120291. * Gets or sets a boolean indicating if particles are enabled on this scene
  120292. */
  120293. particlesEnabled: boolean;
  120294. /**
  120295. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120296. */
  120297. spritesEnabled: boolean;
  120298. private _skeletonsEnabled;
  120299. /**
  120300. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120301. */
  120302. set skeletonsEnabled(value: boolean);
  120303. get skeletonsEnabled(): boolean;
  120304. /**
  120305. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120306. */
  120307. lensFlaresEnabled: boolean;
  120308. /**
  120309. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120310. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120311. */
  120312. collisionsEnabled: boolean;
  120313. private _collisionCoordinator;
  120314. /** @hidden */
  120315. get collisionCoordinator(): ICollisionCoordinator;
  120316. /**
  120317. * Defines the gravity applied to this scene (used only for collisions)
  120318. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120319. */
  120320. gravity: Vector3;
  120321. /**
  120322. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120323. */
  120324. postProcessesEnabled: boolean;
  120325. /**
  120326. * Gets the current postprocess manager
  120327. */
  120328. postProcessManager: PostProcessManager;
  120329. /**
  120330. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120331. */
  120332. renderTargetsEnabled: boolean;
  120333. /**
  120334. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120335. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120336. */
  120337. dumpNextRenderTargets: boolean;
  120338. /**
  120339. * The list of user defined render targets added to the scene
  120340. */
  120341. customRenderTargets: RenderTargetTexture[];
  120342. /**
  120343. * Defines if texture loading must be delayed
  120344. * If true, textures will only be loaded when they need to be rendered
  120345. */
  120346. useDelayedTextureLoading: boolean;
  120347. /**
  120348. * Gets the list of meshes imported to the scene through SceneLoader
  120349. */
  120350. importedMeshesFiles: String[];
  120351. /**
  120352. * Gets or sets a boolean indicating if probes are enabled on this scene
  120353. */
  120354. probesEnabled: boolean;
  120355. /**
  120356. * Gets or sets the current offline provider to use to store scene data
  120357. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120358. */
  120359. offlineProvider: IOfflineProvider;
  120360. /**
  120361. * Gets or sets the action manager associated with the scene
  120362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120363. */
  120364. actionManager: AbstractActionManager;
  120365. private _meshesForIntersections;
  120366. /**
  120367. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120368. */
  120369. proceduralTexturesEnabled: boolean;
  120370. private _engine;
  120371. private _totalVertices;
  120372. /** @hidden */
  120373. _activeIndices: PerfCounter;
  120374. /** @hidden */
  120375. _activeParticles: PerfCounter;
  120376. /** @hidden */
  120377. _activeBones: PerfCounter;
  120378. private _animationRatio;
  120379. /** @hidden */
  120380. _animationTimeLast: number;
  120381. /** @hidden */
  120382. _animationTime: number;
  120383. /**
  120384. * Gets or sets a general scale for animation speed
  120385. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120386. */
  120387. animationTimeScale: number;
  120388. /** @hidden */
  120389. _cachedMaterial: Nullable<Material>;
  120390. /** @hidden */
  120391. _cachedEffect: Nullable<Effect>;
  120392. /** @hidden */
  120393. _cachedVisibility: Nullable<number>;
  120394. private _renderId;
  120395. private _frameId;
  120396. private _executeWhenReadyTimeoutId;
  120397. private _intermediateRendering;
  120398. private _viewUpdateFlag;
  120399. private _projectionUpdateFlag;
  120400. /** @hidden */
  120401. _toBeDisposed: Nullable<IDisposable>[];
  120402. private _activeRequests;
  120403. /** @hidden */
  120404. _pendingData: any[];
  120405. private _isDisposed;
  120406. /**
  120407. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120408. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120409. */
  120410. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120411. private _activeMeshes;
  120412. private _processedMaterials;
  120413. private _renderTargets;
  120414. /** @hidden */
  120415. _activeParticleSystems: SmartArray<IParticleSystem>;
  120416. private _activeSkeletons;
  120417. private _softwareSkinnedMeshes;
  120418. private _renderingManager;
  120419. /** @hidden */
  120420. _activeAnimatables: Animatable[];
  120421. private _transformMatrix;
  120422. private _sceneUbo;
  120423. /** @hidden */
  120424. _viewMatrix: Matrix;
  120425. private _projectionMatrix;
  120426. /** @hidden */
  120427. _forcedViewPosition: Nullable<Vector3>;
  120428. /** @hidden */
  120429. _frustumPlanes: Plane[];
  120430. /**
  120431. * Gets the list of frustum planes (built from the active camera)
  120432. */
  120433. get frustumPlanes(): Plane[];
  120434. /**
  120435. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120436. * This is useful if there are more lights that the maximum simulteanous authorized
  120437. */
  120438. requireLightSorting: boolean;
  120439. /** @hidden */
  120440. readonly useMaterialMeshMap: boolean;
  120441. /** @hidden */
  120442. readonly useClonedMeshMap: boolean;
  120443. private _externalData;
  120444. private _uid;
  120445. /**
  120446. * @hidden
  120447. * Backing store of defined scene components.
  120448. */
  120449. _components: ISceneComponent[];
  120450. /**
  120451. * @hidden
  120452. * Backing store of defined scene components.
  120453. */
  120454. _serializableComponents: ISceneSerializableComponent[];
  120455. /**
  120456. * List of components to register on the next registration step.
  120457. */
  120458. private _transientComponents;
  120459. /**
  120460. * Registers the transient components if needed.
  120461. */
  120462. private _registerTransientComponents;
  120463. /**
  120464. * @hidden
  120465. * Add a component to the scene.
  120466. * Note that the ccomponent could be registered on th next frame if this is called after
  120467. * the register component stage.
  120468. * @param component Defines the component to add to the scene
  120469. */
  120470. _addComponent(component: ISceneComponent): void;
  120471. /**
  120472. * @hidden
  120473. * Gets a component from the scene.
  120474. * @param name defines the name of the component to retrieve
  120475. * @returns the component or null if not present
  120476. */
  120477. _getComponent(name: string): Nullable<ISceneComponent>;
  120478. /**
  120479. * @hidden
  120480. * Defines the actions happening before camera updates.
  120481. */
  120482. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120483. /**
  120484. * @hidden
  120485. * Defines the actions happening before clear the canvas.
  120486. */
  120487. _beforeClearStage: Stage<SimpleStageAction>;
  120488. /**
  120489. * @hidden
  120490. * Defines the actions when collecting render targets for the frame.
  120491. */
  120492. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120493. /**
  120494. * @hidden
  120495. * Defines the actions happening for one camera in the frame.
  120496. */
  120497. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120498. /**
  120499. * @hidden
  120500. * Defines the actions happening during the per mesh ready checks.
  120501. */
  120502. _isReadyForMeshStage: Stage<MeshStageAction>;
  120503. /**
  120504. * @hidden
  120505. * Defines the actions happening before evaluate active mesh checks.
  120506. */
  120507. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120508. /**
  120509. * @hidden
  120510. * Defines the actions happening during the evaluate sub mesh checks.
  120511. */
  120512. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120513. /**
  120514. * @hidden
  120515. * Defines the actions happening during the active mesh stage.
  120516. */
  120517. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120518. /**
  120519. * @hidden
  120520. * Defines the actions happening during the per camera render target step.
  120521. */
  120522. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120523. /**
  120524. * @hidden
  120525. * Defines the actions happening just before the active camera is drawing.
  120526. */
  120527. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120528. /**
  120529. * @hidden
  120530. * Defines the actions happening just before a render target is drawing.
  120531. */
  120532. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120533. /**
  120534. * @hidden
  120535. * Defines the actions happening just before a rendering group is drawing.
  120536. */
  120537. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120538. /**
  120539. * @hidden
  120540. * Defines the actions happening just before a mesh is drawing.
  120541. */
  120542. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120543. /**
  120544. * @hidden
  120545. * Defines the actions happening just after a mesh has been drawn.
  120546. */
  120547. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120548. /**
  120549. * @hidden
  120550. * Defines the actions happening just after a rendering group has been drawn.
  120551. */
  120552. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120553. /**
  120554. * @hidden
  120555. * Defines the actions happening just after the active camera has been drawn.
  120556. */
  120557. _afterCameraDrawStage: Stage<CameraStageAction>;
  120558. /**
  120559. * @hidden
  120560. * Defines the actions happening just after a render target has been drawn.
  120561. */
  120562. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120563. /**
  120564. * @hidden
  120565. * Defines the actions happening just after rendering all cameras and computing intersections.
  120566. */
  120567. _afterRenderStage: Stage<SimpleStageAction>;
  120568. /**
  120569. * @hidden
  120570. * Defines the actions happening when a pointer move event happens.
  120571. */
  120572. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120573. /**
  120574. * @hidden
  120575. * Defines the actions happening when a pointer down event happens.
  120576. */
  120577. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120578. /**
  120579. * @hidden
  120580. * Defines the actions happening when a pointer up event happens.
  120581. */
  120582. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120583. /**
  120584. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120585. */
  120586. private geometriesByUniqueId;
  120587. /**
  120588. * Creates a new Scene
  120589. * @param engine defines the engine to use to render this scene
  120590. * @param options defines the scene options
  120591. */
  120592. constructor(engine: Engine, options?: SceneOptions);
  120593. /**
  120594. * Gets a string identifying the name of the class
  120595. * @returns "Scene" string
  120596. */
  120597. getClassName(): string;
  120598. private _defaultMeshCandidates;
  120599. /**
  120600. * @hidden
  120601. */
  120602. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120603. private _defaultSubMeshCandidates;
  120604. /**
  120605. * @hidden
  120606. */
  120607. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120608. /**
  120609. * Sets the default candidate providers for the scene.
  120610. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120611. * and getCollidingSubMeshCandidates to their default function
  120612. */
  120613. setDefaultCandidateProviders(): void;
  120614. /**
  120615. * Gets the mesh that is currently under the pointer
  120616. */
  120617. get meshUnderPointer(): Nullable<AbstractMesh>;
  120618. /**
  120619. * Gets or sets the current on-screen X position of the pointer
  120620. */
  120621. get pointerX(): number;
  120622. set pointerX(value: number);
  120623. /**
  120624. * Gets or sets the current on-screen Y position of the pointer
  120625. */
  120626. get pointerY(): number;
  120627. set pointerY(value: number);
  120628. /**
  120629. * Gets the cached material (ie. the latest rendered one)
  120630. * @returns the cached material
  120631. */
  120632. getCachedMaterial(): Nullable<Material>;
  120633. /**
  120634. * Gets the cached effect (ie. the latest rendered one)
  120635. * @returns the cached effect
  120636. */
  120637. getCachedEffect(): Nullable<Effect>;
  120638. /**
  120639. * Gets the cached visibility state (ie. the latest rendered one)
  120640. * @returns the cached visibility state
  120641. */
  120642. getCachedVisibility(): Nullable<number>;
  120643. /**
  120644. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120645. * @param material defines the current material
  120646. * @param effect defines the current effect
  120647. * @param visibility defines the current visibility state
  120648. * @returns true if one parameter is not cached
  120649. */
  120650. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120651. /**
  120652. * Gets the engine associated with the scene
  120653. * @returns an Engine
  120654. */
  120655. getEngine(): Engine;
  120656. /**
  120657. * Gets the total number of vertices rendered per frame
  120658. * @returns the total number of vertices rendered per frame
  120659. */
  120660. getTotalVertices(): number;
  120661. /**
  120662. * Gets the performance counter for total vertices
  120663. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120664. */
  120665. get totalVerticesPerfCounter(): PerfCounter;
  120666. /**
  120667. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120668. * @returns the total number of active indices rendered per frame
  120669. */
  120670. getActiveIndices(): number;
  120671. /**
  120672. * Gets the performance counter for active indices
  120673. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120674. */
  120675. get totalActiveIndicesPerfCounter(): PerfCounter;
  120676. /**
  120677. * Gets the total number of active particles rendered per frame
  120678. * @returns the total number of active particles rendered per frame
  120679. */
  120680. getActiveParticles(): number;
  120681. /**
  120682. * Gets the performance counter for active particles
  120683. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120684. */
  120685. get activeParticlesPerfCounter(): PerfCounter;
  120686. /**
  120687. * Gets the total number of active bones rendered per frame
  120688. * @returns the total number of active bones rendered per frame
  120689. */
  120690. getActiveBones(): number;
  120691. /**
  120692. * Gets the performance counter for active bones
  120693. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120694. */
  120695. get activeBonesPerfCounter(): PerfCounter;
  120696. /**
  120697. * Gets the array of active meshes
  120698. * @returns an array of AbstractMesh
  120699. */
  120700. getActiveMeshes(): SmartArray<AbstractMesh>;
  120701. /**
  120702. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120703. * @returns a number
  120704. */
  120705. getAnimationRatio(): number;
  120706. /**
  120707. * Gets an unique Id for the current render phase
  120708. * @returns a number
  120709. */
  120710. getRenderId(): number;
  120711. /**
  120712. * Gets an unique Id for the current frame
  120713. * @returns a number
  120714. */
  120715. getFrameId(): number;
  120716. /** Call this function if you want to manually increment the render Id*/
  120717. incrementRenderId(): void;
  120718. private _createUbo;
  120719. /**
  120720. * Use this method to simulate a pointer move on a mesh
  120721. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120722. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120723. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120724. * @returns the current scene
  120725. */
  120726. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120727. /**
  120728. * Use this method to simulate a pointer down on a mesh
  120729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120732. * @returns the current scene
  120733. */
  120734. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120735. /**
  120736. * Use this method to simulate a pointer up on a mesh
  120737. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120738. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120739. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120740. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120741. * @returns the current scene
  120742. */
  120743. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120744. /**
  120745. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120746. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120747. * @returns true if the pointer was captured
  120748. */
  120749. isPointerCaptured(pointerId?: number): boolean;
  120750. /**
  120751. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120752. * @param attachUp defines if you want to attach events to pointerup
  120753. * @param attachDown defines if you want to attach events to pointerdown
  120754. * @param attachMove defines if you want to attach events to pointermove
  120755. */
  120756. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120757. /** Detaches all event handlers*/
  120758. detachControl(): void;
  120759. /**
  120760. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120761. * Delay loaded resources are not taking in account
  120762. * @return true if all required resources are ready
  120763. */
  120764. isReady(): boolean;
  120765. /** Resets all cached information relative to material (including effect and visibility) */
  120766. resetCachedMaterial(): void;
  120767. /**
  120768. * Registers a function to be called before every frame render
  120769. * @param func defines the function to register
  120770. */
  120771. registerBeforeRender(func: () => void): void;
  120772. /**
  120773. * Unregisters a function called before every frame render
  120774. * @param func defines the function to unregister
  120775. */
  120776. unregisterBeforeRender(func: () => void): void;
  120777. /**
  120778. * Registers a function to be called after every frame render
  120779. * @param func defines the function to register
  120780. */
  120781. registerAfterRender(func: () => void): void;
  120782. /**
  120783. * Unregisters a function called after every frame render
  120784. * @param func defines the function to unregister
  120785. */
  120786. unregisterAfterRender(func: () => void): void;
  120787. private _executeOnceBeforeRender;
  120788. /**
  120789. * The provided function will run before render once and will be disposed afterwards.
  120790. * A timeout delay can be provided so that the function will be executed in N ms.
  120791. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120792. * @param func The function to be executed.
  120793. * @param timeout optional delay in ms
  120794. */
  120795. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120796. /** @hidden */
  120797. _addPendingData(data: any): void;
  120798. /** @hidden */
  120799. _removePendingData(data: any): void;
  120800. /**
  120801. * Returns the number of items waiting to be loaded
  120802. * @returns the number of items waiting to be loaded
  120803. */
  120804. getWaitingItemsCount(): number;
  120805. /**
  120806. * Returns a boolean indicating if the scene is still loading data
  120807. */
  120808. get isLoading(): boolean;
  120809. /**
  120810. * Registers a function to be executed when the scene is ready
  120811. * @param {Function} func - the function to be executed
  120812. */
  120813. executeWhenReady(func: () => void): void;
  120814. /**
  120815. * Returns a promise that resolves when the scene is ready
  120816. * @returns A promise that resolves when the scene is ready
  120817. */
  120818. whenReadyAsync(): Promise<void>;
  120819. /** @hidden */
  120820. _checkIsReady(): void;
  120821. /**
  120822. * Gets all animatable attached to the scene
  120823. */
  120824. get animatables(): Animatable[];
  120825. /**
  120826. * Resets the last animation time frame.
  120827. * Useful to override when animations start running when loading a scene for the first time.
  120828. */
  120829. resetLastAnimationTimeFrame(): void;
  120830. /**
  120831. * Gets the current view matrix
  120832. * @returns a Matrix
  120833. */
  120834. getViewMatrix(): Matrix;
  120835. /**
  120836. * Gets the current projection matrix
  120837. * @returns a Matrix
  120838. */
  120839. getProjectionMatrix(): Matrix;
  120840. /**
  120841. * Gets the current transform matrix
  120842. * @returns a Matrix made of View * Projection
  120843. */
  120844. getTransformMatrix(): Matrix;
  120845. /**
  120846. * Sets the current transform matrix
  120847. * @param viewL defines the View matrix to use
  120848. * @param projectionL defines the Projection matrix to use
  120849. * @param viewR defines the right View matrix to use (if provided)
  120850. * @param projectionR defines the right Projection matrix to use (if provided)
  120851. */
  120852. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120853. /**
  120854. * Gets the uniform buffer used to store scene data
  120855. * @returns a UniformBuffer
  120856. */
  120857. getSceneUniformBuffer(): UniformBuffer;
  120858. /**
  120859. * Gets an unique (relatively to the current scene) Id
  120860. * @returns an unique number for the scene
  120861. */
  120862. getUniqueId(): number;
  120863. /**
  120864. * Add a mesh to the list of scene's meshes
  120865. * @param newMesh defines the mesh to add
  120866. * @param recursive if all child meshes should also be added to the scene
  120867. */
  120868. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120869. /**
  120870. * Remove a mesh for the list of scene's meshes
  120871. * @param toRemove defines the mesh to remove
  120872. * @param recursive if all child meshes should also be removed from the scene
  120873. * @returns the index where the mesh was in the mesh list
  120874. */
  120875. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120876. /**
  120877. * Add a transform node to the list of scene's transform nodes
  120878. * @param newTransformNode defines the transform node to add
  120879. */
  120880. addTransformNode(newTransformNode: TransformNode): void;
  120881. /**
  120882. * Remove a transform node for the list of scene's transform nodes
  120883. * @param toRemove defines the transform node to remove
  120884. * @returns the index where the transform node was in the transform node list
  120885. */
  120886. removeTransformNode(toRemove: TransformNode): number;
  120887. /**
  120888. * Remove a skeleton for the list of scene's skeletons
  120889. * @param toRemove defines the skeleton to remove
  120890. * @returns the index where the skeleton was in the skeleton list
  120891. */
  120892. removeSkeleton(toRemove: Skeleton): number;
  120893. /**
  120894. * Remove a morph target for the list of scene's morph targets
  120895. * @param toRemove defines the morph target to remove
  120896. * @returns the index where the morph target was in the morph target list
  120897. */
  120898. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120899. /**
  120900. * Remove a light for the list of scene's lights
  120901. * @param toRemove defines the light to remove
  120902. * @returns the index where the light was in the light list
  120903. */
  120904. removeLight(toRemove: Light): number;
  120905. /**
  120906. * Remove a camera for the list of scene's cameras
  120907. * @param toRemove defines the camera to remove
  120908. * @returns the index where the camera was in the camera list
  120909. */
  120910. removeCamera(toRemove: Camera): number;
  120911. /**
  120912. * Remove a particle system for the list of scene's particle systems
  120913. * @param toRemove defines the particle system to remove
  120914. * @returns the index where the particle system was in the particle system list
  120915. */
  120916. removeParticleSystem(toRemove: IParticleSystem): number;
  120917. /**
  120918. * Remove a animation for the list of scene's animations
  120919. * @param toRemove defines the animation to remove
  120920. * @returns the index where the animation was in the animation list
  120921. */
  120922. removeAnimation(toRemove: Animation): number;
  120923. /**
  120924. * Will stop the animation of the given target
  120925. * @param target - the target
  120926. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120927. * @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)
  120928. */
  120929. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120930. /**
  120931. * Removes the given animation group from this scene.
  120932. * @param toRemove The animation group to remove
  120933. * @returns The index of the removed animation group
  120934. */
  120935. removeAnimationGroup(toRemove: AnimationGroup): number;
  120936. /**
  120937. * Removes the given multi-material from this scene.
  120938. * @param toRemove The multi-material to remove
  120939. * @returns The index of the removed multi-material
  120940. */
  120941. removeMultiMaterial(toRemove: MultiMaterial): number;
  120942. /**
  120943. * Removes the given material from this scene.
  120944. * @param toRemove The material to remove
  120945. * @returns The index of the removed material
  120946. */
  120947. removeMaterial(toRemove: Material): number;
  120948. /**
  120949. * Removes the given action manager from this scene.
  120950. * @param toRemove The action manager to remove
  120951. * @returns The index of the removed action manager
  120952. */
  120953. removeActionManager(toRemove: AbstractActionManager): number;
  120954. /**
  120955. * Removes the given texture from this scene.
  120956. * @param toRemove The texture to remove
  120957. * @returns The index of the removed texture
  120958. */
  120959. removeTexture(toRemove: BaseTexture): number;
  120960. /**
  120961. * Adds the given light to this scene
  120962. * @param newLight The light to add
  120963. */
  120964. addLight(newLight: Light): void;
  120965. /**
  120966. * Sorts the list list based on light priorities
  120967. */
  120968. sortLightsByPriority(): void;
  120969. /**
  120970. * Adds the given camera to this scene
  120971. * @param newCamera The camera to add
  120972. */
  120973. addCamera(newCamera: Camera): void;
  120974. /**
  120975. * Adds the given skeleton to this scene
  120976. * @param newSkeleton The skeleton to add
  120977. */
  120978. addSkeleton(newSkeleton: Skeleton): void;
  120979. /**
  120980. * Adds the given particle system to this scene
  120981. * @param newParticleSystem The particle system to add
  120982. */
  120983. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120984. /**
  120985. * Adds the given animation to this scene
  120986. * @param newAnimation The animation to add
  120987. */
  120988. addAnimation(newAnimation: Animation): void;
  120989. /**
  120990. * Adds the given animation group to this scene.
  120991. * @param newAnimationGroup The animation group to add
  120992. */
  120993. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120994. /**
  120995. * Adds the given multi-material to this scene
  120996. * @param newMultiMaterial The multi-material to add
  120997. */
  120998. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120999. /**
  121000. * Adds the given material to this scene
  121001. * @param newMaterial The material to add
  121002. */
  121003. addMaterial(newMaterial: Material): void;
  121004. /**
  121005. * Adds the given morph target to this scene
  121006. * @param newMorphTargetManager The morph target to add
  121007. */
  121008. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121009. /**
  121010. * Adds the given geometry to this scene
  121011. * @param newGeometry The geometry to add
  121012. */
  121013. addGeometry(newGeometry: Geometry): void;
  121014. /**
  121015. * Adds the given action manager to this scene
  121016. * @param newActionManager The action manager to add
  121017. */
  121018. addActionManager(newActionManager: AbstractActionManager): void;
  121019. /**
  121020. * Adds the given texture to this scene.
  121021. * @param newTexture The texture to add
  121022. */
  121023. addTexture(newTexture: BaseTexture): void;
  121024. /**
  121025. * Switch active camera
  121026. * @param newCamera defines the new active camera
  121027. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121028. */
  121029. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121030. /**
  121031. * sets the active camera of the scene using its ID
  121032. * @param id defines the camera's ID
  121033. * @return the new active camera or null if none found.
  121034. */
  121035. setActiveCameraByID(id: string): Nullable<Camera>;
  121036. /**
  121037. * sets the active camera of the scene using its name
  121038. * @param name defines the camera's name
  121039. * @returns the new active camera or null if none found.
  121040. */
  121041. setActiveCameraByName(name: string): Nullable<Camera>;
  121042. /**
  121043. * get an animation group using its name
  121044. * @param name defines the material's name
  121045. * @return the animation group or null if none found.
  121046. */
  121047. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121048. /**
  121049. * Get a material using its unique id
  121050. * @param uniqueId defines the material's unique id
  121051. * @return the material or null if none found.
  121052. */
  121053. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121054. /**
  121055. * get a material using its id
  121056. * @param id defines the material's ID
  121057. * @return the material or null if none found.
  121058. */
  121059. getMaterialByID(id: string): Nullable<Material>;
  121060. /**
  121061. * Gets a the last added material using a given id
  121062. * @param id defines the material's ID
  121063. * @return the last material with the given id or null if none found.
  121064. */
  121065. getLastMaterialByID(id: string): Nullable<Material>;
  121066. /**
  121067. * Gets a material using its name
  121068. * @param name defines the material's name
  121069. * @return the material or null if none found.
  121070. */
  121071. getMaterialByName(name: string): Nullable<Material>;
  121072. /**
  121073. * Get a texture using its unique id
  121074. * @param uniqueId defines the texture's unique id
  121075. * @return the texture or null if none found.
  121076. */
  121077. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121078. /**
  121079. * Gets a camera using its id
  121080. * @param id defines the id to look for
  121081. * @returns the camera or null if not found
  121082. */
  121083. getCameraByID(id: string): Nullable<Camera>;
  121084. /**
  121085. * Gets a camera using its unique id
  121086. * @param uniqueId defines the unique id to look for
  121087. * @returns the camera or null if not found
  121088. */
  121089. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121090. /**
  121091. * Gets a camera using its name
  121092. * @param name defines the camera's name
  121093. * @return the camera or null if none found.
  121094. */
  121095. getCameraByName(name: string): Nullable<Camera>;
  121096. /**
  121097. * Gets a bone using its id
  121098. * @param id defines the bone's id
  121099. * @return the bone or null if not found
  121100. */
  121101. getBoneByID(id: string): Nullable<Bone>;
  121102. /**
  121103. * Gets a bone using its id
  121104. * @param name defines the bone's name
  121105. * @return the bone or null if not found
  121106. */
  121107. getBoneByName(name: string): Nullable<Bone>;
  121108. /**
  121109. * Gets a light node using its name
  121110. * @param name defines the the light's name
  121111. * @return the light or null if none found.
  121112. */
  121113. getLightByName(name: string): Nullable<Light>;
  121114. /**
  121115. * Gets a light node using its id
  121116. * @param id defines the light's id
  121117. * @return the light or null if none found.
  121118. */
  121119. getLightByID(id: string): Nullable<Light>;
  121120. /**
  121121. * Gets a light node using its scene-generated unique ID
  121122. * @param uniqueId defines the light's unique id
  121123. * @return the light or null if none found.
  121124. */
  121125. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121126. /**
  121127. * Gets a particle system by id
  121128. * @param id defines the particle system id
  121129. * @return the corresponding system or null if none found
  121130. */
  121131. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121132. /**
  121133. * Gets a geometry using its ID
  121134. * @param id defines the geometry's id
  121135. * @return the geometry or null if none found.
  121136. */
  121137. getGeometryByID(id: string): Nullable<Geometry>;
  121138. private _getGeometryByUniqueID;
  121139. /**
  121140. * Add a new geometry to this scene
  121141. * @param geometry defines the geometry to be added to the scene.
  121142. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121143. * @return a boolean defining if the geometry was added or not
  121144. */
  121145. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121146. /**
  121147. * Removes an existing geometry
  121148. * @param geometry defines the geometry to be removed from the scene
  121149. * @return a boolean defining if the geometry was removed or not
  121150. */
  121151. removeGeometry(geometry: Geometry): boolean;
  121152. /**
  121153. * Gets the list of geometries attached to the scene
  121154. * @returns an array of Geometry
  121155. */
  121156. getGeometries(): Geometry[];
  121157. /**
  121158. * Gets the first added mesh found of a given ID
  121159. * @param id defines the id to search for
  121160. * @return the mesh found or null if not found at all
  121161. */
  121162. getMeshByID(id: string): Nullable<AbstractMesh>;
  121163. /**
  121164. * Gets a list of meshes using their id
  121165. * @param id defines the id to search for
  121166. * @returns a list of meshes
  121167. */
  121168. getMeshesByID(id: string): Array<AbstractMesh>;
  121169. /**
  121170. * Gets the first added transform node found of a given ID
  121171. * @param id defines the id to search for
  121172. * @return the found transform node or null if not found at all.
  121173. */
  121174. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121175. /**
  121176. * Gets a transform node with its auto-generated unique id
  121177. * @param uniqueId efines the unique id to search for
  121178. * @return the found transform node or null if not found at all.
  121179. */
  121180. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121181. /**
  121182. * Gets a list of transform nodes using their id
  121183. * @param id defines the id to search for
  121184. * @returns a list of transform nodes
  121185. */
  121186. getTransformNodesByID(id: string): Array<TransformNode>;
  121187. /**
  121188. * Gets a mesh with its auto-generated unique id
  121189. * @param uniqueId defines the unique id to search for
  121190. * @return the found mesh or null if not found at all.
  121191. */
  121192. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121193. /**
  121194. * Gets a the last added mesh using a given id
  121195. * @param id defines the id to search for
  121196. * @return the found mesh or null if not found at all.
  121197. */
  121198. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121199. /**
  121200. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121201. * @param id defines the id to search for
  121202. * @return the found node or null if not found at all
  121203. */
  121204. getLastEntryByID(id: string): Nullable<Node>;
  121205. /**
  121206. * Gets a node (Mesh, Camera, Light) using a given id
  121207. * @param id defines the id to search for
  121208. * @return the found node or null if not found at all
  121209. */
  121210. getNodeByID(id: string): Nullable<Node>;
  121211. /**
  121212. * Gets a node (Mesh, Camera, Light) using a given name
  121213. * @param name defines the name to search for
  121214. * @return the found node or null if not found at all.
  121215. */
  121216. getNodeByName(name: string): Nullable<Node>;
  121217. /**
  121218. * Gets a mesh using a given name
  121219. * @param name defines the name to search for
  121220. * @return the found mesh or null if not found at all.
  121221. */
  121222. getMeshByName(name: string): Nullable<AbstractMesh>;
  121223. /**
  121224. * Gets a transform node using a given name
  121225. * @param name defines the name to search for
  121226. * @return the found transform node or null if not found at all.
  121227. */
  121228. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121229. /**
  121230. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121231. * @param id defines the id to search for
  121232. * @return the found skeleton or null if not found at all.
  121233. */
  121234. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121235. /**
  121236. * Gets a skeleton using a given auto generated unique id
  121237. * @param uniqueId defines the unique id to search for
  121238. * @return the found skeleton or null if not found at all.
  121239. */
  121240. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121241. /**
  121242. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121243. * @param id defines the id to search for
  121244. * @return the found skeleton or null if not found at all.
  121245. */
  121246. getSkeletonById(id: string): Nullable<Skeleton>;
  121247. /**
  121248. * Gets a skeleton using a given name
  121249. * @param name defines the name to search for
  121250. * @return the found skeleton or null if not found at all.
  121251. */
  121252. getSkeletonByName(name: string): Nullable<Skeleton>;
  121253. /**
  121254. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121255. * @param id defines the id to search for
  121256. * @return the found morph target manager or null if not found at all.
  121257. */
  121258. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121259. /**
  121260. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121261. * @param id defines the id to search for
  121262. * @return the found morph target or null if not found at all.
  121263. */
  121264. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121265. /**
  121266. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121267. * @param name defines the name to search for
  121268. * @return the found morph target or null if not found at all.
  121269. */
  121270. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121271. /**
  121272. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121273. * @param name defines the name to search for
  121274. * @return the found post process or null if not found at all.
  121275. */
  121276. getPostProcessByName(name: string): Nullable<PostProcess>;
  121277. /**
  121278. * Gets a boolean indicating if the given mesh is active
  121279. * @param mesh defines the mesh to look for
  121280. * @returns true if the mesh is in the active list
  121281. */
  121282. isActiveMesh(mesh: AbstractMesh): boolean;
  121283. /**
  121284. * Return a unique id as a string which can serve as an identifier for the scene
  121285. */
  121286. get uid(): string;
  121287. /**
  121288. * Add an externaly attached data from its key.
  121289. * This method call will fail and return false, if such key already exists.
  121290. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121291. * @param key the unique key that identifies the data
  121292. * @param data the data object to associate to the key for this Engine instance
  121293. * @return true if no such key were already present and the data was added successfully, false otherwise
  121294. */
  121295. addExternalData<T>(key: string, data: T): boolean;
  121296. /**
  121297. * Get an externaly attached data from its key
  121298. * @param key the unique key that identifies the data
  121299. * @return the associated data, if present (can be null), or undefined if not present
  121300. */
  121301. getExternalData<T>(key: string): Nullable<T>;
  121302. /**
  121303. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121304. * @param key the unique key that identifies the data
  121305. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121306. * @return the associated data, can be null if the factory returned null.
  121307. */
  121308. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121309. /**
  121310. * Remove an externaly attached data from the Engine instance
  121311. * @param key the unique key that identifies the data
  121312. * @return true if the data was successfully removed, false if it doesn't exist
  121313. */
  121314. removeExternalData(key: string): boolean;
  121315. private _evaluateSubMesh;
  121316. /**
  121317. * Clear the processed materials smart array preventing retention point in material dispose.
  121318. */
  121319. freeProcessedMaterials(): void;
  121320. private _preventFreeActiveMeshesAndRenderingGroups;
  121321. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121322. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121323. * when disposing several meshes in a row or a hierarchy of meshes.
  121324. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121325. */
  121326. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121327. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121328. /**
  121329. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121330. */
  121331. freeActiveMeshes(): void;
  121332. /**
  121333. * Clear the info related to rendering groups preventing retention points during dispose.
  121334. */
  121335. freeRenderingGroups(): void;
  121336. /** @hidden */
  121337. _isInIntermediateRendering(): boolean;
  121338. /**
  121339. * Lambda returning the list of potentially active meshes.
  121340. */
  121341. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121342. /**
  121343. * Lambda returning the list of potentially active sub meshes.
  121344. */
  121345. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121346. /**
  121347. * Lambda returning the list of potentially intersecting sub meshes.
  121348. */
  121349. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121350. /**
  121351. * Lambda returning the list of potentially colliding sub meshes.
  121352. */
  121353. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121354. private _activeMeshesFrozen;
  121355. private _skipEvaluateActiveMeshesCompletely;
  121356. /**
  121357. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121358. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121359. * @returns the current scene
  121360. */
  121361. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121362. /**
  121363. * Use this function to restart evaluating active meshes on every frame
  121364. * @returns the current scene
  121365. */
  121366. unfreezeActiveMeshes(): Scene;
  121367. private _evaluateActiveMeshes;
  121368. private _activeMesh;
  121369. /**
  121370. * Update the transform matrix to update from the current active camera
  121371. * @param force defines a boolean used to force the update even if cache is up to date
  121372. */
  121373. updateTransformMatrix(force?: boolean): void;
  121374. private _bindFrameBuffer;
  121375. /** @hidden */
  121376. _allowPostProcessClearColor: boolean;
  121377. /** @hidden */
  121378. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121379. private _processSubCameras;
  121380. private _checkIntersections;
  121381. /** @hidden */
  121382. _advancePhysicsEngineStep(step: number): void;
  121383. /**
  121384. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121385. */
  121386. getDeterministicFrameTime: () => number;
  121387. /** @hidden */
  121388. _animate(): void;
  121389. /** Execute all animations (for a frame) */
  121390. animate(): void;
  121391. /**
  121392. * Render the scene
  121393. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121394. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121395. */
  121396. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121397. /**
  121398. * Freeze all materials
  121399. * A frozen material will not be updatable but should be faster to render
  121400. */
  121401. freezeMaterials(): void;
  121402. /**
  121403. * Unfreeze all materials
  121404. * A frozen material will not be updatable but should be faster to render
  121405. */
  121406. unfreezeMaterials(): void;
  121407. /**
  121408. * Releases all held ressources
  121409. */
  121410. dispose(): void;
  121411. /**
  121412. * Gets if the scene is already disposed
  121413. */
  121414. get isDisposed(): boolean;
  121415. /**
  121416. * Call this function to reduce memory footprint of the scene.
  121417. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121418. */
  121419. clearCachedVertexData(): void;
  121420. /**
  121421. * This function will remove the local cached buffer data from texture.
  121422. * It will save memory but will prevent the texture from being rebuilt
  121423. */
  121424. cleanCachedTextureBuffer(): void;
  121425. /**
  121426. * Get the world extend vectors with an optional filter
  121427. *
  121428. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121429. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121430. */
  121431. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121432. min: Vector3;
  121433. max: Vector3;
  121434. };
  121435. /**
  121436. * Creates a ray that can be used to pick in the scene
  121437. * @param x defines the x coordinate of the origin (on-screen)
  121438. * @param y defines the y coordinate of the origin (on-screen)
  121439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121440. * @param camera defines the camera to use for the picking
  121441. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121442. * @returns a Ray
  121443. */
  121444. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121445. /**
  121446. * Creates a ray that can be used to pick in the scene
  121447. * @param x defines the x coordinate of the origin (on-screen)
  121448. * @param y defines the y coordinate of the origin (on-screen)
  121449. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121450. * @param result defines the ray where to store the picking ray
  121451. * @param camera defines the camera to use for the picking
  121452. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121453. * @returns the current scene
  121454. */
  121455. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121456. /**
  121457. * Creates a ray that can be used to pick in the scene
  121458. * @param x defines the x coordinate of the origin (on-screen)
  121459. * @param y defines the y coordinate of the origin (on-screen)
  121460. * @param camera defines the camera to use for the picking
  121461. * @returns a Ray
  121462. */
  121463. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121464. /**
  121465. * Creates a ray that can be used to pick in the scene
  121466. * @param x defines the x coordinate of the origin (on-screen)
  121467. * @param y defines the y coordinate of the origin (on-screen)
  121468. * @param result defines the ray where to store the picking ray
  121469. * @param camera defines the camera to use for the picking
  121470. * @returns the current scene
  121471. */
  121472. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121473. /** Launch a ray to try to pick a mesh in the scene
  121474. * @param x position on screen
  121475. * @param y position on screen
  121476. * @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
  121477. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121478. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121480. * @returns a PickingInfo
  121481. */
  121482. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121483. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121484. * @param x position on screen
  121485. * @param y position on screen
  121486. * @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
  121487. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121488. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121489. * @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)
  121490. */
  121491. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121492. /** Use the given ray to pick a mesh in the scene
  121493. * @param ray The ray to use to pick meshes
  121494. * @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
  121495. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121496. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121497. * @returns a PickingInfo
  121498. */
  121499. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121500. /**
  121501. * Launch a ray to try to pick a mesh in the scene
  121502. * @param x X position on screen
  121503. * @param y Y position on screen
  121504. * @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
  121505. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121507. * @returns an array of PickingInfo
  121508. */
  121509. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121510. /**
  121511. * Launch a ray to try to pick a mesh in the scene
  121512. * @param ray Ray to use
  121513. * @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
  121514. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121515. * @returns an array of PickingInfo
  121516. */
  121517. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121518. /**
  121519. * Force the value of meshUnderPointer
  121520. * @param mesh defines the mesh to use
  121521. * @param pointerId optional pointer id when using more than one pointer
  121522. */
  121523. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121524. /**
  121525. * Gets the mesh under the pointer
  121526. * @returns a Mesh or null if no mesh is under the pointer
  121527. */
  121528. getPointerOverMesh(): Nullable<AbstractMesh>;
  121529. /** @hidden */
  121530. _rebuildGeometries(): void;
  121531. /** @hidden */
  121532. _rebuildTextures(): void;
  121533. private _getByTags;
  121534. /**
  121535. * Get a list of meshes by tags
  121536. * @param tagsQuery defines the tags query to use
  121537. * @param forEach defines a predicate used to filter results
  121538. * @returns an array of Mesh
  121539. */
  121540. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121541. /**
  121542. * Get a list of cameras by tags
  121543. * @param tagsQuery defines the tags query to use
  121544. * @param forEach defines a predicate used to filter results
  121545. * @returns an array of Camera
  121546. */
  121547. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121548. /**
  121549. * Get a list of lights by tags
  121550. * @param tagsQuery defines the tags query to use
  121551. * @param forEach defines a predicate used to filter results
  121552. * @returns an array of Light
  121553. */
  121554. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121555. /**
  121556. * Get a list of materials by tags
  121557. * @param tagsQuery defines the tags query to use
  121558. * @param forEach defines a predicate used to filter results
  121559. * @returns an array of Material
  121560. */
  121561. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121562. /**
  121563. * Get a list of transform nodes by tags
  121564. * @param tagsQuery defines the tags query to use
  121565. * @param forEach defines a predicate used to filter results
  121566. * @returns an array of TransformNode
  121567. */
  121568. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121569. /**
  121570. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121571. * This allowed control for front to back rendering or reversly depending of the special needs.
  121572. *
  121573. * @param renderingGroupId The rendering group id corresponding to its index
  121574. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121575. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121576. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121577. */
  121578. 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;
  121579. /**
  121580. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121581. *
  121582. * @param renderingGroupId The rendering group id corresponding to its index
  121583. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121584. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121585. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121586. */
  121587. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121588. /**
  121589. * Gets the current auto clear configuration for one rendering group of the rendering
  121590. * manager.
  121591. * @param index the rendering group index to get the information for
  121592. * @returns The auto clear setup for the requested rendering group
  121593. */
  121594. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121595. private _blockMaterialDirtyMechanism;
  121596. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121597. get blockMaterialDirtyMechanism(): boolean;
  121598. set blockMaterialDirtyMechanism(value: boolean);
  121599. /**
  121600. * Will flag all materials as dirty to trigger new shader compilation
  121601. * @param flag defines the flag used to specify which material part must be marked as dirty
  121602. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121603. */
  121604. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121605. /** @hidden */
  121606. _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;
  121607. /** @hidden */
  121608. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121609. /** @hidden */
  121610. _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;
  121611. /** @hidden */
  121612. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121613. /** @hidden */
  121614. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121615. /** @hidden */
  121616. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121617. }
  121618. }
  121619. declare module BABYLON {
  121620. /**
  121621. * Set of assets to keep when moving a scene into an asset container.
  121622. */
  121623. export class KeepAssets extends AbstractScene {
  121624. }
  121625. /**
  121626. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121627. */
  121628. export class InstantiatedEntries {
  121629. /**
  121630. * List of new root nodes (eg. nodes with no parent)
  121631. */
  121632. rootNodes: TransformNode[];
  121633. /**
  121634. * List of new skeletons
  121635. */
  121636. skeletons: Skeleton[];
  121637. /**
  121638. * List of new animation groups
  121639. */
  121640. animationGroups: AnimationGroup[];
  121641. }
  121642. /**
  121643. * Container with a set of assets that can be added or removed from a scene.
  121644. */
  121645. export class AssetContainer extends AbstractScene {
  121646. private _wasAddedToScene;
  121647. /**
  121648. * The scene the AssetContainer belongs to.
  121649. */
  121650. scene: Scene;
  121651. /**
  121652. * Instantiates an AssetContainer.
  121653. * @param scene The scene the AssetContainer belongs to.
  121654. */
  121655. constructor(scene: Scene);
  121656. /**
  121657. * Instantiate or clone all meshes and add the new ones to the scene.
  121658. * Skeletons and animation groups will all be cloned
  121659. * @param nameFunction defines an optional function used to get new names for clones
  121660. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121661. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121662. */
  121663. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121664. /**
  121665. * Adds all the assets from the container to the scene.
  121666. */
  121667. addAllToScene(): void;
  121668. /**
  121669. * Removes all the assets in the container from the scene
  121670. */
  121671. removeAllFromScene(): void;
  121672. /**
  121673. * Disposes all the assets in the container
  121674. */
  121675. dispose(): void;
  121676. private _moveAssets;
  121677. /**
  121678. * Removes all the assets contained in the scene and adds them to the container.
  121679. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121680. */
  121681. moveAllFromScene(keepAssets?: KeepAssets): void;
  121682. /**
  121683. * 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.
  121684. * @returns the root mesh
  121685. */
  121686. createRootMesh(): Mesh;
  121687. /**
  121688. * Merge animations (direct and animation groups) from this asset container into a scene
  121689. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121690. * @param animatables set of animatables to retarget to a node from the scene
  121691. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121692. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121693. */
  121694. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121695. }
  121696. }
  121697. declare module BABYLON {
  121698. /**
  121699. * Defines how the parser contract is defined.
  121700. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121701. */
  121702. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121703. /**
  121704. * Defines how the individual parser contract is defined.
  121705. * These parser can parse an individual asset
  121706. */
  121707. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121708. /**
  121709. * Base class of the scene acting as a container for the different elements composing a scene.
  121710. * This class is dynamically extended by the different components of the scene increasing
  121711. * flexibility and reducing coupling
  121712. */
  121713. export abstract class AbstractScene {
  121714. /**
  121715. * Stores the list of available parsers in the application.
  121716. */
  121717. private static _BabylonFileParsers;
  121718. /**
  121719. * Stores the list of available individual parsers in the application.
  121720. */
  121721. private static _IndividualBabylonFileParsers;
  121722. /**
  121723. * Adds a parser in the list of available ones
  121724. * @param name Defines the name of the parser
  121725. * @param parser Defines the parser to add
  121726. */
  121727. static AddParser(name: string, parser: BabylonFileParser): void;
  121728. /**
  121729. * Gets a general parser from the list of avaialble ones
  121730. * @param name Defines the name of the parser
  121731. * @returns the requested parser or null
  121732. */
  121733. static GetParser(name: string): Nullable<BabylonFileParser>;
  121734. /**
  121735. * Adds n individual parser in the list of available ones
  121736. * @param name Defines the name of the parser
  121737. * @param parser Defines the parser to add
  121738. */
  121739. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121740. /**
  121741. * Gets an individual parser from the list of avaialble ones
  121742. * @param name Defines the name of the parser
  121743. * @returns the requested parser or null
  121744. */
  121745. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121746. /**
  121747. * Parser json data and populate both a scene and its associated container object
  121748. * @param jsonData Defines the data to parse
  121749. * @param scene Defines the scene to parse the data for
  121750. * @param container Defines the container attached to the parsing sequence
  121751. * @param rootUrl Defines the root url of the data
  121752. */
  121753. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121754. /**
  121755. * Gets the list of root nodes (ie. nodes with no parent)
  121756. */
  121757. rootNodes: Node[];
  121758. /** All of the cameras added to this scene
  121759. * @see https://doc.babylonjs.com/babylon101/cameras
  121760. */
  121761. cameras: Camera[];
  121762. /**
  121763. * All of the lights added to this scene
  121764. * @see https://doc.babylonjs.com/babylon101/lights
  121765. */
  121766. lights: Light[];
  121767. /**
  121768. * All of the (abstract) meshes added to this scene
  121769. */
  121770. meshes: AbstractMesh[];
  121771. /**
  121772. * The list of skeletons added to the scene
  121773. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121774. */
  121775. skeletons: Skeleton[];
  121776. /**
  121777. * All of the particle systems added to this scene
  121778. * @see https://doc.babylonjs.com/babylon101/particles
  121779. */
  121780. particleSystems: IParticleSystem[];
  121781. /**
  121782. * Gets a list of Animations associated with the scene
  121783. */
  121784. animations: Animation[];
  121785. /**
  121786. * All of the animation groups added to this scene
  121787. * @see https://doc.babylonjs.com/how_to/group
  121788. */
  121789. animationGroups: AnimationGroup[];
  121790. /**
  121791. * All of the multi-materials added to this scene
  121792. * @see https://doc.babylonjs.com/how_to/multi_materials
  121793. */
  121794. multiMaterials: MultiMaterial[];
  121795. /**
  121796. * All of the materials added to this scene
  121797. * In the context of a Scene, it is not supposed to be modified manually.
  121798. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121799. * Note also that the order of the Material within the array is not significant and might change.
  121800. * @see https://doc.babylonjs.com/babylon101/materials
  121801. */
  121802. materials: Material[];
  121803. /**
  121804. * The list of morph target managers added to the scene
  121805. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121806. */
  121807. morphTargetManagers: MorphTargetManager[];
  121808. /**
  121809. * The list of geometries used in the scene.
  121810. */
  121811. geometries: Geometry[];
  121812. /**
  121813. * All of the tranform nodes added to this scene
  121814. * In the context of a Scene, it is not supposed to be modified manually.
  121815. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121816. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121817. * @see https://doc.babylonjs.com/how_to/transformnode
  121818. */
  121819. transformNodes: TransformNode[];
  121820. /**
  121821. * ActionManagers available on the scene.
  121822. */
  121823. actionManagers: AbstractActionManager[];
  121824. /**
  121825. * Textures to keep.
  121826. */
  121827. textures: BaseTexture[];
  121828. /** @hidden */
  121829. protected _environmentTexture: Nullable<BaseTexture>;
  121830. /**
  121831. * Texture used in all pbr material as the reflection texture.
  121832. * As in the majority of the scene they are the same (exception for multi room and so on),
  121833. * this is easier to reference from here than from all the materials.
  121834. */
  121835. get environmentTexture(): Nullable<BaseTexture>;
  121836. set environmentTexture(value: Nullable<BaseTexture>);
  121837. /**
  121838. * The list of postprocesses added to the scene
  121839. */
  121840. postProcesses: PostProcess[];
  121841. /**
  121842. * @returns all meshes, lights, cameras, transformNodes and bones
  121843. */
  121844. getNodes(): Array<Node>;
  121845. }
  121846. }
  121847. declare module BABYLON {
  121848. /**
  121849. * Interface used to define options for Sound class
  121850. */
  121851. export interface ISoundOptions {
  121852. /**
  121853. * Does the sound autoplay once loaded.
  121854. */
  121855. autoplay?: boolean;
  121856. /**
  121857. * Does the sound loop after it finishes playing once.
  121858. */
  121859. loop?: boolean;
  121860. /**
  121861. * Sound's volume
  121862. */
  121863. volume?: number;
  121864. /**
  121865. * Is it a spatial sound?
  121866. */
  121867. spatialSound?: boolean;
  121868. /**
  121869. * Maximum distance to hear that sound
  121870. */
  121871. maxDistance?: number;
  121872. /**
  121873. * Uses user defined attenuation function
  121874. */
  121875. useCustomAttenuation?: boolean;
  121876. /**
  121877. * Define the roll off factor of spatial sounds.
  121878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121879. */
  121880. rolloffFactor?: number;
  121881. /**
  121882. * Define the reference distance the sound should be heard perfectly.
  121883. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121884. */
  121885. refDistance?: number;
  121886. /**
  121887. * Define the distance attenuation model the sound will follow.
  121888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121889. */
  121890. distanceModel?: string;
  121891. /**
  121892. * Defines the playback speed (1 by default)
  121893. */
  121894. playbackRate?: number;
  121895. /**
  121896. * Defines if the sound is from a streaming source
  121897. */
  121898. streaming?: boolean;
  121899. /**
  121900. * Defines an optional length (in seconds) inside the sound file
  121901. */
  121902. length?: number;
  121903. /**
  121904. * Defines an optional offset (in seconds) inside the sound file
  121905. */
  121906. offset?: number;
  121907. /**
  121908. * If true, URLs will not be required to state the audio file codec to use.
  121909. */
  121910. skipCodecCheck?: boolean;
  121911. }
  121912. /**
  121913. * Defines a sound that can be played in the application.
  121914. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121916. */
  121917. export class Sound {
  121918. /**
  121919. * The name of the sound in the scene.
  121920. */
  121921. name: string;
  121922. /**
  121923. * Does the sound autoplay once loaded.
  121924. */
  121925. autoplay: boolean;
  121926. /**
  121927. * Does the sound loop after it finishes playing once.
  121928. */
  121929. loop: boolean;
  121930. /**
  121931. * Does the sound use a custom attenuation curve to simulate the falloff
  121932. * happening when the source gets further away from the camera.
  121933. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121934. */
  121935. useCustomAttenuation: boolean;
  121936. /**
  121937. * The sound track id this sound belongs to.
  121938. */
  121939. soundTrackId: number;
  121940. /**
  121941. * Is this sound currently played.
  121942. */
  121943. isPlaying: boolean;
  121944. /**
  121945. * Is this sound currently paused.
  121946. */
  121947. isPaused: boolean;
  121948. /**
  121949. * Does this sound enables spatial sound.
  121950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121951. */
  121952. spatialSound: boolean;
  121953. /**
  121954. * Define the reference distance the sound should be heard perfectly.
  121955. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121956. */
  121957. refDistance: number;
  121958. /**
  121959. * Define the roll off factor of spatial sounds.
  121960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121961. */
  121962. rolloffFactor: number;
  121963. /**
  121964. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121966. */
  121967. maxDistance: number;
  121968. /**
  121969. * Define the distance attenuation model the sound will follow.
  121970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121971. */
  121972. distanceModel: string;
  121973. /**
  121974. * @hidden
  121975. * Back Compat
  121976. **/
  121977. onended: () => any;
  121978. /**
  121979. * Gets or sets an object used to store user defined information for the sound.
  121980. */
  121981. metadata: any;
  121982. /**
  121983. * Observable event when the current playing sound finishes.
  121984. */
  121985. onEndedObservable: Observable<Sound>;
  121986. private _panningModel;
  121987. private _playbackRate;
  121988. private _streaming;
  121989. private _startTime;
  121990. private _startOffset;
  121991. private _position;
  121992. /** @hidden */
  121993. _positionInEmitterSpace: boolean;
  121994. private _localDirection;
  121995. private _volume;
  121996. private _isReadyToPlay;
  121997. private _isDirectional;
  121998. private _readyToPlayCallback;
  121999. private _audioBuffer;
  122000. private _soundSource;
  122001. private _streamingSource;
  122002. private _soundPanner;
  122003. private _soundGain;
  122004. private _inputAudioNode;
  122005. private _outputAudioNode;
  122006. private _coneInnerAngle;
  122007. private _coneOuterAngle;
  122008. private _coneOuterGain;
  122009. private _scene;
  122010. private _connectedTransformNode;
  122011. private _customAttenuationFunction;
  122012. private _registerFunc;
  122013. private _isOutputConnected;
  122014. private _htmlAudioElement;
  122015. private _urlType;
  122016. private _length?;
  122017. private _offset?;
  122018. /** @hidden */
  122019. static _SceneComponentInitialization: (scene: Scene) => void;
  122020. /**
  122021. * Create a sound and attach it to a scene
  122022. * @param name Name of your sound
  122023. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122024. * @param scene defines the scene the sound belongs to
  122025. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122026. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122027. */
  122028. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122029. /**
  122030. * Release the sound and its associated resources
  122031. */
  122032. dispose(): void;
  122033. /**
  122034. * Gets if the sounds is ready to be played or not.
  122035. * @returns true if ready, otherwise false
  122036. */
  122037. isReady(): boolean;
  122038. private _soundLoaded;
  122039. /**
  122040. * Sets the data of the sound from an audiobuffer
  122041. * @param audioBuffer The audioBuffer containing the data
  122042. */
  122043. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122044. /**
  122045. * Updates the current sounds options such as maxdistance, loop...
  122046. * @param options A JSON object containing values named as the object properties
  122047. */
  122048. updateOptions(options: ISoundOptions): void;
  122049. private _createSpatialParameters;
  122050. private _updateSpatialParameters;
  122051. /**
  122052. * Switch the panning model to HRTF:
  122053. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122055. */
  122056. switchPanningModelToHRTF(): void;
  122057. /**
  122058. * Switch the panning model to Equal Power:
  122059. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122061. */
  122062. switchPanningModelToEqualPower(): void;
  122063. private _switchPanningModel;
  122064. /**
  122065. * Connect this sound to a sound track audio node like gain...
  122066. * @param soundTrackAudioNode the sound track audio node to connect to
  122067. */
  122068. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122069. /**
  122070. * Transform this sound into a directional source
  122071. * @param coneInnerAngle Size of the inner cone in degree
  122072. * @param coneOuterAngle Size of the outer cone in degree
  122073. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122074. */
  122075. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122076. /**
  122077. * Gets or sets the inner angle for the directional cone.
  122078. */
  122079. get directionalConeInnerAngle(): number;
  122080. /**
  122081. * Gets or sets the inner angle for the directional cone.
  122082. */
  122083. set directionalConeInnerAngle(value: number);
  122084. /**
  122085. * Gets or sets the outer angle for the directional cone.
  122086. */
  122087. get directionalConeOuterAngle(): number;
  122088. /**
  122089. * Gets or sets the outer angle for the directional cone.
  122090. */
  122091. set directionalConeOuterAngle(value: number);
  122092. /**
  122093. * Sets the position of the emitter if spatial sound is enabled
  122094. * @param newPosition Defines the new posisiton
  122095. */
  122096. setPosition(newPosition: Vector3): void;
  122097. /**
  122098. * Sets the local direction of the emitter if spatial sound is enabled
  122099. * @param newLocalDirection Defines the new local direction
  122100. */
  122101. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122102. private _updateDirection;
  122103. /** @hidden */
  122104. updateDistanceFromListener(): void;
  122105. /**
  122106. * Sets a new custom attenuation function for the sound.
  122107. * @param callback Defines the function used for the attenuation
  122108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122109. */
  122110. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122111. /**
  122112. * Play the sound
  122113. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122114. * @param offset (optional) Start the sound at a specific time in seconds
  122115. * @param length (optional) Sound duration (in seconds)
  122116. */
  122117. play(time?: number, offset?: number, length?: number): void;
  122118. private _onended;
  122119. /**
  122120. * Stop the sound
  122121. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122122. */
  122123. stop(time?: number): void;
  122124. /**
  122125. * Put the sound in pause
  122126. */
  122127. pause(): void;
  122128. /**
  122129. * Sets a dedicated volume for this sounds
  122130. * @param newVolume Define the new volume of the sound
  122131. * @param time Define time for gradual change to new volume
  122132. */
  122133. setVolume(newVolume: number, time?: number): void;
  122134. /**
  122135. * Set the sound play back rate
  122136. * @param newPlaybackRate Define the playback rate the sound should be played at
  122137. */
  122138. setPlaybackRate(newPlaybackRate: number): void;
  122139. /**
  122140. * Gets the volume of the sound.
  122141. * @returns the volume of the sound
  122142. */
  122143. getVolume(): number;
  122144. /**
  122145. * Attach the sound to a dedicated mesh
  122146. * @param transformNode The transform node to connect the sound with
  122147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122148. */
  122149. attachToMesh(transformNode: TransformNode): void;
  122150. /**
  122151. * Detach the sound from the previously attached mesh
  122152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122153. */
  122154. detachFromMesh(): void;
  122155. private _onRegisterAfterWorldMatrixUpdate;
  122156. /**
  122157. * Clone the current sound in the scene.
  122158. * @returns the new sound clone
  122159. */
  122160. clone(): Nullable<Sound>;
  122161. /**
  122162. * Gets the current underlying audio buffer containing the data
  122163. * @returns the audio buffer
  122164. */
  122165. getAudioBuffer(): Nullable<AudioBuffer>;
  122166. /**
  122167. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122168. * @returns the source node
  122169. */
  122170. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122171. /**
  122172. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122173. * @returns the gain node
  122174. */
  122175. getSoundGain(): Nullable<GainNode>;
  122176. /**
  122177. * Serializes the Sound in a JSON representation
  122178. * @returns the JSON representation of the sound
  122179. */
  122180. serialize(): any;
  122181. /**
  122182. * Parse a JSON representation of a sound to innstantiate in a given scene
  122183. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122184. * @param scene Define the scene the new parsed sound should be created in
  122185. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122186. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122187. * @returns the newly parsed sound
  122188. */
  122189. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122190. }
  122191. }
  122192. declare module BABYLON {
  122193. /**
  122194. * This defines an action helpful to play a defined sound on a triggered action.
  122195. */
  122196. export class PlaySoundAction extends Action {
  122197. private _sound;
  122198. /**
  122199. * Instantiate the action
  122200. * @param triggerOptions defines the trigger options
  122201. * @param sound defines the sound to play
  122202. * @param condition defines the trigger related conditions
  122203. */
  122204. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122205. /** @hidden */
  122206. _prepare(): void;
  122207. /**
  122208. * Execute the action and play the sound.
  122209. */
  122210. execute(): void;
  122211. /**
  122212. * Serializes the actions and its related information.
  122213. * @param parent defines the object to serialize in
  122214. * @returns the serialized object
  122215. */
  122216. serialize(parent: any): any;
  122217. }
  122218. /**
  122219. * This defines an action helpful to stop a defined sound on a triggered action.
  122220. */
  122221. export class StopSoundAction extends Action {
  122222. private _sound;
  122223. /**
  122224. * Instantiate the action
  122225. * @param triggerOptions defines the trigger options
  122226. * @param sound defines the sound to stop
  122227. * @param condition defines the trigger related conditions
  122228. */
  122229. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122230. /** @hidden */
  122231. _prepare(): void;
  122232. /**
  122233. * Execute the action and stop the sound.
  122234. */
  122235. execute(): void;
  122236. /**
  122237. * Serializes the actions and its related information.
  122238. * @param parent defines the object to serialize in
  122239. * @returns the serialized object
  122240. */
  122241. serialize(parent: any): any;
  122242. }
  122243. }
  122244. declare module BABYLON {
  122245. /**
  122246. * This defines an action responsible to change the value of a property
  122247. * by interpolating between its current value and the newly set one once triggered.
  122248. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122249. */
  122250. export class InterpolateValueAction extends Action {
  122251. /**
  122252. * Defines the path of the property where the value should be interpolated
  122253. */
  122254. propertyPath: string;
  122255. /**
  122256. * Defines the target value at the end of the interpolation.
  122257. */
  122258. value: any;
  122259. /**
  122260. * Defines the time it will take for the property to interpolate to the value.
  122261. */
  122262. duration: number;
  122263. /**
  122264. * Defines if the other scene animations should be stopped when the action has been triggered
  122265. */
  122266. stopOtherAnimations?: boolean;
  122267. /**
  122268. * Defines a callback raised once the interpolation animation has been done.
  122269. */
  122270. onInterpolationDone?: () => void;
  122271. /**
  122272. * Observable triggered once the interpolation animation has been done.
  122273. */
  122274. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122275. private _target;
  122276. private _effectiveTarget;
  122277. private _property;
  122278. /**
  122279. * Instantiate the action
  122280. * @param triggerOptions defines the trigger options
  122281. * @param target defines the object containing the value to interpolate
  122282. * @param propertyPath defines the path to the property in the target object
  122283. * @param value defines the target value at the end of the interpolation
  122284. * @param duration deines the time it will take for the property to interpolate to the value.
  122285. * @param condition defines the trigger related conditions
  122286. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122287. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122288. */
  122289. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122290. /** @hidden */
  122291. _prepare(): void;
  122292. /**
  122293. * Execute the action starts the value interpolation.
  122294. */
  122295. execute(): void;
  122296. /**
  122297. * Serializes the actions and its related information.
  122298. * @param parent defines the object to serialize in
  122299. * @returns the serialized object
  122300. */
  122301. serialize(parent: any): any;
  122302. }
  122303. }
  122304. declare module BABYLON {
  122305. /**
  122306. * Options allowed during the creation of a sound track.
  122307. */
  122308. export interface ISoundTrackOptions {
  122309. /**
  122310. * The volume the sound track should take during creation
  122311. */
  122312. volume?: number;
  122313. /**
  122314. * Define if the sound track is the main sound track of the scene
  122315. */
  122316. mainTrack?: boolean;
  122317. }
  122318. /**
  122319. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122320. * It will be also used in a future release to apply effects on a specific track.
  122321. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122322. */
  122323. export class SoundTrack {
  122324. /**
  122325. * The unique identifier of the sound track in the scene.
  122326. */
  122327. id: number;
  122328. /**
  122329. * The list of sounds included in the sound track.
  122330. */
  122331. soundCollection: Array<Sound>;
  122332. private _outputAudioNode;
  122333. private _scene;
  122334. private _connectedAnalyser;
  122335. private _options;
  122336. private _isInitialized;
  122337. /**
  122338. * Creates a new sound track.
  122339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122340. * @param scene Define the scene the sound track belongs to
  122341. * @param options
  122342. */
  122343. constructor(scene: Scene, options?: ISoundTrackOptions);
  122344. private _initializeSoundTrackAudioGraph;
  122345. /**
  122346. * Release the sound track and its associated resources
  122347. */
  122348. dispose(): void;
  122349. /**
  122350. * Adds a sound to this sound track
  122351. * @param sound define the cound to add
  122352. * @ignoreNaming
  122353. */
  122354. AddSound(sound: Sound): void;
  122355. /**
  122356. * Removes a sound to this sound track
  122357. * @param sound define the cound to remove
  122358. * @ignoreNaming
  122359. */
  122360. RemoveSound(sound: Sound): void;
  122361. /**
  122362. * Set a global volume for the full sound track.
  122363. * @param newVolume Define the new volume of the sound track
  122364. */
  122365. setVolume(newVolume: number): void;
  122366. /**
  122367. * Switch the panning model to HRTF:
  122368. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122370. */
  122371. switchPanningModelToHRTF(): void;
  122372. /**
  122373. * Switch the panning model to Equal Power:
  122374. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122376. */
  122377. switchPanningModelToEqualPower(): void;
  122378. /**
  122379. * Connect the sound track to an audio analyser allowing some amazing
  122380. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122382. * @param analyser The analyser to connect to the engine
  122383. */
  122384. connectToAnalyser(analyser: Analyser): void;
  122385. }
  122386. }
  122387. declare module BABYLON {
  122388. interface AbstractScene {
  122389. /**
  122390. * The list of sounds used in the scene.
  122391. */
  122392. sounds: Nullable<Array<Sound>>;
  122393. }
  122394. interface Scene {
  122395. /**
  122396. * @hidden
  122397. * Backing field
  122398. */
  122399. _mainSoundTrack: SoundTrack;
  122400. /**
  122401. * The main sound track played by the scene.
  122402. * It cotains your primary collection of sounds.
  122403. */
  122404. mainSoundTrack: SoundTrack;
  122405. /**
  122406. * The list of sound tracks added to the scene
  122407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122408. */
  122409. soundTracks: Nullable<Array<SoundTrack>>;
  122410. /**
  122411. * Gets a sound using a given name
  122412. * @param name defines the name to search for
  122413. * @return the found sound or null if not found at all.
  122414. */
  122415. getSoundByName(name: string): Nullable<Sound>;
  122416. /**
  122417. * Gets or sets if audio support is enabled
  122418. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122419. */
  122420. audioEnabled: boolean;
  122421. /**
  122422. * Gets or sets if audio will be output to headphones
  122423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122424. */
  122425. headphone: boolean;
  122426. /**
  122427. * Gets or sets custom audio listener position provider
  122428. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122429. */
  122430. audioListenerPositionProvider: Nullable<() => Vector3>;
  122431. /**
  122432. * Gets or sets a refresh rate when using 3D audio positioning
  122433. */
  122434. audioPositioningRefreshRate: number;
  122435. }
  122436. /**
  122437. * Defines the sound scene component responsible to manage any sounds
  122438. * in a given scene.
  122439. */
  122440. export class AudioSceneComponent implements ISceneSerializableComponent {
  122441. private static _CameraDirectionLH;
  122442. private static _CameraDirectionRH;
  122443. /**
  122444. * The component name helpfull to identify the component in the list of scene components.
  122445. */
  122446. readonly name: string;
  122447. /**
  122448. * The scene the component belongs to.
  122449. */
  122450. scene: Scene;
  122451. private _audioEnabled;
  122452. /**
  122453. * Gets whether audio is enabled or not.
  122454. * Please use related enable/disable method to switch state.
  122455. */
  122456. get audioEnabled(): boolean;
  122457. private _headphone;
  122458. /**
  122459. * Gets whether audio is outputing to headphone or not.
  122460. * Please use the according Switch methods to change output.
  122461. */
  122462. get headphone(): boolean;
  122463. /**
  122464. * Gets or sets a refresh rate when using 3D audio positioning
  122465. */
  122466. audioPositioningRefreshRate: number;
  122467. private _audioListenerPositionProvider;
  122468. /**
  122469. * Gets the current audio listener position provider
  122470. */
  122471. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122472. /**
  122473. * Sets a custom listener position for all sounds in the scene
  122474. * By default, this is the position of the first active camera
  122475. */
  122476. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122477. /**
  122478. * Creates a new instance of the component for the given scene
  122479. * @param scene Defines the scene to register the component in
  122480. */
  122481. constructor(scene: Scene);
  122482. /**
  122483. * Registers the component in a given scene
  122484. */
  122485. register(): void;
  122486. /**
  122487. * Rebuilds the elements related to this component in case of
  122488. * context lost for instance.
  122489. */
  122490. rebuild(): void;
  122491. /**
  122492. * Serializes the component data to the specified json object
  122493. * @param serializationObject The object to serialize to
  122494. */
  122495. serialize(serializationObject: any): void;
  122496. /**
  122497. * Adds all the elements from the container to the scene
  122498. * @param container the container holding the elements
  122499. */
  122500. addFromContainer(container: AbstractScene): void;
  122501. /**
  122502. * Removes all the elements in the container from the scene
  122503. * @param container contains the elements to remove
  122504. * @param dispose if the removed element should be disposed (default: false)
  122505. */
  122506. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122507. /**
  122508. * Disposes the component and the associated ressources.
  122509. */
  122510. dispose(): void;
  122511. /**
  122512. * Disables audio in the associated scene.
  122513. */
  122514. disableAudio(): void;
  122515. /**
  122516. * Enables audio in the associated scene.
  122517. */
  122518. enableAudio(): void;
  122519. /**
  122520. * Switch audio to headphone output.
  122521. */
  122522. switchAudioModeForHeadphones(): void;
  122523. /**
  122524. * Switch audio to normal speakers.
  122525. */
  122526. switchAudioModeForNormalSpeakers(): void;
  122527. private _cachedCameraDirection;
  122528. private _cachedCameraPosition;
  122529. private _lastCheck;
  122530. private _afterRender;
  122531. }
  122532. }
  122533. declare module BABYLON {
  122534. /**
  122535. * Wraps one or more Sound objects and selects one with random weight for playback.
  122536. */
  122537. export class WeightedSound {
  122538. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122539. loop: boolean;
  122540. private _coneInnerAngle;
  122541. private _coneOuterAngle;
  122542. private _volume;
  122543. /** A Sound is currently playing. */
  122544. isPlaying: boolean;
  122545. /** A Sound is currently paused. */
  122546. isPaused: boolean;
  122547. private _sounds;
  122548. private _weights;
  122549. private _currentIndex?;
  122550. /**
  122551. * Creates a new WeightedSound from the list of sounds given.
  122552. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122553. * @param sounds Array of Sounds that will be selected from.
  122554. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122555. */
  122556. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122557. /**
  122558. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122559. */
  122560. get directionalConeInnerAngle(): number;
  122561. /**
  122562. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122563. */
  122564. set directionalConeInnerAngle(value: number);
  122565. /**
  122566. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122567. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122568. */
  122569. get directionalConeOuterAngle(): number;
  122570. /**
  122571. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122572. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122573. */
  122574. set directionalConeOuterAngle(value: number);
  122575. /**
  122576. * Playback volume.
  122577. */
  122578. get volume(): number;
  122579. /**
  122580. * Playback volume.
  122581. */
  122582. set volume(value: number);
  122583. private _onended;
  122584. /**
  122585. * Suspend playback
  122586. */
  122587. pause(): void;
  122588. /**
  122589. * Stop playback
  122590. */
  122591. stop(): void;
  122592. /**
  122593. * Start playback.
  122594. * @param startOffset Position the clip head at a specific time in seconds.
  122595. */
  122596. play(startOffset?: number): void;
  122597. }
  122598. }
  122599. declare module BABYLON {
  122600. /**
  122601. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122602. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122603. */
  122604. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122605. /**
  122606. * Gets the name of the behavior.
  122607. */
  122608. get name(): string;
  122609. /**
  122610. * The easing function used by animations
  122611. */
  122612. static EasingFunction: BackEase;
  122613. /**
  122614. * The easing mode used by animations
  122615. */
  122616. static EasingMode: number;
  122617. /**
  122618. * The duration of the animation, in milliseconds
  122619. */
  122620. transitionDuration: number;
  122621. /**
  122622. * Length of the distance animated by the transition when lower radius is reached
  122623. */
  122624. lowerRadiusTransitionRange: number;
  122625. /**
  122626. * Length of the distance animated by the transition when upper radius is reached
  122627. */
  122628. upperRadiusTransitionRange: number;
  122629. private _autoTransitionRange;
  122630. /**
  122631. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122632. */
  122633. get autoTransitionRange(): boolean;
  122634. /**
  122635. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122636. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122637. */
  122638. set autoTransitionRange(value: boolean);
  122639. private _attachedCamera;
  122640. private _onAfterCheckInputsObserver;
  122641. private _onMeshTargetChangedObserver;
  122642. /**
  122643. * Initializes the behavior.
  122644. */
  122645. init(): void;
  122646. /**
  122647. * Attaches the behavior to its arc rotate camera.
  122648. * @param camera Defines the camera to attach the behavior to
  122649. */
  122650. attach(camera: ArcRotateCamera): void;
  122651. /**
  122652. * Detaches the behavior from its current arc rotate camera.
  122653. */
  122654. detach(): void;
  122655. private _radiusIsAnimating;
  122656. private _radiusBounceTransition;
  122657. private _animatables;
  122658. private _cachedWheelPrecision;
  122659. /**
  122660. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122661. * @param radiusLimit The limit to check against.
  122662. * @return Bool to indicate if at limit.
  122663. */
  122664. private _isRadiusAtLimit;
  122665. /**
  122666. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122667. * @param radiusDelta The delta by which to animate to. Can be negative.
  122668. */
  122669. private _applyBoundRadiusAnimation;
  122670. /**
  122671. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122672. */
  122673. protected _clearAnimationLocks(): void;
  122674. /**
  122675. * Stops and removes all animations that have been applied to the camera
  122676. */
  122677. stopAllAnimations(): void;
  122678. }
  122679. }
  122680. declare module BABYLON {
  122681. /**
  122682. * 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.
  122683. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122684. */
  122685. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122686. /**
  122687. * Gets the name of the behavior.
  122688. */
  122689. get name(): string;
  122690. private _mode;
  122691. private _radiusScale;
  122692. private _positionScale;
  122693. private _defaultElevation;
  122694. private _elevationReturnTime;
  122695. private _elevationReturnWaitTime;
  122696. private _zoomStopsAnimation;
  122697. private _framingTime;
  122698. /**
  122699. * The easing function used by animations
  122700. */
  122701. static EasingFunction: ExponentialEase;
  122702. /**
  122703. * The easing mode used by animations
  122704. */
  122705. static EasingMode: number;
  122706. /**
  122707. * Sets the current mode used by the behavior
  122708. */
  122709. set mode(mode: number);
  122710. /**
  122711. * Gets current mode used by the behavior.
  122712. */
  122713. get mode(): number;
  122714. /**
  122715. * Sets the scale applied to the radius (1 by default)
  122716. */
  122717. set radiusScale(radius: number);
  122718. /**
  122719. * Gets the scale applied to the radius
  122720. */
  122721. get radiusScale(): number;
  122722. /**
  122723. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122724. */
  122725. set positionScale(scale: number);
  122726. /**
  122727. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122728. */
  122729. get positionScale(): number;
  122730. /**
  122731. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122732. * behaviour is triggered, in radians.
  122733. */
  122734. set defaultElevation(elevation: number);
  122735. /**
  122736. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122737. * behaviour is triggered, in radians.
  122738. */
  122739. get defaultElevation(): number;
  122740. /**
  122741. * Sets the time (in milliseconds) taken to return to the default beta position.
  122742. * Negative value indicates camera should not return to default.
  122743. */
  122744. set elevationReturnTime(speed: number);
  122745. /**
  122746. * Gets the time (in milliseconds) taken to return to the default beta position.
  122747. * Negative value indicates camera should not return to default.
  122748. */
  122749. get elevationReturnTime(): number;
  122750. /**
  122751. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122752. */
  122753. set elevationReturnWaitTime(time: number);
  122754. /**
  122755. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122756. */
  122757. get elevationReturnWaitTime(): number;
  122758. /**
  122759. * Sets the flag that indicates if user zooming should stop animation.
  122760. */
  122761. set zoomStopsAnimation(flag: boolean);
  122762. /**
  122763. * Gets the flag that indicates if user zooming should stop animation.
  122764. */
  122765. get zoomStopsAnimation(): boolean;
  122766. /**
  122767. * Sets the transition time when framing the mesh, in milliseconds
  122768. */
  122769. set framingTime(time: number);
  122770. /**
  122771. * Gets the transition time when framing the mesh, in milliseconds
  122772. */
  122773. get framingTime(): number;
  122774. /**
  122775. * Define if the behavior should automatically change the configured
  122776. * camera limits and sensibilities.
  122777. */
  122778. autoCorrectCameraLimitsAndSensibility: boolean;
  122779. private _onPrePointerObservableObserver;
  122780. private _onAfterCheckInputsObserver;
  122781. private _onMeshTargetChangedObserver;
  122782. private _attachedCamera;
  122783. private _isPointerDown;
  122784. private _lastInteractionTime;
  122785. /**
  122786. * Initializes the behavior.
  122787. */
  122788. init(): void;
  122789. /**
  122790. * Attaches the behavior to its arc rotate camera.
  122791. * @param camera Defines the camera to attach the behavior to
  122792. */
  122793. attach(camera: ArcRotateCamera): void;
  122794. /**
  122795. * Detaches the behavior from its current arc rotate camera.
  122796. */
  122797. detach(): void;
  122798. private _animatables;
  122799. private _betaIsAnimating;
  122800. private _betaTransition;
  122801. private _radiusTransition;
  122802. private _vectorTransition;
  122803. /**
  122804. * Targets the given mesh and updates zoom level accordingly.
  122805. * @param mesh The mesh to target.
  122806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122808. */
  122809. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122810. /**
  122811. * Targets the given mesh with its children and updates zoom level accordingly.
  122812. * @param mesh The mesh to target.
  122813. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122814. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122815. */
  122816. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122817. /**
  122818. * Targets the given meshes with their children and updates zoom level accordingly.
  122819. * @param meshes The mesh to target.
  122820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122822. */
  122823. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122824. /**
  122825. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122826. * @param minimumWorld Determines the smaller position of the bounding box extend
  122827. * @param maximumWorld Determines the bigger position of the bounding box extend
  122828. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122829. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122830. */
  122831. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122832. /**
  122833. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122834. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122835. * frustum width.
  122836. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122837. * to fully enclose the mesh in the viewing frustum.
  122838. */
  122839. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122840. /**
  122841. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122842. * is automatically returned to its default position (expected to be above ground plane).
  122843. */
  122844. private _maintainCameraAboveGround;
  122845. /**
  122846. * Returns the frustum slope based on the canvas ratio and camera FOV
  122847. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122848. */
  122849. private _getFrustumSlope;
  122850. /**
  122851. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122852. */
  122853. private _clearAnimationLocks;
  122854. /**
  122855. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122856. */
  122857. private _applyUserInteraction;
  122858. /**
  122859. * Stops and removes all animations that have been applied to the camera
  122860. */
  122861. stopAllAnimations(): void;
  122862. /**
  122863. * Gets a value indicating if the user is moving the camera
  122864. */
  122865. get isUserIsMoving(): boolean;
  122866. /**
  122867. * The camera can move all the way towards the mesh.
  122868. */
  122869. static IgnoreBoundsSizeMode: number;
  122870. /**
  122871. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122872. */
  122873. static FitFrustumSidesMode: number;
  122874. }
  122875. }
  122876. declare module BABYLON {
  122877. /**
  122878. * Base class for Camera Pointer Inputs.
  122879. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122880. * for example usage.
  122881. */
  122882. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122883. /**
  122884. * Defines the camera the input is attached to.
  122885. */
  122886. abstract camera: Camera;
  122887. /**
  122888. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122889. */
  122890. protected _altKey: boolean;
  122891. protected _ctrlKey: boolean;
  122892. protected _metaKey: boolean;
  122893. protected _shiftKey: boolean;
  122894. /**
  122895. * Which mouse buttons were pressed at time of last mouse event.
  122896. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122897. */
  122898. protected _buttonsPressed: number;
  122899. /**
  122900. * Defines the buttons associated with the input to handle camera move.
  122901. */
  122902. buttons: number[];
  122903. /**
  122904. * Attach the input controls to a specific dom element to get the input from.
  122905. * @param element Defines the element the controls should be listened from
  122906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122907. */
  122908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122909. /**
  122910. * Detach the current controls from the specified dom element.
  122911. * @param element Defines the element to stop listening the inputs from
  122912. */
  122913. detachControl(element: Nullable<HTMLElement>): void;
  122914. /**
  122915. * Gets the class name of the current input.
  122916. * @returns the class name
  122917. */
  122918. getClassName(): string;
  122919. /**
  122920. * Get the friendly name associated with the input class.
  122921. * @returns the input friendly name
  122922. */
  122923. getSimpleName(): string;
  122924. /**
  122925. * Called on pointer POINTERDOUBLETAP event.
  122926. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122927. */
  122928. protected onDoubleTap(type: string): void;
  122929. /**
  122930. * Called on pointer POINTERMOVE event if only a single touch is active.
  122931. * Override this method to provide functionality.
  122932. */
  122933. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122934. /**
  122935. * Called on pointer POINTERMOVE event if multiple touches are active.
  122936. * Override this method to provide functionality.
  122937. */
  122938. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122939. /**
  122940. * Called on JS contextmenu event.
  122941. * Override this method to provide functionality.
  122942. */
  122943. protected onContextMenu(evt: PointerEvent): void;
  122944. /**
  122945. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122946. * press.
  122947. * Override this method to provide functionality.
  122948. */
  122949. protected onButtonDown(evt: PointerEvent): void;
  122950. /**
  122951. * Called each time a new POINTERUP event occurs. Ie, for each button
  122952. * release.
  122953. * Override this method to provide functionality.
  122954. */
  122955. protected onButtonUp(evt: PointerEvent): void;
  122956. /**
  122957. * Called when window becomes inactive.
  122958. * Override this method to provide functionality.
  122959. */
  122960. protected onLostFocus(): void;
  122961. private _pointerInput;
  122962. private _observer;
  122963. private _onLostFocus;
  122964. private pointA;
  122965. private pointB;
  122966. }
  122967. }
  122968. declare module BABYLON {
  122969. /**
  122970. * Manage the pointers inputs to control an arc rotate camera.
  122971. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122972. */
  122973. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122974. /**
  122975. * Defines the camera the input is attached to.
  122976. */
  122977. camera: ArcRotateCamera;
  122978. /**
  122979. * Gets the class name of the current input.
  122980. * @returns the class name
  122981. */
  122982. getClassName(): string;
  122983. /**
  122984. * Defines the buttons associated with the input to handle camera move.
  122985. */
  122986. buttons: number[];
  122987. /**
  122988. * Defines the pointer angular sensibility along the X axis or how fast is
  122989. * the camera rotating.
  122990. */
  122991. angularSensibilityX: number;
  122992. /**
  122993. * Defines the pointer angular sensibility along the Y axis or how fast is
  122994. * the camera rotating.
  122995. */
  122996. angularSensibilityY: number;
  122997. /**
  122998. * Defines the pointer pinch precision or how fast is the camera zooming.
  122999. */
  123000. pinchPrecision: number;
  123001. /**
  123002. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123003. * from 0.
  123004. * It defines the percentage of current camera.radius to use as delta when
  123005. * pinch zoom is used.
  123006. */
  123007. pinchDeltaPercentage: number;
  123008. /**
  123009. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123010. * that any object in the plane at the camera's target point will scale
  123011. * perfectly with finger motion.
  123012. * Overrides pinchDeltaPercentage and pinchPrecision.
  123013. */
  123014. useNaturalPinchZoom: boolean;
  123015. /**
  123016. * Defines the pointer panning sensibility or how fast is the camera moving.
  123017. */
  123018. panningSensibility: number;
  123019. /**
  123020. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123021. */
  123022. multiTouchPanning: boolean;
  123023. /**
  123024. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123025. * zoom (pinch) through multitouch.
  123026. */
  123027. multiTouchPanAndZoom: boolean;
  123028. /**
  123029. * Revers pinch action direction.
  123030. */
  123031. pinchInwards: boolean;
  123032. private _isPanClick;
  123033. private _twoFingerActivityCount;
  123034. private _isPinching;
  123035. /**
  123036. * Called on pointer POINTERMOVE event if only a single touch is active.
  123037. */
  123038. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123039. /**
  123040. * Called on pointer POINTERDOUBLETAP event.
  123041. */
  123042. protected onDoubleTap(type: string): void;
  123043. /**
  123044. * Called on pointer POINTERMOVE event if multiple touches are active.
  123045. */
  123046. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123047. /**
  123048. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123049. * press.
  123050. */
  123051. protected onButtonDown(evt: PointerEvent): void;
  123052. /**
  123053. * Called each time a new POINTERUP event occurs. Ie, for each button
  123054. * release.
  123055. */
  123056. protected onButtonUp(evt: PointerEvent): void;
  123057. /**
  123058. * Called when window becomes inactive.
  123059. */
  123060. protected onLostFocus(): void;
  123061. }
  123062. }
  123063. declare module BABYLON {
  123064. /**
  123065. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123066. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123067. */
  123068. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123069. /**
  123070. * Defines the camera the input is attached to.
  123071. */
  123072. camera: ArcRotateCamera;
  123073. /**
  123074. * Defines the list of key codes associated with the up action (increase alpha)
  123075. */
  123076. keysUp: number[];
  123077. /**
  123078. * Defines the list of key codes associated with the down action (decrease alpha)
  123079. */
  123080. keysDown: number[];
  123081. /**
  123082. * Defines the list of key codes associated with the left action (increase beta)
  123083. */
  123084. keysLeft: number[];
  123085. /**
  123086. * Defines the list of key codes associated with the right action (decrease beta)
  123087. */
  123088. keysRight: number[];
  123089. /**
  123090. * Defines the list of key codes associated with the reset action.
  123091. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123092. */
  123093. keysReset: number[];
  123094. /**
  123095. * Defines the panning sensibility of the inputs.
  123096. * (How fast is the camera panning)
  123097. */
  123098. panningSensibility: number;
  123099. /**
  123100. * Defines the zooming sensibility of the inputs.
  123101. * (How fast is the camera zooming)
  123102. */
  123103. zoomingSensibility: number;
  123104. /**
  123105. * Defines whether maintaining the alt key down switch the movement mode from
  123106. * orientation to zoom.
  123107. */
  123108. useAltToZoom: boolean;
  123109. /**
  123110. * Rotation speed of the camera
  123111. */
  123112. angularSpeed: number;
  123113. private _keys;
  123114. private _ctrlPressed;
  123115. private _altPressed;
  123116. private _onCanvasBlurObserver;
  123117. private _onKeyboardObserver;
  123118. private _engine;
  123119. private _scene;
  123120. /**
  123121. * Attach the input controls to a specific dom element to get the input from.
  123122. * @param element Defines the element the controls should be listened from
  123123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123124. */
  123125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123126. /**
  123127. * Detach the current controls from the specified dom element.
  123128. * @param element Defines the element to stop listening the inputs from
  123129. */
  123130. detachControl(element: Nullable<HTMLElement>): void;
  123131. /**
  123132. * Update the current camera state depending on the inputs that have been used this frame.
  123133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123134. */
  123135. checkInputs(): void;
  123136. /**
  123137. * Gets the class name of the current intput.
  123138. * @returns the class name
  123139. */
  123140. getClassName(): string;
  123141. /**
  123142. * Get the friendly name associated with the input class.
  123143. * @returns the input friendly name
  123144. */
  123145. getSimpleName(): string;
  123146. }
  123147. }
  123148. declare module BABYLON {
  123149. /**
  123150. * Manage the mouse wheel inputs to control an arc rotate camera.
  123151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123152. */
  123153. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123154. /**
  123155. * Defines the camera the input is attached to.
  123156. */
  123157. camera: ArcRotateCamera;
  123158. /**
  123159. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123160. */
  123161. wheelPrecision: number;
  123162. /**
  123163. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123164. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123165. */
  123166. wheelDeltaPercentage: number;
  123167. private _wheel;
  123168. private _observer;
  123169. private computeDeltaFromMouseWheelLegacyEvent;
  123170. /**
  123171. * Attach the input controls to a specific dom element to get the input from.
  123172. * @param element Defines the element the controls should be listened from
  123173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123174. */
  123175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123176. /**
  123177. * Detach the current controls from the specified dom element.
  123178. * @param element Defines the element to stop listening the inputs from
  123179. */
  123180. detachControl(element: Nullable<HTMLElement>): void;
  123181. /**
  123182. * Gets the class name of the current intput.
  123183. * @returns the class name
  123184. */
  123185. getClassName(): string;
  123186. /**
  123187. * Get the friendly name associated with the input class.
  123188. * @returns the input friendly name
  123189. */
  123190. getSimpleName(): string;
  123191. }
  123192. }
  123193. declare module BABYLON {
  123194. /**
  123195. * Default Inputs manager for the ArcRotateCamera.
  123196. * It groups all the default supported inputs for ease of use.
  123197. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123198. */
  123199. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123200. /**
  123201. * Instantiates a new ArcRotateCameraInputsManager.
  123202. * @param camera Defines the camera the inputs belong to
  123203. */
  123204. constructor(camera: ArcRotateCamera);
  123205. /**
  123206. * Add mouse wheel input support to the input manager.
  123207. * @returns the current input manager
  123208. */
  123209. addMouseWheel(): ArcRotateCameraInputsManager;
  123210. /**
  123211. * Add pointers input support to the input manager.
  123212. * @returns the current input manager
  123213. */
  123214. addPointers(): ArcRotateCameraInputsManager;
  123215. /**
  123216. * Add keyboard input support to the input manager.
  123217. * @returns the current input manager
  123218. */
  123219. addKeyboard(): ArcRotateCameraInputsManager;
  123220. }
  123221. }
  123222. declare module BABYLON {
  123223. /**
  123224. * This represents an orbital type of camera.
  123225. *
  123226. * 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.
  123227. * 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.
  123228. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123229. */
  123230. export class ArcRotateCamera extends TargetCamera {
  123231. /**
  123232. * Defines the rotation angle of the camera along the longitudinal axis.
  123233. */
  123234. alpha: number;
  123235. /**
  123236. * Defines the rotation angle of the camera along the latitudinal axis.
  123237. */
  123238. beta: number;
  123239. /**
  123240. * Defines the radius of the camera from it s target point.
  123241. */
  123242. radius: number;
  123243. protected _target: Vector3;
  123244. protected _targetHost: Nullable<AbstractMesh>;
  123245. /**
  123246. * Defines the target point of the camera.
  123247. * The camera looks towards it form the radius distance.
  123248. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123249. */
  123250. get target(): Vector3;
  123251. set target(value: Vector3);
  123252. /**
  123253. * Define the current local position of the camera in the scene
  123254. */
  123255. get position(): Vector3;
  123256. set position(newPosition: Vector3);
  123257. protected _upToYMatrix: Matrix;
  123258. protected _YToUpMatrix: Matrix;
  123259. /**
  123260. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123261. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123262. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123263. */
  123264. set upVector(vec: Vector3);
  123265. get upVector(): Vector3;
  123266. /**
  123267. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123268. */
  123269. setMatUp(): void;
  123270. /**
  123271. * Current inertia value on the longitudinal axis.
  123272. * The bigger this number the longer it will take for the camera to stop.
  123273. */
  123274. inertialAlphaOffset: number;
  123275. /**
  123276. * Current inertia value on the latitudinal axis.
  123277. * The bigger this number the longer it will take for the camera to stop.
  123278. */
  123279. inertialBetaOffset: number;
  123280. /**
  123281. * Current inertia value on the radius axis.
  123282. * The bigger this number the longer it will take for the camera to stop.
  123283. */
  123284. inertialRadiusOffset: number;
  123285. /**
  123286. * Minimum allowed angle on the longitudinal axis.
  123287. * This can help limiting how the Camera is able to move in the scene.
  123288. */
  123289. lowerAlphaLimit: Nullable<number>;
  123290. /**
  123291. * Maximum allowed angle on the longitudinal axis.
  123292. * This can help limiting how the Camera is able to move in the scene.
  123293. */
  123294. upperAlphaLimit: Nullable<number>;
  123295. /**
  123296. * Minimum allowed angle on the latitudinal axis.
  123297. * This can help limiting how the Camera is able to move in the scene.
  123298. */
  123299. lowerBetaLimit: number;
  123300. /**
  123301. * Maximum allowed angle on the latitudinal axis.
  123302. * This can help limiting how the Camera is able to move in the scene.
  123303. */
  123304. upperBetaLimit: number;
  123305. /**
  123306. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123307. * This can help limiting how the Camera is able to move in the scene.
  123308. */
  123309. lowerRadiusLimit: Nullable<number>;
  123310. /**
  123311. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123312. * This can help limiting how the Camera is able to move in the scene.
  123313. */
  123314. upperRadiusLimit: Nullable<number>;
  123315. /**
  123316. * Defines the current inertia value used during panning of the camera along the X axis.
  123317. */
  123318. inertialPanningX: number;
  123319. /**
  123320. * Defines the current inertia value used during panning of the camera along the Y axis.
  123321. */
  123322. inertialPanningY: number;
  123323. /**
  123324. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123325. * Basically if your fingers moves away from more than this distance you will be considered
  123326. * in pinch mode.
  123327. */
  123328. pinchToPanMaxDistance: number;
  123329. /**
  123330. * Defines the maximum distance the camera can pan.
  123331. * This could help keeping the cammera always in your scene.
  123332. */
  123333. panningDistanceLimit: Nullable<number>;
  123334. /**
  123335. * Defines the target of the camera before paning.
  123336. */
  123337. panningOriginTarget: Vector3;
  123338. /**
  123339. * Defines the value of the inertia used during panning.
  123340. * 0 would mean stop inertia and one would mean no decelleration at all.
  123341. */
  123342. panningInertia: number;
  123343. /**
  123344. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123345. */
  123346. get angularSensibilityX(): number;
  123347. set angularSensibilityX(value: number);
  123348. /**
  123349. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123350. */
  123351. get angularSensibilityY(): number;
  123352. set angularSensibilityY(value: number);
  123353. /**
  123354. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123355. */
  123356. get pinchPrecision(): number;
  123357. set pinchPrecision(value: number);
  123358. /**
  123359. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123360. * It will be used instead of pinchDeltaPrecision if different from 0.
  123361. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123362. */
  123363. get pinchDeltaPercentage(): number;
  123364. set pinchDeltaPercentage(value: number);
  123365. /**
  123366. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123367. * and pinch delta percentage.
  123368. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123369. * that any object in the plane at the camera's target point will scale
  123370. * perfectly with finger motion.
  123371. */
  123372. get useNaturalPinchZoom(): boolean;
  123373. set useNaturalPinchZoom(value: boolean);
  123374. /**
  123375. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123376. */
  123377. get panningSensibility(): number;
  123378. set panningSensibility(value: number);
  123379. /**
  123380. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123381. */
  123382. get keysUp(): number[];
  123383. set keysUp(value: number[]);
  123384. /**
  123385. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123386. */
  123387. get keysDown(): number[];
  123388. set keysDown(value: number[]);
  123389. /**
  123390. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123391. */
  123392. get keysLeft(): number[];
  123393. set keysLeft(value: number[]);
  123394. /**
  123395. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123396. */
  123397. get keysRight(): number[];
  123398. set keysRight(value: number[]);
  123399. /**
  123400. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123401. */
  123402. get wheelPrecision(): number;
  123403. set wheelPrecision(value: number);
  123404. /**
  123405. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123406. * It will be used instead of pinchDeltaPrecision if different from 0.
  123407. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123408. */
  123409. get wheelDeltaPercentage(): number;
  123410. set wheelDeltaPercentage(value: number);
  123411. /**
  123412. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123413. */
  123414. zoomOnFactor: number;
  123415. /**
  123416. * Defines a screen offset for the camera position.
  123417. */
  123418. targetScreenOffset: Vector2;
  123419. /**
  123420. * Allows the camera to be completely reversed.
  123421. * If false the camera can not arrive upside down.
  123422. */
  123423. allowUpsideDown: boolean;
  123424. /**
  123425. * Define if double tap/click is used to restore the previously saved state of the camera.
  123426. */
  123427. useInputToRestoreState: boolean;
  123428. /** @hidden */
  123429. _viewMatrix: Matrix;
  123430. /** @hidden */
  123431. _useCtrlForPanning: boolean;
  123432. /** @hidden */
  123433. _panningMouseButton: number;
  123434. /**
  123435. * Defines the input associated to the camera.
  123436. */
  123437. inputs: ArcRotateCameraInputsManager;
  123438. /** @hidden */
  123439. _reset: () => void;
  123440. /**
  123441. * Defines the allowed panning axis.
  123442. */
  123443. panningAxis: Vector3;
  123444. protected _localDirection: Vector3;
  123445. protected _transformedDirection: Vector3;
  123446. private _bouncingBehavior;
  123447. /**
  123448. * Gets the bouncing behavior of the camera if it has been enabled.
  123449. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123450. */
  123451. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123452. /**
  123453. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123454. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123455. */
  123456. get useBouncingBehavior(): boolean;
  123457. set useBouncingBehavior(value: boolean);
  123458. private _framingBehavior;
  123459. /**
  123460. * Gets the framing behavior of the camera if it has been enabled.
  123461. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123462. */
  123463. get framingBehavior(): Nullable<FramingBehavior>;
  123464. /**
  123465. * Defines if the framing behavior of the camera is enabled on the camera.
  123466. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123467. */
  123468. get useFramingBehavior(): boolean;
  123469. set useFramingBehavior(value: boolean);
  123470. private _autoRotationBehavior;
  123471. /**
  123472. * Gets the auto rotation behavior of the camera if it has been enabled.
  123473. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123474. */
  123475. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123476. /**
  123477. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123478. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123479. */
  123480. get useAutoRotationBehavior(): boolean;
  123481. set useAutoRotationBehavior(value: boolean);
  123482. /**
  123483. * Observable triggered when the mesh target has been changed on the camera.
  123484. */
  123485. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123486. /**
  123487. * Event raised when the camera is colliding with a mesh.
  123488. */
  123489. onCollide: (collidedMesh: AbstractMesh) => void;
  123490. /**
  123491. * Defines whether the camera should check collision with the objects oh the scene.
  123492. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123493. */
  123494. checkCollisions: boolean;
  123495. /**
  123496. * Defines the collision radius of the camera.
  123497. * This simulates a sphere around the camera.
  123498. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123499. */
  123500. collisionRadius: Vector3;
  123501. protected _collider: Collider;
  123502. protected _previousPosition: Vector3;
  123503. protected _collisionVelocity: Vector3;
  123504. protected _newPosition: Vector3;
  123505. protected _previousAlpha: number;
  123506. protected _previousBeta: number;
  123507. protected _previousRadius: number;
  123508. protected _collisionTriggered: boolean;
  123509. protected _targetBoundingCenter: Nullable<Vector3>;
  123510. private _computationVector;
  123511. /**
  123512. * Instantiates a new ArcRotateCamera in a given scene
  123513. * @param name Defines the name of the camera
  123514. * @param alpha Defines the camera rotation along the logitudinal axis
  123515. * @param beta Defines the camera rotation along the latitudinal axis
  123516. * @param radius Defines the camera distance from its target
  123517. * @param target Defines the camera target
  123518. * @param scene Defines the scene the camera belongs to
  123519. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123520. */
  123521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123522. /** @hidden */
  123523. _initCache(): void;
  123524. /** @hidden */
  123525. _updateCache(ignoreParentClass?: boolean): void;
  123526. protected _getTargetPosition(): Vector3;
  123527. private _storedAlpha;
  123528. private _storedBeta;
  123529. private _storedRadius;
  123530. private _storedTarget;
  123531. private _storedTargetScreenOffset;
  123532. /**
  123533. * Stores the current state of the camera (alpha, beta, radius and target)
  123534. * @returns the camera itself
  123535. */
  123536. storeState(): Camera;
  123537. /**
  123538. * @hidden
  123539. * Restored camera state. You must call storeState() first
  123540. */
  123541. _restoreStateValues(): boolean;
  123542. /** @hidden */
  123543. _isSynchronizedViewMatrix(): boolean;
  123544. /**
  123545. * Attached controls to the current camera.
  123546. * @param element Defines the element the controls should be listened from
  123547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123548. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123549. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123550. */
  123551. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123552. /**
  123553. * Detach the current controls from the camera.
  123554. * The camera will stop reacting to inputs.
  123555. * @param element Defines the element to stop listening the inputs from
  123556. */
  123557. detachControl(element: HTMLElement): void;
  123558. /** @hidden */
  123559. _checkInputs(): void;
  123560. protected _checkLimits(): void;
  123561. /**
  123562. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123563. */
  123564. rebuildAnglesAndRadius(): void;
  123565. /**
  123566. * Use a position to define the current camera related information like alpha, beta and radius
  123567. * @param position Defines the position to set the camera at
  123568. */
  123569. setPosition(position: Vector3): void;
  123570. /**
  123571. * Defines the target the camera should look at.
  123572. * This will automatically adapt alpha beta and radius to fit within the new target.
  123573. * @param target Defines the new target as a Vector or a mesh
  123574. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123575. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123576. */
  123577. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123578. /** @hidden */
  123579. _getViewMatrix(): Matrix;
  123580. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123581. /**
  123582. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123583. * @param meshes Defines the mesh to zoom on
  123584. * @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)
  123585. */
  123586. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123587. /**
  123588. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123589. * The target will be changed but the radius
  123590. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123591. * @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)
  123592. */
  123593. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123594. min: Vector3;
  123595. max: Vector3;
  123596. distance: number;
  123597. }, doNotUpdateMaxZ?: boolean): void;
  123598. /**
  123599. * @override
  123600. * Override Camera.createRigCamera
  123601. */
  123602. createRigCamera(name: string, cameraIndex: number): Camera;
  123603. /**
  123604. * @hidden
  123605. * @override
  123606. * Override Camera._updateRigCameras
  123607. */
  123608. _updateRigCameras(): void;
  123609. /**
  123610. * Destroy the camera and release the current resources hold by it.
  123611. */
  123612. dispose(): void;
  123613. /**
  123614. * Gets the current object class name.
  123615. * @return the class name
  123616. */
  123617. getClassName(): string;
  123618. }
  123619. }
  123620. declare module BABYLON {
  123621. /**
  123622. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123623. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123624. */
  123625. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123626. /**
  123627. * Gets the name of the behavior.
  123628. */
  123629. get name(): string;
  123630. private _zoomStopsAnimation;
  123631. private _idleRotationSpeed;
  123632. private _idleRotationWaitTime;
  123633. private _idleRotationSpinupTime;
  123634. /**
  123635. * Sets the flag that indicates if user zooming should stop animation.
  123636. */
  123637. set zoomStopsAnimation(flag: boolean);
  123638. /**
  123639. * Gets the flag that indicates if user zooming should stop animation.
  123640. */
  123641. get zoomStopsAnimation(): boolean;
  123642. /**
  123643. * Sets the default speed at which the camera rotates around the model.
  123644. */
  123645. set idleRotationSpeed(speed: number);
  123646. /**
  123647. * Gets the default speed at which the camera rotates around the model.
  123648. */
  123649. get idleRotationSpeed(): number;
  123650. /**
  123651. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123652. */
  123653. set idleRotationWaitTime(time: number);
  123654. /**
  123655. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123656. */
  123657. get idleRotationWaitTime(): number;
  123658. /**
  123659. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123660. */
  123661. set idleRotationSpinupTime(time: number);
  123662. /**
  123663. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123664. */
  123665. get idleRotationSpinupTime(): number;
  123666. /**
  123667. * Gets a value indicating if the camera is currently rotating because of this behavior
  123668. */
  123669. get rotationInProgress(): boolean;
  123670. private _onPrePointerObservableObserver;
  123671. private _onAfterCheckInputsObserver;
  123672. private _attachedCamera;
  123673. private _isPointerDown;
  123674. private _lastFrameTime;
  123675. private _lastInteractionTime;
  123676. private _cameraRotationSpeed;
  123677. /**
  123678. * Initializes the behavior.
  123679. */
  123680. init(): void;
  123681. /**
  123682. * Attaches the behavior to its arc rotate camera.
  123683. * @param camera Defines the camera to attach the behavior to
  123684. */
  123685. attach(camera: ArcRotateCamera): void;
  123686. /**
  123687. * Detaches the behavior from its current arc rotate camera.
  123688. */
  123689. detach(): void;
  123690. /**
  123691. * Returns true if user is scrolling.
  123692. * @return true if user is scrolling.
  123693. */
  123694. private _userIsZooming;
  123695. private _lastFrameRadius;
  123696. private _shouldAnimationStopForInteraction;
  123697. /**
  123698. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123699. */
  123700. private _applyUserInteraction;
  123701. private _userIsMoving;
  123702. }
  123703. }
  123704. declare module BABYLON {
  123705. /**
  123706. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123707. */
  123708. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123709. private ui;
  123710. /**
  123711. * The name of the behavior
  123712. */
  123713. name: string;
  123714. /**
  123715. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123716. */
  123717. distanceAwayFromFace: number;
  123718. /**
  123719. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123720. */
  123721. distanceAwayFromBottomOfFace: number;
  123722. private _faceVectors;
  123723. private _target;
  123724. private _scene;
  123725. private _onRenderObserver;
  123726. private _tmpMatrix;
  123727. private _tmpVector;
  123728. /**
  123729. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123730. * @param ui The transform node that should be attched to the mesh
  123731. */
  123732. constructor(ui: TransformNode);
  123733. /**
  123734. * Initializes the behavior
  123735. */
  123736. init(): void;
  123737. private _closestFace;
  123738. private _zeroVector;
  123739. private _lookAtTmpMatrix;
  123740. private _lookAtToRef;
  123741. /**
  123742. * Attaches the AttachToBoxBehavior to the passed in mesh
  123743. * @param target The mesh that the specified node will be attached to
  123744. */
  123745. attach(target: Mesh): void;
  123746. /**
  123747. * Detaches the behavior from the mesh
  123748. */
  123749. detach(): void;
  123750. }
  123751. }
  123752. declare module BABYLON {
  123753. /**
  123754. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123755. */
  123756. export class FadeInOutBehavior implements Behavior<Mesh> {
  123757. /**
  123758. * Time in milliseconds to delay before fading in (Default: 0)
  123759. */
  123760. delay: number;
  123761. /**
  123762. * Time in milliseconds for the mesh to fade in (Default: 300)
  123763. */
  123764. fadeInTime: number;
  123765. private _millisecondsPerFrame;
  123766. private _hovered;
  123767. private _hoverValue;
  123768. private _ownerNode;
  123769. /**
  123770. * Instatiates the FadeInOutBehavior
  123771. */
  123772. constructor();
  123773. /**
  123774. * The name of the behavior
  123775. */
  123776. get name(): string;
  123777. /**
  123778. * Initializes the behavior
  123779. */
  123780. init(): void;
  123781. /**
  123782. * Attaches the fade behavior on the passed in mesh
  123783. * @param ownerNode The mesh that will be faded in/out once attached
  123784. */
  123785. attach(ownerNode: Mesh): void;
  123786. /**
  123787. * Detaches the behavior from the mesh
  123788. */
  123789. detach(): void;
  123790. /**
  123791. * Triggers the mesh to begin fading in or out
  123792. * @param value if the object should fade in or out (true to fade in)
  123793. */
  123794. fadeIn(value: boolean): void;
  123795. private _update;
  123796. private _setAllVisibility;
  123797. }
  123798. }
  123799. declare module BABYLON {
  123800. /**
  123801. * Class containing a set of static utilities functions for managing Pivots
  123802. * @hidden
  123803. */
  123804. export class PivotTools {
  123805. private static _PivotCached;
  123806. private static _OldPivotPoint;
  123807. private static _PivotTranslation;
  123808. private static _PivotTmpVector;
  123809. private static _PivotPostMultiplyPivotMatrix;
  123810. /** @hidden */
  123811. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123812. /** @hidden */
  123813. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123814. }
  123815. }
  123816. declare module BABYLON {
  123817. /**
  123818. * Class containing static functions to help procedurally build meshes
  123819. */
  123820. export class PlaneBuilder {
  123821. /**
  123822. * Creates a plane mesh
  123823. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123824. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123825. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123829. * @param name defines the name of the mesh
  123830. * @param options defines the options used to create the mesh
  123831. * @param scene defines the hosting scene
  123832. * @returns the plane mesh
  123833. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123834. */
  123835. static CreatePlane(name: string, options: {
  123836. size?: number;
  123837. width?: number;
  123838. height?: number;
  123839. sideOrientation?: number;
  123840. frontUVs?: Vector4;
  123841. backUVs?: Vector4;
  123842. updatable?: boolean;
  123843. sourcePlane?: Plane;
  123844. }, scene?: Nullable<Scene>): Mesh;
  123845. }
  123846. }
  123847. declare module BABYLON {
  123848. /**
  123849. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123850. */
  123851. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123852. private static _AnyMouseID;
  123853. /**
  123854. * Abstract mesh the behavior is set on
  123855. */
  123856. attachedNode: AbstractMesh;
  123857. private _dragPlane;
  123858. private _scene;
  123859. private _pointerObserver;
  123860. private _beforeRenderObserver;
  123861. private static _planeScene;
  123862. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123863. /**
  123864. * 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)
  123865. */
  123866. maxDragAngle: number;
  123867. /**
  123868. * @hidden
  123869. */
  123870. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123871. /**
  123872. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123873. */
  123874. currentDraggingPointerID: number;
  123875. /**
  123876. * The last position where the pointer hit the drag plane in world space
  123877. */
  123878. lastDragPosition: Vector3;
  123879. /**
  123880. * If the behavior is currently in a dragging state
  123881. */
  123882. dragging: boolean;
  123883. /**
  123884. * 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)
  123885. */
  123886. dragDeltaRatio: number;
  123887. /**
  123888. * If the drag plane orientation should be updated during the dragging (Default: true)
  123889. */
  123890. updateDragPlane: boolean;
  123891. private _debugMode;
  123892. private _moving;
  123893. /**
  123894. * Fires each time the attached mesh is dragged with the pointer
  123895. * * delta between last drag position and current drag position in world space
  123896. * * dragDistance along the drag axis
  123897. * * dragPlaneNormal normal of the current drag plane used during the drag
  123898. * * dragPlanePoint in world space where the drag intersects the drag plane
  123899. */
  123900. onDragObservable: Observable<{
  123901. delta: Vector3;
  123902. dragPlanePoint: Vector3;
  123903. dragPlaneNormal: Vector3;
  123904. dragDistance: number;
  123905. pointerId: number;
  123906. }>;
  123907. /**
  123908. * Fires each time a drag begins (eg. mouse down on mesh)
  123909. */
  123910. onDragStartObservable: Observable<{
  123911. dragPlanePoint: Vector3;
  123912. pointerId: number;
  123913. }>;
  123914. /**
  123915. * Fires each time a drag ends (eg. mouse release after drag)
  123916. */
  123917. onDragEndObservable: Observable<{
  123918. dragPlanePoint: Vector3;
  123919. pointerId: number;
  123920. }>;
  123921. /**
  123922. * If the attached mesh should be moved when dragged
  123923. */
  123924. moveAttached: boolean;
  123925. /**
  123926. * If the drag behavior will react to drag events (Default: true)
  123927. */
  123928. enabled: boolean;
  123929. /**
  123930. * If pointer events should start and release the drag (Default: true)
  123931. */
  123932. startAndReleaseDragOnPointerEvents: boolean;
  123933. /**
  123934. * If camera controls should be detached during the drag
  123935. */
  123936. detachCameraControls: boolean;
  123937. /**
  123938. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123939. */
  123940. useObjectOrientationForDragging: boolean;
  123941. private _options;
  123942. /**
  123943. * Gets the options used by the behavior
  123944. */
  123945. get options(): {
  123946. dragAxis?: Vector3;
  123947. dragPlaneNormal?: Vector3;
  123948. };
  123949. /**
  123950. * Sets the options used by the behavior
  123951. */
  123952. set options(options: {
  123953. dragAxis?: Vector3;
  123954. dragPlaneNormal?: Vector3;
  123955. });
  123956. /**
  123957. * Creates a pointer drag behavior that can be attached to a mesh
  123958. * @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)
  123959. */
  123960. constructor(options?: {
  123961. dragAxis?: Vector3;
  123962. dragPlaneNormal?: Vector3;
  123963. });
  123964. /**
  123965. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123966. */
  123967. validateDrag: (targetPosition: Vector3) => boolean;
  123968. /**
  123969. * The name of the behavior
  123970. */
  123971. get name(): string;
  123972. /**
  123973. * Initializes the behavior
  123974. */
  123975. init(): void;
  123976. private _tmpVector;
  123977. private _alternatePickedPoint;
  123978. private _worldDragAxis;
  123979. private _targetPosition;
  123980. private _attachedElement;
  123981. /**
  123982. * Attaches the drag behavior the passed in mesh
  123983. * @param ownerNode The mesh that will be dragged around once attached
  123984. * @param predicate Predicate to use for pick filtering
  123985. */
  123986. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123987. /**
  123988. * Force relase the drag action by code.
  123989. */
  123990. releaseDrag(): void;
  123991. private _startDragRay;
  123992. private _lastPointerRay;
  123993. /**
  123994. * Simulates the start of a pointer drag event on the behavior
  123995. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123996. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123997. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123998. */
  123999. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124000. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124001. private _dragDelta;
  124002. protected _moveDrag(ray: Ray): void;
  124003. private _pickWithRayOnDragPlane;
  124004. private _pointA;
  124005. private _pointC;
  124006. private _localAxis;
  124007. private _lookAt;
  124008. private _updateDragPlanePosition;
  124009. /**
  124010. * Detaches the behavior from the mesh
  124011. */
  124012. detach(): void;
  124013. }
  124014. }
  124015. declare module BABYLON {
  124016. /**
  124017. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124018. */
  124019. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124020. private _dragBehaviorA;
  124021. private _dragBehaviorB;
  124022. private _startDistance;
  124023. private _initialScale;
  124024. private _targetScale;
  124025. private _ownerNode;
  124026. private _sceneRenderObserver;
  124027. /**
  124028. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124029. */
  124030. constructor();
  124031. /**
  124032. * The name of the behavior
  124033. */
  124034. get name(): string;
  124035. /**
  124036. * Initializes the behavior
  124037. */
  124038. init(): void;
  124039. private _getCurrentDistance;
  124040. /**
  124041. * Attaches the scale behavior the passed in mesh
  124042. * @param ownerNode The mesh that will be scaled around once attached
  124043. */
  124044. attach(ownerNode: Mesh): void;
  124045. /**
  124046. * Detaches the behavior from the mesh
  124047. */
  124048. detach(): void;
  124049. }
  124050. }
  124051. declare module BABYLON {
  124052. /**
  124053. * 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
  124054. */
  124055. export class SixDofDragBehavior implements Behavior<Mesh> {
  124056. private static _virtualScene;
  124057. private _ownerNode;
  124058. private _sceneRenderObserver;
  124059. private _scene;
  124060. private _targetPosition;
  124061. private _virtualOriginMesh;
  124062. private _virtualDragMesh;
  124063. private _pointerObserver;
  124064. private _moving;
  124065. private _startingOrientation;
  124066. private _attachedElement;
  124067. /**
  124068. * 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)
  124069. */
  124070. private zDragFactor;
  124071. /**
  124072. * If the object should rotate to face the drag origin
  124073. */
  124074. rotateDraggedObject: boolean;
  124075. /**
  124076. * If the behavior is currently in a dragging state
  124077. */
  124078. dragging: boolean;
  124079. /**
  124080. * 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)
  124081. */
  124082. dragDeltaRatio: number;
  124083. /**
  124084. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124085. */
  124086. currentDraggingPointerID: number;
  124087. /**
  124088. * If camera controls should be detached during the drag
  124089. */
  124090. detachCameraControls: boolean;
  124091. /**
  124092. * Fires each time a drag starts
  124093. */
  124094. onDragStartObservable: Observable<{}>;
  124095. /**
  124096. * Fires each time a drag ends (eg. mouse release after drag)
  124097. */
  124098. onDragEndObservable: Observable<{}>;
  124099. /**
  124100. * 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
  124101. */
  124102. constructor();
  124103. /**
  124104. * The name of the behavior
  124105. */
  124106. get name(): string;
  124107. /**
  124108. * Initializes the behavior
  124109. */
  124110. init(): void;
  124111. /**
  124112. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124113. */
  124114. private get _pointerCamera();
  124115. /**
  124116. * Attaches the scale behavior the passed in mesh
  124117. * @param ownerNode The mesh that will be scaled around once attached
  124118. */
  124119. attach(ownerNode: Mesh): void;
  124120. /**
  124121. * Detaches the behavior from the mesh
  124122. */
  124123. detach(): void;
  124124. }
  124125. }
  124126. declare module BABYLON {
  124127. /**
  124128. * Class used to apply inverse kinematics to bones
  124129. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124130. */
  124131. export class BoneIKController {
  124132. private static _tmpVecs;
  124133. private static _tmpQuat;
  124134. private static _tmpMats;
  124135. /**
  124136. * Gets or sets the target mesh
  124137. */
  124138. targetMesh: AbstractMesh;
  124139. /** Gets or sets the mesh used as pole */
  124140. poleTargetMesh: AbstractMesh;
  124141. /**
  124142. * Gets or sets the bone used as pole
  124143. */
  124144. poleTargetBone: Nullable<Bone>;
  124145. /**
  124146. * Gets or sets the target position
  124147. */
  124148. targetPosition: Vector3;
  124149. /**
  124150. * Gets or sets the pole target position
  124151. */
  124152. poleTargetPosition: Vector3;
  124153. /**
  124154. * Gets or sets the pole target local offset
  124155. */
  124156. poleTargetLocalOffset: Vector3;
  124157. /**
  124158. * Gets or sets the pole angle
  124159. */
  124160. poleAngle: number;
  124161. /**
  124162. * Gets or sets the mesh associated with the controller
  124163. */
  124164. mesh: AbstractMesh;
  124165. /**
  124166. * 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)
  124167. */
  124168. slerpAmount: number;
  124169. private _bone1Quat;
  124170. private _bone1Mat;
  124171. private _bone2Ang;
  124172. private _bone1;
  124173. private _bone2;
  124174. private _bone1Length;
  124175. private _bone2Length;
  124176. private _maxAngle;
  124177. private _maxReach;
  124178. private _rightHandedSystem;
  124179. private _bendAxis;
  124180. private _slerping;
  124181. private _adjustRoll;
  124182. /**
  124183. * Gets or sets maximum allowed angle
  124184. */
  124185. get maxAngle(): number;
  124186. set maxAngle(value: number);
  124187. /**
  124188. * Creates a new BoneIKController
  124189. * @param mesh defines the mesh to control
  124190. * @param bone defines the bone to control
  124191. * @param options defines options to set up the controller
  124192. */
  124193. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124194. targetMesh?: AbstractMesh;
  124195. poleTargetMesh?: AbstractMesh;
  124196. poleTargetBone?: Bone;
  124197. poleTargetLocalOffset?: Vector3;
  124198. poleAngle?: number;
  124199. bendAxis?: Vector3;
  124200. maxAngle?: number;
  124201. slerpAmount?: number;
  124202. });
  124203. private _setMaxAngle;
  124204. /**
  124205. * Force the controller to update the bones
  124206. */
  124207. update(): void;
  124208. }
  124209. }
  124210. declare module BABYLON {
  124211. /**
  124212. * Class used to make a bone look toward a point in space
  124213. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124214. */
  124215. export class BoneLookController {
  124216. private static _tmpVecs;
  124217. private static _tmpQuat;
  124218. private static _tmpMats;
  124219. /**
  124220. * The target Vector3 that the bone will look at
  124221. */
  124222. target: Vector3;
  124223. /**
  124224. * The mesh that the bone is attached to
  124225. */
  124226. mesh: AbstractMesh;
  124227. /**
  124228. * The bone that will be looking to the target
  124229. */
  124230. bone: Bone;
  124231. /**
  124232. * The up axis of the coordinate system that is used when the bone is rotated
  124233. */
  124234. upAxis: Vector3;
  124235. /**
  124236. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124237. */
  124238. upAxisSpace: Space;
  124239. /**
  124240. * Used to make an adjustment to the yaw of the bone
  124241. */
  124242. adjustYaw: number;
  124243. /**
  124244. * Used to make an adjustment to the pitch of the bone
  124245. */
  124246. adjustPitch: number;
  124247. /**
  124248. * Used to make an adjustment to the roll of the bone
  124249. */
  124250. adjustRoll: number;
  124251. /**
  124252. * 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)
  124253. */
  124254. slerpAmount: number;
  124255. private _minYaw;
  124256. private _maxYaw;
  124257. private _minPitch;
  124258. private _maxPitch;
  124259. private _minYawSin;
  124260. private _minYawCos;
  124261. private _maxYawSin;
  124262. private _maxYawCos;
  124263. private _midYawConstraint;
  124264. private _minPitchTan;
  124265. private _maxPitchTan;
  124266. private _boneQuat;
  124267. private _slerping;
  124268. private _transformYawPitch;
  124269. private _transformYawPitchInv;
  124270. private _firstFrameSkipped;
  124271. private _yawRange;
  124272. private _fowardAxis;
  124273. /**
  124274. * Gets or sets the minimum yaw angle that the bone can look to
  124275. */
  124276. get minYaw(): number;
  124277. set minYaw(value: number);
  124278. /**
  124279. * Gets or sets the maximum yaw angle that the bone can look to
  124280. */
  124281. get maxYaw(): number;
  124282. set maxYaw(value: number);
  124283. /**
  124284. * Gets or sets the minimum pitch angle that the bone can look to
  124285. */
  124286. get minPitch(): number;
  124287. set minPitch(value: number);
  124288. /**
  124289. * Gets or sets the maximum pitch angle that the bone can look to
  124290. */
  124291. get maxPitch(): number;
  124292. set maxPitch(value: number);
  124293. /**
  124294. * Create a BoneLookController
  124295. * @param mesh the mesh that the bone belongs to
  124296. * @param bone the bone that will be looking to the target
  124297. * @param target the target Vector3 to look at
  124298. * @param options optional settings:
  124299. * * maxYaw: the maximum angle the bone will yaw to
  124300. * * minYaw: the minimum angle the bone will yaw to
  124301. * * maxPitch: the maximum angle the bone will pitch to
  124302. * * minPitch: the minimum angle the bone will yaw to
  124303. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124304. * * upAxis: the up axis of the coordinate system
  124305. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124306. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124307. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124308. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124309. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124310. * * adjustRoll: used to make an adjustment to the roll of the bone
  124311. **/
  124312. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124313. maxYaw?: number;
  124314. minYaw?: number;
  124315. maxPitch?: number;
  124316. minPitch?: number;
  124317. slerpAmount?: number;
  124318. upAxis?: Vector3;
  124319. upAxisSpace?: Space;
  124320. yawAxis?: Vector3;
  124321. pitchAxis?: Vector3;
  124322. adjustYaw?: number;
  124323. adjustPitch?: number;
  124324. adjustRoll?: number;
  124325. });
  124326. /**
  124327. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124328. */
  124329. update(): void;
  124330. private _getAngleDiff;
  124331. private _getAngleBetween;
  124332. private _isAngleBetween;
  124333. }
  124334. }
  124335. declare module BABYLON {
  124336. /**
  124337. * Manage the gamepad inputs to control an arc rotate camera.
  124338. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124339. */
  124340. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124341. /**
  124342. * Defines the camera the input is attached to.
  124343. */
  124344. camera: ArcRotateCamera;
  124345. /**
  124346. * Defines the gamepad the input is gathering event from.
  124347. */
  124348. gamepad: Nullable<Gamepad>;
  124349. /**
  124350. * Defines the gamepad rotation sensiblity.
  124351. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124352. */
  124353. gamepadRotationSensibility: number;
  124354. /**
  124355. * Defines the gamepad move sensiblity.
  124356. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124357. */
  124358. gamepadMoveSensibility: number;
  124359. private _yAxisScale;
  124360. /**
  124361. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124362. */
  124363. get invertYAxis(): boolean;
  124364. set invertYAxis(value: boolean);
  124365. private _onGamepadConnectedObserver;
  124366. private _onGamepadDisconnectedObserver;
  124367. /**
  124368. * Attach the input controls to a specific dom element to get the input from.
  124369. * @param element Defines the element the controls should be listened from
  124370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124371. */
  124372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124373. /**
  124374. * Detach the current controls from the specified dom element.
  124375. * @param element Defines the element to stop listening the inputs from
  124376. */
  124377. detachControl(element: Nullable<HTMLElement>): void;
  124378. /**
  124379. * Update the current camera state depending on the inputs that have been used this frame.
  124380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124381. */
  124382. checkInputs(): void;
  124383. /**
  124384. * Gets the class name of the current intput.
  124385. * @returns the class name
  124386. */
  124387. getClassName(): string;
  124388. /**
  124389. * Get the friendly name associated with the input class.
  124390. * @returns the input friendly name
  124391. */
  124392. getSimpleName(): string;
  124393. }
  124394. }
  124395. declare module BABYLON {
  124396. interface ArcRotateCameraInputsManager {
  124397. /**
  124398. * Add orientation input support to the input manager.
  124399. * @returns the current input manager
  124400. */
  124401. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124402. }
  124403. /**
  124404. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124405. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124406. */
  124407. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124408. /**
  124409. * Defines the camera the input is attached to.
  124410. */
  124411. camera: ArcRotateCamera;
  124412. /**
  124413. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124414. */
  124415. alphaCorrection: number;
  124416. /**
  124417. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124418. */
  124419. gammaCorrection: number;
  124420. private _alpha;
  124421. private _gamma;
  124422. private _dirty;
  124423. private _deviceOrientationHandler;
  124424. /**
  124425. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124426. */
  124427. constructor();
  124428. /**
  124429. * Attach the input controls to a specific dom element to get the input from.
  124430. * @param element Defines the element the controls should be listened from
  124431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124432. */
  124433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124434. /** @hidden */
  124435. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124436. /**
  124437. * Update the current camera state depending on the inputs that have been used this frame.
  124438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124439. */
  124440. checkInputs(): void;
  124441. /**
  124442. * Detach the current controls from the specified dom element.
  124443. * @param element Defines the element to stop listening the inputs from
  124444. */
  124445. detachControl(element: Nullable<HTMLElement>): void;
  124446. /**
  124447. * Gets the class name of the current intput.
  124448. * @returns the class name
  124449. */
  124450. getClassName(): string;
  124451. /**
  124452. * Get the friendly name associated with the input class.
  124453. * @returns the input friendly name
  124454. */
  124455. getSimpleName(): string;
  124456. }
  124457. }
  124458. declare module BABYLON {
  124459. /**
  124460. * Listen to mouse events to control the camera.
  124461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124462. */
  124463. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124464. /**
  124465. * Defines the camera the input is attached to.
  124466. */
  124467. camera: FlyCamera;
  124468. /**
  124469. * Defines if touch is enabled. (Default is true.)
  124470. */
  124471. touchEnabled: boolean;
  124472. /**
  124473. * Defines the buttons associated with the input to handle camera rotation.
  124474. */
  124475. buttons: number[];
  124476. /**
  124477. * Assign buttons for Yaw control.
  124478. */
  124479. buttonsYaw: number[];
  124480. /**
  124481. * Assign buttons for Pitch control.
  124482. */
  124483. buttonsPitch: number[];
  124484. /**
  124485. * Assign buttons for Roll control.
  124486. */
  124487. buttonsRoll: number[];
  124488. /**
  124489. * Detect if any button is being pressed while mouse is moved.
  124490. * -1 = Mouse locked.
  124491. * 0 = Left button.
  124492. * 1 = Middle Button.
  124493. * 2 = Right Button.
  124494. */
  124495. activeButton: number;
  124496. /**
  124497. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124498. * Higher values reduce its sensitivity.
  124499. */
  124500. angularSensibility: number;
  124501. private _mousemoveCallback;
  124502. private _observer;
  124503. private _rollObserver;
  124504. private previousPosition;
  124505. private noPreventDefault;
  124506. private element;
  124507. /**
  124508. * Listen to mouse events to control the camera.
  124509. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124510. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124511. */
  124512. constructor(touchEnabled?: boolean);
  124513. /**
  124514. * Attach the mouse control to the HTML DOM element.
  124515. * @param element Defines the element that listens to the input events.
  124516. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124517. */
  124518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124519. /**
  124520. * Detach the current controls from the specified dom element.
  124521. * @param element Defines the element to stop listening the inputs from
  124522. */
  124523. detachControl(element: Nullable<HTMLElement>): void;
  124524. /**
  124525. * Gets the class name of the current input.
  124526. * @returns the class name.
  124527. */
  124528. getClassName(): string;
  124529. /**
  124530. * Get the friendly name associated with the input class.
  124531. * @returns the input's friendly name.
  124532. */
  124533. getSimpleName(): string;
  124534. private _pointerInput;
  124535. private _onMouseMove;
  124536. /**
  124537. * Rotate camera by mouse offset.
  124538. */
  124539. private rotateCamera;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. /**
  124544. * Default Inputs manager for the FlyCamera.
  124545. * It groups all the default supported inputs for ease of use.
  124546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124547. */
  124548. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124549. /**
  124550. * Instantiates a new FlyCameraInputsManager.
  124551. * @param camera Defines the camera the inputs belong to.
  124552. */
  124553. constructor(camera: FlyCamera);
  124554. /**
  124555. * Add keyboard input support to the input manager.
  124556. * @returns the new FlyCameraKeyboardMoveInput().
  124557. */
  124558. addKeyboard(): FlyCameraInputsManager;
  124559. /**
  124560. * Add mouse input support to the input manager.
  124561. * @param touchEnabled Enable touch screen support.
  124562. * @returns the new FlyCameraMouseInput().
  124563. */
  124564. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124565. }
  124566. }
  124567. declare module BABYLON {
  124568. /**
  124569. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124570. * such as in a 3D Space Shooter or a Flight Simulator.
  124571. */
  124572. export class FlyCamera extends TargetCamera {
  124573. /**
  124574. * Define the collision ellipsoid of the camera.
  124575. * This is helpful for simulating a camera body, like a player's body.
  124576. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124577. */
  124578. ellipsoid: Vector3;
  124579. /**
  124580. * Define an offset for the position of the ellipsoid around the camera.
  124581. * This can be helpful if the camera is attached away from the player's body center,
  124582. * such as at its head.
  124583. */
  124584. ellipsoidOffset: Vector3;
  124585. /**
  124586. * Enable or disable collisions of the camera with the rest of the scene objects.
  124587. */
  124588. checkCollisions: boolean;
  124589. /**
  124590. * Enable or disable gravity on the camera.
  124591. */
  124592. applyGravity: boolean;
  124593. /**
  124594. * Define the current direction the camera is moving to.
  124595. */
  124596. cameraDirection: Vector3;
  124597. /**
  124598. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124599. * This overrides and empties cameraRotation.
  124600. */
  124601. rotationQuaternion: Quaternion;
  124602. /**
  124603. * Track Roll to maintain the wanted Rolling when looking around.
  124604. */
  124605. _trackRoll: number;
  124606. /**
  124607. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124608. */
  124609. rollCorrect: number;
  124610. /**
  124611. * Mimic a banked turn, Rolling the camera when Yawing.
  124612. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124613. */
  124614. bankedTurn: boolean;
  124615. /**
  124616. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124617. */
  124618. bankedTurnLimit: number;
  124619. /**
  124620. * Value of 0 disables the banked Roll.
  124621. * Value of 1 is equal to the Yaw angle in radians.
  124622. */
  124623. bankedTurnMultiplier: number;
  124624. /**
  124625. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124626. */
  124627. inputs: FlyCameraInputsManager;
  124628. /**
  124629. * Gets the input sensibility for mouse input.
  124630. * Higher values reduce sensitivity.
  124631. */
  124632. get angularSensibility(): number;
  124633. /**
  124634. * Sets the input sensibility for a mouse input.
  124635. * Higher values reduce sensitivity.
  124636. */
  124637. set angularSensibility(value: number);
  124638. /**
  124639. * Get the keys for camera movement forward.
  124640. */
  124641. get keysForward(): number[];
  124642. /**
  124643. * Set the keys for camera movement forward.
  124644. */
  124645. set keysForward(value: number[]);
  124646. /**
  124647. * Get the keys for camera movement backward.
  124648. */
  124649. get keysBackward(): number[];
  124650. set keysBackward(value: number[]);
  124651. /**
  124652. * Get the keys for camera movement up.
  124653. */
  124654. get keysUp(): number[];
  124655. /**
  124656. * Set the keys for camera movement up.
  124657. */
  124658. set keysUp(value: number[]);
  124659. /**
  124660. * Get the keys for camera movement down.
  124661. */
  124662. get keysDown(): number[];
  124663. /**
  124664. * Set the keys for camera movement down.
  124665. */
  124666. set keysDown(value: number[]);
  124667. /**
  124668. * Get the keys for camera movement left.
  124669. */
  124670. get keysLeft(): number[];
  124671. /**
  124672. * Set the keys for camera movement left.
  124673. */
  124674. set keysLeft(value: number[]);
  124675. /**
  124676. * Set the keys for camera movement right.
  124677. */
  124678. get keysRight(): number[];
  124679. /**
  124680. * Set the keys for camera movement right.
  124681. */
  124682. set keysRight(value: number[]);
  124683. /**
  124684. * Event raised when the camera collides with a mesh in the scene.
  124685. */
  124686. onCollide: (collidedMesh: AbstractMesh) => void;
  124687. private _collider;
  124688. private _needMoveForGravity;
  124689. private _oldPosition;
  124690. private _diffPosition;
  124691. private _newPosition;
  124692. /** @hidden */
  124693. _localDirection: Vector3;
  124694. /** @hidden */
  124695. _transformedDirection: Vector3;
  124696. /**
  124697. * Instantiates a FlyCamera.
  124698. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124699. * such as in a 3D Space Shooter or a Flight Simulator.
  124700. * @param name Define the name of the camera in the scene.
  124701. * @param position Define the starting position of the camera in the scene.
  124702. * @param scene Define the scene the camera belongs to.
  124703. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124704. */
  124705. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124706. /**
  124707. * Attach a control to the HTML DOM element.
  124708. * @param element Defines the element that listens to the input events.
  124709. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124710. */
  124711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124712. /**
  124713. * Detach a control from the HTML DOM element.
  124714. * The camera will stop reacting to that input.
  124715. * @param element Defines the element that listens to the input events.
  124716. */
  124717. detachControl(element: HTMLElement): void;
  124718. private _collisionMask;
  124719. /**
  124720. * Get the mask that the camera ignores in collision events.
  124721. */
  124722. get collisionMask(): number;
  124723. /**
  124724. * Set the mask that the camera ignores in collision events.
  124725. */
  124726. set collisionMask(mask: number);
  124727. /** @hidden */
  124728. _collideWithWorld(displacement: Vector3): void;
  124729. /** @hidden */
  124730. private _onCollisionPositionChange;
  124731. /** @hidden */
  124732. _checkInputs(): void;
  124733. /** @hidden */
  124734. _decideIfNeedsToMove(): boolean;
  124735. /** @hidden */
  124736. _updatePosition(): void;
  124737. /**
  124738. * Restore the Roll to its target value at the rate specified.
  124739. * @param rate - Higher means slower restoring.
  124740. * @hidden
  124741. */
  124742. restoreRoll(rate: number): void;
  124743. /**
  124744. * Destroy the camera and release the current resources held by it.
  124745. */
  124746. dispose(): void;
  124747. /**
  124748. * Get the current object class name.
  124749. * @returns the class name.
  124750. */
  124751. getClassName(): string;
  124752. }
  124753. }
  124754. declare module BABYLON {
  124755. /**
  124756. * Listen to keyboard events to control the camera.
  124757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124758. */
  124759. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124760. /**
  124761. * Defines the camera the input is attached to.
  124762. */
  124763. camera: FlyCamera;
  124764. /**
  124765. * The list of keyboard keys used to control the forward move of the camera.
  124766. */
  124767. keysForward: number[];
  124768. /**
  124769. * The list of keyboard keys used to control the backward move of the camera.
  124770. */
  124771. keysBackward: number[];
  124772. /**
  124773. * The list of keyboard keys used to control the forward move of the camera.
  124774. */
  124775. keysUp: number[];
  124776. /**
  124777. * The list of keyboard keys used to control the backward move of the camera.
  124778. */
  124779. keysDown: number[];
  124780. /**
  124781. * The list of keyboard keys used to control the right strafe move of the camera.
  124782. */
  124783. keysRight: number[];
  124784. /**
  124785. * The list of keyboard keys used to control the left strafe move of the camera.
  124786. */
  124787. keysLeft: number[];
  124788. private _keys;
  124789. private _onCanvasBlurObserver;
  124790. private _onKeyboardObserver;
  124791. private _engine;
  124792. private _scene;
  124793. /**
  124794. * Attach the input controls to a specific dom element to get the input from.
  124795. * @param element Defines the element the controls should be listened from
  124796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124797. */
  124798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124799. /**
  124800. * Detach the current controls from the specified dom element.
  124801. * @param element Defines the element to stop listening the inputs from
  124802. */
  124803. detachControl(element: Nullable<HTMLElement>): void;
  124804. /**
  124805. * Gets the class name of the current intput.
  124806. * @returns the class name
  124807. */
  124808. getClassName(): string;
  124809. /** @hidden */
  124810. _onLostFocus(e: FocusEvent): void;
  124811. /**
  124812. * Get the friendly name associated with the input class.
  124813. * @returns the input friendly name
  124814. */
  124815. getSimpleName(): string;
  124816. /**
  124817. * Update the current camera state depending on the inputs that have been used this frame.
  124818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124819. */
  124820. checkInputs(): void;
  124821. }
  124822. }
  124823. declare module BABYLON {
  124824. /**
  124825. * Manage the mouse wheel inputs to control a follow camera.
  124826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124827. */
  124828. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124829. /**
  124830. * Defines the camera the input is attached to.
  124831. */
  124832. camera: FollowCamera;
  124833. /**
  124834. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124835. */
  124836. axisControlRadius: boolean;
  124837. /**
  124838. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124839. */
  124840. axisControlHeight: boolean;
  124841. /**
  124842. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124843. */
  124844. axisControlRotation: boolean;
  124845. /**
  124846. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124847. * relation to mouseWheel events.
  124848. */
  124849. wheelPrecision: number;
  124850. /**
  124851. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124852. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124853. */
  124854. wheelDeltaPercentage: number;
  124855. private _wheel;
  124856. private _observer;
  124857. /**
  124858. * Attach the input controls to a specific dom element to get the input from.
  124859. * @param element Defines the element the controls should be listened from
  124860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124861. */
  124862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124863. /**
  124864. * Detach the current controls from the specified dom element.
  124865. * @param element Defines the element to stop listening the inputs from
  124866. */
  124867. detachControl(element: Nullable<HTMLElement>): void;
  124868. /**
  124869. * Gets the class name of the current intput.
  124870. * @returns the class name
  124871. */
  124872. getClassName(): string;
  124873. /**
  124874. * Get the friendly name associated with the input class.
  124875. * @returns the input friendly name
  124876. */
  124877. getSimpleName(): string;
  124878. }
  124879. }
  124880. declare module BABYLON {
  124881. /**
  124882. * Manage the pointers inputs to control an follow camera.
  124883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124884. */
  124885. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124886. /**
  124887. * Defines the camera the input is attached to.
  124888. */
  124889. camera: FollowCamera;
  124890. /**
  124891. * Gets the class name of the current input.
  124892. * @returns the class name
  124893. */
  124894. getClassName(): string;
  124895. /**
  124896. * Defines the pointer angular sensibility along the X axis or how fast is
  124897. * the camera rotating.
  124898. * A negative number will reverse the axis direction.
  124899. */
  124900. angularSensibilityX: number;
  124901. /**
  124902. * Defines the pointer angular sensibility along the Y axis or how fast is
  124903. * the camera rotating.
  124904. * A negative number will reverse the axis direction.
  124905. */
  124906. angularSensibilityY: number;
  124907. /**
  124908. * Defines the pointer pinch precision or how fast is the camera zooming.
  124909. * A negative number will reverse the axis direction.
  124910. */
  124911. pinchPrecision: number;
  124912. /**
  124913. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124914. * from 0.
  124915. * It defines the percentage of current camera.radius to use as delta when
  124916. * pinch zoom is used.
  124917. */
  124918. pinchDeltaPercentage: number;
  124919. /**
  124920. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124921. */
  124922. axisXControlRadius: boolean;
  124923. /**
  124924. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124925. */
  124926. axisXControlHeight: boolean;
  124927. /**
  124928. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124929. */
  124930. axisXControlRotation: boolean;
  124931. /**
  124932. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124933. */
  124934. axisYControlRadius: boolean;
  124935. /**
  124936. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124937. */
  124938. axisYControlHeight: boolean;
  124939. /**
  124940. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124941. */
  124942. axisYControlRotation: boolean;
  124943. /**
  124944. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124945. */
  124946. axisPinchControlRadius: boolean;
  124947. /**
  124948. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124949. */
  124950. axisPinchControlHeight: boolean;
  124951. /**
  124952. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124953. */
  124954. axisPinchControlRotation: boolean;
  124955. /**
  124956. * Log error messages if basic misconfiguration has occurred.
  124957. */
  124958. warningEnable: boolean;
  124959. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124960. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124961. private _warningCounter;
  124962. private _warning;
  124963. }
  124964. }
  124965. declare module BABYLON {
  124966. /**
  124967. * Default Inputs manager for the FollowCamera.
  124968. * It groups all the default supported inputs for ease of use.
  124969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124970. */
  124971. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124972. /**
  124973. * Instantiates a new FollowCameraInputsManager.
  124974. * @param camera Defines the camera the inputs belong to
  124975. */
  124976. constructor(camera: FollowCamera);
  124977. /**
  124978. * Add keyboard input support to the input manager.
  124979. * @returns the current input manager
  124980. */
  124981. addKeyboard(): FollowCameraInputsManager;
  124982. /**
  124983. * Add mouse wheel input support to the input manager.
  124984. * @returns the current input manager
  124985. */
  124986. addMouseWheel(): FollowCameraInputsManager;
  124987. /**
  124988. * Add pointers input support to the input manager.
  124989. * @returns the current input manager
  124990. */
  124991. addPointers(): FollowCameraInputsManager;
  124992. /**
  124993. * Add orientation input support to the input manager.
  124994. * @returns the current input manager
  124995. */
  124996. addVRDeviceOrientation(): FollowCameraInputsManager;
  124997. }
  124998. }
  124999. declare module BABYLON {
  125000. /**
  125001. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125002. * an arc rotate version arcFollowCamera are available.
  125003. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125004. */
  125005. export class FollowCamera extends TargetCamera {
  125006. /**
  125007. * Distance the follow camera should follow an object at
  125008. */
  125009. radius: number;
  125010. /**
  125011. * Minimum allowed distance of the camera to the axis of rotation
  125012. * (The camera can not get closer).
  125013. * This can help limiting how the Camera is able to move in the scene.
  125014. */
  125015. lowerRadiusLimit: Nullable<number>;
  125016. /**
  125017. * Maximum allowed distance of the camera to the axis of rotation
  125018. * (The camera can not get further).
  125019. * This can help limiting how the Camera is able to move in the scene.
  125020. */
  125021. upperRadiusLimit: Nullable<number>;
  125022. /**
  125023. * Define a rotation offset between the camera and the object it follows
  125024. */
  125025. rotationOffset: number;
  125026. /**
  125027. * Minimum allowed angle to camera position relative to target object.
  125028. * This can help limiting how the Camera is able to move in the scene.
  125029. */
  125030. lowerRotationOffsetLimit: Nullable<number>;
  125031. /**
  125032. * Maximum allowed angle to camera position relative to target object.
  125033. * This can help limiting how the Camera is able to move in the scene.
  125034. */
  125035. upperRotationOffsetLimit: Nullable<number>;
  125036. /**
  125037. * Define a height offset between the camera and the object it follows.
  125038. * It can help following an object from the top (like a car chaing a plane)
  125039. */
  125040. heightOffset: number;
  125041. /**
  125042. * Minimum allowed height of camera position relative to target object.
  125043. * This can help limiting how the Camera is able to move in the scene.
  125044. */
  125045. lowerHeightOffsetLimit: Nullable<number>;
  125046. /**
  125047. * Maximum allowed height of camera position relative to target object.
  125048. * This can help limiting how the Camera is able to move in the scene.
  125049. */
  125050. upperHeightOffsetLimit: Nullable<number>;
  125051. /**
  125052. * Define how fast the camera can accelerate to follow it s target.
  125053. */
  125054. cameraAcceleration: number;
  125055. /**
  125056. * Define the speed limit of the camera following an object.
  125057. */
  125058. maxCameraSpeed: number;
  125059. /**
  125060. * Define the target of the camera.
  125061. */
  125062. lockedTarget: Nullable<AbstractMesh>;
  125063. /**
  125064. * Defines the input associated with the camera.
  125065. */
  125066. inputs: FollowCameraInputsManager;
  125067. /**
  125068. * Instantiates the follow camera.
  125069. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125070. * @param name Define the name of the camera in the scene
  125071. * @param position Define the position of the camera
  125072. * @param scene Define the scene the camera belong to
  125073. * @param lockedTarget Define the target of the camera
  125074. */
  125075. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125076. private _follow;
  125077. /**
  125078. * Attached controls to the current camera.
  125079. * @param element Defines the element the controls should be listened from
  125080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125081. */
  125082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125083. /**
  125084. * Detach the current controls from the camera.
  125085. * The camera will stop reacting to inputs.
  125086. * @param element Defines the element to stop listening the inputs from
  125087. */
  125088. detachControl(element: HTMLElement): void;
  125089. /** @hidden */
  125090. _checkInputs(): void;
  125091. private _checkLimits;
  125092. /**
  125093. * Gets the camera class name.
  125094. * @returns the class name
  125095. */
  125096. getClassName(): string;
  125097. }
  125098. /**
  125099. * Arc Rotate version of the follow camera.
  125100. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125101. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125102. */
  125103. export class ArcFollowCamera extends TargetCamera {
  125104. /** The longitudinal angle of the camera */
  125105. alpha: number;
  125106. /** The latitudinal angle of the camera */
  125107. beta: number;
  125108. /** The radius of the camera from its target */
  125109. radius: number;
  125110. private _cartesianCoordinates;
  125111. /** Define the camera target (the mesh it should follow) */
  125112. private _meshTarget;
  125113. /**
  125114. * Instantiates a new ArcFollowCamera
  125115. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125116. * @param name Define the name of the camera
  125117. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125118. * @param beta Define the rotation angle of the camera around the elevation axis
  125119. * @param radius Define the radius of the camera from its target point
  125120. * @param target Define the target of the camera
  125121. * @param scene Define the scene the camera belongs to
  125122. */
  125123. constructor(name: string,
  125124. /** The longitudinal angle of the camera */
  125125. alpha: number,
  125126. /** The latitudinal angle of the camera */
  125127. beta: number,
  125128. /** The radius of the camera from its target */
  125129. radius: number,
  125130. /** Define the camera target (the mesh it should follow) */
  125131. target: Nullable<AbstractMesh>, scene: Scene);
  125132. private _follow;
  125133. /** @hidden */
  125134. _checkInputs(): void;
  125135. /**
  125136. * Returns the class name of the object.
  125137. * It is mostly used internally for serialization purposes.
  125138. */
  125139. getClassName(): string;
  125140. }
  125141. }
  125142. declare module BABYLON {
  125143. /**
  125144. * Manage the keyboard inputs to control the movement of a follow camera.
  125145. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125146. */
  125147. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125148. /**
  125149. * Defines the camera the input is attached to.
  125150. */
  125151. camera: FollowCamera;
  125152. /**
  125153. * Defines the list of key codes associated with the up action (increase heightOffset)
  125154. */
  125155. keysHeightOffsetIncr: number[];
  125156. /**
  125157. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125158. */
  125159. keysHeightOffsetDecr: number[];
  125160. /**
  125161. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125162. */
  125163. keysHeightOffsetModifierAlt: boolean;
  125164. /**
  125165. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125166. */
  125167. keysHeightOffsetModifierCtrl: boolean;
  125168. /**
  125169. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125170. */
  125171. keysHeightOffsetModifierShift: boolean;
  125172. /**
  125173. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125174. */
  125175. keysRotationOffsetIncr: number[];
  125176. /**
  125177. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125178. */
  125179. keysRotationOffsetDecr: number[];
  125180. /**
  125181. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125182. */
  125183. keysRotationOffsetModifierAlt: boolean;
  125184. /**
  125185. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125186. */
  125187. keysRotationOffsetModifierCtrl: boolean;
  125188. /**
  125189. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125190. */
  125191. keysRotationOffsetModifierShift: boolean;
  125192. /**
  125193. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125194. */
  125195. keysRadiusIncr: number[];
  125196. /**
  125197. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125198. */
  125199. keysRadiusDecr: number[];
  125200. /**
  125201. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125202. */
  125203. keysRadiusModifierAlt: boolean;
  125204. /**
  125205. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125206. */
  125207. keysRadiusModifierCtrl: boolean;
  125208. /**
  125209. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125210. */
  125211. keysRadiusModifierShift: boolean;
  125212. /**
  125213. * Defines the rate of change of heightOffset.
  125214. */
  125215. heightSensibility: number;
  125216. /**
  125217. * Defines the rate of change of rotationOffset.
  125218. */
  125219. rotationSensibility: number;
  125220. /**
  125221. * Defines the rate of change of radius.
  125222. */
  125223. radiusSensibility: number;
  125224. private _keys;
  125225. private _ctrlPressed;
  125226. private _altPressed;
  125227. private _shiftPressed;
  125228. private _onCanvasBlurObserver;
  125229. private _onKeyboardObserver;
  125230. private _engine;
  125231. private _scene;
  125232. /**
  125233. * Attach the input controls to a specific dom element to get the input from.
  125234. * @param element Defines the element the controls should be listened from
  125235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125236. */
  125237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125238. /**
  125239. * Detach the current controls from the specified dom element.
  125240. * @param element Defines the element to stop listening the inputs from
  125241. */
  125242. detachControl(element: Nullable<HTMLElement>): void;
  125243. /**
  125244. * Update the current camera state depending on the inputs that have been used this frame.
  125245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125246. */
  125247. checkInputs(): void;
  125248. /**
  125249. * Gets the class name of the current input.
  125250. * @returns the class name
  125251. */
  125252. getClassName(): string;
  125253. /**
  125254. * Get the friendly name associated with the input class.
  125255. * @returns the input friendly name
  125256. */
  125257. getSimpleName(): string;
  125258. /**
  125259. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125260. * allow modification of the heightOffset value.
  125261. */
  125262. private _modifierHeightOffset;
  125263. /**
  125264. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125265. * allow modification of the rotationOffset value.
  125266. */
  125267. private _modifierRotationOffset;
  125268. /**
  125269. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125270. * allow modification of the radius value.
  125271. */
  125272. private _modifierRadius;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. interface FreeCameraInputsManager {
  125277. /**
  125278. * @hidden
  125279. */
  125280. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125281. /**
  125282. * Add orientation input support to the input manager.
  125283. * @returns the current input manager
  125284. */
  125285. addDeviceOrientation(): FreeCameraInputsManager;
  125286. }
  125287. /**
  125288. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125289. * Screen rotation is taken into account.
  125290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125291. */
  125292. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125293. private _camera;
  125294. private _screenOrientationAngle;
  125295. private _constantTranform;
  125296. private _screenQuaternion;
  125297. private _alpha;
  125298. private _beta;
  125299. private _gamma;
  125300. /**
  125301. * Can be used to detect if a device orientation sensor is available on a device
  125302. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125303. * @returns a promise that will resolve on orientation change
  125304. */
  125305. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125306. /**
  125307. * @hidden
  125308. */
  125309. _onDeviceOrientationChangedObservable: Observable<void>;
  125310. /**
  125311. * Instantiates a new input
  125312. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125313. */
  125314. constructor();
  125315. /**
  125316. * Define the camera controlled by the input.
  125317. */
  125318. get camera(): FreeCamera;
  125319. set camera(camera: FreeCamera);
  125320. /**
  125321. * Attach the input controls to a specific dom element to get the input from.
  125322. * @param element Defines the element the controls should be listened from
  125323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125324. */
  125325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125326. private _orientationChanged;
  125327. private _deviceOrientation;
  125328. /**
  125329. * Detach the current controls from the specified dom element.
  125330. * @param element Defines the element to stop listening the inputs from
  125331. */
  125332. detachControl(element: Nullable<HTMLElement>): void;
  125333. /**
  125334. * Update the current camera state depending on the inputs that have been used this frame.
  125335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125336. */
  125337. checkInputs(): void;
  125338. /**
  125339. * Gets the class name of the current intput.
  125340. * @returns the class name
  125341. */
  125342. getClassName(): string;
  125343. /**
  125344. * Get the friendly name associated with the input class.
  125345. * @returns the input friendly name
  125346. */
  125347. getSimpleName(): string;
  125348. }
  125349. }
  125350. declare module BABYLON {
  125351. /**
  125352. * Manage the gamepad inputs to control a free camera.
  125353. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125354. */
  125355. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125356. /**
  125357. * Define the camera the input is attached to.
  125358. */
  125359. camera: FreeCamera;
  125360. /**
  125361. * Define the Gamepad controlling the input
  125362. */
  125363. gamepad: Nullable<Gamepad>;
  125364. /**
  125365. * Defines the gamepad rotation sensiblity.
  125366. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125367. */
  125368. gamepadAngularSensibility: number;
  125369. /**
  125370. * Defines the gamepad move sensiblity.
  125371. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125372. */
  125373. gamepadMoveSensibility: number;
  125374. private _yAxisScale;
  125375. /**
  125376. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125377. */
  125378. get invertYAxis(): boolean;
  125379. set invertYAxis(value: boolean);
  125380. private _onGamepadConnectedObserver;
  125381. private _onGamepadDisconnectedObserver;
  125382. private _cameraTransform;
  125383. private _deltaTransform;
  125384. private _vector3;
  125385. private _vector2;
  125386. /**
  125387. * Attach the input controls to a specific dom element to get the input from.
  125388. * @param element Defines the element the controls should be listened from
  125389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125390. */
  125391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125392. /**
  125393. * Detach the current controls from the specified dom element.
  125394. * @param element Defines the element to stop listening the inputs from
  125395. */
  125396. detachControl(element: Nullable<HTMLElement>): void;
  125397. /**
  125398. * Update the current camera state depending on the inputs that have been used this frame.
  125399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125400. */
  125401. checkInputs(): void;
  125402. /**
  125403. * Gets the class name of the current intput.
  125404. * @returns the class name
  125405. */
  125406. getClassName(): string;
  125407. /**
  125408. * Get the friendly name associated with the input class.
  125409. * @returns the input friendly name
  125410. */
  125411. getSimpleName(): string;
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /**
  125416. * Defines the potential axis of a Joystick
  125417. */
  125418. export enum JoystickAxis {
  125419. /** X axis */
  125420. X = 0,
  125421. /** Y axis */
  125422. Y = 1,
  125423. /** Z axis */
  125424. Z = 2
  125425. }
  125426. /**
  125427. * Represents the different customization options available
  125428. * for VirtualJoystick
  125429. */
  125430. interface VirtualJoystickCustomizations {
  125431. /**
  125432. * Size of the joystick's puck
  125433. */
  125434. puckSize: number;
  125435. /**
  125436. * Size of the joystick's container
  125437. */
  125438. containerSize: number;
  125439. /**
  125440. * Color of the joystick && puck
  125441. */
  125442. color: string;
  125443. /**
  125444. * Image URL for the joystick's puck
  125445. */
  125446. puckImage?: string;
  125447. /**
  125448. * Image URL for the joystick's container
  125449. */
  125450. containerImage?: string;
  125451. /**
  125452. * Defines the unmoving position of the joystick container
  125453. */
  125454. position?: {
  125455. x: number;
  125456. y: number;
  125457. };
  125458. /**
  125459. * Defines whether or not the joystick container is always visible
  125460. */
  125461. alwaysVisible: boolean;
  125462. /**
  125463. * Defines whether or not to limit the movement of the puck to the joystick's container
  125464. */
  125465. limitToContainer: boolean;
  125466. }
  125467. /**
  125468. * Class used to define virtual joystick (used in touch mode)
  125469. */
  125470. export class VirtualJoystick {
  125471. /**
  125472. * Gets or sets a boolean indicating that left and right values must be inverted
  125473. */
  125474. reverseLeftRight: boolean;
  125475. /**
  125476. * Gets or sets a boolean indicating that up and down values must be inverted
  125477. */
  125478. reverseUpDown: boolean;
  125479. /**
  125480. * Gets the offset value for the position (ie. the change of the position value)
  125481. */
  125482. deltaPosition: Vector3;
  125483. /**
  125484. * Gets a boolean indicating if the virtual joystick was pressed
  125485. */
  125486. pressed: boolean;
  125487. /**
  125488. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125489. */
  125490. static Canvas: Nullable<HTMLCanvasElement>;
  125491. /**
  125492. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125493. */
  125494. limitToContainer: boolean;
  125495. private static _globalJoystickIndex;
  125496. private static _alwaysVisibleSticks;
  125497. private static vjCanvasContext;
  125498. private static vjCanvasWidth;
  125499. private static vjCanvasHeight;
  125500. private static halfWidth;
  125501. private static _GetDefaultOptions;
  125502. private _action;
  125503. private _axisTargetedByLeftAndRight;
  125504. private _axisTargetedByUpAndDown;
  125505. private _joystickSensibility;
  125506. private _inversedSensibility;
  125507. private _joystickPointerID;
  125508. private _joystickColor;
  125509. private _joystickPointerPos;
  125510. private _joystickPreviousPointerPos;
  125511. private _joystickPointerStartPos;
  125512. private _deltaJoystickVector;
  125513. private _leftJoystick;
  125514. private _touches;
  125515. private _joystickPosition;
  125516. private _alwaysVisible;
  125517. private _puckImage;
  125518. private _containerImage;
  125519. private _joystickPuckSize;
  125520. private _joystickContainerSize;
  125521. private _clearPuckSize;
  125522. private _clearContainerSize;
  125523. private _clearPuckSizeOffset;
  125524. private _clearContainerSizeOffset;
  125525. private _onPointerDownHandlerRef;
  125526. private _onPointerMoveHandlerRef;
  125527. private _onPointerUpHandlerRef;
  125528. private _onResize;
  125529. /**
  125530. * Creates a new virtual joystick
  125531. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125532. * @param customizations Defines the options we want to customize the VirtualJoystick
  125533. */
  125534. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125535. /**
  125536. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125537. * @param newJoystickSensibility defines the new sensibility
  125538. */
  125539. setJoystickSensibility(newJoystickSensibility: number): void;
  125540. private _onPointerDown;
  125541. private _onPointerMove;
  125542. private _onPointerUp;
  125543. /**
  125544. * Change the color of the virtual joystick
  125545. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125546. */
  125547. setJoystickColor(newColor: string): void;
  125548. /**
  125549. * Size of the joystick's container
  125550. */
  125551. set containerSize(newSize: number);
  125552. get containerSize(): number;
  125553. /**
  125554. * Size of the joystick's puck
  125555. */
  125556. set puckSize(newSize: number);
  125557. get puckSize(): number;
  125558. /**
  125559. * Clears the set position of the joystick
  125560. */
  125561. clearPosition(): void;
  125562. /**
  125563. * Defines whether or not the joystick container is always visible
  125564. */
  125565. set alwaysVisible(value: boolean);
  125566. get alwaysVisible(): boolean;
  125567. /**
  125568. * Sets the constant position of the Joystick container
  125569. * @param x X axis coordinate
  125570. * @param y Y axis coordinate
  125571. */
  125572. setPosition(x: number, y: number): void;
  125573. /**
  125574. * Defines a callback to call when the joystick is touched
  125575. * @param action defines the callback
  125576. */
  125577. setActionOnTouch(action: () => any): void;
  125578. /**
  125579. * Defines which axis you'd like to control for left & right
  125580. * @param axis defines the axis to use
  125581. */
  125582. setAxisForLeftRight(axis: JoystickAxis): void;
  125583. /**
  125584. * Defines which axis you'd like to control for up & down
  125585. * @param axis defines the axis to use
  125586. */
  125587. setAxisForUpDown(axis: JoystickAxis): void;
  125588. /**
  125589. * Clears the canvas from the previous puck / container draw
  125590. */
  125591. private _clearPreviousDraw;
  125592. /**
  125593. * Loads `urlPath` to be used for the container's image
  125594. * @param urlPath defines the urlPath of an image to use
  125595. */
  125596. setContainerImage(urlPath: string): void;
  125597. /**
  125598. * Loads `urlPath` to be used for the puck's image
  125599. * @param urlPath defines the urlPath of an image to use
  125600. */
  125601. setPuckImage(urlPath: string): void;
  125602. /**
  125603. * Draws the Virtual Joystick's container
  125604. */
  125605. private _drawContainer;
  125606. /**
  125607. * Draws the Virtual Joystick's puck
  125608. */
  125609. private _drawPuck;
  125610. private _drawVirtualJoystick;
  125611. /**
  125612. * Release internal HTML canvas
  125613. */
  125614. releaseCanvas(): void;
  125615. }
  125616. }
  125617. declare module BABYLON {
  125618. interface FreeCameraInputsManager {
  125619. /**
  125620. * Add virtual joystick input support to the input manager.
  125621. * @returns the current input manager
  125622. */
  125623. addVirtualJoystick(): FreeCameraInputsManager;
  125624. }
  125625. /**
  125626. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125628. */
  125629. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125630. /**
  125631. * Defines the camera the input is attached to.
  125632. */
  125633. camera: FreeCamera;
  125634. private _leftjoystick;
  125635. private _rightjoystick;
  125636. /**
  125637. * Gets the left stick of the virtual joystick.
  125638. * @returns The virtual Joystick
  125639. */
  125640. getLeftJoystick(): VirtualJoystick;
  125641. /**
  125642. * Gets the right stick of the virtual joystick.
  125643. * @returns The virtual Joystick
  125644. */
  125645. getRightJoystick(): VirtualJoystick;
  125646. /**
  125647. * Update the current camera state depending on the inputs that have been used this frame.
  125648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125649. */
  125650. checkInputs(): void;
  125651. /**
  125652. * Attach the input controls to a specific dom element to get the input from.
  125653. * @param element Defines the element the controls should be listened from
  125654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125655. */
  125656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125657. /**
  125658. * Detach the current controls from the specified dom element.
  125659. * @param element Defines the element to stop listening the inputs from
  125660. */
  125661. detachControl(element: Nullable<HTMLElement>): void;
  125662. /**
  125663. * Gets the class name of the current intput.
  125664. * @returns the class name
  125665. */
  125666. getClassName(): string;
  125667. /**
  125668. * Get the friendly name associated with the input class.
  125669. * @returns the input friendly name
  125670. */
  125671. getSimpleName(): string;
  125672. }
  125673. }
  125674. declare module BABYLON {
  125675. /**
  125676. * This represents a FPS type of camera controlled by touch.
  125677. * This is like a universal camera minus the Gamepad controls.
  125678. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125679. */
  125680. export class TouchCamera extends FreeCamera {
  125681. /**
  125682. * Defines the touch sensibility for rotation.
  125683. * The higher the faster.
  125684. */
  125685. get touchAngularSensibility(): number;
  125686. set touchAngularSensibility(value: number);
  125687. /**
  125688. * Defines the touch sensibility for move.
  125689. * The higher the faster.
  125690. */
  125691. get touchMoveSensibility(): number;
  125692. set touchMoveSensibility(value: number);
  125693. /**
  125694. * Instantiates a new touch camera.
  125695. * This represents a FPS type of camera controlled by touch.
  125696. * This is like a universal camera minus the Gamepad controls.
  125697. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125698. * @param name Define the name of the camera in the scene
  125699. * @param position Define the start position of the camera in the scene
  125700. * @param scene Define the scene the camera belongs to
  125701. */
  125702. constructor(name: string, position: Vector3, scene: Scene);
  125703. /**
  125704. * Gets the current object class name.
  125705. * @return the class name
  125706. */
  125707. getClassName(): string;
  125708. /** @hidden */
  125709. _setupInputs(): void;
  125710. }
  125711. }
  125712. declare module BABYLON {
  125713. /**
  125714. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125715. * being tilted forward or back and left or right.
  125716. */
  125717. export class DeviceOrientationCamera extends FreeCamera {
  125718. private _initialQuaternion;
  125719. private _quaternionCache;
  125720. private _tmpDragQuaternion;
  125721. private _disablePointerInputWhenUsingDeviceOrientation;
  125722. /**
  125723. * Creates a new device orientation camera
  125724. * @param name The name of the camera
  125725. * @param position The start position camera
  125726. * @param scene The scene the camera belongs to
  125727. */
  125728. constructor(name: string, position: Vector3, scene: Scene);
  125729. /**
  125730. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125731. */
  125732. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125733. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125734. private _dragFactor;
  125735. /**
  125736. * Enabled turning on the y axis when the orientation sensor is active
  125737. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125738. */
  125739. enableHorizontalDragging(dragFactor?: number): void;
  125740. /**
  125741. * Gets the current instance class name ("DeviceOrientationCamera").
  125742. * This helps avoiding instanceof at run time.
  125743. * @returns the class name
  125744. */
  125745. getClassName(): string;
  125746. /**
  125747. * @hidden
  125748. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125749. */
  125750. _checkInputs(): void;
  125751. /**
  125752. * Reset the camera to its default orientation on the specified axis only.
  125753. * @param axis The axis to reset
  125754. */
  125755. resetToCurrentRotation(axis?: Axis): void;
  125756. }
  125757. }
  125758. declare module BABYLON {
  125759. /**
  125760. * Defines supported buttons for XBox360 compatible gamepads
  125761. */
  125762. export enum Xbox360Button {
  125763. /** A */
  125764. A = 0,
  125765. /** B */
  125766. B = 1,
  125767. /** X */
  125768. X = 2,
  125769. /** Y */
  125770. Y = 3,
  125771. /** Left button */
  125772. LB = 4,
  125773. /** Right button */
  125774. RB = 5,
  125775. /** Back */
  125776. Back = 8,
  125777. /** Start */
  125778. Start = 9,
  125779. /** Left stick */
  125780. LeftStick = 10,
  125781. /** Right stick */
  125782. RightStick = 11
  125783. }
  125784. /** Defines values for XBox360 DPad */
  125785. export enum Xbox360Dpad {
  125786. /** Up */
  125787. Up = 12,
  125788. /** Down */
  125789. Down = 13,
  125790. /** Left */
  125791. Left = 14,
  125792. /** Right */
  125793. Right = 15
  125794. }
  125795. /**
  125796. * Defines a XBox360 gamepad
  125797. */
  125798. export class Xbox360Pad extends Gamepad {
  125799. private _leftTrigger;
  125800. private _rightTrigger;
  125801. private _onlefttriggerchanged;
  125802. private _onrighttriggerchanged;
  125803. private _onbuttondown;
  125804. private _onbuttonup;
  125805. private _ondpaddown;
  125806. private _ondpadup;
  125807. /** Observable raised when a button is pressed */
  125808. onButtonDownObservable: Observable<Xbox360Button>;
  125809. /** Observable raised when a button is released */
  125810. onButtonUpObservable: Observable<Xbox360Button>;
  125811. /** Observable raised when a pad is pressed */
  125812. onPadDownObservable: Observable<Xbox360Dpad>;
  125813. /** Observable raised when a pad is released */
  125814. onPadUpObservable: Observable<Xbox360Dpad>;
  125815. private _buttonA;
  125816. private _buttonB;
  125817. private _buttonX;
  125818. private _buttonY;
  125819. private _buttonBack;
  125820. private _buttonStart;
  125821. private _buttonLB;
  125822. private _buttonRB;
  125823. private _buttonLeftStick;
  125824. private _buttonRightStick;
  125825. private _dPadUp;
  125826. private _dPadDown;
  125827. private _dPadLeft;
  125828. private _dPadRight;
  125829. private _isXboxOnePad;
  125830. /**
  125831. * Creates a new XBox360 gamepad object
  125832. * @param id defines the id of this gamepad
  125833. * @param index defines its index
  125834. * @param gamepad defines the internal HTML gamepad object
  125835. * @param xboxOne defines if it is a XBox One gamepad
  125836. */
  125837. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125838. /**
  125839. * Defines the callback to call when left trigger is pressed
  125840. * @param callback defines the callback to use
  125841. */
  125842. onlefttriggerchanged(callback: (value: number) => void): void;
  125843. /**
  125844. * Defines the callback to call when right trigger is pressed
  125845. * @param callback defines the callback to use
  125846. */
  125847. onrighttriggerchanged(callback: (value: number) => void): void;
  125848. /**
  125849. * Gets the left trigger value
  125850. */
  125851. get leftTrigger(): number;
  125852. /**
  125853. * Sets the left trigger value
  125854. */
  125855. set leftTrigger(newValue: number);
  125856. /**
  125857. * Gets the right trigger value
  125858. */
  125859. get rightTrigger(): number;
  125860. /**
  125861. * Sets the right trigger value
  125862. */
  125863. set rightTrigger(newValue: number);
  125864. /**
  125865. * Defines the callback to call when a button is pressed
  125866. * @param callback defines the callback to use
  125867. */
  125868. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125869. /**
  125870. * Defines the callback to call when a button is released
  125871. * @param callback defines the callback to use
  125872. */
  125873. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125874. /**
  125875. * Defines the callback to call when a pad is pressed
  125876. * @param callback defines the callback to use
  125877. */
  125878. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125879. /**
  125880. * Defines the callback to call when a pad is released
  125881. * @param callback defines the callback to use
  125882. */
  125883. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125884. private _setButtonValue;
  125885. private _setDPadValue;
  125886. /**
  125887. * Gets the value of the `A` button
  125888. */
  125889. get buttonA(): number;
  125890. /**
  125891. * Sets the value of the `A` button
  125892. */
  125893. set buttonA(value: number);
  125894. /**
  125895. * Gets the value of the `B` button
  125896. */
  125897. get buttonB(): number;
  125898. /**
  125899. * Sets the value of the `B` button
  125900. */
  125901. set buttonB(value: number);
  125902. /**
  125903. * Gets the value of the `X` button
  125904. */
  125905. get buttonX(): number;
  125906. /**
  125907. * Sets the value of the `X` button
  125908. */
  125909. set buttonX(value: number);
  125910. /**
  125911. * Gets the value of the `Y` button
  125912. */
  125913. get buttonY(): number;
  125914. /**
  125915. * Sets the value of the `Y` button
  125916. */
  125917. set buttonY(value: number);
  125918. /**
  125919. * Gets the value of the `Start` button
  125920. */
  125921. get buttonStart(): number;
  125922. /**
  125923. * Sets the value of the `Start` button
  125924. */
  125925. set buttonStart(value: number);
  125926. /**
  125927. * Gets the value of the `Back` button
  125928. */
  125929. get buttonBack(): number;
  125930. /**
  125931. * Sets the value of the `Back` button
  125932. */
  125933. set buttonBack(value: number);
  125934. /**
  125935. * Gets the value of the `Left` button
  125936. */
  125937. get buttonLB(): number;
  125938. /**
  125939. * Sets the value of the `Left` button
  125940. */
  125941. set buttonLB(value: number);
  125942. /**
  125943. * Gets the value of the `Right` button
  125944. */
  125945. get buttonRB(): number;
  125946. /**
  125947. * Sets the value of the `Right` button
  125948. */
  125949. set buttonRB(value: number);
  125950. /**
  125951. * Gets the value of the Left joystick
  125952. */
  125953. get buttonLeftStick(): number;
  125954. /**
  125955. * Sets the value of the Left joystick
  125956. */
  125957. set buttonLeftStick(value: number);
  125958. /**
  125959. * Gets the value of the Right joystick
  125960. */
  125961. get buttonRightStick(): number;
  125962. /**
  125963. * Sets the value of the Right joystick
  125964. */
  125965. set buttonRightStick(value: number);
  125966. /**
  125967. * Gets the value of D-pad up
  125968. */
  125969. get dPadUp(): number;
  125970. /**
  125971. * Sets the value of D-pad up
  125972. */
  125973. set dPadUp(value: number);
  125974. /**
  125975. * Gets the value of D-pad down
  125976. */
  125977. get dPadDown(): number;
  125978. /**
  125979. * Sets the value of D-pad down
  125980. */
  125981. set dPadDown(value: number);
  125982. /**
  125983. * Gets the value of D-pad left
  125984. */
  125985. get dPadLeft(): number;
  125986. /**
  125987. * Sets the value of D-pad left
  125988. */
  125989. set dPadLeft(value: number);
  125990. /**
  125991. * Gets the value of D-pad right
  125992. */
  125993. get dPadRight(): number;
  125994. /**
  125995. * Sets the value of D-pad right
  125996. */
  125997. set dPadRight(value: number);
  125998. /**
  125999. * Force the gamepad to synchronize with device values
  126000. */
  126001. update(): void;
  126002. /**
  126003. * Disposes the gamepad
  126004. */
  126005. dispose(): void;
  126006. }
  126007. }
  126008. declare module BABYLON {
  126009. /**
  126010. * Defines supported buttons for DualShock compatible gamepads
  126011. */
  126012. export enum DualShockButton {
  126013. /** Cross */
  126014. Cross = 0,
  126015. /** Circle */
  126016. Circle = 1,
  126017. /** Square */
  126018. Square = 2,
  126019. /** Triangle */
  126020. Triangle = 3,
  126021. /** L1 */
  126022. L1 = 4,
  126023. /** R1 */
  126024. R1 = 5,
  126025. /** Share */
  126026. Share = 8,
  126027. /** Options */
  126028. Options = 9,
  126029. /** Left stick */
  126030. LeftStick = 10,
  126031. /** Right stick */
  126032. RightStick = 11
  126033. }
  126034. /** Defines values for DualShock DPad */
  126035. export enum DualShockDpad {
  126036. /** Up */
  126037. Up = 12,
  126038. /** Down */
  126039. Down = 13,
  126040. /** Left */
  126041. Left = 14,
  126042. /** Right */
  126043. Right = 15
  126044. }
  126045. /**
  126046. * Defines a DualShock gamepad
  126047. */
  126048. export class DualShockPad extends Gamepad {
  126049. private _leftTrigger;
  126050. private _rightTrigger;
  126051. private _onlefttriggerchanged;
  126052. private _onrighttriggerchanged;
  126053. private _onbuttondown;
  126054. private _onbuttonup;
  126055. private _ondpaddown;
  126056. private _ondpadup;
  126057. /** Observable raised when a button is pressed */
  126058. onButtonDownObservable: Observable<DualShockButton>;
  126059. /** Observable raised when a button is released */
  126060. onButtonUpObservable: Observable<DualShockButton>;
  126061. /** Observable raised when a pad is pressed */
  126062. onPadDownObservable: Observable<DualShockDpad>;
  126063. /** Observable raised when a pad is released */
  126064. onPadUpObservable: Observable<DualShockDpad>;
  126065. private _buttonCross;
  126066. private _buttonCircle;
  126067. private _buttonSquare;
  126068. private _buttonTriangle;
  126069. private _buttonShare;
  126070. private _buttonOptions;
  126071. private _buttonL1;
  126072. private _buttonR1;
  126073. private _buttonLeftStick;
  126074. private _buttonRightStick;
  126075. private _dPadUp;
  126076. private _dPadDown;
  126077. private _dPadLeft;
  126078. private _dPadRight;
  126079. /**
  126080. * Creates a new DualShock gamepad object
  126081. * @param id defines the id of this gamepad
  126082. * @param index defines its index
  126083. * @param gamepad defines the internal HTML gamepad object
  126084. */
  126085. constructor(id: string, index: number, gamepad: any);
  126086. /**
  126087. * Defines the callback to call when left trigger is pressed
  126088. * @param callback defines the callback to use
  126089. */
  126090. onlefttriggerchanged(callback: (value: number) => void): void;
  126091. /**
  126092. * Defines the callback to call when right trigger is pressed
  126093. * @param callback defines the callback to use
  126094. */
  126095. onrighttriggerchanged(callback: (value: number) => void): void;
  126096. /**
  126097. * Gets the left trigger value
  126098. */
  126099. get leftTrigger(): number;
  126100. /**
  126101. * Sets the left trigger value
  126102. */
  126103. set leftTrigger(newValue: number);
  126104. /**
  126105. * Gets the right trigger value
  126106. */
  126107. get rightTrigger(): number;
  126108. /**
  126109. * Sets the right trigger value
  126110. */
  126111. set rightTrigger(newValue: number);
  126112. /**
  126113. * Defines the callback to call when a button is pressed
  126114. * @param callback defines the callback to use
  126115. */
  126116. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126117. /**
  126118. * Defines the callback to call when a button is released
  126119. * @param callback defines the callback to use
  126120. */
  126121. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126122. /**
  126123. * Defines the callback to call when a pad is pressed
  126124. * @param callback defines the callback to use
  126125. */
  126126. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126127. /**
  126128. * Defines the callback to call when a pad is released
  126129. * @param callback defines the callback to use
  126130. */
  126131. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126132. private _setButtonValue;
  126133. private _setDPadValue;
  126134. /**
  126135. * Gets the value of the `Cross` button
  126136. */
  126137. get buttonCross(): number;
  126138. /**
  126139. * Sets the value of the `Cross` button
  126140. */
  126141. set buttonCross(value: number);
  126142. /**
  126143. * Gets the value of the `Circle` button
  126144. */
  126145. get buttonCircle(): number;
  126146. /**
  126147. * Sets the value of the `Circle` button
  126148. */
  126149. set buttonCircle(value: number);
  126150. /**
  126151. * Gets the value of the `Square` button
  126152. */
  126153. get buttonSquare(): number;
  126154. /**
  126155. * Sets the value of the `Square` button
  126156. */
  126157. set buttonSquare(value: number);
  126158. /**
  126159. * Gets the value of the `Triangle` button
  126160. */
  126161. get buttonTriangle(): number;
  126162. /**
  126163. * Sets the value of the `Triangle` button
  126164. */
  126165. set buttonTriangle(value: number);
  126166. /**
  126167. * Gets the value of the `Options` button
  126168. */
  126169. get buttonOptions(): number;
  126170. /**
  126171. * Sets the value of the `Options` button
  126172. */
  126173. set buttonOptions(value: number);
  126174. /**
  126175. * Gets the value of the `Share` button
  126176. */
  126177. get buttonShare(): number;
  126178. /**
  126179. * Sets the value of the `Share` button
  126180. */
  126181. set buttonShare(value: number);
  126182. /**
  126183. * Gets the value of the `L1` button
  126184. */
  126185. get buttonL1(): number;
  126186. /**
  126187. * Sets the value of the `L1` button
  126188. */
  126189. set buttonL1(value: number);
  126190. /**
  126191. * Gets the value of the `R1` button
  126192. */
  126193. get buttonR1(): number;
  126194. /**
  126195. * Sets the value of the `R1` button
  126196. */
  126197. set buttonR1(value: number);
  126198. /**
  126199. * Gets the value of the Left joystick
  126200. */
  126201. get buttonLeftStick(): number;
  126202. /**
  126203. * Sets the value of the Left joystick
  126204. */
  126205. set buttonLeftStick(value: number);
  126206. /**
  126207. * Gets the value of the Right joystick
  126208. */
  126209. get buttonRightStick(): number;
  126210. /**
  126211. * Sets the value of the Right joystick
  126212. */
  126213. set buttonRightStick(value: number);
  126214. /**
  126215. * Gets the value of D-pad up
  126216. */
  126217. get dPadUp(): number;
  126218. /**
  126219. * Sets the value of D-pad up
  126220. */
  126221. set dPadUp(value: number);
  126222. /**
  126223. * Gets the value of D-pad down
  126224. */
  126225. get dPadDown(): number;
  126226. /**
  126227. * Sets the value of D-pad down
  126228. */
  126229. set dPadDown(value: number);
  126230. /**
  126231. * Gets the value of D-pad left
  126232. */
  126233. get dPadLeft(): number;
  126234. /**
  126235. * Sets the value of D-pad left
  126236. */
  126237. set dPadLeft(value: number);
  126238. /**
  126239. * Gets the value of D-pad right
  126240. */
  126241. get dPadRight(): number;
  126242. /**
  126243. * Sets the value of D-pad right
  126244. */
  126245. set dPadRight(value: number);
  126246. /**
  126247. * Force the gamepad to synchronize with device values
  126248. */
  126249. update(): void;
  126250. /**
  126251. * Disposes the gamepad
  126252. */
  126253. dispose(): void;
  126254. }
  126255. }
  126256. declare module BABYLON {
  126257. /**
  126258. * Manager for handling gamepads
  126259. */
  126260. export class GamepadManager {
  126261. private _scene?;
  126262. private _babylonGamepads;
  126263. private _oneGamepadConnected;
  126264. /** @hidden */
  126265. _isMonitoring: boolean;
  126266. private _gamepadEventSupported;
  126267. private _gamepadSupport?;
  126268. /**
  126269. * observable to be triggered when the gamepad controller has been connected
  126270. */
  126271. onGamepadConnectedObservable: Observable<Gamepad>;
  126272. /**
  126273. * observable to be triggered when the gamepad controller has been disconnected
  126274. */
  126275. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126276. private _onGamepadConnectedEvent;
  126277. private _onGamepadDisconnectedEvent;
  126278. /**
  126279. * Initializes the gamepad manager
  126280. * @param _scene BabylonJS scene
  126281. */
  126282. constructor(_scene?: Scene | undefined);
  126283. /**
  126284. * The gamepads in the game pad manager
  126285. */
  126286. get gamepads(): Gamepad[];
  126287. /**
  126288. * Get the gamepad controllers based on type
  126289. * @param type The type of gamepad controller
  126290. * @returns Nullable gamepad
  126291. */
  126292. getGamepadByType(type?: number): Nullable<Gamepad>;
  126293. /**
  126294. * Disposes the gamepad manager
  126295. */
  126296. dispose(): void;
  126297. private _addNewGamepad;
  126298. private _startMonitoringGamepads;
  126299. private _stopMonitoringGamepads;
  126300. /** @hidden */
  126301. _checkGamepadsStatus(): void;
  126302. private _updateGamepadObjects;
  126303. }
  126304. }
  126305. declare module BABYLON {
  126306. interface Scene {
  126307. /** @hidden */
  126308. _gamepadManager: Nullable<GamepadManager>;
  126309. /**
  126310. * Gets the gamepad manager associated with the scene
  126311. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126312. */
  126313. gamepadManager: GamepadManager;
  126314. }
  126315. /**
  126316. * Interface representing a free camera inputs manager
  126317. */
  126318. interface FreeCameraInputsManager {
  126319. /**
  126320. * Adds gamepad input support to the FreeCameraInputsManager.
  126321. * @returns the FreeCameraInputsManager
  126322. */
  126323. addGamepad(): FreeCameraInputsManager;
  126324. }
  126325. /**
  126326. * Interface representing an arc rotate camera inputs manager
  126327. */
  126328. interface ArcRotateCameraInputsManager {
  126329. /**
  126330. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126331. * @returns the camera inputs manager
  126332. */
  126333. addGamepad(): ArcRotateCameraInputsManager;
  126334. }
  126335. /**
  126336. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126337. */
  126338. export class GamepadSystemSceneComponent implements ISceneComponent {
  126339. /**
  126340. * The component name helpfull to identify the component in the list of scene components.
  126341. */
  126342. readonly name: string;
  126343. /**
  126344. * The scene the component belongs to.
  126345. */
  126346. scene: Scene;
  126347. /**
  126348. * Creates a new instance of the component for the given scene
  126349. * @param scene Defines the scene to register the component in
  126350. */
  126351. constructor(scene: Scene);
  126352. /**
  126353. * Registers the component in a given scene
  126354. */
  126355. register(): void;
  126356. /**
  126357. * Rebuilds the elements related to this component in case of
  126358. * context lost for instance.
  126359. */
  126360. rebuild(): void;
  126361. /**
  126362. * Disposes the component and the associated ressources
  126363. */
  126364. dispose(): void;
  126365. private _beforeCameraUpdate;
  126366. }
  126367. }
  126368. declare module BABYLON {
  126369. /**
  126370. * 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,
  126371. * which still works and will still be found in many Playgrounds.
  126372. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126373. */
  126374. export class UniversalCamera extends TouchCamera {
  126375. /**
  126376. * Defines the gamepad rotation sensiblity.
  126377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126378. */
  126379. get gamepadAngularSensibility(): number;
  126380. set gamepadAngularSensibility(value: number);
  126381. /**
  126382. * Defines the gamepad move sensiblity.
  126383. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126384. */
  126385. get gamepadMoveSensibility(): number;
  126386. set gamepadMoveSensibility(value: number);
  126387. /**
  126388. * 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,
  126389. * which still works and will still be found in many Playgrounds.
  126390. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126391. * @param name Define the name of the camera in the scene
  126392. * @param position Define the start position of the camera in the scene
  126393. * @param scene Define the scene the camera belongs to
  126394. */
  126395. constructor(name: string, position: Vector3, scene: Scene);
  126396. /**
  126397. * Gets the current object class name.
  126398. * @return the class name
  126399. */
  126400. getClassName(): string;
  126401. }
  126402. }
  126403. declare module BABYLON {
  126404. /**
  126405. * This represents a FPS type of camera. This is only here for back compat purpose.
  126406. * Please use the UniversalCamera instead as both are identical.
  126407. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126408. */
  126409. export class GamepadCamera extends UniversalCamera {
  126410. /**
  126411. * Instantiates a new Gamepad Camera
  126412. * This represents a FPS type of camera. This is only here for back compat purpose.
  126413. * Please use the UniversalCamera instead as both are identical.
  126414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126415. * @param name Define the name of the camera in the scene
  126416. * @param position Define the start position of the camera in the scene
  126417. * @param scene Define the scene the camera belongs to
  126418. */
  126419. constructor(name: string, position: Vector3, scene: Scene);
  126420. /**
  126421. * Gets the current object class name.
  126422. * @return the class name
  126423. */
  126424. getClassName(): string;
  126425. }
  126426. }
  126427. declare module BABYLON {
  126428. /** @hidden */
  126429. export var passPixelShader: {
  126430. name: string;
  126431. shader: string;
  126432. };
  126433. }
  126434. declare module BABYLON {
  126435. /** @hidden */
  126436. export var passCubePixelShader: {
  126437. name: string;
  126438. shader: string;
  126439. };
  126440. }
  126441. declare module BABYLON {
  126442. /**
  126443. * PassPostProcess which produces an output the same as it's input
  126444. */
  126445. export class PassPostProcess extends PostProcess {
  126446. /**
  126447. * Gets a string identifying the name of the class
  126448. * @returns "PassPostProcess" string
  126449. */
  126450. getClassName(): string;
  126451. /**
  126452. * Creates the PassPostProcess
  126453. * @param name The name of the effect.
  126454. * @param options The required width/height ratio to downsize to before computing the render pass.
  126455. * @param camera The camera to apply the render pass to.
  126456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126457. * @param engine The engine which the post process will be applied. (default: current engine)
  126458. * @param reusable If the post process can be reused on the same frame. (default: false)
  126459. * @param textureType The type of texture to be used when performing the post processing.
  126460. * @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)
  126461. */
  126462. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126463. /** @hidden */
  126464. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126465. }
  126466. /**
  126467. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126468. */
  126469. export class PassCubePostProcess extends PostProcess {
  126470. private _face;
  126471. /**
  126472. * Gets or sets the cube face to display.
  126473. * * 0 is +X
  126474. * * 1 is -X
  126475. * * 2 is +Y
  126476. * * 3 is -Y
  126477. * * 4 is +Z
  126478. * * 5 is -Z
  126479. */
  126480. get face(): number;
  126481. set face(value: number);
  126482. /**
  126483. * Gets a string identifying the name of the class
  126484. * @returns "PassCubePostProcess" string
  126485. */
  126486. getClassName(): string;
  126487. /**
  126488. * Creates the PassCubePostProcess
  126489. * @param name The name of the effect.
  126490. * @param options The required width/height ratio to downsize to before computing the render pass.
  126491. * @param camera The camera to apply the render pass to.
  126492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126493. * @param engine The engine which the post process will be applied. (default: current engine)
  126494. * @param reusable If the post process can be reused on the same frame. (default: false)
  126495. * @param textureType The type of texture to be used when performing the post processing.
  126496. * @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)
  126497. */
  126498. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126499. /** @hidden */
  126500. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126501. }
  126502. }
  126503. declare module BABYLON {
  126504. /** @hidden */
  126505. export var anaglyphPixelShader: {
  126506. name: string;
  126507. shader: string;
  126508. };
  126509. }
  126510. declare module BABYLON {
  126511. /**
  126512. * Postprocess used to generate anaglyphic rendering
  126513. */
  126514. export class AnaglyphPostProcess extends PostProcess {
  126515. private _passedProcess;
  126516. /**
  126517. * Gets a string identifying the name of the class
  126518. * @returns "AnaglyphPostProcess" string
  126519. */
  126520. getClassName(): string;
  126521. /**
  126522. * Creates a new AnaglyphPostProcess
  126523. * @param name defines postprocess name
  126524. * @param options defines creation options or target ratio scale
  126525. * @param rigCameras defines cameras using this postprocess
  126526. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126527. * @param engine defines hosting engine
  126528. * @param reusable defines if the postprocess will be reused multiple times per frame
  126529. */
  126530. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126531. }
  126532. }
  126533. declare module BABYLON {
  126534. /**
  126535. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126536. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126537. */
  126538. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126539. /**
  126540. * Creates a new AnaglyphArcRotateCamera
  126541. * @param name defines camera name
  126542. * @param alpha defines alpha angle (in radians)
  126543. * @param beta defines beta angle (in radians)
  126544. * @param radius defines radius
  126545. * @param target defines camera target
  126546. * @param interaxialDistance defines distance between each color axis
  126547. * @param scene defines the hosting scene
  126548. */
  126549. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126550. /**
  126551. * Gets camera class name
  126552. * @returns AnaglyphArcRotateCamera
  126553. */
  126554. getClassName(): string;
  126555. }
  126556. }
  126557. declare module BABYLON {
  126558. /**
  126559. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126560. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126561. */
  126562. export class AnaglyphFreeCamera extends FreeCamera {
  126563. /**
  126564. * Creates a new AnaglyphFreeCamera
  126565. * @param name defines camera name
  126566. * @param position defines initial position
  126567. * @param interaxialDistance defines distance between each color axis
  126568. * @param scene defines the hosting scene
  126569. */
  126570. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126571. /**
  126572. * Gets camera class name
  126573. * @returns AnaglyphFreeCamera
  126574. */
  126575. getClassName(): string;
  126576. }
  126577. }
  126578. declare module BABYLON {
  126579. /**
  126580. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126581. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126582. */
  126583. export class AnaglyphGamepadCamera extends GamepadCamera {
  126584. /**
  126585. * Creates a new AnaglyphGamepadCamera
  126586. * @param name defines camera name
  126587. * @param position defines initial position
  126588. * @param interaxialDistance defines distance between each color axis
  126589. * @param scene defines the hosting scene
  126590. */
  126591. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126592. /**
  126593. * Gets camera class name
  126594. * @returns AnaglyphGamepadCamera
  126595. */
  126596. getClassName(): string;
  126597. }
  126598. }
  126599. declare module BABYLON {
  126600. /**
  126601. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126602. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126603. */
  126604. export class AnaglyphUniversalCamera extends UniversalCamera {
  126605. /**
  126606. * Creates a new AnaglyphUniversalCamera
  126607. * @param name defines camera name
  126608. * @param position defines initial position
  126609. * @param interaxialDistance defines distance between each color axis
  126610. * @param scene defines the hosting scene
  126611. */
  126612. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126613. /**
  126614. * Gets camera class name
  126615. * @returns AnaglyphUniversalCamera
  126616. */
  126617. getClassName(): string;
  126618. }
  126619. }
  126620. declare module BABYLON {
  126621. /**
  126622. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126623. * @see https://doc.babylonjs.com/features/cameras
  126624. */
  126625. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126626. /**
  126627. * Creates a new StereoscopicArcRotateCamera
  126628. * @param name defines camera name
  126629. * @param alpha defines alpha angle (in radians)
  126630. * @param beta defines beta angle (in radians)
  126631. * @param radius defines radius
  126632. * @param target defines camera target
  126633. * @param interaxialDistance defines distance between each color axis
  126634. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126635. * @param scene defines the hosting scene
  126636. */
  126637. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126638. /**
  126639. * Gets camera class name
  126640. * @returns StereoscopicArcRotateCamera
  126641. */
  126642. getClassName(): string;
  126643. }
  126644. }
  126645. declare module BABYLON {
  126646. /**
  126647. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126648. * @see https://doc.babylonjs.com/features/cameras
  126649. */
  126650. export class StereoscopicFreeCamera extends FreeCamera {
  126651. /**
  126652. * Creates a new StereoscopicFreeCamera
  126653. * @param name defines camera name
  126654. * @param position defines initial position
  126655. * @param interaxialDistance defines distance between each color axis
  126656. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126657. * @param scene defines the hosting scene
  126658. */
  126659. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126660. /**
  126661. * Gets camera class name
  126662. * @returns StereoscopicFreeCamera
  126663. */
  126664. getClassName(): string;
  126665. }
  126666. }
  126667. declare module BABYLON {
  126668. /**
  126669. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126670. * @see https://doc.babylonjs.com/features/cameras
  126671. */
  126672. export class StereoscopicGamepadCamera extends GamepadCamera {
  126673. /**
  126674. * Creates a new StereoscopicGamepadCamera
  126675. * @param name defines camera name
  126676. * @param position defines initial position
  126677. * @param interaxialDistance defines distance between each color axis
  126678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126679. * @param scene defines the hosting scene
  126680. */
  126681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126682. /**
  126683. * Gets camera class name
  126684. * @returns StereoscopicGamepadCamera
  126685. */
  126686. getClassName(): string;
  126687. }
  126688. }
  126689. declare module BABYLON {
  126690. /**
  126691. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126692. * @see https://doc.babylonjs.com/features/cameras
  126693. */
  126694. export class StereoscopicUniversalCamera extends UniversalCamera {
  126695. /**
  126696. * Creates a new StereoscopicUniversalCamera
  126697. * @param name defines camera name
  126698. * @param position defines initial position
  126699. * @param interaxialDistance defines distance between each color axis
  126700. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126701. * @param scene defines the hosting scene
  126702. */
  126703. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126704. /**
  126705. * Gets camera class name
  126706. * @returns StereoscopicUniversalCamera
  126707. */
  126708. getClassName(): string;
  126709. }
  126710. }
  126711. declare module BABYLON {
  126712. /**
  126713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126714. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126715. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126716. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126717. */
  126718. export class VirtualJoysticksCamera extends FreeCamera {
  126719. /**
  126720. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126721. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126722. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126723. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126724. * @param name Define the name of the camera in the scene
  126725. * @param position Define the start position of the camera in the scene
  126726. * @param scene Define the scene the camera belongs to
  126727. */
  126728. constructor(name: string, position: Vector3, scene: Scene);
  126729. /**
  126730. * Gets the current object class name.
  126731. * @return the class name
  126732. */
  126733. getClassName(): string;
  126734. }
  126735. }
  126736. declare module BABYLON {
  126737. /**
  126738. * This represents all the required metrics to create a VR camera.
  126739. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126740. */
  126741. export class VRCameraMetrics {
  126742. /**
  126743. * Define the horizontal resolution off the screen.
  126744. */
  126745. hResolution: number;
  126746. /**
  126747. * Define the vertical resolution off the screen.
  126748. */
  126749. vResolution: number;
  126750. /**
  126751. * Define the horizontal screen size.
  126752. */
  126753. hScreenSize: number;
  126754. /**
  126755. * Define the vertical screen size.
  126756. */
  126757. vScreenSize: number;
  126758. /**
  126759. * Define the vertical screen center position.
  126760. */
  126761. vScreenCenter: number;
  126762. /**
  126763. * Define the distance of the eyes to the screen.
  126764. */
  126765. eyeToScreenDistance: number;
  126766. /**
  126767. * Define the distance between both lenses
  126768. */
  126769. lensSeparationDistance: number;
  126770. /**
  126771. * Define the distance between both viewer's eyes.
  126772. */
  126773. interpupillaryDistance: number;
  126774. /**
  126775. * Define the distortion factor of the VR postprocess.
  126776. * Please, touch with care.
  126777. */
  126778. distortionK: number[];
  126779. /**
  126780. * Define the chromatic aberration correction factors for the VR post process.
  126781. */
  126782. chromaAbCorrection: number[];
  126783. /**
  126784. * Define the scale factor of the post process.
  126785. * The smaller the better but the slower.
  126786. */
  126787. postProcessScaleFactor: number;
  126788. /**
  126789. * Define an offset for the lens center.
  126790. */
  126791. lensCenterOffset: number;
  126792. /**
  126793. * Define if the current vr camera should compensate the distortion of the lense or not.
  126794. */
  126795. compensateDistortion: boolean;
  126796. /**
  126797. * Defines if multiview should be enabled when rendering (Default: false)
  126798. */
  126799. multiviewEnabled: boolean;
  126800. /**
  126801. * Gets the rendering aspect ratio based on the provided resolutions.
  126802. */
  126803. get aspectRatio(): number;
  126804. /**
  126805. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126806. */
  126807. get aspectRatioFov(): number;
  126808. /**
  126809. * @hidden
  126810. */
  126811. get leftHMatrix(): Matrix;
  126812. /**
  126813. * @hidden
  126814. */
  126815. get rightHMatrix(): Matrix;
  126816. /**
  126817. * @hidden
  126818. */
  126819. get leftPreViewMatrix(): Matrix;
  126820. /**
  126821. * @hidden
  126822. */
  126823. get rightPreViewMatrix(): Matrix;
  126824. /**
  126825. * Get the default VRMetrics based on the most generic setup.
  126826. * @returns the default vr metrics
  126827. */
  126828. static GetDefault(): VRCameraMetrics;
  126829. }
  126830. }
  126831. declare module BABYLON {
  126832. /** @hidden */
  126833. export var vrDistortionCorrectionPixelShader: {
  126834. name: string;
  126835. shader: string;
  126836. };
  126837. }
  126838. declare module BABYLON {
  126839. /**
  126840. * VRDistortionCorrectionPostProcess used for mobile VR
  126841. */
  126842. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126843. private _isRightEye;
  126844. private _distortionFactors;
  126845. private _postProcessScaleFactor;
  126846. private _lensCenterOffset;
  126847. private _scaleIn;
  126848. private _scaleFactor;
  126849. private _lensCenter;
  126850. /**
  126851. * Gets a string identifying the name of the class
  126852. * @returns "VRDistortionCorrectionPostProcess" string
  126853. */
  126854. getClassName(): string;
  126855. /**
  126856. * Initializes the VRDistortionCorrectionPostProcess
  126857. * @param name The name of the effect.
  126858. * @param camera The camera to apply the render pass to.
  126859. * @param isRightEye If this is for the right eye distortion
  126860. * @param vrMetrics All the required metrics for the VR camera
  126861. */
  126862. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126863. }
  126864. }
  126865. declare module BABYLON {
  126866. /**
  126867. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126868. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126869. */
  126870. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126871. /**
  126872. * Creates a new VRDeviceOrientationArcRotateCamera
  126873. * @param name defines camera name
  126874. * @param alpha defines the camera rotation along the logitudinal axis
  126875. * @param beta defines the camera rotation along the latitudinal axis
  126876. * @param radius defines the camera distance from its target
  126877. * @param target defines the camera target
  126878. * @param scene defines the scene the camera belongs to
  126879. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126880. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126881. */
  126882. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126883. /**
  126884. * Gets camera class name
  126885. * @returns VRDeviceOrientationArcRotateCamera
  126886. */
  126887. getClassName(): string;
  126888. }
  126889. }
  126890. declare module BABYLON {
  126891. /**
  126892. * Camera used to simulate VR rendering (based on FreeCamera)
  126893. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126894. */
  126895. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126896. /**
  126897. * Creates a new VRDeviceOrientationFreeCamera
  126898. * @param name defines camera name
  126899. * @param position defines the start position of the camera
  126900. * @param scene defines the scene the camera belongs to
  126901. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126902. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126903. */
  126904. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126905. /**
  126906. * Gets camera class name
  126907. * @returns VRDeviceOrientationFreeCamera
  126908. */
  126909. getClassName(): string;
  126910. }
  126911. }
  126912. declare module BABYLON {
  126913. /**
  126914. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126915. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126916. */
  126917. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126918. /**
  126919. * Creates a new VRDeviceOrientationGamepadCamera
  126920. * @param name defines camera name
  126921. * @param position defines the start position of the camera
  126922. * @param scene defines the scene the camera belongs to
  126923. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126924. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126925. */
  126926. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126927. /**
  126928. * Gets camera class name
  126929. * @returns VRDeviceOrientationGamepadCamera
  126930. */
  126931. getClassName(): string;
  126932. }
  126933. }
  126934. declare module BABYLON {
  126935. /**
  126936. * A class extending Texture allowing drawing on a texture
  126937. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126938. */
  126939. export class DynamicTexture extends Texture {
  126940. private _generateMipMaps;
  126941. private _canvas;
  126942. private _context;
  126943. /**
  126944. * Creates a DynamicTexture
  126945. * @param name defines the name of the texture
  126946. * @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
  126947. * @param scene defines the scene where you want the texture
  126948. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126949. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126950. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126951. */
  126952. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126953. /**
  126954. * Get the current class name of the texture useful for serialization or dynamic coding.
  126955. * @returns "DynamicTexture"
  126956. */
  126957. getClassName(): string;
  126958. /**
  126959. * Gets the current state of canRescale
  126960. */
  126961. get canRescale(): boolean;
  126962. private _recreate;
  126963. /**
  126964. * Scales the texture
  126965. * @param ratio the scale factor to apply to both width and height
  126966. */
  126967. scale(ratio: number): void;
  126968. /**
  126969. * Resizes the texture
  126970. * @param width the new width
  126971. * @param height the new height
  126972. */
  126973. scaleTo(width: number, height: number): void;
  126974. /**
  126975. * Gets the context of the canvas used by the texture
  126976. * @returns the canvas context of the dynamic texture
  126977. */
  126978. getContext(): CanvasRenderingContext2D;
  126979. /**
  126980. * Clears the texture
  126981. */
  126982. clear(): void;
  126983. /**
  126984. * Updates the texture
  126985. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126986. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126987. */
  126988. update(invertY?: boolean, premulAlpha?: boolean): void;
  126989. /**
  126990. * Draws text onto the texture
  126991. * @param text defines the text to be drawn
  126992. * @param x defines the placement of the text from the left
  126993. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126994. * @param font defines the font to be used with font-style, font-size, font-name
  126995. * @param color defines the color used for the text
  126996. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126997. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126998. * @param update defines whether texture is immediately update (default is true)
  126999. */
  127000. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127001. /**
  127002. * Clones the texture
  127003. * @returns the clone of the texture.
  127004. */
  127005. clone(): DynamicTexture;
  127006. /**
  127007. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127008. * @returns a serialized dynamic texture object
  127009. */
  127010. serialize(): any;
  127011. private _IsCanvasElement;
  127012. /** @hidden */
  127013. _rebuild(): void;
  127014. }
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * Class containing static functions to help procedurally build meshes
  127019. */
  127020. export class GroundBuilder {
  127021. /**
  127022. * Creates a ground mesh
  127023. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127024. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127026. * @param name defines the name of the mesh
  127027. * @param options defines the options used to create the mesh
  127028. * @param scene defines the hosting scene
  127029. * @returns the ground mesh
  127030. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127031. */
  127032. static CreateGround(name: string, options: {
  127033. width?: number;
  127034. height?: number;
  127035. subdivisions?: number;
  127036. subdivisionsX?: number;
  127037. subdivisionsY?: number;
  127038. updatable?: boolean;
  127039. }, scene: any): Mesh;
  127040. /**
  127041. * Creates a tiled ground mesh
  127042. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127043. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127044. * * 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
  127045. * * 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
  127046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127047. * @param name defines the name of the mesh
  127048. * @param options defines the options used to create the mesh
  127049. * @param scene defines the hosting scene
  127050. * @returns the tiled ground mesh
  127051. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127052. */
  127053. static CreateTiledGround(name: string, options: {
  127054. xmin: number;
  127055. zmin: number;
  127056. xmax: number;
  127057. zmax: number;
  127058. subdivisions?: {
  127059. w: number;
  127060. h: number;
  127061. };
  127062. precision?: {
  127063. w: number;
  127064. h: number;
  127065. };
  127066. updatable?: boolean;
  127067. }, scene?: Nullable<Scene>): Mesh;
  127068. /**
  127069. * Creates a ground mesh from a height map
  127070. * * The parameter `url` sets the URL of the height map image resource.
  127071. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127072. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127073. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127074. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127075. * * 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.
  127076. * * 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).
  127077. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127079. * @param name defines the name of the mesh
  127080. * @param url defines the url to the height map
  127081. * @param options defines the options used to create the mesh
  127082. * @param scene defines the hosting scene
  127083. * @returns the ground mesh
  127084. * @see https://doc.babylonjs.com/babylon101/height_map
  127085. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127086. */
  127087. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127088. width?: number;
  127089. height?: number;
  127090. subdivisions?: number;
  127091. minHeight?: number;
  127092. maxHeight?: number;
  127093. colorFilter?: Color3;
  127094. alphaFilter?: number;
  127095. updatable?: boolean;
  127096. onReady?: (mesh: GroundMesh) => void;
  127097. }, scene?: Nullable<Scene>): GroundMesh;
  127098. }
  127099. }
  127100. declare module BABYLON {
  127101. /**
  127102. * Class containing static functions to help procedurally build meshes
  127103. */
  127104. export class TorusBuilder {
  127105. /**
  127106. * Creates a torus mesh
  127107. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127108. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127109. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127113. * @param name defines the name of the mesh
  127114. * @param options defines the options used to create the mesh
  127115. * @param scene defines the hosting scene
  127116. * @returns the torus mesh
  127117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127118. */
  127119. static CreateTorus(name: string, options: {
  127120. diameter?: number;
  127121. thickness?: number;
  127122. tessellation?: number;
  127123. updatable?: boolean;
  127124. sideOrientation?: number;
  127125. frontUVs?: Vector4;
  127126. backUVs?: Vector4;
  127127. }, scene: any): Mesh;
  127128. }
  127129. }
  127130. declare module BABYLON {
  127131. /**
  127132. * Class containing static functions to help procedurally build meshes
  127133. */
  127134. export class CylinderBuilder {
  127135. /**
  127136. * Creates a cylinder or a cone mesh
  127137. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127138. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127139. * * 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.
  127140. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127141. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127142. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127143. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127144. * * 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).
  127145. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127146. * * 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).
  127147. * * 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
  127148. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127149. * * 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
  127150. * * 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.
  127151. * * If `enclose` is false, a ring surface is one element.
  127152. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127153. * * 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
  127154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127157. * @param name defines the name of the mesh
  127158. * @param options defines the options used to create the mesh
  127159. * @param scene defines the hosting scene
  127160. * @returns the cylinder mesh
  127161. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127162. */
  127163. static CreateCylinder(name: string, options: {
  127164. height?: number;
  127165. diameterTop?: number;
  127166. diameterBottom?: number;
  127167. diameter?: number;
  127168. tessellation?: number;
  127169. subdivisions?: number;
  127170. arc?: number;
  127171. faceColors?: Color4[];
  127172. faceUV?: Vector4[];
  127173. updatable?: boolean;
  127174. hasRings?: boolean;
  127175. enclose?: boolean;
  127176. cap?: number;
  127177. sideOrientation?: number;
  127178. frontUVs?: Vector4;
  127179. backUVs?: Vector4;
  127180. }, scene: any): Mesh;
  127181. }
  127182. }
  127183. declare module BABYLON {
  127184. /**
  127185. * States of the webXR experience
  127186. */
  127187. export enum WebXRState {
  127188. /**
  127189. * Transitioning to being in XR mode
  127190. */
  127191. ENTERING_XR = 0,
  127192. /**
  127193. * Transitioning to non XR mode
  127194. */
  127195. EXITING_XR = 1,
  127196. /**
  127197. * In XR mode and presenting
  127198. */
  127199. IN_XR = 2,
  127200. /**
  127201. * Not entered XR mode
  127202. */
  127203. NOT_IN_XR = 3
  127204. }
  127205. /**
  127206. * Abstraction of the XR render target
  127207. */
  127208. export interface WebXRRenderTarget extends IDisposable {
  127209. /**
  127210. * xrpresent context of the canvas which can be used to display/mirror xr content
  127211. */
  127212. canvasContext: WebGLRenderingContext;
  127213. /**
  127214. * xr layer for the canvas
  127215. */
  127216. xrLayer: Nullable<XRWebGLLayer>;
  127217. /**
  127218. * Initializes the xr layer for the session
  127219. * @param xrSession xr session
  127220. * @returns a promise that will resolve once the XR Layer has been created
  127221. */
  127222. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127223. }
  127224. }
  127225. declare module BABYLON {
  127226. /**
  127227. * COnfiguration object for WebXR output canvas
  127228. */
  127229. export class WebXRManagedOutputCanvasOptions {
  127230. /**
  127231. * An optional canvas in case you wish to create it yourself and provide it here.
  127232. * If not provided, a new canvas will be created
  127233. */
  127234. canvasElement?: HTMLCanvasElement;
  127235. /**
  127236. * Options for this XR Layer output
  127237. */
  127238. canvasOptions?: XRWebGLLayerOptions;
  127239. /**
  127240. * CSS styling for a newly created canvas (if not provided)
  127241. */
  127242. newCanvasCssStyle?: string;
  127243. /**
  127244. * Get the default values of the configuration object
  127245. * @param engine defines the engine to use (can be null)
  127246. * @returns default values of this configuration object
  127247. */
  127248. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127249. }
  127250. /**
  127251. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127252. */
  127253. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127254. private _options;
  127255. private _canvas;
  127256. private _engine;
  127257. private _originalCanvasSize;
  127258. /**
  127259. * Rendering context of the canvas which can be used to display/mirror xr content
  127260. */
  127261. canvasContext: WebGLRenderingContext;
  127262. /**
  127263. * xr layer for the canvas
  127264. */
  127265. xrLayer: Nullable<XRWebGLLayer>;
  127266. /**
  127267. * Obseervers registered here will be triggered when the xr layer was initialized
  127268. */
  127269. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127270. /**
  127271. * Initializes the canvas to be added/removed upon entering/exiting xr
  127272. * @param _xrSessionManager The XR Session manager
  127273. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127274. */
  127275. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127276. /**
  127277. * Disposes of the object
  127278. */
  127279. dispose(): void;
  127280. /**
  127281. * Initializes the xr layer for the session
  127282. * @param xrSession xr session
  127283. * @returns a promise that will resolve once the XR Layer has been created
  127284. */
  127285. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127286. private _addCanvas;
  127287. private _removeCanvas;
  127288. private _setCanvasSize;
  127289. private _setManagedOutputCanvas;
  127290. }
  127291. }
  127292. declare module BABYLON {
  127293. /**
  127294. * Manages an XRSession to work with Babylon's engine
  127295. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127296. */
  127297. export class WebXRSessionManager implements IDisposable {
  127298. /** The scene which the session should be created for */
  127299. scene: Scene;
  127300. private _referenceSpace;
  127301. private _rttProvider;
  127302. private _sessionEnded;
  127303. private _xrNavigator;
  127304. private baseLayer;
  127305. /**
  127306. * The base reference space from which the session started. good if you want to reset your
  127307. * reference space
  127308. */
  127309. baseReferenceSpace: XRReferenceSpace;
  127310. /**
  127311. * Current XR frame
  127312. */
  127313. currentFrame: Nullable<XRFrame>;
  127314. /** WebXR timestamp updated every frame */
  127315. currentTimestamp: number;
  127316. /**
  127317. * Used just in case of a failure to initialize an immersive session.
  127318. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127319. */
  127320. defaultHeightCompensation: number;
  127321. /**
  127322. * Fires every time a new xrFrame arrives which can be used to update the camera
  127323. */
  127324. onXRFrameObservable: Observable<XRFrame>;
  127325. /**
  127326. * Fires when the reference space changed
  127327. */
  127328. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127329. /**
  127330. * Fires when the xr session is ended either by the device or manually done
  127331. */
  127332. onXRSessionEnded: Observable<any>;
  127333. /**
  127334. * Fires when the xr session is ended either by the device or manually done
  127335. */
  127336. onXRSessionInit: Observable<XRSession>;
  127337. /**
  127338. * Underlying xr session
  127339. */
  127340. session: XRSession;
  127341. /**
  127342. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127343. * or get the offset the player is currently at.
  127344. */
  127345. viewerReferenceSpace: XRReferenceSpace;
  127346. /**
  127347. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127348. * @param scene The scene which the session should be created for
  127349. */
  127350. constructor(
  127351. /** The scene which the session should be created for */
  127352. scene: Scene);
  127353. /**
  127354. * The current reference space used in this session. This reference space can constantly change!
  127355. * It is mainly used to offset the camera's position.
  127356. */
  127357. get referenceSpace(): XRReferenceSpace;
  127358. /**
  127359. * Set a new reference space and triggers the observable
  127360. */
  127361. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127362. /**
  127363. * Disposes of the session manager
  127364. */
  127365. dispose(): void;
  127366. /**
  127367. * Stops the xrSession and restores the render loop
  127368. * @returns Promise which resolves after it exits XR
  127369. */
  127370. exitXRAsync(): Promise<void>;
  127371. /**
  127372. * Gets the correct render target texture to be rendered this frame for this eye
  127373. * @param eye the eye for which to get the render target
  127374. * @returns the render target for the specified eye
  127375. */
  127376. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127377. /**
  127378. * Creates a WebXRRenderTarget object for the XR session
  127379. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127380. * @param options optional options to provide when creating a new render target
  127381. * @returns a WebXR render target to which the session can render
  127382. */
  127383. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127384. /**
  127385. * Initializes the manager
  127386. * After initialization enterXR can be called to start an XR session
  127387. * @returns Promise which resolves after it is initialized
  127388. */
  127389. initializeAsync(): Promise<void>;
  127390. /**
  127391. * Initializes an xr session
  127392. * @param xrSessionMode mode to initialize
  127393. * @param xrSessionInit defines optional and required values to pass to the session builder
  127394. * @returns a promise which will resolve once the session has been initialized
  127395. */
  127396. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127397. /**
  127398. * Checks if a session would be supported for the creation options specified
  127399. * @param sessionMode session mode to check if supported eg. immersive-vr
  127400. * @returns A Promise that resolves to true if supported and false if not
  127401. */
  127402. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127403. /**
  127404. * Resets the reference space to the one started the session
  127405. */
  127406. resetReferenceSpace(): void;
  127407. /**
  127408. * Starts rendering to the xr layer
  127409. */
  127410. runXRRenderLoop(): void;
  127411. /**
  127412. * Sets the reference space on the xr session
  127413. * @param referenceSpaceType space to set
  127414. * @returns a promise that will resolve once the reference space has been set
  127415. */
  127416. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127417. /**
  127418. * Updates the render state of the session
  127419. * @param state state to set
  127420. * @returns a promise that resolves once the render state has been updated
  127421. */
  127422. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127423. /**
  127424. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127425. * @param sessionMode defines the session to test
  127426. * @returns a promise with boolean as final value
  127427. */
  127428. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127429. private _createRenderTargetTexture;
  127430. }
  127431. }
  127432. declare module BABYLON {
  127433. /**
  127434. * WebXR Camera which holds the views for the xrSession
  127435. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127436. */
  127437. export class WebXRCamera extends FreeCamera {
  127438. private _xrSessionManager;
  127439. private _firstFrame;
  127440. private _referenceQuaternion;
  127441. private _referencedPosition;
  127442. private _xrInvPositionCache;
  127443. private _xrInvQuaternionCache;
  127444. /**
  127445. * Observable raised before camera teleportation
  127446. */
  127447. onBeforeCameraTeleport: Observable<Vector3>;
  127448. /**
  127449. * Observable raised after camera teleportation
  127450. */
  127451. onAfterCameraTeleport: Observable<Vector3>;
  127452. /**
  127453. * Should position compensation execute on first frame.
  127454. * This is used when copying the position from a native (non XR) camera
  127455. */
  127456. compensateOnFirstFrame: boolean;
  127457. /**
  127458. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127459. * @param name the name of the camera
  127460. * @param scene the scene to add the camera to
  127461. * @param _xrSessionManager a constructed xr session manager
  127462. */
  127463. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127464. /**
  127465. * Return the user's height, unrelated to the current ground.
  127466. * This will be the y position of this camera, when ground level is 0.
  127467. */
  127468. get realWorldHeight(): number;
  127469. /** @hidden */
  127470. _updateForDualEyeDebugging(): void;
  127471. /**
  127472. * Sets this camera's transformation based on a non-vr camera
  127473. * @param otherCamera the non-vr camera to copy the transformation from
  127474. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127475. */
  127476. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127477. /**
  127478. * Gets the current instance class name ("WebXRCamera").
  127479. * @returns the class name
  127480. */
  127481. getClassName(): string;
  127482. private _rotate180;
  127483. private _updateFromXRSession;
  127484. private _updateNumberOfRigCameras;
  127485. private _updateReferenceSpace;
  127486. private _updateReferenceSpaceOffset;
  127487. }
  127488. }
  127489. declare module BABYLON {
  127490. /**
  127491. * Defining the interface required for a (webxr) feature
  127492. */
  127493. export interface IWebXRFeature extends IDisposable {
  127494. /**
  127495. * Is this feature attached
  127496. */
  127497. attached: boolean;
  127498. /**
  127499. * Should auto-attach be disabled?
  127500. */
  127501. disableAutoAttach: boolean;
  127502. /**
  127503. * Attach the feature to the session
  127504. * Will usually be called by the features manager
  127505. *
  127506. * @param force should attachment be forced (even when already attached)
  127507. * @returns true if successful.
  127508. */
  127509. attach(force?: boolean): boolean;
  127510. /**
  127511. * Detach the feature from the session
  127512. * Will usually be called by the features manager
  127513. *
  127514. * @returns true if successful.
  127515. */
  127516. detach(): boolean;
  127517. /**
  127518. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127519. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127520. *
  127521. * @returns whether or not the feature is compatible in this environment
  127522. */
  127523. isCompatible(): boolean;
  127524. /**
  127525. * Was this feature disposed;
  127526. */
  127527. isDisposed: boolean;
  127528. /**
  127529. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127530. */
  127531. xrNativeFeatureName?: string;
  127532. /**
  127533. * A list of (Babylon WebXR) features this feature depends on
  127534. */
  127535. dependsOn?: string[];
  127536. }
  127537. /**
  127538. * A list of the currently available features without referencing them
  127539. */
  127540. export class WebXRFeatureName {
  127541. /**
  127542. * The name of the anchor system feature
  127543. */
  127544. static readonly ANCHOR_SYSTEM: string;
  127545. /**
  127546. * The name of the background remover feature
  127547. */
  127548. static readonly BACKGROUND_REMOVER: string;
  127549. /**
  127550. * The name of the hit test feature
  127551. */
  127552. static readonly HIT_TEST: string;
  127553. /**
  127554. * physics impostors for xr controllers feature
  127555. */
  127556. static readonly PHYSICS_CONTROLLERS: string;
  127557. /**
  127558. * The name of the plane detection feature
  127559. */
  127560. static readonly PLANE_DETECTION: string;
  127561. /**
  127562. * The name of the pointer selection feature
  127563. */
  127564. static readonly POINTER_SELECTION: string;
  127565. /**
  127566. * The name of the teleportation feature
  127567. */
  127568. static readonly TELEPORTATION: string;
  127569. /**
  127570. * The name of the feature points feature.
  127571. */
  127572. static readonly FEATURE_POINTS: string;
  127573. /**
  127574. * The name of the hand tracking feature.
  127575. */
  127576. static readonly HAND_TRACKING: string;
  127577. }
  127578. /**
  127579. * Defining the constructor of a feature. Used to register the modules.
  127580. */
  127581. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127582. /**
  127583. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127584. * It is mainly used in AR sessions.
  127585. *
  127586. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127587. */
  127588. export class WebXRFeaturesManager implements IDisposable {
  127589. private _xrSessionManager;
  127590. private static readonly _AvailableFeatures;
  127591. private _features;
  127592. /**
  127593. * constructs a new features manages.
  127594. *
  127595. * @param _xrSessionManager an instance of WebXRSessionManager
  127596. */
  127597. constructor(_xrSessionManager: WebXRSessionManager);
  127598. /**
  127599. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127600. * Mainly used internally.
  127601. *
  127602. * @param featureName the name of the feature to register
  127603. * @param constructorFunction the function used to construct the module
  127604. * @param version the (babylon) version of the module
  127605. * @param stable is that a stable version of this module
  127606. */
  127607. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127608. /**
  127609. * Returns a constructor of a specific feature.
  127610. *
  127611. * @param featureName the name of the feature to construct
  127612. * @param version the version of the feature to load
  127613. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127614. * @param options optional options provided to the module.
  127615. * @returns a function that, when called, will return a new instance of this feature
  127616. */
  127617. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127618. /**
  127619. * Can be used to return the list of features currently registered
  127620. *
  127621. * @returns an Array of available features
  127622. */
  127623. static GetAvailableFeatures(): string[];
  127624. /**
  127625. * Gets the versions available for a specific feature
  127626. * @param featureName the name of the feature
  127627. * @returns an array with the available versions
  127628. */
  127629. static GetAvailableVersions(featureName: string): string[];
  127630. /**
  127631. * Return the latest unstable version of this feature
  127632. * @param featureName the name of the feature to search
  127633. * @returns the version number. if not found will return -1
  127634. */
  127635. static GetLatestVersionOfFeature(featureName: string): number;
  127636. /**
  127637. * Return the latest stable version of this feature
  127638. * @param featureName the name of the feature to search
  127639. * @returns the version number. if not found will return -1
  127640. */
  127641. static GetStableVersionOfFeature(featureName: string): number;
  127642. /**
  127643. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127644. * Can be used during a session to start a feature
  127645. * @param featureName the name of feature to attach
  127646. */
  127647. attachFeature(featureName: string): void;
  127648. /**
  127649. * Can be used inside a session or when the session ends to detach a specific feature
  127650. * @param featureName the name of the feature to detach
  127651. */
  127652. detachFeature(featureName: string): void;
  127653. /**
  127654. * Used to disable an already-enabled feature
  127655. * The feature will be disposed and will be recreated once enabled.
  127656. * @param featureName the feature to disable
  127657. * @returns true if disable was successful
  127658. */
  127659. disableFeature(featureName: string | {
  127660. Name: string;
  127661. }): boolean;
  127662. /**
  127663. * dispose this features manager
  127664. */
  127665. dispose(): void;
  127666. /**
  127667. * 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.
  127668. * 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.
  127669. *
  127670. * @param featureName the name of the feature to load or the class of the feature
  127671. * @param version optional version to load. if not provided the latest version will be enabled
  127672. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127673. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127674. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127675. * @returns a new constructed feature or throws an error if feature not found.
  127676. */
  127677. enableFeature(featureName: string | {
  127678. Name: string;
  127679. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127680. /**
  127681. * get the implementation of an enabled feature.
  127682. * @param featureName the name of the feature to load
  127683. * @returns the feature class, if found
  127684. */
  127685. getEnabledFeature(featureName: string): IWebXRFeature;
  127686. /**
  127687. * Get the list of enabled features
  127688. * @returns an array of enabled features
  127689. */
  127690. getEnabledFeatures(): string[];
  127691. /**
  127692. * This function will exten the session creation configuration object with enabled features.
  127693. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127694. * according to the defined "required" variable, provided during enableFeature call
  127695. * @param xrSessionInit the xr Session init object to extend
  127696. *
  127697. * @returns an extended XRSessionInit object
  127698. */
  127699. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127700. }
  127701. }
  127702. declare module BABYLON {
  127703. /**
  127704. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127705. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127706. */
  127707. export class WebXRExperienceHelper implements IDisposable {
  127708. private scene;
  127709. private _nonVRCamera;
  127710. private _originalSceneAutoClear;
  127711. private _supported;
  127712. /**
  127713. * Camera used to render xr content
  127714. */
  127715. camera: WebXRCamera;
  127716. /** A features manager for this xr session */
  127717. featuresManager: WebXRFeaturesManager;
  127718. /**
  127719. * Observers registered here will be triggered after the camera's initial transformation is set
  127720. * This can be used to set a different ground level or an extra rotation.
  127721. *
  127722. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127723. * to the position set after this observable is done executing.
  127724. */
  127725. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127726. /**
  127727. * Fires when the state of the experience helper has changed
  127728. */
  127729. onStateChangedObservable: Observable<WebXRState>;
  127730. /** Session manager used to keep track of xr session */
  127731. sessionManager: WebXRSessionManager;
  127732. /**
  127733. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127734. */
  127735. state: WebXRState;
  127736. /**
  127737. * Creates a WebXRExperienceHelper
  127738. * @param scene The scene the helper should be created in
  127739. */
  127740. private constructor();
  127741. /**
  127742. * Creates the experience helper
  127743. * @param scene the scene to attach the experience helper to
  127744. * @returns a promise for the experience helper
  127745. */
  127746. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127747. /**
  127748. * Disposes of the experience helper
  127749. */
  127750. dispose(): void;
  127751. /**
  127752. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127753. * @param sessionMode options for the XR session
  127754. * @param referenceSpaceType frame of reference of the XR session
  127755. * @param renderTarget the output canvas that will be used to enter XR mode
  127756. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127757. * @returns promise that resolves after xr mode has entered
  127758. */
  127759. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127760. /**
  127761. * Exits XR mode and returns the scene to its original state
  127762. * @returns promise that resolves after xr mode has exited
  127763. */
  127764. exitXRAsync(): Promise<void>;
  127765. private _nonXRToXRCamera;
  127766. private _setState;
  127767. }
  127768. }
  127769. declare module BABYLON {
  127770. /**
  127771. * X-Y values for axes in WebXR
  127772. */
  127773. export interface IWebXRMotionControllerAxesValue {
  127774. /**
  127775. * The value of the x axis
  127776. */
  127777. x: number;
  127778. /**
  127779. * The value of the y-axis
  127780. */
  127781. y: number;
  127782. }
  127783. /**
  127784. * changed / previous values for the values of this component
  127785. */
  127786. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127787. /**
  127788. * current (this frame) value
  127789. */
  127790. current: T;
  127791. /**
  127792. * previous (last change) value
  127793. */
  127794. previous: T;
  127795. }
  127796. /**
  127797. * Represents changes in the component between current frame and last values recorded
  127798. */
  127799. export interface IWebXRMotionControllerComponentChanges {
  127800. /**
  127801. * will be populated with previous and current values if axes changed
  127802. */
  127803. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127804. /**
  127805. * will be populated with previous and current values if pressed changed
  127806. */
  127807. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127808. /**
  127809. * will be populated with previous and current values if touched changed
  127810. */
  127811. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127812. /**
  127813. * will be populated with previous and current values if value changed
  127814. */
  127815. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127816. }
  127817. /**
  127818. * This class represents a single component (for example button or thumbstick) of a motion controller
  127819. */
  127820. export class WebXRControllerComponent implements IDisposable {
  127821. /**
  127822. * the id of this component
  127823. */
  127824. id: string;
  127825. /**
  127826. * the type of the component
  127827. */
  127828. type: MotionControllerComponentType;
  127829. private _buttonIndex;
  127830. private _axesIndices;
  127831. private _axes;
  127832. private _changes;
  127833. private _currentValue;
  127834. private _hasChanges;
  127835. private _pressed;
  127836. private _touched;
  127837. /**
  127838. * button component type
  127839. */
  127840. static BUTTON_TYPE: MotionControllerComponentType;
  127841. /**
  127842. * squeeze component type
  127843. */
  127844. static SQUEEZE_TYPE: MotionControllerComponentType;
  127845. /**
  127846. * Thumbstick component type
  127847. */
  127848. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127849. /**
  127850. * Touchpad component type
  127851. */
  127852. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127853. /**
  127854. * trigger component type
  127855. */
  127856. static TRIGGER_TYPE: MotionControllerComponentType;
  127857. /**
  127858. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127859. * the axes data changes
  127860. */
  127861. onAxisValueChangedObservable: Observable<{
  127862. x: number;
  127863. y: number;
  127864. }>;
  127865. /**
  127866. * Observers registered here will be triggered when the state of a button changes
  127867. * State change is either pressed / touched / value
  127868. */
  127869. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127870. /**
  127871. * Creates a new component for a motion controller.
  127872. * It is created by the motion controller itself
  127873. *
  127874. * @param id the id of this component
  127875. * @param type the type of the component
  127876. * @param _buttonIndex index in the buttons array of the gamepad
  127877. * @param _axesIndices indices of the values in the axes array of the gamepad
  127878. */
  127879. constructor(
  127880. /**
  127881. * the id of this component
  127882. */
  127883. id: string,
  127884. /**
  127885. * the type of the component
  127886. */
  127887. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127888. /**
  127889. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127890. */
  127891. get axes(): IWebXRMotionControllerAxesValue;
  127892. /**
  127893. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127894. */
  127895. get changes(): IWebXRMotionControllerComponentChanges;
  127896. /**
  127897. * Return whether or not the component changed the last frame
  127898. */
  127899. get hasChanges(): boolean;
  127900. /**
  127901. * is the button currently pressed
  127902. */
  127903. get pressed(): boolean;
  127904. /**
  127905. * is the button currently touched
  127906. */
  127907. get touched(): boolean;
  127908. /**
  127909. * Get the current value of this component
  127910. */
  127911. get value(): number;
  127912. /**
  127913. * Dispose this component
  127914. */
  127915. dispose(): void;
  127916. /**
  127917. * Are there axes correlating to this component
  127918. * @return true is axes data is available
  127919. */
  127920. isAxes(): boolean;
  127921. /**
  127922. * Is this component a button (hence - pressable)
  127923. * @returns true if can be pressed
  127924. */
  127925. isButton(): boolean;
  127926. /**
  127927. * update this component using the gamepad object it is in. Called on every frame
  127928. * @param nativeController the native gamepad controller object
  127929. */
  127930. update(nativeController: IMinimalMotionControllerObject): void;
  127931. }
  127932. }
  127933. declare module BABYLON {
  127934. /**
  127935. * Interface used to represent data loading progression
  127936. */
  127937. export interface ISceneLoaderProgressEvent {
  127938. /**
  127939. * Defines if data length to load can be evaluated
  127940. */
  127941. readonly lengthComputable: boolean;
  127942. /**
  127943. * Defines the loaded data length
  127944. */
  127945. readonly loaded: number;
  127946. /**
  127947. * Defines the data length to load
  127948. */
  127949. readonly total: number;
  127950. }
  127951. /**
  127952. * Interface used by SceneLoader plugins to define supported file extensions
  127953. */
  127954. export interface ISceneLoaderPluginExtensions {
  127955. /**
  127956. * Defines the list of supported extensions
  127957. */
  127958. [extension: string]: {
  127959. isBinary: boolean;
  127960. };
  127961. }
  127962. /**
  127963. * Interface used by SceneLoader plugin factory
  127964. */
  127965. export interface ISceneLoaderPluginFactory {
  127966. /**
  127967. * Defines the name of the factory
  127968. */
  127969. name: string;
  127970. /**
  127971. * Function called to create a new plugin
  127972. * @return the new plugin
  127973. */
  127974. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127975. /**
  127976. * The callback that returns true if the data can be directly loaded.
  127977. * @param data string containing the file data
  127978. * @returns if the data can be loaded directly
  127979. */
  127980. canDirectLoad?(data: string): boolean;
  127981. }
  127982. /**
  127983. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127984. */
  127985. export interface ISceneLoaderPluginBase {
  127986. /**
  127987. * The friendly name of this plugin.
  127988. */
  127989. name: string;
  127990. /**
  127991. * The file extensions supported by this plugin.
  127992. */
  127993. extensions: string | ISceneLoaderPluginExtensions;
  127994. /**
  127995. * The callback called when loading from a url.
  127996. * @param scene scene loading this url
  127997. * @param url url to load
  127998. * @param onSuccess callback called when the file successfully loads
  127999. * @param onProgress callback called while file is loading (if the server supports this mode)
  128000. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128001. * @param onError callback called when the file fails to load
  128002. * @returns a file request object
  128003. */
  128004. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128005. /**
  128006. * The callback called when loading from a file object.
  128007. * @param scene scene loading this file
  128008. * @param file defines the file to load
  128009. * @param onSuccess defines the callback to call when data is loaded
  128010. * @param onProgress defines the callback to call during loading process
  128011. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128012. * @param onError defines the callback to call when an error occurs
  128013. * @returns a file request object
  128014. */
  128015. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128016. /**
  128017. * The callback that returns true if the data can be directly loaded.
  128018. * @param data string containing the file data
  128019. * @returns if the data can be loaded directly
  128020. */
  128021. canDirectLoad?(data: string): boolean;
  128022. /**
  128023. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128024. * @param scene scene loading this data
  128025. * @param data string containing the data
  128026. * @returns data to pass to the plugin
  128027. */
  128028. directLoad?(scene: Scene, data: string): any;
  128029. /**
  128030. * The callback that allows custom handling of the root url based on the response url.
  128031. * @param rootUrl the original root url
  128032. * @param responseURL the response url if available
  128033. * @returns the new root url
  128034. */
  128035. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128036. }
  128037. /**
  128038. * Interface used to define a SceneLoader plugin
  128039. */
  128040. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128041. /**
  128042. * Import meshes into a scene.
  128043. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128044. * @param scene The scene to import into
  128045. * @param data The data to import
  128046. * @param rootUrl The root url for scene and resources
  128047. * @param meshes The meshes array to import into
  128048. * @param particleSystems The particle systems array to import into
  128049. * @param skeletons The skeletons array to import into
  128050. * @param onError The callback when import fails
  128051. * @returns True if successful or false otherwise
  128052. */
  128053. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128054. /**
  128055. * Load into a scene.
  128056. * @param scene The scene to load into
  128057. * @param data The data to import
  128058. * @param rootUrl The root url for scene and resources
  128059. * @param onError The callback when import fails
  128060. * @returns True if successful or false otherwise
  128061. */
  128062. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128063. /**
  128064. * Load into an asset container.
  128065. * @param scene The scene to load into
  128066. * @param data The data to import
  128067. * @param rootUrl The root url for scene and resources
  128068. * @param onError The callback when import fails
  128069. * @returns The loaded asset container
  128070. */
  128071. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128072. }
  128073. /**
  128074. * Interface used to define an async SceneLoader plugin
  128075. */
  128076. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128077. /**
  128078. * Import meshes into a scene.
  128079. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128080. * @param scene The scene to import into
  128081. * @param data The data to import
  128082. * @param rootUrl The root url for scene and resources
  128083. * @param onProgress The callback when the load progresses
  128084. * @param fileName Defines the name of the file to load
  128085. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128086. */
  128087. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128088. meshes: AbstractMesh[];
  128089. particleSystems: IParticleSystem[];
  128090. skeletons: Skeleton[];
  128091. animationGroups: AnimationGroup[];
  128092. }>;
  128093. /**
  128094. * Load into a scene.
  128095. * @param scene The scene to load into
  128096. * @param data The data to import
  128097. * @param rootUrl The root url for scene and resources
  128098. * @param onProgress The callback when the load progresses
  128099. * @param fileName Defines the name of the file to load
  128100. * @returns Nothing
  128101. */
  128102. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128103. /**
  128104. * Load into an asset container.
  128105. * @param scene The scene to load into
  128106. * @param data The data to import
  128107. * @param rootUrl The root url for scene and resources
  128108. * @param onProgress The callback when the load progresses
  128109. * @param fileName Defines the name of the file to load
  128110. * @returns The loaded asset container
  128111. */
  128112. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128113. }
  128114. /**
  128115. * Mode that determines how to handle old animation groups before loading new ones.
  128116. */
  128117. export enum SceneLoaderAnimationGroupLoadingMode {
  128118. /**
  128119. * Reset all old animations to initial state then dispose them.
  128120. */
  128121. Clean = 0,
  128122. /**
  128123. * Stop all old animations.
  128124. */
  128125. Stop = 1,
  128126. /**
  128127. * Restart old animations from first frame.
  128128. */
  128129. Sync = 2,
  128130. /**
  128131. * Old animations remains untouched.
  128132. */
  128133. NoSync = 3
  128134. }
  128135. /**
  128136. * Defines a plugin registered by the SceneLoader
  128137. */
  128138. interface IRegisteredPlugin {
  128139. /**
  128140. * Defines the plugin to use
  128141. */
  128142. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128143. /**
  128144. * Defines if the plugin supports binary data
  128145. */
  128146. isBinary: boolean;
  128147. }
  128148. /**
  128149. * Class used to load scene from various file formats using registered plugins
  128150. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128151. */
  128152. export class SceneLoader {
  128153. /**
  128154. * No logging while loading
  128155. */
  128156. static readonly NO_LOGGING: number;
  128157. /**
  128158. * Minimal logging while loading
  128159. */
  128160. static readonly MINIMAL_LOGGING: number;
  128161. /**
  128162. * Summary logging while loading
  128163. */
  128164. static readonly SUMMARY_LOGGING: number;
  128165. /**
  128166. * Detailled logging while loading
  128167. */
  128168. static readonly DETAILED_LOGGING: number;
  128169. /**
  128170. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128171. */
  128172. static get ForceFullSceneLoadingForIncremental(): boolean;
  128173. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128174. /**
  128175. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128176. */
  128177. static get ShowLoadingScreen(): boolean;
  128178. static set ShowLoadingScreen(value: boolean);
  128179. /**
  128180. * Defines the current logging level (while loading the scene)
  128181. * @ignorenaming
  128182. */
  128183. static get loggingLevel(): number;
  128184. static set loggingLevel(value: number);
  128185. /**
  128186. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128187. */
  128188. static get CleanBoneMatrixWeights(): boolean;
  128189. static set CleanBoneMatrixWeights(value: boolean);
  128190. /**
  128191. * Event raised when a plugin is used to load a scene
  128192. */
  128193. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128194. private static _registeredPlugins;
  128195. private static _showingLoadingScreen;
  128196. /**
  128197. * Gets the default plugin (used to load Babylon files)
  128198. * @returns the .babylon plugin
  128199. */
  128200. static GetDefaultPlugin(): IRegisteredPlugin;
  128201. private static _GetPluginForExtension;
  128202. private static _GetPluginForDirectLoad;
  128203. private static _GetPluginForFilename;
  128204. private static _GetDirectLoad;
  128205. private static _LoadData;
  128206. private static _GetFileInfo;
  128207. /**
  128208. * Gets a plugin that can load the given extension
  128209. * @param extension defines the extension to load
  128210. * @returns a plugin or null if none works
  128211. */
  128212. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128213. /**
  128214. * Gets a boolean indicating that the given extension can be loaded
  128215. * @param extension defines the extension to load
  128216. * @returns true if the extension is supported
  128217. */
  128218. static IsPluginForExtensionAvailable(extension: string): boolean;
  128219. /**
  128220. * Adds a new plugin to the list of registered plugins
  128221. * @param plugin defines the plugin to add
  128222. */
  128223. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128224. /**
  128225. * Import meshes into a scene
  128226. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128227. * @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)
  128228. * @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)
  128229. * @param scene the instance of BABYLON.Scene to append to
  128230. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128231. * @param onProgress a callback with a progress event for each file being loaded
  128232. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128233. * @param pluginExtension the extension used to determine the plugin
  128234. * @returns The loaded plugin
  128235. */
  128236. 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>;
  128237. /**
  128238. * Import meshes into a scene
  128239. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128240. * @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)
  128241. * @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)
  128242. * @param scene the instance of BABYLON.Scene to append to
  128243. * @param onProgress a callback with a progress event for each file being loaded
  128244. * @param pluginExtension the extension used to determine the plugin
  128245. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128246. */
  128247. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128248. meshes: AbstractMesh[];
  128249. particleSystems: IParticleSystem[];
  128250. skeletons: Skeleton[];
  128251. animationGroups: AnimationGroup[];
  128252. }>;
  128253. /**
  128254. * Load a scene
  128255. * @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)
  128256. * @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)
  128257. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128258. * @param onSuccess a callback with the scene when import succeeds
  128259. * @param onProgress a callback with a progress event for each file being loaded
  128260. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128261. * @param pluginExtension the extension used to determine the plugin
  128262. * @returns The loaded plugin
  128263. */
  128264. 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>;
  128265. /**
  128266. * Load a scene
  128267. * @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)
  128268. * @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)
  128269. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128270. * @param onProgress a callback with a progress event for each file being loaded
  128271. * @param pluginExtension the extension used to determine the plugin
  128272. * @returns The loaded scene
  128273. */
  128274. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128275. /**
  128276. * Append a scene
  128277. * @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)
  128278. * @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)
  128279. * @param scene is the instance of BABYLON.Scene to append to
  128280. * @param onSuccess a callback with the scene when import succeeds
  128281. * @param onProgress a callback with a progress event for each file being loaded
  128282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128283. * @param pluginExtension the extension used to determine the plugin
  128284. * @returns The loaded plugin
  128285. */
  128286. 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>;
  128287. /**
  128288. * Append a scene
  128289. * @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)
  128290. * @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)
  128291. * @param scene is the instance of BABYLON.Scene to append to
  128292. * @param onProgress a callback with a progress event for each file being loaded
  128293. * @param pluginExtension the extension used to determine the plugin
  128294. * @returns The given scene
  128295. */
  128296. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128297. /**
  128298. * Load a scene into an asset container
  128299. * @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)
  128300. * @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)
  128301. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128302. * @param onSuccess a callback with the scene when import succeeds
  128303. * @param onProgress a callback with a progress event for each file being loaded
  128304. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128305. * @param pluginExtension the extension used to determine the plugin
  128306. * @returns The loaded plugin
  128307. */
  128308. 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>;
  128309. /**
  128310. * Load a scene into an asset container
  128311. * @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)
  128312. * @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)
  128313. * @param scene is the instance of Scene to append to
  128314. * @param onProgress a callback with a progress event for each file being loaded
  128315. * @param pluginExtension the extension used to determine the plugin
  128316. * @returns The loaded asset container
  128317. */
  128318. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128319. /**
  128320. * Import animations from a file into a scene
  128321. * @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)
  128322. * @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)
  128323. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128324. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128325. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128326. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128327. * @param onSuccess a callback with the scene when import succeeds
  128328. * @param onProgress a callback with a progress event for each file being loaded
  128329. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128330. * @param pluginExtension the extension used to determine the plugin
  128331. */
  128332. 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;
  128333. /**
  128334. * Import animations from a file into a scene
  128335. * @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)
  128336. * @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)
  128337. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128338. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128339. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128340. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128341. * @param onSuccess a callback with the scene when import succeeds
  128342. * @param onProgress a callback with a progress event for each file being loaded
  128343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128344. * @param pluginExtension the extension used to determine the plugin
  128345. * @returns the updated scene with imported animations
  128346. */
  128347. 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>;
  128348. }
  128349. }
  128350. declare module BABYLON {
  128351. /**
  128352. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128353. */
  128354. export type MotionControllerHandedness = "none" | "left" | "right";
  128355. /**
  128356. * The type of components available in motion controllers.
  128357. * This is not the name of the component.
  128358. */
  128359. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128360. /**
  128361. * The state of a controller component
  128362. */
  128363. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128364. /**
  128365. * The schema of motion controller layout.
  128366. * No object will be initialized using this interface
  128367. * This is used just to define the profile.
  128368. */
  128369. export interface IMotionControllerLayout {
  128370. /**
  128371. * Path to load the assets. Usually relative to the base path
  128372. */
  128373. assetPath: string;
  128374. /**
  128375. * Available components (unsorted)
  128376. */
  128377. components: {
  128378. /**
  128379. * A map of component Ids
  128380. */
  128381. [componentId: string]: {
  128382. /**
  128383. * The type of input the component outputs
  128384. */
  128385. type: MotionControllerComponentType;
  128386. /**
  128387. * The indices of this component in the gamepad object
  128388. */
  128389. gamepadIndices: {
  128390. /**
  128391. * Index of button
  128392. */
  128393. button?: number;
  128394. /**
  128395. * If available, index of x-axis
  128396. */
  128397. xAxis?: number;
  128398. /**
  128399. * If available, index of y-axis
  128400. */
  128401. yAxis?: number;
  128402. };
  128403. /**
  128404. * The mesh's root node name
  128405. */
  128406. rootNodeName: string;
  128407. /**
  128408. * Animation definitions for this model
  128409. */
  128410. visualResponses: {
  128411. [stateKey: string]: {
  128412. /**
  128413. * What property will be animated
  128414. */
  128415. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128416. /**
  128417. * What states influence this visual response
  128418. */
  128419. states: MotionControllerComponentStateType[];
  128420. /**
  128421. * Type of animation - movement or visibility
  128422. */
  128423. valueNodeProperty: "transform" | "visibility";
  128424. /**
  128425. * Base node name to move. Its position will be calculated according to the min and max nodes
  128426. */
  128427. valueNodeName?: string;
  128428. /**
  128429. * Minimum movement node
  128430. */
  128431. minNodeName?: string;
  128432. /**
  128433. * Max movement node
  128434. */
  128435. maxNodeName?: string;
  128436. };
  128437. };
  128438. /**
  128439. * If touch enabled, what is the name of node to display user feedback
  128440. */
  128441. touchPointNodeName?: string;
  128442. };
  128443. };
  128444. /**
  128445. * Is it xr standard mapping or not
  128446. */
  128447. gamepadMapping: "" | "xr-standard";
  128448. /**
  128449. * Base root node of this entire model
  128450. */
  128451. rootNodeName: string;
  128452. /**
  128453. * Defines the main button component id
  128454. */
  128455. selectComponentId: string;
  128456. }
  128457. /**
  128458. * A definition for the layout map in the input profile
  128459. */
  128460. export interface IMotionControllerLayoutMap {
  128461. /**
  128462. * Layouts with handedness type as a key
  128463. */
  128464. [handedness: string]: IMotionControllerLayout;
  128465. }
  128466. /**
  128467. * The XR Input profile schema
  128468. * Profiles can be found here:
  128469. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128470. */
  128471. export interface IMotionControllerProfile {
  128472. /**
  128473. * fallback profiles for this profileId
  128474. */
  128475. fallbackProfileIds: string[];
  128476. /**
  128477. * The layout map, with handedness as key
  128478. */
  128479. layouts: IMotionControllerLayoutMap;
  128480. /**
  128481. * The id of this profile
  128482. * correlates to the profile(s) in the xrInput.profiles array
  128483. */
  128484. profileId: string;
  128485. }
  128486. /**
  128487. * A helper-interface for the 3 meshes needed for controller button animation
  128488. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128489. */
  128490. export interface IMotionControllerButtonMeshMap {
  128491. /**
  128492. * the mesh that defines the pressed value mesh position.
  128493. * This is used to find the max-position of this button
  128494. */
  128495. pressedMesh: AbstractMesh;
  128496. /**
  128497. * the mesh that defines the unpressed value mesh position.
  128498. * This is used to find the min (or initial) position of this button
  128499. */
  128500. unpressedMesh: AbstractMesh;
  128501. /**
  128502. * The mesh that will be changed when value changes
  128503. */
  128504. valueMesh: AbstractMesh;
  128505. }
  128506. /**
  128507. * A helper-interface for the 3 meshes needed for controller axis animation.
  128508. * This will be expanded when touchpad animations are fully supported
  128509. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128510. */
  128511. export interface IMotionControllerMeshMap {
  128512. /**
  128513. * the mesh that defines the maximum value mesh position.
  128514. */
  128515. maxMesh?: AbstractMesh;
  128516. /**
  128517. * the mesh that defines the minimum value mesh position.
  128518. */
  128519. minMesh?: AbstractMesh;
  128520. /**
  128521. * The mesh that will be changed when axis value changes
  128522. */
  128523. valueMesh?: AbstractMesh;
  128524. }
  128525. /**
  128526. * The elements needed for change-detection of the gamepad objects in motion controllers
  128527. */
  128528. export interface IMinimalMotionControllerObject {
  128529. /**
  128530. * Available axes of this controller
  128531. */
  128532. axes: number[];
  128533. /**
  128534. * An array of available buttons
  128535. */
  128536. buttons: Array<{
  128537. /**
  128538. * Value of the button/trigger
  128539. */
  128540. value: number;
  128541. /**
  128542. * If the button/trigger is currently touched
  128543. */
  128544. touched: boolean;
  128545. /**
  128546. * If the button/trigger is currently pressed
  128547. */
  128548. pressed: boolean;
  128549. }>;
  128550. /**
  128551. * EXPERIMENTAL haptic support.
  128552. */
  128553. hapticActuators?: Array<{
  128554. pulse: (value: number, duration: number) => Promise<boolean>;
  128555. }>;
  128556. }
  128557. /**
  128558. * An Abstract Motion controller
  128559. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128560. * Each component has an observable to check for changes in value and state
  128561. */
  128562. export abstract class WebXRAbstractMotionController implements IDisposable {
  128563. protected scene: Scene;
  128564. protected layout: IMotionControllerLayout;
  128565. /**
  128566. * The gamepad object correlating to this controller
  128567. */
  128568. gamepadObject: IMinimalMotionControllerObject;
  128569. /**
  128570. * handedness (left/right/none) of this controller
  128571. */
  128572. handedness: MotionControllerHandedness;
  128573. private _initComponent;
  128574. private _modelReady;
  128575. /**
  128576. * A map of components (WebXRControllerComponent) in this motion controller
  128577. * Components have a ComponentType and can also have both button and axis definitions
  128578. */
  128579. readonly components: {
  128580. [id: string]: WebXRControllerComponent;
  128581. };
  128582. /**
  128583. * Disable the model's animation. Can be set at any time.
  128584. */
  128585. disableAnimation: boolean;
  128586. /**
  128587. * Observers registered here will be triggered when the model of this controller is done loading
  128588. */
  128589. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128590. /**
  128591. * The profile id of this motion controller
  128592. */
  128593. abstract profileId: string;
  128594. /**
  128595. * The root mesh of the model. It is null if the model was not yet initialized
  128596. */
  128597. rootMesh: Nullable<AbstractMesh>;
  128598. /**
  128599. * constructs a new abstract motion controller
  128600. * @param scene the scene to which the model of the controller will be added
  128601. * @param layout The profile layout to load
  128602. * @param gamepadObject The gamepad object correlating to this controller
  128603. * @param handedness handedness (left/right/none) of this controller
  128604. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128605. */
  128606. constructor(scene: Scene, layout: IMotionControllerLayout,
  128607. /**
  128608. * The gamepad object correlating to this controller
  128609. */
  128610. gamepadObject: IMinimalMotionControllerObject,
  128611. /**
  128612. * handedness (left/right/none) of this controller
  128613. */
  128614. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128615. /**
  128616. * Dispose this controller, the model mesh and all its components
  128617. */
  128618. dispose(): void;
  128619. /**
  128620. * Returns all components of specific type
  128621. * @param type the type to search for
  128622. * @return an array of components with this type
  128623. */
  128624. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128625. /**
  128626. * get a component based an its component id as defined in layout.components
  128627. * @param id the id of the component
  128628. * @returns the component correlates to the id or undefined if not found
  128629. */
  128630. getComponent(id: string): WebXRControllerComponent;
  128631. /**
  128632. * Get the list of components available in this motion controller
  128633. * @returns an array of strings correlating to available components
  128634. */
  128635. getComponentIds(): string[];
  128636. /**
  128637. * Get the first component of specific type
  128638. * @param type type of component to find
  128639. * @return a controller component or null if not found
  128640. */
  128641. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128642. /**
  128643. * Get the main (Select) component of this controller as defined in the layout
  128644. * @returns the main component of this controller
  128645. */
  128646. getMainComponent(): WebXRControllerComponent;
  128647. /**
  128648. * Loads the model correlating to this controller
  128649. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128650. * @returns A promise fulfilled with the result of the model loading
  128651. */
  128652. loadModel(): Promise<boolean>;
  128653. /**
  128654. * Update this model using the current XRFrame
  128655. * @param xrFrame the current xr frame to use and update the model
  128656. */
  128657. updateFromXRFrame(xrFrame: XRFrame): void;
  128658. /**
  128659. * Backwards compatibility due to a deeply-integrated typo
  128660. */
  128661. get handness(): XREye;
  128662. /**
  128663. * Pulse (vibrate) this controller
  128664. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128665. * Consecutive calls to this function will cancel the last pulse call
  128666. *
  128667. * @param value the strength of the pulse in 0.0...1.0 range
  128668. * @param duration Duration of the pulse in milliseconds
  128669. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128670. * @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
  128671. */
  128672. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128673. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128674. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128675. /**
  128676. * Moves the axis on the controller mesh based on its current state
  128677. * @param axis the index of the axis
  128678. * @param axisValue the value of the axis which determines the meshes new position
  128679. * @hidden
  128680. */
  128681. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128682. /**
  128683. * Update the model itself with the current frame data
  128684. * @param xrFrame the frame to use for updating the model mesh
  128685. */
  128686. protected updateModel(xrFrame: XRFrame): void;
  128687. /**
  128688. * Get the filename and path for this controller's model
  128689. * @returns a map of filename and path
  128690. */
  128691. protected abstract _getFilenameAndPath(): {
  128692. filename: string;
  128693. path: string;
  128694. };
  128695. /**
  128696. * This function is called before the mesh is loaded. It checks for loading constraints.
  128697. * For example, this function can check if the GLB loader is available
  128698. * If this function returns false, the generic controller will be loaded instead
  128699. * @returns Is the client ready to load the mesh
  128700. */
  128701. protected abstract _getModelLoadingConstraints(): boolean;
  128702. /**
  128703. * This function will be called after the model was successfully loaded and can be used
  128704. * for mesh transformations before it is available for the user
  128705. * @param meshes the loaded meshes
  128706. */
  128707. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128708. /**
  128709. * Set the root mesh for this controller. Important for the WebXR controller class
  128710. * @param meshes the loaded meshes
  128711. */
  128712. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128713. /**
  128714. * A function executed each frame that updates the mesh (if needed)
  128715. * @param xrFrame the current xrFrame
  128716. */
  128717. protected abstract _updateModel(xrFrame: XRFrame): void;
  128718. private _getGenericFilenameAndPath;
  128719. private _getGenericParentMesh;
  128720. }
  128721. }
  128722. declare module BABYLON {
  128723. /**
  128724. * A generic trigger-only motion controller for WebXR
  128725. */
  128726. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128727. /**
  128728. * Static version of the profile id of this controller
  128729. */
  128730. static ProfileId: string;
  128731. profileId: string;
  128732. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128733. protected _getFilenameAndPath(): {
  128734. filename: string;
  128735. path: string;
  128736. };
  128737. protected _getModelLoadingConstraints(): boolean;
  128738. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128739. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128740. protected _updateModel(): void;
  128741. }
  128742. }
  128743. declare module BABYLON {
  128744. /**
  128745. * Class containing static functions to help procedurally build meshes
  128746. */
  128747. export class SphereBuilder {
  128748. /**
  128749. * Creates a sphere mesh
  128750. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128751. * * 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`)
  128752. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128753. * * 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
  128754. * * 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)
  128755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128758. * @param name defines the name of the mesh
  128759. * @param options defines the options used to create the mesh
  128760. * @param scene defines the hosting scene
  128761. * @returns the sphere mesh
  128762. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128763. */
  128764. static CreateSphere(name: string, options: {
  128765. segments?: number;
  128766. diameter?: number;
  128767. diameterX?: number;
  128768. diameterY?: number;
  128769. diameterZ?: number;
  128770. arc?: number;
  128771. slice?: number;
  128772. sideOrientation?: number;
  128773. frontUVs?: Vector4;
  128774. backUVs?: Vector4;
  128775. updatable?: boolean;
  128776. }, scene?: Nullable<Scene>): Mesh;
  128777. }
  128778. }
  128779. declare module BABYLON {
  128780. /**
  128781. * A profiled motion controller has its profile loaded from an online repository.
  128782. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128783. */
  128784. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128785. private _repositoryUrl;
  128786. private _buttonMeshMapping;
  128787. private _touchDots;
  128788. /**
  128789. * The profile ID of this controller. Will be populated when the controller initializes.
  128790. */
  128791. profileId: string;
  128792. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128793. dispose(): void;
  128794. protected _getFilenameAndPath(): {
  128795. filename: string;
  128796. path: string;
  128797. };
  128798. protected _getModelLoadingConstraints(): boolean;
  128799. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128800. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128801. protected _updateModel(_xrFrame: XRFrame): void;
  128802. }
  128803. }
  128804. declare module BABYLON {
  128805. /**
  128806. * A construction function type to create a new controller based on an xrInput object
  128807. */
  128808. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128809. /**
  128810. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128811. *
  128812. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128813. * it should be replaced with auto-loaded controllers.
  128814. *
  128815. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128816. */
  128817. export class WebXRMotionControllerManager {
  128818. private static _AvailableControllers;
  128819. private static _Fallbacks;
  128820. private static _ProfileLoadingPromises;
  128821. private static _ProfilesList;
  128822. /**
  128823. * The base URL of the online controller repository. Can be changed at any time.
  128824. */
  128825. static BaseRepositoryUrl: string;
  128826. /**
  128827. * Which repository gets priority - local or online
  128828. */
  128829. static PrioritizeOnlineRepository: boolean;
  128830. /**
  128831. * Use the online repository, or use only locally-defined controllers
  128832. */
  128833. static UseOnlineRepository: boolean;
  128834. /**
  128835. * Clear the cache used for profile loading and reload when requested again
  128836. */
  128837. static ClearProfilesCache(): void;
  128838. /**
  128839. * Register the default fallbacks.
  128840. * This function is called automatically when this file is imported.
  128841. */
  128842. static DefaultFallbacks(): void;
  128843. /**
  128844. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128845. * @param profileId the profile to which a fallback needs to be found
  128846. * @return an array with corresponding fallback profiles
  128847. */
  128848. static FindFallbackWithProfileId(profileId: string): string[];
  128849. /**
  128850. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128851. * The order of search:
  128852. *
  128853. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128854. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128855. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128856. * 4) return the generic trigger controller if none were found
  128857. *
  128858. * @param xrInput the xrInput to which a new controller is initialized
  128859. * @param scene the scene to which the model will be added
  128860. * @param forceProfile force a certain profile for this controller
  128861. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128862. */
  128863. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128864. /**
  128865. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128866. *
  128867. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128868. *
  128869. * @param type the profile type to register
  128870. * @param constructFunction the function to be called when loading this profile
  128871. */
  128872. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128873. /**
  128874. * Register a fallback to a specific profile.
  128875. * @param profileId the profileId that will receive the fallbacks
  128876. * @param fallbacks A list of fallback profiles
  128877. */
  128878. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128879. /**
  128880. * Will update the list of profiles available in the repository
  128881. * @return a promise that resolves to a map of profiles available online
  128882. */
  128883. static UpdateProfilesList(): Promise<{
  128884. [profile: string]: string;
  128885. }>;
  128886. private static _LoadProfileFromRepository;
  128887. private static _LoadProfilesFromAvailableControllers;
  128888. }
  128889. }
  128890. declare module BABYLON {
  128891. /**
  128892. * Configuration options for the WebXR controller creation
  128893. */
  128894. export interface IWebXRControllerOptions {
  128895. /**
  128896. * Should the controller mesh be animated when a user interacts with it
  128897. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128898. */
  128899. disableMotionControllerAnimation?: boolean;
  128900. /**
  128901. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128902. */
  128903. doNotLoadControllerMesh?: boolean;
  128904. /**
  128905. * Force a specific controller type for this controller.
  128906. * This can be used when creating your own profile or when testing different controllers
  128907. */
  128908. forceControllerProfile?: string;
  128909. /**
  128910. * Defines a rendering group ID for meshes that will be loaded.
  128911. * This is for the default controllers only.
  128912. */
  128913. renderingGroupId?: number;
  128914. }
  128915. /**
  128916. * Represents an XR controller
  128917. */
  128918. export class WebXRInputSource {
  128919. private _scene;
  128920. /** The underlying input source for the controller */
  128921. inputSource: XRInputSource;
  128922. private _options;
  128923. private _tmpVector;
  128924. private _uniqueId;
  128925. private _disposed;
  128926. /**
  128927. * 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
  128928. */
  128929. grip?: AbstractMesh;
  128930. /**
  128931. * If available, this is the gamepad object related to this controller.
  128932. * Using this object it is possible to get click events and trackpad changes of the
  128933. * webxr controller that is currently being used.
  128934. */
  128935. motionController?: WebXRAbstractMotionController;
  128936. /**
  128937. * Event that fires when the controller is removed/disposed.
  128938. * The object provided as event data is this controller, after associated assets were disposed.
  128939. * uniqueId is still available.
  128940. */
  128941. onDisposeObservable: Observable<WebXRInputSource>;
  128942. /**
  128943. * Will be triggered when the mesh associated with the motion controller is done loading.
  128944. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128945. * A shortened version of controller -> motion controller -> on mesh loaded.
  128946. */
  128947. onMeshLoadedObservable: Observable<AbstractMesh>;
  128948. /**
  128949. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128950. */
  128951. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128952. /**
  128953. * Pointer which can be used to select objects or attach a visible laser to
  128954. */
  128955. pointer: AbstractMesh;
  128956. /**
  128957. * Creates the input source object
  128958. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128959. * @param _scene the scene which the controller should be associated to
  128960. * @param inputSource the underlying input source for the controller
  128961. * @param _options options for this controller creation
  128962. */
  128963. constructor(_scene: Scene,
  128964. /** The underlying input source for the controller */
  128965. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128966. /**
  128967. * Get this controllers unique id
  128968. */
  128969. get uniqueId(): string;
  128970. /**
  128971. * Disposes of the object
  128972. */
  128973. dispose(): void;
  128974. /**
  128975. * Gets a world space ray coming from the pointer or grip
  128976. * @param result the resulting ray
  128977. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128978. */
  128979. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128980. /**
  128981. * Updates the controller pose based on the given XRFrame
  128982. * @param xrFrame xr frame to update the pose with
  128983. * @param referenceSpace reference space to use
  128984. */
  128985. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128986. }
  128987. }
  128988. declare module BABYLON {
  128989. /**
  128990. * The schema for initialization options of the XR Input class
  128991. */
  128992. export interface IWebXRInputOptions {
  128993. /**
  128994. * If set to true no model will be automatically loaded
  128995. */
  128996. doNotLoadControllerMeshes?: boolean;
  128997. /**
  128998. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128999. * If not found, the xr input profile data will be used.
  129000. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129001. */
  129002. forceInputProfile?: string;
  129003. /**
  129004. * Do not send a request to the controller repository to load the profile.
  129005. *
  129006. * Instead, use the controllers available in babylon itself.
  129007. */
  129008. disableOnlineControllerRepository?: boolean;
  129009. /**
  129010. * A custom URL for the controllers repository
  129011. */
  129012. customControllersRepositoryURL?: string;
  129013. /**
  129014. * Should the controller model's components not move according to the user input
  129015. */
  129016. disableControllerAnimation?: boolean;
  129017. /**
  129018. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129019. */
  129020. controllerOptions?: IWebXRControllerOptions;
  129021. }
  129022. /**
  129023. * XR input used to track XR inputs such as controllers/rays
  129024. */
  129025. export class WebXRInput implements IDisposable {
  129026. /**
  129027. * the xr session manager for this session
  129028. */
  129029. xrSessionManager: WebXRSessionManager;
  129030. /**
  129031. * the WebXR camera for this session. Mainly used for teleportation
  129032. */
  129033. xrCamera: WebXRCamera;
  129034. private readonly options;
  129035. /**
  129036. * XR controllers being tracked
  129037. */
  129038. controllers: Array<WebXRInputSource>;
  129039. private _frameObserver;
  129040. private _sessionEndedObserver;
  129041. private _sessionInitObserver;
  129042. /**
  129043. * Event when a controller has been connected/added
  129044. */
  129045. onControllerAddedObservable: Observable<WebXRInputSource>;
  129046. /**
  129047. * Event when a controller has been removed/disconnected
  129048. */
  129049. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129050. /**
  129051. * Initializes the WebXRInput
  129052. * @param xrSessionManager the xr session manager for this session
  129053. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129054. * @param options = initialization options for this xr input
  129055. */
  129056. constructor(
  129057. /**
  129058. * the xr session manager for this session
  129059. */
  129060. xrSessionManager: WebXRSessionManager,
  129061. /**
  129062. * the WebXR camera for this session. Mainly used for teleportation
  129063. */
  129064. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129065. private _onInputSourcesChange;
  129066. private _addAndRemoveControllers;
  129067. /**
  129068. * Disposes of the object
  129069. */
  129070. dispose(): void;
  129071. }
  129072. }
  129073. declare module BABYLON {
  129074. /**
  129075. * This is the base class for all WebXR features.
  129076. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129077. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129078. */
  129079. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129080. protected _xrSessionManager: WebXRSessionManager;
  129081. private _attached;
  129082. private _removeOnDetach;
  129083. /**
  129084. * Is this feature disposed?
  129085. */
  129086. isDisposed: boolean;
  129087. /**
  129088. * Should auto-attach be disabled?
  129089. */
  129090. disableAutoAttach: boolean;
  129091. /**
  129092. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129093. */
  129094. xrNativeFeatureName: string;
  129095. /**
  129096. * Construct a new (abstract) WebXR feature
  129097. * @param _xrSessionManager the xr session manager for this feature
  129098. */
  129099. constructor(_xrSessionManager: WebXRSessionManager);
  129100. /**
  129101. * Is this feature attached
  129102. */
  129103. get attached(): boolean;
  129104. /**
  129105. * attach this feature
  129106. *
  129107. * @param force should attachment be forced (even when already attached)
  129108. * @returns true if successful, false is failed or already attached
  129109. */
  129110. attach(force?: boolean): boolean;
  129111. /**
  129112. * detach this feature.
  129113. *
  129114. * @returns true if successful, false if failed or already detached
  129115. */
  129116. detach(): boolean;
  129117. /**
  129118. * Dispose this feature and all of the resources attached
  129119. */
  129120. dispose(): void;
  129121. /**
  129122. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129123. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129124. *
  129125. * @returns whether or not the feature is compatible in this environment
  129126. */
  129127. isCompatible(): boolean;
  129128. /**
  129129. * This is used to register callbacks that will automatically be removed when detach is called.
  129130. * @param observable the observable to which the observer will be attached
  129131. * @param callback the callback to register
  129132. */
  129133. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129134. /**
  129135. * Code in this function will be executed on each xrFrame received from the browser.
  129136. * This function will not execute after the feature is detached.
  129137. * @param _xrFrame the current frame
  129138. */
  129139. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129140. }
  129141. }
  129142. declare module BABYLON {
  129143. /**
  129144. * Renders a layer on top of an existing scene
  129145. */
  129146. export class UtilityLayerRenderer implements IDisposable {
  129147. /** the original scene that will be rendered on top of */
  129148. originalScene: Scene;
  129149. private _pointerCaptures;
  129150. private _lastPointerEvents;
  129151. private static _DefaultUtilityLayer;
  129152. private static _DefaultKeepDepthUtilityLayer;
  129153. private _sharedGizmoLight;
  129154. private _renderCamera;
  129155. /**
  129156. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129157. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129158. * @returns the camera that is used when rendering the utility layer
  129159. */
  129160. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129161. /**
  129162. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129163. * @param cam the camera that should be used when rendering the utility layer
  129164. */
  129165. setRenderCamera(cam: Nullable<Camera>): void;
  129166. /**
  129167. * @hidden
  129168. * Light which used by gizmos to get light shading
  129169. */
  129170. _getSharedGizmoLight(): HemisphericLight;
  129171. /**
  129172. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129173. */
  129174. pickUtilitySceneFirst: boolean;
  129175. /**
  129176. * 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)
  129177. */
  129178. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129179. /**
  129180. * 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)
  129181. */
  129182. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129183. /**
  129184. * The scene that is rendered on top of the original scene
  129185. */
  129186. utilityLayerScene: Scene;
  129187. /**
  129188. * If the utility layer should automatically be rendered on top of existing scene
  129189. */
  129190. shouldRender: boolean;
  129191. /**
  129192. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129193. */
  129194. onlyCheckPointerDownEvents: boolean;
  129195. /**
  129196. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129197. */
  129198. processAllEvents: boolean;
  129199. /**
  129200. * Observable raised when the pointer move from the utility layer scene to the main scene
  129201. */
  129202. onPointerOutObservable: Observable<number>;
  129203. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129204. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129205. private _afterRenderObserver;
  129206. private _sceneDisposeObserver;
  129207. private _originalPointerObserver;
  129208. /**
  129209. * Instantiates a UtilityLayerRenderer
  129210. * @param originalScene the original scene that will be rendered on top of
  129211. * @param handleEvents boolean indicating if the utility layer should handle events
  129212. */
  129213. constructor(
  129214. /** the original scene that will be rendered on top of */
  129215. originalScene: Scene, handleEvents?: boolean);
  129216. private _notifyObservers;
  129217. /**
  129218. * Renders the utility layers scene on top of the original scene
  129219. */
  129220. render(): void;
  129221. /**
  129222. * Disposes of the renderer
  129223. */
  129224. dispose(): void;
  129225. private _updateCamera;
  129226. }
  129227. }
  129228. declare module BABYLON {
  129229. /**
  129230. * Options interface for the pointer selection module
  129231. */
  129232. export interface IWebXRControllerPointerSelectionOptions {
  129233. /**
  129234. * if provided, this scene will be used to render meshes.
  129235. */
  129236. customUtilityLayerScene?: Scene;
  129237. /**
  129238. * 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)
  129239. * If not disabled, the last picked point will be used to execute a pointer up event
  129240. * If disabled, pointer up event will be triggered right after the pointer down event.
  129241. * Used in screen and gaze target ray mode only
  129242. */
  129243. disablePointerUpOnTouchOut: boolean;
  129244. /**
  129245. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129246. */
  129247. forceGazeMode: boolean;
  129248. /**
  129249. * 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
  129250. * to start a new countdown to the pointer down event.
  129251. * Defaults to 1.
  129252. */
  129253. gazeModePointerMovedFactor?: number;
  129254. /**
  129255. * Different button type to use instead of the main component
  129256. */
  129257. overrideButtonId?: string;
  129258. /**
  129259. * use this rendering group id for the meshes (optional)
  129260. */
  129261. renderingGroupId?: number;
  129262. /**
  129263. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129264. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129265. * 3000 means 3 seconds between pointing at something and selecting it
  129266. */
  129267. timeToSelect?: number;
  129268. /**
  129269. * Should meshes created here be added to a utility layer or the main scene
  129270. */
  129271. useUtilityLayer?: boolean;
  129272. /**
  129273. * Optional WebXR camera to be used for gaze selection
  129274. */
  129275. gazeCamera?: WebXRCamera;
  129276. /**
  129277. * the xr input to use with this pointer selection
  129278. */
  129279. xrInput: WebXRInput;
  129280. }
  129281. /**
  129282. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129283. */
  129284. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129285. private readonly _options;
  129286. private static _idCounter;
  129287. private _attachController;
  129288. private _controllers;
  129289. private _scene;
  129290. private _tmpVectorForPickCompare;
  129291. /**
  129292. * The module's name
  129293. */
  129294. static readonly Name: string;
  129295. /**
  129296. * The (Babylon) version of this module.
  129297. * This is an integer representing the implementation version.
  129298. * This number does not correspond to the WebXR specs version
  129299. */
  129300. static readonly Version: number;
  129301. /**
  129302. * Disable lighting on the laser pointer (so it will always be visible)
  129303. */
  129304. disablePointerLighting: boolean;
  129305. /**
  129306. * Disable lighting on the selection mesh (so it will always be visible)
  129307. */
  129308. disableSelectionMeshLighting: boolean;
  129309. /**
  129310. * Should the laser pointer be displayed
  129311. */
  129312. displayLaserPointer: boolean;
  129313. /**
  129314. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129315. */
  129316. displaySelectionMesh: boolean;
  129317. /**
  129318. * This color will be set to the laser pointer when selection is triggered
  129319. */
  129320. laserPointerPickedColor: Color3;
  129321. /**
  129322. * Default color of the laser pointer
  129323. */
  129324. laserPointerDefaultColor: Color3;
  129325. /**
  129326. * default color of the selection ring
  129327. */
  129328. selectionMeshDefaultColor: Color3;
  129329. /**
  129330. * This color will be applied to the selection ring when selection is triggered
  129331. */
  129332. selectionMeshPickedColor: Color3;
  129333. /**
  129334. * Optional filter to be used for ray selection. This predicate shares behavior with
  129335. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129336. */
  129337. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129338. /**
  129339. * constructs a new background remover module
  129340. * @param _xrSessionManager the session manager for this module
  129341. * @param _options read-only options to be used in this module
  129342. */
  129343. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129344. /**
  129345. * attach this feature
  129346. * Will usually be called by the features manager
  129347. *
  129348. * @returns true if successful.
  129349. */
  129350. attach(): boolean;
  129351. /**
  129352. * detach this feature.
  129353. * Will usually be called by the features manager
  129354. *
  129355. * @returns true if successful.
  129356. */
  129357. detach(): boolean;
  129358. /**
  129359. * Will get the mesh under a specific pointer.
  129360. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129361. * @param controllerId the controllerId to check
  129362. * @returns The mesh under pointer or null if no mesh is under the pointer
  129363. */
  129364. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129365. /**
  129366. * Get the xr controller that correlates to the pointer id in the pointer event
  129367. *
  129368. * @param id the pointer id to search for
  129369. * @returns the controller that correlates to this id or null if not found
  129370. */
  129371. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129372. protected _onXRFrame(_xrFrame: XRFrame): void;
  129373. private _attachGazeMode;
  129374. private _attachScreenRayMode;
  129375. private _attachTrackedPointerRayMode;
  129376. private _convertNormalToDirectionOfRay;
  129377. private _detachController;
  129378. private _generateNewMeshPair;
  129379. private _pickingMoved;
  129380. private _updatePointerDistance;
  129381. /** @hidden */
  129382. get lasterPointerDefaultColor(): Color3;
  129383. }
  129384. }
  129385. declare module BABYLON {
  129386. /**
  129387. * Button which can be used to enter a different mode of XR
  129388. */
  129389. export class WebXREnterExitUIButton {
  129390. /** button element */
  129391. element: HTMLElement;
  129392. /** XR initialization options for the button */
  129393. sessionMode: XRSessionMode;
  129394. /** Reference space type */
  129395. referenceSpaceType: XRReferenceSpaceType;
  129396. /**
  129397. * Creates a WebXREnterExitUIButton
  129398. * @param element button element
  129399. * @param sessionMode XR initialization session mode
  129400. * @param referenceSpaceType the type of reference space to be used
  129401. */
  129402. constructor(
  129403. /** button element */
  129404. element: HTMLElement,
  129405. /** XR initialization options for the button */
  129406. sessionMode: XRSessionMode,
  129407. /** Reference space type */
  129408. referenceSpaceType: XRReferenceSpaceType);
  129409. /**
  129410. * Extendable function which can be used to update the button's visuals when the state changes
  129411. * @param activeButton the current active button in the UI
  129412. */
  129413. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129414. }
  129415. /**
  129416. * Options to create the webXR UI
  129417. */
  129418. export class WebXREnterExitUIOptions {
  129419. /**
  129420. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129421. */
  129422. customButtons?: Array<WebXREnterExitUIButton>;
  129423. /**
  129424. * A reference space type to use when creating the default button.
  129425. * Default is local-floor
  129426. */
  129427. referenceSpaceType?: XRReferenceSpaceType;
  129428. /**
  129429. * Context to enter xr with
  129430. */
  129431. renderTarget?: Nullable<WebXRRenderTarget>;
  129432. /**
  129433. * A session mode to use when creating the default button.
  129434. * Default is immersive-vr
  129435. */
  129436. sessionMode?: XRSessionMode;
  129437. /**
  129438. * A list of optional features to init the session with
  129439. */
  129440. optionalFeatures?: string[];
  129441. /**
  129442. * A list of optional features to init the session with
  129443. */
  129444. requiredFeatures?: string[];
  129445. }
  129446. /**
  129447. * UI to allow the user to enter/exit XR mode
  129448. */
  129449. export class WebXREnterExitUI implements IDisposable {
  129450. private scene;
  129451. /** version of the options passed to this UI */
  129452. options: WebXREnterExitUIOptions;
  129453. private _activeButton;
  129454. private _buttons;
  129455. /**
  129456. * The HTML Div Element to which buttons are added.
  129457. */
  129458. readonly overlay: HTMLDivElement;
  129459. /**
  129460. * Fired every time the active button is changed.
  129461. *
  129462. * When xr is entered via a button that launches xr that button will be the callback parameter
  129463. *
  129464. * When exiting xr the callback parameter will be null)
  129465. */
  129466. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129467. /**
  129468. *
  129469. * @param scene babylon scene object to use
  129470. * @param options (read-only) version of the options passed to this UI
  129471. */
  129472. private constructor();
  129473. /**
  129474. * Creates UI to allow the user to enter/exit XR mode
  129475. * @param scene the scene to add the ui to
  129476. * @param helper the xr experience helper to enter/exit xr with
  129477. * @param options options to configure the UI
  129478. * @returns the created ui
  129479. */
  129480. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129481. /**
  129482. * Disposes of the XR UI component
  129483. */
  129484. dispose(): void;
  129485. private _updateButtons;
  129486. }
  129487. }
  129488. declare module BABYLON {
  129489. /**
  129490. * Class containing static functions to help procedurally build meshes
  129491. */
  129492. export class LinesBuilder {
  129493. /**
  129494. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129495. * * 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
  129496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129497. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129498. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129499. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129500. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129501. * * 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
  129502. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129505. * @param name defines the name of the new line system
  129506. * @param options defines the options used to create the line system
  129507. * @param scene defines the hosting scene
  129508. * @returns a new line system mesh
  129509. */
  129510. static CreateLineSystem(name: string, options: {
  129511. lines: Vector3[][];
  129512. updatable?: boolean;
  129513. instance?: Nullable<LinesMesh>;
  129514. colors?: Nullable<Color4[][]>;
  129515. useVertexAlpha?: boolean;
  129516. }, scene: Nullable<Scene>): LinesMesh;
  129517. /**
  129518. * Creates a line mesh
  129519. * 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
  129520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129521. * * The parameter `points` is an array successive Vector3
  129522. * * 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
  129523. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129524. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129525. * * When updating an instance, remember that only point positions can change, not the number of points
  129526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129528. * @param name defines the name of the new line system
  129529. * @param options defines the options used to create the line system
  129530. * @param scene defines the hosting scene
  129531. * @returns a new line mesh
  129532. */
  129533. static CreateLines(name: string, options: {
  129534. points: Vector3[];
  129535. updatable?: boolean;
  129536. instance?: Nullable<LinesMesh>;
  129537. colors?: Color4[];
  129538. useVertexAlpha?: boolean;
  129539. }, scene?: Nullable<Scene>): LinesMesh;
  129540. /**
  129541. * Creates a dashed line mesh
  129542. * * 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
  129543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129544. * * The parameter `points` is an array successive Vector3
  129545. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129546. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129547. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129548. * * 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
  129549. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129550. * * When updating an instance, remember that only point positions can change, not the number of points
  129551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129552. * @param name defines the name of the mesh
  129553. * @param options defines the options used to create the mesh
  129554. * @param scene defines the hosting scene
  129555. * @returns the dashed line mesh
  129556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129557. */
  129558. static CreateDashedLines(name: string, options: {
  129559. points: Vector3[];
  129560. dashSize?: number;
  129561. gapSize?: number;
  129562. dashNb?: number;
  129563. updatable?: boolean;
  129564. instance?: LinesMesh;
  129565. useVertexAlpha?: boolean;
  129566. }, scene?: Nullable<Scene>): LinesMesh;
  129567. }
  129568. }
  129569. declare module BABYLON {
  129570. /**
  129571. * Construction options for a timer
  129572. */
  129573. export interface ITimerOptions<T> {
  129574. /**
  129575. * Time-to-end
  129576. */
  129577. timeout: number;
  129578. /**
  129579. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129580. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129581. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129582. */
  129583. contextObservable: Observable<T>;
  129584. /**
  129585. * Optional parameters when adding an observer to the observable
  129586. */
  129587. observableParameters?: {
  129588. mask?: number;
  129589. insertFirst?: boolean;
  129590. scope?: any;
  129591. };
  129592. /**
  129593. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129594. */
  129595. breakCondition?: (data?: ITimerData<T>) => boolean;
  129596. /**
  129597. * Will be triggered when the time condition has met
  129598. */
  129599. onEnded?: (data: ITimerData<any>) => void;
  129600. /**
  129601. * Will be triggered when the break condition has met (prematurely ended)
  129602. */
  129603. onAborted?: (data: ITimerData<any>) => void;
  129604. /**
  129605. * Optional function to execute on each tick (or count)
  129606. */
  129607. onTick?: (data: ITimerData<any>) => void;
  129608. }
  129609. /**
  129610. * An interface defining the data sent by the timer
  129611. */
  129612. export interface ITimerData<T> {
  129613. /**
  129614. * When did it start
  129615. */
  129616. startTime: number;
  129617. /**
  129618. * Time now
  129619. */
  129620. currentTime: number;
  129621. /**
  129622. * Time passed since started
  129623. */
  129624. deltaTime: number;
  129625. /**
  129626. * How much is completed, in [0.0...1.0].
  129627. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129628. */
  129629. completeRate: number;
  129630. /**
  129631. * What the registered observable sent in the last count
  129632. */
  129633. payload: T;
  129634. }
  129635. /**
  129636. * The current state of the timer
  129637. */
  129638. export enum TimerState {
  129639. /**
  129640. * Timer initialized, not yet started
  129641. */
  129642. INIT = 0,
  129643. /**
  129644. * Timer started and counting
  129645. */
  129646. STARTED = 1,
  129647. /**
  129648. * Timer ended (whether aborted or time reached)
  129649. */
  129650. ENDED = 2
  129651. }
  129652. /**
  129653. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129654. *
  129655. * @param options options with which to initialize this timer
  129656. */
  129657. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129658. /**
  129659. * An advanced implementation of a timer class
  129660. */
  129661. export class AdvancedTimer<T = any> implements IDisposable {
  129662. /**
  129663. * Will notify each time the timer calculates the remaining time
  129664. */
  129665. onEachCountObservable: Observable<ITimerData<T>>;
  129666. /**
  129667. * Will trigger when the timer was aborted due to the break condition
  129668. */
  129669. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129670. /**
  129671. * Will trigger when the timer ended successfully
  129672. */
  129673. onTimerEndedObservable: Observable<ITimerData<T>>;
  129674. /**
  129675. * Will trigger when the timer state has changed
  129676. */
  129677. onStateChangedObservable: Observable<TimerState>;
  129678. private _observer;
  129679. private _contextObservable;
  129680. private _observableParameters;
  129681. private _startTime;
  129682. private _timer;
  129683. private _state;
  129684. private _breakCondition;
  129685. private _timeToEnd;
  129686. private _breakOnNextTick;
  129687. /**
  129688. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129689. * @param options construction options for this advanced timer
  129690. */
  129691. constructor(options: ITimerOptions<T>);
  129692. /**
  129693. * set a breaking condition for this timer. Default is to never break during count
  129694. * @param predicate the new break condition. Returns true to break, false otherwise
  129695. */
  129696. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129697. /**
  129698. * Reset ALL associated observables in this advanced timer
  129699. */
  129700. clearObservables(): void;
  129701. /**
  129702. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129703. *
  129704. * @param timeToEnd how much time to measure until timer ended
  129705. */
  129706. start(timeToEnd?: number): void;
  129707. /**
  129708. * Will force a stop on the next tick.
  129709. */
  129710. stop(): void;
  129711. /**
  129712. * Dispose this timer, clearing all resources
  129713. */
  129714. dispose(): void;
  129715. private _setState;
  129716. private _tick;
  129717. private _stop;
  129718. }
  129719. }
  129720. declare module BABYLON {
  129721. /**
  129722. * The options container for the teleportation module
  129723. */
  129724. export interface IWebXRTeleportationOptions {
  129725. /**
  129726. * if provided, this scene will be used to render meshes.
  129727. */
  129728. customUtilityLayerScene?: Scene;
  129729. /**
  129730. * Values to configure the default target mesh
  129731. */
  129732. defaultTargetMeshOptions?: {
  129733. /**
  129734. * Fill color of the teleportation area
  129735. */
  129736. teleportationFillColor?: string;
  129737. /**
  129738. * Border color for the teleportation area
  129739. */
  129740. teleportationBorderColor?: string;
  129741. /**
  129742. * Disable the mesh's animation sequence
  129743. */
  129744. disableAnimation?: boolean;
  129745. /**
  129746. * Disable lighting on the material or the ring and arrow
  129747. */
  129748. disableLighting?: boolean;
  129749. /**
  129750. * Override the default material of the torus and arrow
  129751. */
  129752. torusArrowMaterial?: Material;
  129753. };
  129754. /**
  129755. * A list of meshes to use as floor meshes.
  129756. * Meshes can be added and removed after initializing the feature using the
  129757. * addFloorMesh and removeFloorMesh functions
  129758. * If empty, rotation will still work
  129759. */
  129760. floorMeshes?: AbstractMesh[];
  129761. /**
  129762. * use this rendering group id for the meshes (optional)
  129763. */
  129764. renderingGroupId?: number;
  129765. /**
  129766. * Should teleportation move only to snap points
  129767. */
  129768. snapPointsOnly?: boolean;
  129769. /**
  129770. * An array of points to which the teleportation will snap to.
  129771. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129772. */
  129773. snapPositions?: Vector3[];
  129774. /**
  129775. * How close should the teleportation ray be in order to snap to position.
  129776. * Default to 0.8 units (meters)
  129777. */
  129778. snapToPositionRadius?: number;
  129779. /**
  129780. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129781. * If you want to support rotation, make sure your mesh has a direction indicator.
  129782. *
  129783. * When left untouched, the default mesh will be initialized.
  129784. */
  129785. teleportationTargetMesh?: AbstractMesh;
  129786. /**
  129787. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129788. */
  129789. timeToTeleport?: number;
  129790. /**
  129791. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129792. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129793. */
  129794. useMainComponentOnly?: boolean;
  129795. /**
  129796. * Should meshes created here be added to a utility layer or the main scene
  129797. */
  129798. useUtilityLayer?: boolean;
  129799. /**
  129800. * Babylon XR Input class for controller
  129801. */
  129802. xrInput: WebXRInput;
  129803. /**
  129804. * Meshes that the teleportation ray cannot go through
  129805. */
  129806. pickBlockerMeshes?: AbstractMesh[];
  129807. }
  129808. /**
  129809. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129810. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129811. * the input of the attached controllers.
  129812. */
  129813. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129814. private _options;
  129815. private _controllers;
  129816. private _currentTeleportationControllerId;
  129817. private _floorMeshes;
  129818. private _quadraticBezierCurve;
  129819. private _selectionFeature;
  129820. private _snapToPositions;
  129821. private _snappedToPoint;
  129822. private _teleportationRingMaterial?;
  129823. private _tmpRay;
  129824. private _tmpVector;
  129825. private _tmpQuaternion;
  129826. /**
  129827. * The module's name
  129828. */
  129829. static readonly Name: string;
  129830. /**
  129831. * The (Babylon) version of this module.
  129832. * This is an integer representing the implementation version.
  129833. * This number does not correspond to the webxr specs version
  129834. */
  129835. static readonly Version: number;
  129836. /**
  129837. * Is movement backwards enabled
  129838. */
  129839. backwardsMovementEnabled: boolean;
  129840. /**
  129841. * Distance to travel when moving backwards
  129842. */
  129843. backwardsTeleportationDistance: number;
  129844. /**
  129845. * The distance from the user to the inspection point in the direction of the controller
  129846. * A higher number will allow the user to move further
  129847. * defaults to 5 (meters, in xr units)
  129848. */
  129849. parabolicCheckRadius: number;
  129850. /**
  129851. * Should the module support parabolic ray on top of direct ray
  129852. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129853. * Very helpful when moving between floors / different heights
  129854. */
  129855. parabolicRayEnabled: boolean;
  129856. /**
  129857. * How much rotation should be applied when rotating right and left
  129858. */
  129859. rotationAngle: number;
  129860. /**
  129861. * Is rotation enabled when moving forward?
  129862. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129863. */
  129864. rotationEnabled: boolean;
  129865. /**
  129866. * constructs a new anchor system
  129867. * @param _xrSessionManager an instance of WebXRSessionManager
  129868. * @param _options configuration object for this feature
  129869. */
  129870. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129871. /**
  129872. * Get the snapPointsOnly flag
  129873. */
  129874. get snapPointsOnly(): boolean;
  129875. /**
  129876. * Sets the snapPointsOnly flag
  129877. * @param snapToPoints should teleportation be exclusively to snap points
  129878. */
  129879. set snapPointsOnly(snapToPoints: boolean);
  129880. /**
  129881. * Add a new mesh to the floor meshes array
  129882. * @param mesh the mesh to use as floor mesh
  129883. */
  129884. addFloorMesh(mesh: AbstractMesh): void;
  129885. /**
  129886. * Add a new snap-to point to fix teleportation to this position
  129887. * @param newSnapPoint The new Snap-To point
  129888. */
  129889. addSnapPoint(newSnapPoint: Vector3): void;
  129890. attach(): boolean;
  129891. detach(): boolean;
  129892. dispose(): void;
  129893. /**
  129894. * Remove a mesh from the floor meshes array
  129895. * @param mesh the mesh to remove
  129896. */
  129897. removeFloorMesh(mesh: AbstractMesh): void;
  129898. /**
  129899. * Remove a mesh from the floor meshes array using its name
  129900. * @param name the mesh name to remove
  129901. */
  129902. removeFloorMeshByName(name: string): void;
  129903. /**
  129904. * 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
  129905. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129906. * @returns was the point found and removed or not
  129907. */
  129908. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129909. /**
  129910. * This function sets a selection feature that will be disabled when
  129911. * the forward ray is shown and will be reattached when hidden.
  129912. * This is used to remove the selection rays when moving.
  129913. * @param selectionFeature the feature to disable when forward movement is enabled
  129914. */
  129915. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129916. protected _onXRFrame(_xrFrame: XRFrame): void;
  129917. private _attachController;
  129918. private _createDefaultTargetMesh;
  129919. private _detachController;
  129920. private _findClosestSnapPointWithRadius;
  129921. private _setTargetMeshPosition;
  129922. private _setTargetMeshVisibility;
  129923. private _showParabolicPath;
  129924. private _teleportForward;
  129925. }
  129926. }
  129927. declare module BABYLON {
  129928. /**
  129929. * Options for the default xr helper
  129930. */
  129931. export class WebXRDefaultExperienceOptions {
  129932. /**
  129933. * Enable or disable default UI to enter XR
  129934. */
  129935. disableDefaultUI?: boolean;
  129936. /**
  129937. * Should teleportation not initialize. defaults to false.
  129938. */
  129939. disableTeleportation?: boolean;
  129940. /**
  129941. * Floor meshes that will be used for teleport
  129942. */
  129943. floorMeshes?: Array<AbstractMesh>;
  129944. /**
  129945. * If set to true, the first frame will not be used to reset position
  129946. * The first frame is mainly used when copying transformation from the old camera
  129947. * Mainly used in AR
  129948. */
  129949. ignoreNativeCameraTransformation?: boolean;
  129950. /**
  129951. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129952. */
  129953. inputOptions?: IWebXRInputOptions;
  129954. /**
  129955. * optional configuration for the output canvas
  129956. */
  129957. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129958. /**
  129959. * optional UI options. This can be used among other to change session mode and reference space type
  129960. */
  129961. uiOptions?: WebXREnterExitUIOptions;
  129962. /**
  129963. * When loading teleportation and pointer select, use stable versions instead of latest.
  129964. */
  129965. useStablePlugins?: boolean;
  129966. /**
  129967. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129968. */
  129969. renderingGroupId?: number;
  129970. /**
  129971. * A list of optional features to init the session with
  129972. * If set to true, all features we support will be added
  129973. */
  129974. optionalFeatures?: boolean | string[];
  129975. }
  129976. /**
  129977. * Default experience which provides a similar setup to the previous webVRExperience
  129978. */
  129979. export class WebXRDefaultExperience {
  129980. /**
  129981. * Base experience
  129982. */
  129983. baseExperience: WebXRExperienceHelper;
  129984. /**
  129985. * Enables ui for entering/exiting xr
  129986. */
  129987. enterExitUI: WebXREnterExitUI;
  129988. /**
  129989. * Input experience extension
  129990. */
  129991. input: WebXRInput;
  129992. /**
  129993. * Enables laser pointer and selection
  129994. */
  129995. pointerSelection: WebXRControllerPointerSelection;
  129996. /**
  129997. * Default target xr should render to
  129998. */
  129999. renderTarget: WebXRRenderTarget;
  130000. /**
  130001. * Enables teleportation
  130002. */
  130003. teleportation: WebXRMotionControllerTeleportation;
  130004. private constructor();
  130005. /**
  130006. * Creates the default xr experience
  130007. * @param scene scene
  130008. * @param options options for basic configuration
  130009. * @returns resulting WebXRDefaultExperience
  130010. */
  130011. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130012. /**
  130013. * DIsposes of the experience helper
  130014. */
  130015. dispose(): void;
  130016. }
  130017. }
  130018. declare module BABYLON {
  130019. /**
  130020. * Options to modify the vr teleportation behavior.
  130021. */
  130022. export interface VRTeleportationOptions {
  130023. /**
  130024. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130025. */
  130026. floorMeshName?: string;
  130027. /**
  130028. * A list of meshes to be used as the teleportation floor. (default: empty)
  130029. */
  130030. floorMeshes?: Mesh[];
  130031. /**
  130032. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130033. */
  130034. teleportationMode?: number;
  130035. /**
  130036. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130037. */
  130038. teleportationTime?: number;
  130039. /**
  130040. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130041. */
  130042. teleportationSpeed?: number;
  130043. /**
  130044. * The easing function used in the animation or null for Linear. (default CircleEase)
  130045. */
  130046. easingFunction?: EasingFunction;
  130047. }
  130048. /**
  130049. * Options to modify the vr experience helper's behavior.
  130050. */
  130051. export interface VRExperienceHelperOptions extends WebVROptions {
  130052. /**
  130053. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130054. */
  130055. createDeviceOrientationCamera?: boolean;
  130056. /**
  130057. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130058. */
  130059. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130060. /**
  130061. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130062. */
  130063. laserToggle?: boolean;
  130064. /**
  130065. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130066. */
  130067. floorMeshes?: Mesh[];
  130068. /**
  130069. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130070. */
  130071. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130072. /**
  130073. * Defines if WebXR should be used instead of WebVR (if available)
  130074. */
  130075. useXR?: boolean;
  130076. }
  130077. /**
  130078. * Event containing information after VR has been entered
  130079. */
  130080. export class OnAfterEnteringVRObservableEvent {
  130081. /**
  130082. * If entering vr was successful
  130083. */
  130084. success: boolean;
  130085. }
  130086. /**
  130087. * Helps to quickly add VR support to an existing scene.
  130088. * See https://doc.babylonjs.com/how_to/webvr_helper
  130089. */
  130090. export class VRExperienceHelper {
  130091. /** Options to modify the vr experience helper's behavior. */
  130092. webVROptions: VRExperienceHelperOptions;
  130093. private _scene;
  130094. private _position;
  130095. private _btnVR;
  130096. private _btnVRDisplayed;
  130097. private _webVRsupported;
  130098. private _webVRready;
  130099. private _webVRrequesting;
  130100. private _webVRpresenting;
  130101. private _hasEnteredVR;
  130102. private _fullscreenVRpresenting;
  130103. private _inputElement;
  130104. private _webVRCamera;
  130105. private _vrDeviceOrientationCamera;
  130106. private _deviceOrientationCamera;
  130107. private _existingCamera;
  130108. private _onKeyDown;
  130109. private _onVrDisplayPresentChange;
  130110. private _onVRDisplayChanged;
  130111. private _onVRRequestPresentStart;
  130112. private _onVRRequestPresentComplete;
  130113. /**
  130114. * 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)
  130115. */
  130116. enableGazeEvenWhenNoPointerLock: boolean;
  130117. /**
  130118. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130119. */
  130120. exitVROnDoubleTap: boolean;
  130121. /**
  130122. * Observable raised right before entering VR.
  130123. */
  130124. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130125. /**
  130126. * Observable raised when entering VR has completed.
  130127. */
  130128. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130129. /**
  130130. * Observable raised when exiting VR.
  130131. */
  130132. onExitingVRObservable: Observable<VRExperienceHelper>;
  130133. /**
  130134. * Observable raised when controller mesh is loaded.
  130135. */
  130136. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130137. /** Return this.onEnteringVRObservable
  130138. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130139. */
  130140. get onEnteringVR(): Observable<VRExperienceHelper>;
  130141. /** Return this.onExitingVRObservable
  130142. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130143. */
  130144. get onExitingVR(): Observable<VRExperienceHelper>;
  130145. /** Return this.onControllerMeshLoadedObservable
  130146. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130147. */
  130148. get onControllerMeshLoaded(): Observable<WebVRController>;
  130149. private _rayLength;
  130150. private _useCustomVRButton;
  130151. private _teleportationRequested;
  130152. private _teleportActive;
  130153. private _floorMeshName;
  130154. private _floorMeshesCollection;
  130155. private _teleportationMode;
  130156. private _teleportationTime;
  130157. private _teleportationSpeed;
  130158. private _teleportationEasing;
  130159. private _rotationAllowed;
  130160. private _teleportBackwardsVector;
  130161. private _teleportationTarget;
  130162. private _isDefaultTeleportationTarget;
  130163. private _postProcessMove;
  130164. private _teleportationFillColor;
  130165. private _teleportationBorderColor;
  130166. private _rotationAngle;
  130167. private _haloCenter;
  130168. private _cameraGazer;
  130169. private _padSensibilityUp;
  130170. private _padSensibilityDown;
  130171. private _leftController;
  130172. private _rightController;
  130173. private _gazeColor;
  130174. private _laserColor;
  130175. private _pickedLaserColor;
  130176. private _pickedGazeColor;
  130177. /**
  130178. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130179. */
  130180. onNewMeshSelected: Observable<AbstractMesh>;
  130181. /**
  130182. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130183. * This observable will provide the mesh and the controller used to select the mesh
  130184. */
  130185. onMeshSelectedWithController: Observable<{
  130186. mesh: AbstractMesh;
  130187. controller: WebVRController;
  130188. }>;
  130189. /**
  130190. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130191. */
  130192. onNewMeshPicked: Observable<PickingInfo>;
  130193. private _circleEase;
  130194. /**
  130195. * Observable raised before camera teleportation
  130196. */
  130197. onBeforeCameraTeleport: Observable<Vector3>;
  130198. /**
  130199. * Observable raised after camera teleportation
  130200. */
  130201. onAfterCameraTeleport: Observable<Vector3>;
  130202. /**
  130203. * Observable raised when current selected mesh gets unselected
  130204. */
  130205. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130206. private _raySelectionPredicate;
  130207. /**
  130208. * To be optionaly changed by user to define custom ray selection
  130209. */
  130210. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130211. /**
  130212. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130213. */
  130214. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130215. /**
  130216. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130217. */
  130218. teleportationEnabled: boolean;
  130219. private _defaultHeight;
  130220. private _teleportationInitialized;
  130221. private _interactionsEnabled;
  130222. private _interactionsRequested;
  130223. private _displayGaze;
  130224. private _displayLaserPointer;
  130225. /**
  130226. * The mesh used to display where the user is going to teleport.
  130227. */
  130228. get teleportationTarget(): Mesh;
  130229. /**
  130230. * Sets the mesh to be used to display where the user is going to teleport.
  130231. */
  130232. set teleportationTarget(value: Mesh);
  130233. /**
  130234. * 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
  130235. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130236. * See https://doc.babylonjs.com/resources/baking_transformations
  130237. */
  130238. get gazeTrackerMesh(): Mesh;
  130239. set gazeTrackerMesh(value: Mesh);
  130240. /**
  130241. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130242. */
  130243. updateGazeTrackerScale: boolean;
  130244. /**
  130245. * If the gaze trackers color should be updated when selecting meshes
  130246. */
  130247. updateGazeTrackerColor: boolean;
  130248. /**
  130249. * If the controller laser color should be updated when selecting meshes
  130250. */
  130251. updateControllerLaserColor: boolean;
  130252. /**
  130253. * The gaze tracking mesh corresponding to the left controller
  130254. */
  130255. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130256. /**
  130257. * The gaze tracking mesh corresponding to the right controller
  130258. */
  130259. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130260. /**
  130261. * If the ray of the gaze should be displayed.
  130262. */
  130263. get displayGaze(): boolean;
  130264. /**
  130265. * Sets if the ray of the gaze should be displayed.
  130266. */
  130267. set displayGaze(value: boolean);
  130268. /**
  130269. * If the ray of the LaserPointer should be displayed.
  130270. */
  130271. get displayLaserPointer(): boolean;
  130272. /**
  130273. * Sets if the ray of the LaserPointer should be displayed.
  130274. */
  130275. set displayLaserPointer(value: boolean);
  130276. /**
  130277. * The deviceOrientationCamera used as the camera when not in VR.
  130278. */
  130279. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130280. /**
  130281. * Based on the current WebVR support, returns the current VR camera used.
  130282. */
  130283. get currentVRCamera(): Nullable<Camera>;
  130284. /**
  130285. * The webVRCamera which is used when in VR.
  130286. */
  130287. get webVRCamera(): WebVRFreeCamera;
  130288. /**
  130289. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130290. */
  130291. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130292. /**
  130293. * The html button that is used to trigger entering into VR.
  130294. */
  130295. get vrButton(): Nullable<HTMLButtonElement>;
  130296. private get _teleportationRequestInitiated();
  130297. /**
  130298. * Defines whether or not Pointer lock should be requested when switching to
  130299. * full screen.
  130300. */
  130301. requestPointerLockOnFullScreen: boolean;
  130302. /**
  130303. * If asking to force XR, this will be populated with the default xr experience
  130304. */
  130305. xr: WebXRDefaultExperience;
  130306. /**
  130307. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130308. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130309. */
  130310. xrTestDone: boolean;
  130311. /**
  130312. * Instantiates a VRExperienceHelper.
  130313. * Helps to quickly add VR support to an existing scene.
  130314. * @param scene The scene the VRExperienceHelper belongs to.
  130315. * @param webVROptions Options to modify the vr experience helper's behavior.
  130316. */
  130317. constructor(scene: Scene,
  130318. /** Options to modify the vr experience helper's behavior. */
  130319. webVROptions?: VRExperienceHelperOptions);
  130320. private completeVRInit;
  130321. private _onDefaultMeshLoaded;
  130322. private _onResize;
  130323. private _onFullscreenChange;
  130324. /**
  130325. * Gets a value indicating if we are currently in VR mode.
  130326. */
  130327. get isInVRMode(): boolean;
  130328. private onVrDisplayPresentChange;
  130329. private onVRDisplayChanged;
  130330. private moveButtonToBottomRight;
  130331. private displayVRButton;
  130332. private updateButtonVisibility;
  130333. private _cachedAngularSensibility;
  130334. /**
  130335. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130336. * Otherwise, will use the fullscreen API.
  130337. */
  130338. enterVR(): void;
  130339. /**
  130340. * Attempt to exit VR, or fullscreen.
  130341. */
  130342. exitVR(): void;
  130343. /**
  130344. * The position of the vr experience helper.
  130345. */
  130346. get position(): Vector3;
  130347. /**
  130348. * Sets the position of the vr experience helper.
  130349. */
  130350. set position(value: Vector3);
  130351. /**
  130352. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130353. */
  130354. enableInteractions(): void;
  130355. private get _noControllerIsActive();
  130356. private beforeRender;
  130357. private _isTeleportationFloor;
  130358. /**
  130359. * Adds a floor mesh to be used for teleportation.
  130360. * @param floorMesh the mesh to be used for teleportation.
  130361. */
  130362. addFloorMesh(floorMesh: Mesh): void;
  130363. /**
  130364. * Removes a floor mesh from being used for teleportation.
  130365. * @param floorMesh the mesh to be removed.
  130366. */
  130367. removeFloorMesh(floorMesh: Mesh): void;
  130368. /**
  130369. * Enables interactions and teleportation using the VR controllers and gaze.
  130370. * @param vrTeleportationOptions options to modify teleportation behavior.
  130371. */
  130372. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130373. private _onNewGamepadConnected;
  130374. private _tryEnableInteractionOnController;
  130375. private _onNewGamepadDisconnected;
  130376. private _enableInteractionOnController;
  130377. private _checkTeleportWithRay;
  130378. private _checkRotate;
  130379. private _checkTeleportBackwards;
  130380. private _enableTeleportationOnController;
  130381. private _createTeleportationCircles;
  130382. private _displayTeleportationTarget;
  130383. private _hideTeleportationTarget;
  130384. private _rotateCamera;
  130385. private _moveTeleportationSelectorTo;
  130386. private _workingVector;
  130387. private _workingQuaternion;
  130388. private _workingMatrix;
  130389. /**
  130390. * Time Constant Teleportation Mode
  130391. */
  130392. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130393. /**
  130394. * Speed Constant Teleportation Mode
  130395. */
  130396. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130397. /**
  130398. * Teleports the users feet to the desired location
  130399. * @param location The location where the user's feet should be placed
  130400. */
  130401. teleportCamera(location: Vector3): void;
  130402. private _convertNormalToDirectionOfRay;
  130403. private _castRayAndSelectObject;
  130404. private _notifySelectedMeshUnselected;
  130405. /**
  130406. * Permanently set new colors for the laser pointer
  130407. * @param color the new laser color
  130408. * @param pickedColor the new laser color when picked mesh detected
  130409. */
  130410. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130411. /**
  130412. * Set lighting enabled / disabled on the laser pointer of both controllers
  130413. * @param enabled should the lighting be enabled on the laser pointer
  130414. */
  130415. setLaserLightingState(enabled?: boolean): void;
  130416. /**
  130417. * Permanently set new colors for the gaze pointer
  130418. * @param color the new gaze color
  130419. * @param pickedColor the new gaze color when picked mesh detected
  130420. */
  130421. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130422. /**
  130423. * Sets the color of the laser ray from the vr controllers.
  130424. * @param color new color for the ray.
  130425. */
  130426. changeLaserColor(color: Color3): void;
  130427. /**
  130428. * Sets the color of the ray from the vr headsets gaze.
  130429. * @param color new color for the ray.
  130430. */
  130431. changeGazeColor(color: Color3): void;
  130432. /**
  130433. * Exits VR and disposes of the vr experience helper
  130434. */
  130435. dispose(): void;
  130436. /**
  130437. * Gets the name of the VRExperienceHelper class
  130438. * @returns "VRExperienceHelper"
  130439. */
  130440. getClassName(): string;
  130441. }
  130442. }
  130443. declare module BABYLON {
  130444. /**
  130445. * Contains an array of blocks representing the octree
  130446. */
  130447. export interface IOctreeContainer<T> {
  130448. /**
  130449. * Blocks within the octree
  130450. */
  130451. blocks: Array<OctreeBlock<T>>;
  130452. }
  130453. /**
  130454. * Class used to store a cell in an octree
  130455. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130456. */
  130457. export class OctreeBlock<T> {
  130458. /**
  130459. * Gets the content of the current block
  130460. */
  130461. entries: T[];
  130462. /**
  130463. * Gets the list of block children
  130464. */
  130465. blocks: Array<OctreeBlock<T>>;
  130466. private _depth;
  130467. private _maxDepth;
  130468. private _capacity;
  130469. private _minPoint;
  130470. private _maxPoint;
  130471. private _boundingVectors;
  130472. private _creationFunc;
  130473. /**
  130474. * Creates a new block
  130475. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130476. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130477. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130478. * @param depth defines the current depth of this block in the octree
  130479. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130480. * @param creationFunc defines a callback to call when an element is added to the block
  130481. */
  130482. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130483. /**
  130484. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130485. */
  130486. get capacity(): number;
  130487. /**
  130488. * Gets the minimum vector (in world space) of the block's bounding box
  130489. */
  130490. get minPoint(): Vector3;
  130491. /**
  130492. * Gets the maximum vector (in world space) of the block's bounding box
  130493. */
  130494. get maxPoint(): Vector3;
  130495. /**
  130496. * Add a new element to this block
  130497. * @param entry defines the element to add
  130498. */
  130499. addEntry(entry: T): void;
  130500. /**
  130501. * Remove an element from this block
  130502. * @param entry defines the element to remove
  130503. */
  130504. removeEntry(entry: T): void;
  130505. /**
  130506. * Add an array of elements to this block
  130507. * @param entries defines the array of elements to add
  130508. */
  130509. addEntries(entries: T[]): void;
  130510. /**
  130511. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130512. * @param frustumPlanes defines the frustum planes to test
  130513. * @param selection defines the array to store current content if selection is positive
  130514. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130515. */
  130516. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130517. /**
  130518. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130519. * @param sphereCenter defines the bounding sphere center
  130520. * @param sphereRadius defines the bounding sphere radius
  130521. * @param selection defines the array to store current content if selection is positive
  130522. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130523. */
  130524. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130525. /**
  130526. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130527. * @param ray defines the ray to test with
  130528. * @param selection defines the array to store current content if selection is positive
  130529. */
  130530. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130531. /**
  130532. * Subdivide the content into child blocks (this block will then be empty)
  130533. */
  130534. createInnerBlocks(): void;
  130535. /**
  130536. * @hidden
  130537. */
  130538. 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;
  130539. }
  130540. }
  130541. declare module BABYLON {
  130542. /**
  130543. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130544. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130545. */
  130546. export class Octree<T> {
  130547. /** 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.) */
  130548. maxDepth: number;
  130549. /**
  130550. * Blocks within the octree containing objects
  130551. */
  130552. blocks: Array<OctreeBlock<T>>;
  130553. /**
  130554. * Content stored in the octree
  130555. */
  130556. dynamicContent: T[];
  130557. private _maxBlockCapacity;
  130558. private _selectionContent;
  130559. private _creationFunc;
  130560. /**
  130561. * Creates a octree
  130562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130563. * @param creationFunc function to be used to instatiate the octree
  130564. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130565. * @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.)
  130566. */
  130567. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130568. /** 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.) */
  130569. maxDepth?: number);
  130570. /**
  130571. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130572. * @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);
  130573. * @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);
  130574. * @param entries meshes to be added to the octree blocks
  130575. */
  130576. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130577. /**
  130578. * Adds a mesh to the octree
  130579. * @param entry Mesh to add to the octree
  130580. */
  130581. addMesh(entry: T): void;
  130582. /**
  130583. * Remove an element from the octree
  130584. * @param entry defines the element to remove
  130585. */
  130586. removeMesh(entry: T): void;
  130587. /**
  130588. * Selects an array of meshes within the frustum
  130589. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130590. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130591. * @returns array of meshes within the frustum
  130592. */
  130593. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130594. /**
  130595. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130596. * @param sphereCenter defines the bounding sphere center
  130597. * @param sphereRadius defines the bounding sphere radius
  130598. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130599. * @returns an array of objects that intersect the sphere
  130600. */
  130601. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130602. /**
  130603. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130604. * @param ray defines the ray to test with
  130605. * @returns array of intersected objects
  130606. */
  130607. intersectsRay(ray: Ray): SmartArray<T>;
  130608. /**
  130609. * Adds a mesh into the octree block if it intersects the block
  130610. */
  130611. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130612. /**
  130613. * Adds a submesh into the octree block if it intersects the block
  130614. */
  130615. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130616. }
  130617. }
  130618. declare module BABYLON {
  130619. interface Scene {
  130620. /**
  130621. * @hidden
  130622. * Backing Filed
  130623. */
  130624. _selectionOctree: Octree<AbstractMesh>;
  130625. /**
  130626. * Gets the octree used to boost mesh selection (picking)
  130627. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130628. */
  130629. selectionOctree: Octree<AbstractMesh>;
  130630. /**
  130631. * Creates or updates the octree used to boost selection (picking)
  130632. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130633. * @param maxCapacity defines the maximum capacity per leaf
  130634. * @param maxDepth defines the maximum depth of the octree
  130635. * @returns an octree of AbstractMesh
  130636. */
  130637. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130638. }
  130639. interface AbstractMesh {
  130640. /**
  130641. * @hidden
  130642. * Backing Field
  130643. */
  130644. _submeshesOctree: Octree<SubMesh>;
  130645. /**
  130646. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130647. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130648. * @param maxCapacity defines the maximum size of each block (64 by default)
  130649. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130650. * @returns the new octree
  130651. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130652. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130653. */
  130654. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130655. }
  130656. /**
  130657. * Defines the octree scene component responsible to manage any octrees
  130658. * in a given scene.
  130659. */
  130660. export class OctreeSceneComponent {
  130661. /**
  130662. * The component name help to identify the component in the list of scene components.
  130663. */
  130664. readonly name: string;
  130665. /**
  130666. * The scene the component belongs to.
  130667. */
  130668. scene: Scene;
  130669. /**
  130670. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130671. */
  130672. readonly checksIsEnabled: boolean;
  130673. /**
  130674. * Creates a new instance of the component for the given scene
  130675. * @param scene Defines the scene to register the component in
  130676. */
  130677. constructor(scene: Scene);
  130678. /**
  130679. * Registers the component in a given scene
  130680. */
  130681. register(): void;
  130682. /**
  130683. * Return the list of active meshes
  130684. * @returns the list of active meshes
  130685. */
  130686. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130687. /**
  130688. * Return the list of active sub meshes
  130689. * @param mesh The mesh to get the candidates sub meshes from
  130690. * @returns the list of active sub meshes
  130691. */
  130692. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130693. private _tempRay;
  130694. /**
  130695. * Return the list of sub meshes intersecting with a given local ray
  130696. * @param mesh defines the mesh to find the submesh for
  130697. * @param localRay defines the ray in local space
  130698. * @returns the list of intersecting sub meshes
  130699. */
  130700. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130701. /**
  130702. * Return the list of sub meshes colliding with a collider
  130703. * @param mesh defines the mesh to find the submesh for
  130704. * @param collider defines the collider to evaluate the collision against
  130705. * @returns the list of colliding sub meshes
  130706. */
  130707. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130708. /**
  130709. * Rebuilds the elements related to this component in case of
  130710. * context lost for instance.
  130711. */
  130712. rebuild(): void;
  130713. /**
  130714. * Disposes the component and the associated ressources.
  130715. */
  130716. dispose(): void;
  130717. }
  130718. }
  130719. declare module BABYLON {
  130720. /**
  130721. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130722. */
  130723. export class Gizmo implements IDisposable {
  130724. /** The utility layer the gizmo will be added to */
  130725. gizmoLayer: UtilityLayerRenderer;
  130726. /**
  130727. * The root mesh of the gizmo
  130728. */
  130729. _rootMesh: Mesh;
  130730. private _attachedMesh;
  130731. private _attachedNode;
  130732. /**
  130733. * Ratio for the scale of the gizmo (Default: 1)
  130734. */
  130735. protected _scaleRatio: number;
  130736. /**
  130737. * boolean updated by pointermove when a gizmo mesh is hovered
  130738. */
  130739. protected _isHovered: boolean;
  130740. /**
  130741. * Ratio for the scale of the gizmo (Default: 1)
  130742. */
  130743. set scaleRatio(value: number);
  130744. get scaleRatio(): number;
  130745. /**
  130746. * True when the mouse pointer is hovered a gizmo mesh
  130747. */
  130748. get isHovered(): boolean;
  130749. /**
  130750. * If a custom mesh has been set (Default: false)
  130751. */
  130752. protected _customMeshSet: boolean;
  130753. /**
  130754. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130755. * * When set, interactions will be enabled
  130756. */
  130757. get attachedMesh(): Nullable<AbstractMesh>;
  130758. set attachedMesh(value: Nullable<AbstractMesh>);
  130759. /**
  130760. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130761. * * When set, interactions will be enabled
  130762. */
  130763. get attachedNode(): Nullable<Node>;
  130764. set attachedNode(value: Nullable<Node>);
  130765. /**
  130766. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130767. * @param mesh The mesh to replace the default mesh of the gizmo
  130768. */
  130769. setCustomMesh(mesh: Mesh): void;
  130770. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130771. /**
  130772. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130773. */
  130774. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130775. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130776. /**
  130777. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130778. */
  130779. updateGizmoPositionToMatchAttachedMesh: boolean;
  130780. /**
  130781. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130782. */
  130783. updateScale: boolean;
  130784. protected _interactionsEnabled: boolean;
  130785. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130786. private _beforeRenderObserver;
  130787. private _tempQuaternion;
  130788. private _tempVector;
  130789. private _tempVector2;
  130790. private _tempMatrix1;
  130791. private _tempMatrix2;
  130792. private _rightHandtoLeftHandMatrix;
  130793. /**
  130794. * Creates a gizmo
  130795. * @param gizmoLayer The utility layer the gizmo will be added to
  130796. */
  130797. constructor(
  130798. /** The utility layer the gizmo will be added to */
  130799. gizmoLayer?: UtilityLayerRenderer);
  130800. /**
  130801. * Updates the gizmo to match the attached mesh's position/rotation
  130802. */
  130803. protected _update(): void;
  130804. /**
  130805. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130806. * @param value Node, TransformNode or mesh
  130807. */
  130808. protected _matrixChanged(): void;
  130809. /**
  130810. * Disposes of the gizmo
  130811. */
  130812. dispose(): void;
  130813. }
  130814. }
  130815. declare module BABYLON {
  130816. /**
  130817. * Single plane drag gizmo
  130818. */
  130819. export class PlaneDragGizmo extends Gizmo {
  130820. /**
  130821. * Drag behavior responsible for the gizmos dragging interactions
  130822. */
  130823. dragBehavior: PointerDragBehavior;
  130824. private _pointerObserver;
  130825. /**
  130826. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130827. */
  130828. snapDistance: number;
  130829. /**
  130830. * Event that fires each time the gizmo snaps to a new location.
  130831. * * snapDistance is the the change in distance
  130832. */
  130833. onSnapObservable: Observable<{
  130834. snapDistance: number;
  130835. }>;
  130836. private _plane;
  130837. private _coloredMaterial;
  130838. private _hoverMaterial;
  130839. private _isEnabled;
  130840. private _parent;
  130841. /** @hidden */
  130842. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130843. /** @hidden */
  130844. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130845. /**
  130846. * Creates a PlaneDragGizmo
  130847. * @param gizmoLayer The utility layer the gizmo will be added to
  130848. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130849. * @param color The color of the gizmo
  130850. */
  130851. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130852. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130853. /**
  130854. * If the gizmo is enabled
  130855. */
  130856. set isEnabled(value: boolean);
  130857. get isEnabled(): boolean;
  130858. /**
  130859. * Disposes of the gizmo
  130860. */
  130861. dispose(): void;
  130862. }
  130863. }
  130864. declare module BABYLON {
  130865. /**
  130866. * Gizmo that enables dragging a mesh along 3 axis
  130867. */
  130868. export class PositionGizmo extends Gizmo {
  130869. /**
  130870. * Internal gizmo used for interactions on the x axis
  130871. */
  130872. xGizmo: AxisDragGizmo;
  130873. /**
  130874. * Internal gizmo used for interactions on the y axis
  130875. */
  130876. yGizmo: AxisDragGizmo;
  130877. /**
  130878. * Internal gizmo used for interactions on the z axis
  130879. */
  130880. zGizmo: AxisDragGizmo;
  130881. /**
  130882. * Internal gizmo used for interactions on the yz plane
  130883. */
  130884. xPlaneGizmo: PlaneDragGizmo;
  130885. /**
  130886. * Internal gizmo used for interactions on the xz plane
  130887. */
  130888. yPlaneGizmo: PlaneDragGizmo;
  130889. /**
  130890. * Internal gizmo used for interactions on the xy plane
  130891. */
  130892. zPlaneGizmo: PlaneDragGizmo;
  130893. /**
  130894. * private variables
  130895. */
  130896. private _meshAttached;
  130897. private _nodeAttached;
  130898. private _snapDistance;
  130899. /** Fires an event when any of it's sub gizmos are dragged */
  130900. onDragStartObservable: Observable<unknown>;
  130901. /** Fires an event when any of it's sub gizmos are released from dragging */
  130902. onDragEndObservable: Observable<unknown>;
  130903. /**
  130904. * If set to true, planar drag is enabled
  130905. */
  130906. private _planarGizmoEnabled;
  130907. get attachedMesh(): Nullable<AbstractMesh>;
  130908. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130909. get attachedNode(): Nullable<Node>;
  130910. set attachedNode(node: Nullable<Node>);
  130911. /**
  130912. * True when the mouse pointer is hovering a gizmo mesh
  130913. */
  130914. get isHovered(): boolean;
  130915. /**
  130916. * Creates a PositionGizmo
  130917. * @param gizmoLayer The utility layer the gizmo will be added to
  130918. @param thickness display gizmo axis thickness
  130919. */
  130920. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130921. /**
  130922. * If the planar drag gizmo is enabled
  130923. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130924. */
  130925. set planarGizmoEnabled(value: boolean);
  130926. get planarGizmoEnabled(): boolean;
  130927. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130928. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130929. /**
  130930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130931. */
  130932. set snapDistance(value: number);
  130933. get snapDistance(): number;
  130934. /**
  130935. * Ratio for the scale of the gizmo (Default: 1)
  130936. */
  130937. set scaleRatio(value: number);
  130938. get scaleRatio(): number;
  130939. /**
  130940. * Disposes of the gizmo
  130941. */
  130942. dispose(): void;
  130943. /**
  130944. * CustomMeshes are not supported by this gizmo
  130945. * @param mesh The mesh to replace the default mesh of the gizmo
  130946. */
  130947. setCustomMesh(mesh: Mesh): void;
  130948. }
  130949. }
  130950. declare module BABYLON {
  130951. /**
  130952. * Single axis drag gizmo
  130953. */
  130954. export class AxisDragGizmo extends Gizmo {
  130955. /**
  130956. * Drag behavior responsible for the gizmos dragging interactions
  130957. */
  130958. dragBehavior: PointerDragBehavior;
  130959. private _pointerObserver;
  130960. /**
  130961. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130962. */
  130963. snapDistance: number;
  130964. /**
  130965. * Event that fires each time the gizmo snaps to a new location.
  130966. * * snapDistance is the the change in distance
  130967. */
  130968. onSnapObservable: Observable<{
  130969. snapDistance: number;
  130970. }>;
  130971. private _isEnabled;
  130972. private _parent;
  130973. private _arrow;
  130974. private _coloredMaterial;
  130975. private _hoverMaterial;
  130976. /** @hidden */
  130977. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130978. /** @hidden */
  130979. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130980. /**
  130981. * Creates an AxisDragGizmo
  130982. * @param gizmoLayer The utility layer the gizmo will be added to
  130983. * @param dragAxis The axis which the gizmo will be able to drag on
  130984. * @param color The color of the gizmo
  130985. * @param thickness display gizmo axis thickness
  130986. */
  130987. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130988. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130989. /**
  130990. * If the gizmo is enabled
  130991. */
  130992. set isEnabled(value: boolean);
  130993. get isEnabled(): boolean;
  130994. /**
  130995. * Disposes of the gizmo
  130996. */
  130997. dispose(): void;
  130998. }
  130999. }
  131000. declare module BABYLON.Debug {
  131001. /**
  131002. * The Axes viewer will show 3 axes in a specific point in space
  131003. */
  131004. export class AxesViewer {
  131005. private _xAxis;
  131006. private _yAxis;
  131007. private _zAxis;
  131008. private _scaleLinesFactor;
  131009. private _instanced;
  131010. /**
  131011. * Gets the hosting scene
  131012. */
  131013. scene: Nullable<Scene>;
  131014. /**
  131015. * Gets or sets a number used to scale line length
  131016. */
  131017. scaleLines: number;
  131018. /** Gets the node hierarchy used to render x-axis */
  131019. get xAxis(): TransformNode;
  131020. /** Gets the node hierarchy used to render y-axis */
  131021. get yAxis(): TransformNode;
  131022. /** Gets the node hierarchy used to render z-axis */
  131023. get zAxis(): TransformNode;
  131024. /**
  131025. * Creates a new AxesViewer
  131026. * @param scene defines the hosting scene
  131027. * @param scaleLines defines a number used to scale line length (1 by default)
  131028. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131029. * @param xAxis defines the node hierarchy used to render the x-axis
  131030. * @param yAxis defines the node hierarchy used to render the y-axis
  131031. * @param zAxis defines the node hierarchy used to render the z-axis
  131032. */
  131033. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131034. /**
  131035. * Force the viewer to update
  131036. * @param position defines the position of the viewer
  131037. * @param xaxis defines the x axis of the viewer
  131038. * @param yaxis defines the y axis of the viewer
  131039. * @param zaxis defines the z axis of the viewer
  131040. */
  131041. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131042. /**
  131043. * Creates an instance of this axes viewer.
  131044. * @returns a new axes viewer with instanced meshes
  131045. */
  131046. createInstance(): AxesViewer;
  131047. /** Releases resources */
  131048. dispose(): void;
  131049. private static _SetRenderingGroupId;
  131050. }
  131051. }
  131052. declare module BABYLON.Debug {
  131053. /**
  131054. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131055. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131056. */
  131057. export class BoneAxesViewer extends AxesViewer {
  131058. /**
  131059. * Gets or sets the target mesh where to display the axes viewer
  131060. */
  131061. mesh: Nullable<Mesh>;
  131062. /**
  131063. * Gets or sets the target bone where to display the axes viewer
  131064. */
  131065. bone: Nullable<Bone>;
  131066. /** Gets current position */
  131067. pos: Vector3;
  131068. /** Gets direction of X axis */
  131069. xaxis: Vector3;
  131070. /** Gets direction of Y axis */
  131071. yaxis: Vector3;
  131072. /** Gets direction of Z axis */
  131073. zaxis: Vector3;
  131074. /**
  131075. * Creates a new BoneAxesViewer
  131076. * @param scene defines the hosting scene
  131077. * @param bone defines the target bone
  131078. * @param mesh defines the target mesh
  131079. * @param scaleLines defines a scaling factor for line length (1 by default)
  131080. */
  131081. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131082. /**
  131083. * Force the viewer to update
  131084. */
  131085. update(): void;
  131086. /** Releases resources */
  131087. dispose(): void;
  131088. }
  131089. }
  131090. declare module BABYLON {
  131091. /**
  131092. * Interface used to define scene explorer extensibility option
  131093. */
  131094. export interface IExplorerExtensibilityOption {
  131095. /**
  131096. * Define the option label
  131097. */
  131098. label: string;
  131099. /**
  131100. * Defines the action to execute on click
  131101. */
  131102. action: (entity: any) => void;
  131103. }
  131104. /**
  131105. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131106. */
  131107. export interface IExplorerExtensibilityGroup {
  131108. /**
  131109. * Defines a predicate to test if a given type mut be extended
  131110. */
  131111. predicate: (entity: any) => boolean;
  131112. /**
  131113. * Gets the list of options added to a type
  131114. */
  131115. entries: IExplorerExtensibilityOption[];
  131116. }
  131117. /**
  131118. * Interface used to define the options to use to create the Inspector
  131119. */
  131120. export interface IInspectorOptions {
  131121. /**
  131122. * Display in overlay mode (default: false)
  131123. */
  131124. overlay?: boolean;
  131125. /**
  131126. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131127. */
  131128. globalRoot?: HTMLElement;
  131129. /**
  131130. * Display the Scene explorer
  131131. */
  131132. showExplorer?: boolean;
  131133. /**
  131134. * Display the property inspector
  131135. */
  131136. showInspector?: boolean;
  131137. /**
  131138. * Display in embed mode (both panes on the right)
  131139. */
  131140. embedMode?: boolean;
  131141. /**
  131142. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131143. */
  131144. handleResize?: boolean;
  131145. /**
  131146. * Allow the panes to popup (default: true)
  131147. */
  131148. enablePopup?: boolean;
  131149. /**
  131150. * Allow the panes to be closed by users (default: true)
  131151. */
  131152. enableClose?: boolean;
  131153. /**
  131154. * Optional list of extensibility entries
  131155. */
  131156. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131157. /**
  131158. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131159. */
  131160. inspectorURL?: string;
  131161. /**
  131162. * Optional initial tab (default to DebugLayerTab.Properties)
  131163. */
  131164. initialTab?: DebugLayerTab;
  131165. }
  131166. interface Scene {
  131167. /**
  131168. * @hidden
  131169. * Backing field
  131170. */
  131171. _debugLayer: DebugLayer;
  131172. /**
  131173. * Gets the debug layer (aka Inspector) associated with the scene
  131174. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131175. */
  131176. debugLayer: DebugLayer;
  131177. }
  131178. /**
  131179. * Enum of inspector action tab
  131180. */
  131181. export enum DebugLayerTab {
  131182. /**
  131183. * Properties tag (default)
  131184. */
  131185. Properties = 0,
  131186. /**
  131187. * Debug tab
  131188. */
  131189. Debug = 1,
  131190. /**
  131191. * Statistics tab
  131192. */
  131193. Statistics = 2,
  131194. /**
  131195. * Tools tab
  131196. */
  131197. Tools = 3,
  131198. /**
  131199. * Settings tab
  131200. */
  131201. Settings = 4
  131202. }
  131203. /**
  131204. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131205. * what is happening in your scene
  131206. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131207. */
  131208. export class DebugLayer {
  131209. /**
  131210. * Define the url to get the inspector script from.
  131211. * By default it uses the babylonjs CDN.
  131212. * @ignoreNaming
  131213. */
  131214. static InspectorURL: string;
  131215. private _scene;
  131216. private BJSINSPECTOR;
  131217. private _onPropertyChangedObservable?;
  131218. /**
  131219. * Observable triggered when a property is changed through the inspector.
  131220. */
  131221. get onPropertyChangedObservable(): any;
  131222. /**
  131223. * Instantiates a new debug layer.
  131224. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131225. * what is happening in your scene
  131226. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131227. * @param scene Defines the scene to inspect
  131228. */
  131229. constructor(scene: Scene);
  131230. /** Creates the inspector window. */
  131231. private _createInspector;
  131232. /**
  131233. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131234. * @param entity defines the entity to select
  131235. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131236. */
  131237. select(entity: any, lineContainerTitles?: string | string[]): void;
  131238. /** Get the inspector from bundle or global */
  131239. private _getGlobalInspector;
  131240. /**
  131241. * Get if the inspector is visible or not.
  131242. * @returns true if visible otherwise, false
  131243. */
  131244. isVisible(): boolean;
  131245. /**
  131246. * Hide the inspector and close its window.
  131247. */
  131248. hide(): void;
  131249. /**
  131250. * Update the scene in the inspector
  131251. */
  131252. setAsActiveScene(): void;
  131253. /**
  131254. * Launch the debugLayer.
  131255. * @param config Define the configuration of the inspector
  131256. * @return a promise fulfilled when the debug layer is visible
  131257. */
  131258. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131259. }
  131260. }
  131261. declare module BABYLON {
  131262. /**
  131263. * Class containing static functions to help procedurally build meshes
  131264. */
  131265. export class BoxBuilder {
  131266. /**
  131267. * Creates a box mesh
  131268. * * The parameter `size` sets the size (float) of each box side (default 1)
  131269. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131270. * * 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)
  131271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131275. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131276. * @param name defines the name of the mesh
  131277. * @param options defines the options used to create the mesh
  131278. * @param scene defines the hosting scene
  131279. * @returns the box mesh
  131280. */
  131281. static CreateBox(name: string, options: {
  131282. size?: number;
  131283. width?: number;
  131284. height?: number;
  131285. depth?: number;
  131286. faceUV?: Vector4[];
  131287. faceColors?: Color4[];
  131288. sideOrientation?: number;
  131289. frontUVs?: Vector4;
  131290. backUVs?: Vector4;
  131291. wrap?: boolean;
  131292. topBaseAt?: number;
  131293. bottomBaseAt?: number;
  131294. updatable?: boolean;
  131295. }, scene?: Nullable<Scene>): Mesh;
  131296. }
  131297. }
  131298. declare module BABYLON.Debug {
  131299. /**
  131300. * Used to show the physics impostor around the specific mesh
  131301. */
  131302. export class PhysicsViewer {
  131303. /** @hidden */
  131304. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131305. /** @hidden */
  131306. protected _meshes: Array<Nullable<AbstractMesh>>;
  131307. /** @hidden */
  131308. protected _scene: Nullable<Scene>;
  131309. /** @hidden */
  131310. protected _numMeshes: number;
  131311. /** @hidden */
  131312. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131313. private _renderFunction;
  131314. private _utilityLayer;
  131315. private _debugBoxMesh;
  131316. private _debugSphereMesh;
  131317. private _debugCylinderMesh;
  131318. private _debugMaterial;
  131319. private _debugMeshMeshes;
  131320. /**
  131321. * Creates a new PhysicsViewer
  131322. * @param scene defines the hosting scene
  131323. */
  131324. constructor(scene: Scene);
  131325. /** @hidden */
  131326. protected _updateDebugMeshes(): void;
  131327. /**
  131328. * Renders a specified physic impostor
  131329. * @param impostor defines the impostor to render
  131330. * @param targetMesh defines the mesh represented by the impostor
  131331. * @returns the new debug mesh used to render the impostor
  131332. */
  131333. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131334. /**
  131335. * Hides a specified physic impostor
  131336. * @param impostor defines the impostor to hide
  131337. */
  131338. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131339. private _getDebugMaterial;
  131340. private _getDebugBoxMesh;
  131341. private _getDebugSphereMesh;
  131342. private _getDebugCylinderMesh;
  131343. private _getDebugMeshMesh;
  131344. private _getDebugMesh;
  131345. /** Releases all resources */
  131346. dispose(): void;
  131347. }
  131348. }
  131349. declare module BABYLON {
  131350. /**
  131351. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131352. * in order to better appreciate the issue one might have.
  131353. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131354. */
  131355. export class RayHelper {
  131356. /**
  131357. * Defines the ray we are currently tryin to visualize.
  131358. */
  131359. ray: Nullable<Ray>;
  131360. private _renderPoints;
  131361. private _renderLine;
  131362. private _renderFunction;
  131363. private _scene;
  131364. private _onAfterRenderObserver;
  131365. private _onAfterStepObserver;
  131366. private _attachedToMesh;
  131367. private _meshSpaceDirection;
  131368. private _meshSpaceOrigin;
  131369. /**
  131370. * Helper function to create a colored helper in a scene in one line.
  131371. * @param ray Defines the ray we are currently tryin to visualize
  131372. * @param scene Defines the scene the ray is used in
  131373. * @param color Defines the color we want to see the ray in
  131374. * @returns The newly created ray helper.
  131375. */
  131376. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131377. /**
  131378. * Instantiate a new ray helper.
  131379. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131380. * in order to better appreciate the issue one might have.
  131381. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131382. * @param ray Defines the ray we are currently tryin to visualize
  131383. */
  131384. constructor(ray: Ray);
  131385. /**
  131386. * Shows the ray we are willing to debug.
  131387. * @param scene Defines the scene the ray needs to be rendered in
  131388. * @param color Defines the color the ray needs to be rendered in
  131389. */
  131390. show(scene: Scene, color?: Color3): void;
  131391. /**
  131392. * Hides the ray we are debugging.
  131393. */
  131394. hide(): void;
  131395. private _render;
  131396. /**
  131397. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131398. * @param mesh Defines the mesh we want the helper attached to
  131399. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131400. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131401. * @param length Defines the length of the ray
  131402. */
  131403. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131404. /**
  131405. * Detach the ray helper from the mesh it has previously been attached to.
  131406. */
  131407. detachFromMesh(): void;
  131408. private _updateToMesh;
  131409. /**
  131410. * Dispose the helper and release its associated resources.
  131411. */
  131412. dispose(): void;
  131413. }
  131414. }
  131415. declare module BABYLON {
  131416. /**
  131417. * Defines the options associated with the creation of a SkeletonViewer.
  131418. */
  131419. export interface ISkeletonViewerOptions {
  131420. /** Should the system pause animations before building the Viewer? */
  131421. pauseAnimations: boolean;
  131422. /** Should the system return the skeleton to rest before building? */
  131423. returnToRest: boolean;
  131424. /** public Display Mode of the Viewer */
  131425. displayMode: number;
  131426. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131427. displayOptions: ISkeletonViewerDisplayOptions;
  131428. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131429. computeBonesUsingShaders: boolean;
  131430. /** Flag ignore non weighted bones */
  131431. useAllBones: boolean;
  131432. }
  131433. /**
  131434. * Defines how to display the various bone meshes for the viewer.
  131435. */
  131436. export interface ISkeletonViewerDisplayOptions {
  131437. /** How far down to start tapering the bone spurs */
  131438. midStep?: number;
  131439. /** How big is the midStep? */
  131440. midStepFactor?: number;
  131441. /** Base for the Sphere Size */
  131442. sphereBaseSize?: number;
  131443. /** The ratio of the sphere to the longest bone in units */
  131444. sphereScaleUnit?: number;
  131445. /** Ratio for the Sphere Size */
  131446. sphereFactor?: number;
  131447. /** Whether to show local axes or not */
  131448. showLocalAxes?: boolean;
  131449. /** Length of each local axis */
  131450. localAxesSize?: number;
  131451. }
  131452. /**
  131453. * Defines the constructor options for the BoneWeight Shader.
  131454. */
  131455. export interface IBoneWeightShaderOptions {
  131456. /** Skeleton to Map */
  131457. skeleton: Skeleton;
  131458. /** Colors for Uninfluenced bones */
  131459. colorBase?: Color3;
  131460. /** Colors for 0.0-0.25 Weight bones */
  131461. colorZero?: Color3;
  131462. /** Color for 0.25-0.5 Weight Influence */
  131463. colorQuarter?: Color3;
  131464. /** Color for 0.5-0.75 Weight Influence */
  131465. colorHalf?: Color3;
  131466. /** Color for 0.75-1 Weight Influence */
  131467. colorFull?: Color3;
  131468. /** Color for Zero Weight Influence */
  131469. targetBoneIndex?: number;
  131470. }
  131471. /**
  131472. * Simple structure of the gradient steps for the Color Map.
  131473. */
  131474. export interface ISkeletonMapShaderColorMapKnot {
  131475. /** Color of the Knot */
  131476. color: Color3;
  131477. /** Location of the Knot */
  131478. location: number;
  131479. }
  131480. /**
  131481. * Defines the constructor options for the SkeletonMap Shader.
  131482. */
  131483. export interface ISkeletonMapShaderOptions {
  131484. /** Skeleton to Map */
  131485. skeleton: Skeleton;
  131486. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131487. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131488. }
  131489. }
  131490. declare module BABYLON {
  131491. /**
  131492. * Class containing static functions to help procedurally build meshes
  131493. */
  131494. export class RibbonBuilder {
  131495. /**
  131496. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131497. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131498. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131499. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131500. * * 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
  131501. * * 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
  131502. * * 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
  131503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131506. * * 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
  131507. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131508. * * 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
  131509. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131511. * @param name defines the name of the mesh
  131512. * @param options defines the options used to create the mesh
  131513. * @param scene defines the hosting scene
  131514. * @returns the ribbon mesh
  131515. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131517. */
  131518. static CreateRibbon(name: string, options: {
  131519. pathArray: Vector3[][];
  131520. closeArray?: boolean;
  131521. closePath?: boolean;
  131522. offset?: number;
  131523. updatable?: boolean;
  131524. sideOrientation?: number;
  131525. frontUVs?: Vector4;
  131526. backUVs?: Vector4;
  131527. instance?: Mesh;
  131528. invertUV?: boolean;
  131529. uvs?: Vector2[];
  131530. colors?: Color4[];
  131531. }, scene?: Nullable<Scene>): Mesh;
  131532. }
  131533. }
  131534. declare module BABYLON {
  131535. /**
  131536. * Class containing static functions to help procedurally build meshes
  131537. */
  131538. export class ShapeBuilder {
  131539. /**
  131540. * 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.
  131541. * * 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.
  131542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131543. * * 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.
  131544. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131545. * * 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
  131546. * * 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
  131547. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131552. * @param name defines the name of the mesh
  131553. * @param options defines the options used to create the mesh
  131554. * @param scene defines the hosting scene
  131555. * @returns the extruded shape mesh
  131556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131558. */
  131559. static ExtrudeShape(name: string, options: {
  131560. shape: Vector3[];
  131561. path: Vector3[];
  131562. scale?: number;
  131563. rotation?: number;
  131564. cap?: number;
  131565. updatable?: boolean;
  131566. sideOrientation?: number;
  131567. frontUVs?: Vector4;
  131568. backUVs?: Vector4;
  131569. instance?: Mesh;
  131570. invertUV?: boolean;
  131571. }, scene?: Nullable<Scene>): Mesh;
  131572. /**
  131573. * Creates an custom extruded shape mesh.
  131574. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131575. * * 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.
  131576. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131577. * * 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
  131578. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131579. * * 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
  131580. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131581. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131582. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131583. * * 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
  131584. * * 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
  131585. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131590. * @param name defines the name of the mesh
  131591. * @param options defines the options used to create the mesh
  131592. * @param scene defines the hosting scene
  131593. * @returns the custom extruded shape mesh
  131594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131597. */
  131598. static ExtrudeShapeCustom(name: string, options: {
  131599. shape: Vector3[];
  131600. path: Vector3[];
  131601. scaleFunction?: any;
  131602. rotationFunction?: any;
  131603. ribbonCloseArray?: boolean;
  131604. ribbonClosePath?: boolean;
  131605. cap?: number;
  131606. updatable?: boolean;
  131607. sideOrientation?: number;
  131608. frontUVs?: Vector4;
  131609. backUVs?: Vector4;
  131610. instance?: Mesh;
  131611. invertUV?: boolean;
  131612. }, scene?: Nullable<Scene>): Mesh;
  131613. private static _ExtrudeShapeGeneric;
  131614. }
  131615. }
  131616. declare module BABYLON.Debug {
  131617. /**
  131618. * Class used to render a debug view of a given skeleton
  131619. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131620. */
  131621. export class SkeletonViewer {
  131622. /** defines the skeleton to render */
  131623. skeleton: Skeleton;
  131624. /** defines the mesh attached to the skeleton */
  131625. mesh: AbstractMesh;
  131626. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131627. autoUpdateBonesMatrices: boolean;
  131628. /** defines the rendering group id to use with the viewer */
  131629. renderingGroupId: number;
  131630. /** is the options for the viewer */
  131631. options: Partial<ISkeletonViewerOptions>;
  131632. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131633. static readonly DISPLAY_LINES: number;
  131634. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131635. static readonly DISPLAY_SPHERES: number;
  131636. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131637. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131638. /** public static method to create a BoneWeight Shader
  131639. * @param options The constructor options
  131640. * @param scene The scene that the shader is scoped to
  131641. * @returns The created ShaderMaterial
  131642. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131643. */
  131644. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131645. /** public static method to create a BoneWeight Shader
  131646. * @param options The constructor options
  131647. * @param scene The scene that the shader is scoped to
  131648. * @returns The created ShaderMaterial
  131649. */
  131650. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131651. /** private static method to create a BoneWeight Shader
  131652. * @param size The size of the buffer to create (usually the bone count)
  131653. * @param colorMap The gradient data to generate
  131654. * @param scene The scene that the shader is scoped to
  131655. * @returns an Array of floats from the color gradient values
  131656. */
  131657. private static _CreateBoneMapColorBuffer;
  131658. /** If SkeletonViewer scene scope. */
  131659. private _scene;
  131660. /** Gets or sets the color used to render the skeleton */
  131661. color: Color3;
  131662. /** Array of the points of the skeleton fo the line view. */
  131663. private _debugLines;
  131664. /** The SkeletonViewers Mesh. */
  131665. private _debugMesh;
  131666. /** The local axes Meshes. */
  131667. private _localAxes;
  131668. /** If SkeletonViewer is enabled. */
  131669. private _isEnabled;
  131670. /** If SkeletonViewer is ready. */
  131671. private _ready;
  131672. /** SkeletonViewer render observable. */
  131673. private _obs;
  131674. /** The Utility Layer to render the gizmos in. */
  131675. private _utilityLayer;
  131676. private _boneIndices;
  131677. /** Gets the Scene. */
  131678. get scene(): Scene;
  131679. /** Gets the utilityLayer. */
  131680. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131681. /** Checks Ready Status. */
  131682. get isReady(): Boolean;
  131683. /** Sets Ready Status. */
  131684. set ready(value: boolean);
  131685. /** Gets the debugMesh */
  131686. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131687. /** Sets the debugMesh */
  131688. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131689. /** Gets the displayMode */
  131690. get displayMode(): number;
  131691. /** Sets the displayMode */
  131692. set displayMode(value: number);
  131693. /**
  131694. * Creates a new SkeletonViewer
  131695. * @param skeleton defines the skeleton to render
  131696. * @param mesh defines the mesh attached to the skeleton
  131697. * @param scene defines the hosting scene
  131698. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131699. * @param renderingGroupId defines the rendering group id to use with the viewer
  131700. * @param options All of the extra constructor options for the SkeletonViewer
  131701. */
  131702. constructor(
  131703. /** defines the skeleton to render */
  131704. skeleton: Skeleton,
  131705. /** defines the mesh attached to the skeleton */
  131706. mesh: AbstractMesh,
  131707. /** The Scene scope*/
  131708. scene: Scene,
  131709. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131710. autoUpdateBonesMatrices?: boolean,
  131711. /** defines the rendering group id to use with the viewer */
  131712. renderingGroupId?: number,
  131713. /** is the options for the viewer */
  131714. options?: Partial<ISkeletonViewerOptions>);
  131715. /** The Dynamic bindings for the update functions */
  131716. private _bindObs;
  131717. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131718. update(): void;
  131719. /** Gets or sets a boolean indicating if the viewer is enabled */
  131720. set isEnabled(value: boolean);
  131721. get isEnabled(): boolean;
  131722. private _getBonePosition;
  131723. private _getLinesForBonesWithLength;
  131724. private _getLinesForBonesNoLength;
  131725. /** function to revert the mesh and scene back to the initial state. */
  131726. private _revert;
  131727. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  131728. private _getAbsoluteBindPoseToRef;
  131729. /** function to build and bind sphere joint points and spur bone representations. */
  131730. private _buildSpheresAndSpurs;
  131731. private _buildLocalAxes;
  131732. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131733. private _displayLinesUpdate;
  131734. /** Changes the displayMode of the skeleton viewer
  131735. * @param mode The displayMode numerical value
  131736. */
  131737. changeDisplayMode(mode: number): void;
  131738. /** Sets a display option of the skeleton viewer
  131739. *
  131740. * | Option | Type | Default | Description |
  131741. * | --------------- | ------- | ------- | ----------- |
  131742. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131743. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131744. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131745. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131746. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131747. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131748. *
  131749. * @param option String of the option name
  131750. * @param value The numerical option value
  131751. */
  131752. changeDisplayOptions(option: string, value: number): void;
  131753. /** Release associated resources */
  131754. dispose(): void;
  131755. }
  131756. }
  131757. declare module BABYLON {
  131758. /**
  131759. * Enum for Device Types
  131760. */
  131761. export enum DeviceType {
  131762. /** Generic */
  131763. Generic = 0,
  131764. /** Keyboard */
  131765. Keyboard = 1,
  131766. /** Mouse */
  131767. Mouse = 2,
  131768. /** Touch Pointers */
  131769. Touch = 3,
  131770. /** PS4 Dual Shock */
  131771. DualShock = 4,
  131772. /** Xbox */
  131773. Xbox = 5,
  131774. /** Switch Controller */
  131775. Switch = 6
  131776. }
  131777. /**
  131778. * Enum for All Pointers (Touch/Mouse)
  131779. */
  131780. export enum PointerInput {
  131781. /** Horizontal Axis */
  131782. Horizontal = 0,
  131783. /** Vertical Axis */
  131784. Vertical = 1,
  131785. /** Left Click or Touch */
  131786. LeftClick = 2,
  131787. /** Middle Click */
  131788. MiddleClick = 3,
  131789. /** Right Click */
  131790. RightClick = 4,
  131791. /** Browser Back */
  131792. BrowserBack = 5,
  131793. /** Browser Forward */
  131794. BrowserForward = 6
  131795. }
  131796. /**
  131797. * Enum for Dual Shock Gamepad
  131798. */
  131799. export enum DualShockInput {
  131800. /** Cross */
  131801. Cross = 0,
  131802. /** Circle */
  131803. Circle = 1,
  131804. /** Square */
  131805. Square = 2,
  131806. /** Triangle */
  131807. Triangle = 3,
  131808. /** L1 */
  131809. L1 = 4,
  131810. /** R1 */
  131811. R1 = 5,
  131812. /** L2 */
  131813. L2 = 6,
  131814. /** R2 */
  131815. R2 = 7,
  131816. /** Share */
  131817. Share = 8,
  131818. /** Options */
  131819. Options = 9,
  131820. /** L3 */
  131821. L3 = 10,
  131822. /** R3 */
  131823. R3 = 11,
  131824. /** DPadUp */
  131825. DPadUp = 12,
  131826. /** DPadDown */
  131827. DPadDown = 13,
  131828. /** DPadLeft */
  131829. DPadLeft = 14,
  131830. /** DRight */
  131831. DPadRight = 15,
  131832. /** Home */
  131833. Home = 16,
  131834. /** TouchPad */
  131835. TouchPad = 17,
  131836. /** LStickXAxis */
  131837. LStickXAxis = 18,
  131838. /** LStickYAxis */
  131839. LStickYAxis = 19,
  131840. /** RStickXAxis */
  131841. RStickXAxis = 20,
  131842. /** RStickYAxis */
  131843. RStickYAxis = 21
  131844. }
  131845. /**
  131846. * Enum for Xbox Gamepad
  131847. */
  131848. export enum XboxInput {
  131849. /** A */
  131850. A = 0,
  131851. /** B */
  131852. B = 1,
  131853. /** X */
  131854. X = 2,
  131855. /** Y */
  131856. Y = 3,
  131857. /** LB */
  131858. LB = 4,
  131859. /** RB */
  131860. RB = 5,
  131861. /** LT */
  131862. LT = 6,
  131863. /** RT */
  131864. RT = 7,
  131865. /** Back */
  131866. Back = 8,
  131867. /** Start */
  131868. Start = 9,
  131869. /** LS */
  131870. LS = 10,
  131871. /** RS */
  131872. RS = 11,
  131873. /** DPadUp */
  131874. DPadUp = 12,
  131875. /** DPadDown */
  131876. DPadDown = 13,
  131877. /** DPadLeft */
  131878. DPadLeft = 14,
  131879. /** DRight */
  131880. DPadRight = 15,
  131881. /** Home */
  131882. Home = 16,
  131883. /** LStickXAxis */
  131884. LStickXAxis = 17,
  131885. /** LStickYAxis */
  131886. LStickYAxis = 18,
  131887. /** RStickXAxis */
  131888. RStickXAxis = 19,
  131889. /** RStickYAxis */
  131890. RStickYAxis = 20
  131891. }
  131892. /**
  131893. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131894. */
  131895. export enum SwitchInput {
  131896. /** B */
  131897. B = 0,
  131898. /** A */
  131899. A = 1,
  131900. /** Y */
  131901. Y = 2,
  131902. /** X */
  131903. X = 3,
  131904. /** L */
  131905. L = 4,
  131906. /** R */
  131907. R = 5,
  131908. /** ZL */
  131909. ZL = 6,
  131910. /** ZR */
  131911. ZR = 7,
  131912. /** Minus */
  131913. Minus = 8,
  131914. /** Plus */
  131915. Plus = 9,
  131916. /** LS */
  131917. LS = 10,
  131918. /** RS */
  131919. RS = 11,
  131920. /** DPadUp */
  131921. DPadUp = 12,
  131922. /** DPadDown */
  131923. DPadDown = 13,
  131924. /** DPadLeft */
  131925. DPadLeft = 14,
  131926. /** DRight */
  131927. DPadRight = 15,
  131928. /** Home */
  131929. Home = 16,
  131930. /** Capture */
  131931. Capture = 17,
  131932. /** LStickXAxis */
  131933. LStickXAxis = 18,
  131934. /** LStickYAxis */
  131935. LStickYAxis = 19,
  131936. /** RStickXAxis */
  131937. RStickXAxis = 20,
  131938. /** RStickYAxis */
  131939. RStickYAxis = 21
  131940. }
  131941. }
  131942. declare module BABYLON {
  131943. /**
  131944. * This class will take all inputs from Keyboard, Pointer, and
  131945. * any Gamepads and provide a polling system that all devices
  131946. * will use. This class assumes that there will only be one
  131947. * pointer device and one keyboard.
  131948. */
  131949. export class DeviceInputSystem implements IDisposable {
  131950. /**
  131951. * Callback to be triggered when a device is connected
  131952. */
  131953. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131954. /**
  131955. * Callback to be triggered when a device is disconnected
  131956. */
  131957. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131958. /**
  131959. * Callback to be triggered when event driven input is updated
  131960. */
  131961. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131962. private _inputs;
  131963. private _gamepads;
  131964. private _keyboardActive;
  131965. private _pointerActive;
  131966. private _elementToAttachTo;
  131967. private _keyboardDownEvent;
  131968. private _keyboardUpEvent;
  131969. private _pointerMoveEvent;
  131970. private _pointerDownEvent;
  131971. private _pointerUpEvent;
  131972. private _gamepadConnectedEvent;
  131973. private _gamepadDisconnectedEvent;
  131974. private static _MAX_KEYCODES;
  131975. private static _MAX_POINTER_INPUTS;
  131976. private constructor();
  131977. /**
  131978. * Creates a new DeviceInputSystem instance
  131979. * @param engine Engine to pull input element from
  131980. * @returns The new instance
  131981. */
  131982. static Create(engine: Engine): DeviceInputSystem;
  131983. /**
  131984. * Checks for current device input value, given an id and input index
  131985. * @param deviceName Id of connected device
  131986. * @param inputIndex Index of device input
  131987. * @returns Current value of input
  131988. */
  131989. /**
  131990. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131991. * @param deviceType Enum specifiying device type
  131992. * @param deviceSlot "Slot" or index that device is referenced in
  131993. * @param inputIndex Id of input to be checked
  131994. * @returns Current value of input
  131995. */
  131996. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131997. /**
  131998. * Dispose of all the eventlisteners
  131999. */
  132000. dispose(): void;
  132001. /**
  132002. * Add device and inputs to device array
  132003. * @param deviceType Enum specifiying device type
  132004. * @param deviceSlot "Slot" or index that device is referenced in
  132005. * @param numberOfInputs Number of input entries to create for given device
  132006. */
  132007. private _registerDevice;
  132008. /**
  132009. * Given a specific device name, remove that device from the device map
  132010. * @param deviceType Enum specifiying device type
  132011. * @param deviceSlot "Slot" or index that device is referenced in
  132012. */
  132013. private _unregisterDevice;
  132014. /**
  132015. * Handle all actions that come from keyboard interaction
  132016. */
  132017. private _handleKeyActions;
  132018. /**
  132019. * Handle all actions that come from pointer interaction
  132020. */
  132021. private _handlePointerActions;
  132022. /**
  132023. * Handle all actions that come from gamepad interaction
  132024. */
  132025. private _handleGamepadActions;
  132026. /**
  132027. * Update all non-event based devices with each frame
  132028. * @param deviceType Enum specifiying device type
  132029. * @param deviceSlot "Slot" or index that device is referenced in
  132030. * @param inputIndex Id of input to be checked
  132031. */
  132032. private _updateDevice;
  132033. /**
  132034. * Gets DeviceType from the device name
  132035. * @param deviceName Name of Device from DeviceInputSystem
  132036. * @returns DeviceType enum value
  132037. */
  132038. private _getGamepadDeviceType;
  132039. }
  132040. }
  132041. declare module BABYLON {
  132042. /**
  132043. * Type to handle enforcement of inputs
  132044. */
  132045. 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;
  132046. }
  132047. declare module BABYLON {
  132048. /**
  132049. * Class that handles all input for a specific device
  132050. */
  132051. export class DeviceSource<T extends DeviceType> {
  132052. /** Type of device */
  132053. readonly deviceType: DeviceType;
  132054. /** "Slot" or index that device is referenced in */
  132055. readonly deviceSlot: number;
  132056. /**
  132057. * Observable to handle device input changes per device
  132058. */
  132059. readonly onInputChangedObservable: Observable<{
  132060. inputIndex: DeviceInput<T>;
  132061. previousState: Nullable<number>;
  132062. currentState: Nullable<number>;
  132063. }>;
  132064. private readonly _deviceInputSystem;
  132065. /**
  132066. * Default Constructor
  132067. * @param deviceInputSystem Reference to DeviceInputSystem
  132068. * @param deviceType Type of device
  132069. * @param deviceSlot "Slot" or index that device is referenced in
  132070. */
  132071. constructor(deviceInputSystem: DeviceInputSystem,
  132072. /** Type of device */
  132073. deviceType: DeviceType,
  132074. /** "Slot" or index that device is referenced in */
  132075. deviceSlot?: number);
  132076. /**
  132077. * Get input for specific input
  132078. * @param inputIndex index of specific input on device
  132079. * @returns Input value from DeviceInputSystem
  132080. */
  132081. getInput(inputIndex: DeviceInput<T>): number;
  132082. }
  132083. /**
  132084. * Class to keep track of devices
  132085. */
  132086. export class DeviceSourceManager implements IDisposable {
  132087. /**
  132088. * Observable to be triggered when before a device is connected
  132089. */
  132090. readonly onBeforeDeviceConnectedObservable: Observable<{
  132091. deviceType: DeviceType;
  132092. deviceSlot: number;
  132093. }>;
  132094. /**
  132095. * Observable to be triggered when before a device is disconnected
  132096. */
  132097. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132098. deviceType: DeviceType;
  132099. deviceSlot: number;
  132100. }>;
  132101. /**
  132102. * Observable to be triggered when after a device is connected
  132103. */
  132104. readonly onAfterDeviceConnectedObservable: Observable<{
  132105. deviceType: DeviceType;
  132106. deviceSlot: number;
  132107. }>;
  132108. /**
  132109. * Observable to be triggered when after a device is disconnected
  132110. */
  132111. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132112. deviceType: DeviceType;
  132113. deviceSlot: number;
  132114. }>;
  132115. private readonly _devices;
  132116. private readonly _firstDevice;
  132117. private readonly _deviceInputSystem;
  132118. /**
  132119. * Default Constructor
  132120. * @param engine engine to pull input element from
  132121. */
  132122. constructor(engine: Engine);
  132123. /**
  132124. * Gets a DeviceSource, given a type and slot
  132125. * @param deviceType Enum specifying device type
  132126. * @param deviceSlot "Slot" or index that device is referenced in
  132127. * @returns DeviceSource object
  132128. */
  132129. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132130. /**
  132131. * Gets an array of DeviceSource objects for a given device type
  132132. * @param deviceType Enum specifying device type
  132133. * @returns Array of DeviceSource objects
  132134. */
  132135. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132136. /**
  132137. * Dispose of DeviceInputSystem and other parts
  132138. */
  132139. dispose(): void;
  132140. /**
  132141. * Function to add device name to device list
  132142. * @param deviceType Enum specifying device type
  132143. * @param deviceSlot "Slot" or index that device is referenced in
  132144. */
  132145. private _addDevice;
  132146. /**
  132147. * Function to remove device name to device list
  132148. * @param deviceType Enum specifying device type
  132149. * @param deviceSlot "Slot" or index that device is referenced in
  132150. */
  132151. private _removeDevice;
  132152. /**
  132153. * Updates array storing first connected device of each type
  132154. * @param type Type of Device
  132155. */
  132156. private _updateFirstDevices;
  132157. }
  132158. }
  132159. declare module BABYLON {
  132160. /**
  132161. * Options to create the null engine
  132162. */
  132163. export class NullEngineOptions {
  132164. /**
  132165. * Render width (Default: 512)
  132166. */
  132167. renderWidth: number;
  132168. /**
  132169. * Render height (Default: 256)
  132170. */
  132171. renderHeight: number;
  132172. /**
  132173. * Texture size (Default: 512)
  132174. */
  132175. textureSize: number;
  132176. /**
  132177. * If delta time between frames should be constant
  132178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132179. */
  132180. deterministicLockstep: boolean;
  132181. /**
  132182. * Maximum about of steps between frames (Default: 4)
  132183. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132184. */
  132185. lockstepMaxSteps: number;
  132186. /**
  132187. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132188. */
  132189. useHighPrecisionMatrix?: boolean;
  132190. }
  132191. /**
  132192. * The null engine class provides support for headless version of babylon.js.
  132193. * This can be used in server side scenario or for testing purposes
  132194. */
  132195. export class NullEngine extends Engine {
  132196. private _options;
  132197. /**
  132198. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132200. * @returns true if engine is in deterministic lock step mode
  132201. */
  132202. isDeterministicLockStep(): boolean;
  132203. /**
  132204. * Gets the max steps when engine is running in deterministic lock step
  132205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132206. * @returns the max steps
  132207. */
  132208. getLockstepMaxSteps(): number;
  132209. /**
  132210. * Gets the current hardware scaling level.
  132211. * By default the hardware scaling level is computed from the window device ratio.
  132212. * 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.
  132213. * @returns a number indicating the current hardware scaling level
  132214. */
  132215. getHardwareScalingLevel(): number;
  132216. constructor(options?: NullEngineOptions);
  132217. /**
  132218. * Creates a vertex buffer
  132219. * @param vertices the data for the vertex buffer
  132220. * @returns the new WebGL static buffer
  132221. */
  132222. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132223. /**
  132224. * Creates a new index buffer
  132225. * @param indices defines the content of the index buffer
  132226. * @param updatable defines if the index buffer must be updatable
  132227. * @returns a new webGL buffer
  132228. */
  132229. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132230. /**
  132231. * Clear the current render buffer or the current render target (if any is set up)
  132232. * @param color defines the color to use
  132233. * @param backBuffer defines if the back buffer must be cleared
  132234. * @param depth defines if the depth buffer must be cleared
  132235. * @param stencil defines if the stencil buffer must be cleared
  132236. */
  132237. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132238. /**
  132239. * Gets the current render width
  132240. * @param useScreen defines if screen size must be used (or the current render target if any)
  132241. * @returns a number defining the current render width
  132242. */
  132243. getRenderWidth(useScreen?: boolean): number;
  132244. /**
  132245. * Gets the current render height
  132246. * @param useScreen defines if screen size must be used (or the current render target if any)
  132247. * @returns a number defining the current render height
  132248. */
  132249. getRenderHeight(useScreen?: boolean): number;
  132250. /**
  132251. * Set the WebGL's viewport
  132252. * @param viewport defines the viewport element to be used
  132253. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132254. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132255. */
  132256. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132257. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132258. /**
  132259. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132260. * @param pipelineContext defines the pipeline context to use
  132261. * @param uniformsNames defines the list of uniform names
  132262. * @returns an array of webGL uniform locations
  132263. */
  132264. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132265. /**
  132266. * Gets the lsit of active attributes for a given webGL program
  132267. * @param pipelineContext defines the pipeline context to use
  132268. * @param attributesNames defines the list of attribute names to get
  132269. * @returns an array of indices indicating the offset of each attribute
  132270. */
  132271. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132272. /**
  132273. * Binds an effect to the webGL context
  132274. * @param effect defines the effect to bind
  132275. */
  132276. bindSamplers(effect: Effect): void;
  132277. /**
  132278. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132279. * @param effect defines the effect to activate
  132280. */
  132281. enableEffect(effect: Effect): void;
  132282. /**
  132283. * Set various states to the webGL context
  132284. * @param culling defines backface culling state
  132285. * @param zOffset defines the value to apply to zOffset (0 by default)
  132286. * @param force defines if states must be applied even if cache is up to date
  132287. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132288. */
  132289. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132290. /**
  132291. * Set the value of an uniform to an array of int32
  132292. * @param uniform defines the webGL uniform location where to store the value
  132293. * @param array defines the array of int32 to store
  132294. * @returns true if value was set
  132295. */
  132296. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132297. /**
  132298. * Set the value of an uniform to an array of int32 (stored as vec2)
  132299. * @param uniform defines the webGL uniform location where to store the value
  132300. * @param array defines the array of int32 to store
  132301. * @returns true if value was set
  132302. */
  132303. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132304. /**
  132305. * Set the value of an uniform to an array of int32 (stored as vec3)
  132306. * @param uniform defines the webGL uniform location where to store the value
  132307. * @param array defines the array of int32 to store
  132308. * @returns true if value was set
  132309. */
  132310. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132311. /**
  132312. * Set the value of an uniform to an array of int32 (stored as vec4)
  132313. * @param uniform defines the webGL uniform location where to store the value
  132314. * @param array defines the array of int32 to store
  132315. * @returns true if value was set
  132316. */
  132317. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132318. /**
  132319. * Set the value of an uniform to an array of float32
  132320. * @param uniform defines the webGL uniform location where to store the value
  132321. * @param array defines the array of float32 to store
  132322. * @returns true if value was set
  132323. */
  132324. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132325. /**
  132326. * Set the value of an uniform to an array of float32 (stored as vec2)
  132327. * @param uniform defines the webGL uniform location where to store the value
  132328. * @param array defines the array of float32 to store
  132329. * @returns true if value was set
  132330. */
  132331. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132332. /**
  132333. * Set the value of an uniform to an array of float32 (stored as vec3)
  132334. * @param uniform defines the webGL uniform location where to store the value
  132335. * @param array defines the array of float32 to store
  132336. * @returns true if value was set
  132337. */
  132338. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132339. /**
  132340. * Set the value of an uniform to an array of float32 (stored as vec4)
  132341. * @param uniform defines the webGL uniform location where to store the value
  132342. * @param array defines the array of float32 to store
  132343. * @returns true if value was set
  132344. */
  132345. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132346. /**
  132347. * Set the value of an uniform to an array of number
  132348. * @param uniform defines the webGL uniform location where to store the value
  132349. * @param array defines the array of number to store
  132350. * @returns true if value was set
  132351. */
  132352. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132353. /**
  132354. * Set the value of an uniform to an array of number (stored as vec2)
  132355. * @param uniform defines the webGL uniform location where to store the value
  132356. * @param array defines the array of number to store
  132357. * @returns true if value was set
  132358. */
  132359. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132360. /**
  132361. * Set the value of an uniform to an array of number (stored as vec3)
  132362. * @param uniform defines the webGL uniform location where to store the value
  132363. * @param array defines the array of number to store
  132364. * @returns true if value was set
  132365. */
  132366. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132367. /**
  132368. * Set the value of an uniform to an array of number (stored as vec4)
  132369. * @param uniform defines the webGL uniform location where to store the value
  132370. * @param array defines the array of number to store
  132371. * @returns true if value was set
  132372. */
  132373. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132374. /**
  132375. * Set the value of an uniform to an array of float32 (stored as matrices)
  132376. * @param uniform defines the webGL uniform location where to store the value
  132377. * @param matrices defines the array of float32 to store
  132378. * @returns true if value was set
  132379. */
  132380. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132381. /**
  132382. * Set the value of an uniform to a matrix (3x3)
  132383. * @param uniform defines the webGL uniform location where to store the value
  132384. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132385. * @returns true if value was set
  132386. */
  132387. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132388. /**
  132389. * Set the value of an uniform to a matrix (2x2)
  132390. * @param uniform defines the webGL uniform location where to store the value
  132391. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132392. * @returns true if value was set
  132393. */
  132394. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132395. /**
  132396. * Set the value of an uniform to a number (float)
  132397. * @param uniform defines the webGL uniform location where to store the value
  132398. * @param value defines the float number to store
  132399. * @returns true if value was set
  132400. */
  132401. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132402. /**
  132403. * Set the value of an uniform to a vec2
  132404. * @param uniform defines the webGL uniform location where to store the value
  132405. * @param x defines the 1st component of the value
  132406. * @param y defines the 2nd component of the value
  132407. * @returns true if value was set
  132408. */
  132409. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132410. /**
  132411. * Set the value of an uniform to a vec3
  132412. * @param uniform defines the webGL uniform location where to store the value
  132413. * @param x defines the 1st component of the value
  132414. * @param y defines the 2nd component of the value
  132415. * @param z defines the 3rd component of the value
  132416. * @returns true if value was set
  132417. */
  132418. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132419. /**
  132420. * Set the value of an uniform to a boolean
  132421. * @param uniform defines the webGL uniform location where to store the value
  132422. * @param bool defines the boolean to store
  132423. * @returns true if value was set
  132424. */
  132425. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132426. /**
  132427. * Set the value of an uniform to a vec4
  132428. * @param uniform defines the webGL uniform location where to store the value
  132429. * @param x defines the 1st component of the value
  132430. * @param y defines the 2nd component of the value
  132431. * @param z defines the 3rd component of the value
  132432. * @param w defines the 4th component of the value
  132433. * @returns true if value was set
  132434. */
  132435. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132436. /**
  132437. * Sets the current alpha mode
  132438. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132439. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132440. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132441. */
  132442. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132443. /**
  132444. * Bind webGl buffers directly to the webGL context
  132445. * @param vertexBuffers defines the vertex buffer to bind
  132446. * @param indexBuffer defines the index buffer to bind
  132447. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132448. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132449. * @param effect defines the effect associated with the vertex buffer
  132450. */
  132451. bindBuffers(vertexBuffers: {
  132452. [key: string]: VertexBuffer;
  132453. }, indexBuffer: DataBuffer, effect: Effect): void;
  132454. /**
  132455. * Force the entire cache to be cleared
  132456. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132457. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132458. */
  132459. wipeCaches(bruteForce?: boolean): void;
  132460. /**
  132461. * Send a draw order
  132462. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132463. * @param indexStart defines the starting index
  132464. * @param indexCount defines the number of index to draw
  132465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132466. */
  132467. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132468. /**
  132469. * Draw a list of indexed primitives
  132470. * @param fillMode defines the primitive to use
  132471. * @param indexStart defines the starting index
  132472. * @param indexCount defines the number of index to draw
  132473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132474. */
  132475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132476. /**
  132477. * Draw a list of unindexed primitives
  132478. * @param fillMode defines the primitive to use
  132479. * @param verticesStart defines the index of first vertex to draw
  132480. * @param verticesCount defines the count of vertices to draw
  132481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132482. */
  132483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132484. /** @hidden */
  132485. _createTexture(): WebGLTexture;
  132486. /** @hidden */
  132487. _releaseTexture(texture: InternalTexture): void;
  132488. /**
  132489. * Usually called from Texture.ts.
  132490. * Passed information to create a WebGLTexture
  132491. * @param urlArg defines a value which contains one of the following:
  132492. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132493. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132494. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132496. * @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)
  132497. * @param scene needed for loading to the correct scene
  132498. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132499. * @param onLoad optional callback to be called upon successful completion
  132500. * @param onError optional callback to be called upon failure
  132501. * @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
  132502. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132503. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132504. * @param forcedExtension defines the extension to use to pick the right loader
  132505. * @param mimeType defines an optional mime type
  132506. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132507. */
  132508. 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;
  132509. /**
  132510. * Creates a new render target texture
  132511. * @param size defines the size of the texture
  132512. * @param options defines the options used to create the texture
  132513. * @returns a new render target texture stored in an InternalTexture
  132514. */
  132515. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132516. /**
  132517. * Update the sampling mode of a given texture
  132518. * @param samplingMode defines the required sampling mode
  132519. * @param texture defines the texture to update
  132520. */
  132521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132522. /**
  132523. * Binds the frame buffer to the specified texture.
  132524. * @param texture The texture to render to or null for the default canvas
  132525. * @param faceIndex The face of the texture to render to in case of cube texture
  132526. * @param requiredWidth The width of the target to render to
  132527. * @param requiredHeight The height of the target to render to
  132528. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132529. * @param lodLevel defines le lod level to bind to the frame buffer
  132530. */
  132531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132532. /**
  132533. * Unbind the current render target texture from the webGL context
  132534. * @param texture defines the render target texture to unbind
  132535. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132536. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132537. */
  132538. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132539. /**
  132540. * Creates a dynamic vertex buffer
  132541. * @param vertices the data for the dynamic vertex buffer
  132542. * @returns the new WebGL dynamic buffer
  132543. */
  132544. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132545. /**
  132546. * Update the content of a dynamic texture
  132547. * @param texture defines the texture to update
  132548. * @param canvas defines the canvas containing the source
  132549. * @param invertY defines if data must be stored with Y axis inverted
  132550. * @param premulAlpha defines if alpha is stored as premultiplied
  132551. * @param format defines the format of the data
  132552. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132553. */
  132554. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132555. /**
  132556. * Gets a boolean indicating if all created effects are ready
  132557. * @returns true if all effects are ready
  132558. */
  132559. areAllEffectsReady(): boolean;
  132560. /**
  132561. * @hidden
  132562. * Get the current error code of the webGL context
  132563. * @returns the error code
  132564. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132565. */
  132566. getError(): number;
  132567. /** @hidden */
  132568. _getUnpackAlignement(): number;
  132569. /** @hidden */
  132570. _unpackFlipY(value: boolean): void;
  132571. /**
  132572. * Update a dynamic index buffer
  132573. * @param indexBuffer defines the target index buffer
  132574. * @param indices defines the data to update
  132575. * @param offset defines the offset in the target index buffer where update should start
  132576. */
  132577. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132578. /**
  132579. * Updates a dynamic vertex buffer.
  132580. * @param vertexBuffer the vertex buffer to update
  132581. * @param vertices the data used to update the vertex buffer
  132582. * @param byteOffset the byte offset of the data (optional)
  132583. * @param byteLength the byte length of the data (optional)
  132584. */
  132585. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132586. /** @hidden */
  132587. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132588. /** @hidden */
  132589. _bindTexture(channel: number, texture: InternalTexture): void;
  132590. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132591. /**
  132592. * 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
  132593. */
  132594. releaseEffects(): void;
  132595. displayLoadingUI(): void;
  132596. hideLoadingUI(): void;
  132597. /** @hidden */
  132598. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132599. /** @hidden */
  132600. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132601. /** @hidden */
  132602. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132603. /** @hidden */
  132604. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132605. }
  132606. }
  132607. declare module BABYLON {
  132608. /**
  132609. * @hidden
  132610. **/
  132611. export class _TimeToken {
  132612. _startTimeQuery: Nullable<WebGLQuery>;
  132613. _endTimeQuery: Nullable<WebGLQuery>;
  132614. _timeElapsedQuery: Nullable<WebGLQuery>;
  132615. _timeElapsedQueryEnded: boolean;
  132616. }
  132617. }
  132618. declare module BABYLON {
  132619. /** @hidden */
  132620. export class _OcclusionDataStorage {
  132621. /** @hidden */
  132622. occlusionInternalRetryCounter: number;
  132623. /** @hidden */
  132624. isOcclusionQueryInProgress: boolean;
  132625. /** @hidden */
  132626. isOccluded: boolean;
  132627. /** @hidden */
  132628. occlusionRetryCount: number;
  132629. /** @hidden */
  132630. occlusionType: number;
  132631. /** @hidden */
  132632. occlusionQueryAlgorithmType: number;
  132633. }
  132634. interface Engine {
  132635. /**
  132636. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132637. * @return the new query
  132638. */
  132639. createQuery(): WebGLQuery;
  132640. /**
  132641. * Delete and release a webGL query
  132642. * @param query defines the query to delete
  132643. * @return the current engine
  132644. */
  132645. deleteQuery(query: WebGLQuery): Engine;
  132646. /**
  132647. * Check if a given query has resolved and got its value
  132648. * @param query defines the query to check
  132649. * @returns true if the query got its value
  132650. */
  132651. isQueryResultAvailable(query: WebGLQuery): boolean;
  132652. /**
  132653. * Gets the value of a given query
  132654. * @param query defines the query to check
  132655. * @returns the value of the query
  132656. */
  132657. getQueryResult(query: WebGLQuery): number;
  132658. /**
  132659. * Initiates an occlusion query
  132660. * @param algorithmType defines the algorithm to use
  132661. * @param query defines the query to use
  132662. * @returns the current engine
  132663. * @see https://doc.babylonjs.com/features/occlusionquery
  132664. */
  132665. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132666. /**
  132667. * Ends an occlusion query
  132668. * @see https://doc.babylonjs.com/features/occlusionquery
  132669. * @param algorithmType defines the algorithm to use
  132670. * @returns the current engine
  132671. */
  132672. endOcclusionQuery(algorithmType: number): Engine;
  132673. /**
  132674. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132675. * Please note that only one query can be issued at a time
  132676. * @returns a time token used to track the time span
  132677. */
  132678. startTimeQuery(): Nullable<_TimeToken>;
  132679. /**
  132680. * Ends a time query
  132681. * @param token defines the token used to measure the time span
  132682. * @returns the time spent (in ns)
  132683. */
  132684. endTimeQuery(token: _TimeToken): int;
  132685. /** @hidden */
  132686. _currentNonTimestampToken: Nullable<_TimeToken>;
  132687. /** @hidden */
  132688. _createTimeQuery(): WebGLQuery;
  132689. /** @hidden */
  132690. _deleteTimeQuery(query: WebGLQuery): void;
  132691. /** @hidden */
  132692. _getGlAlgorithmType(algorithmType: number): number;
  132693. /** @hidden */
  132694. _getTimeQueryResult(query: WebGLQuery): any;
  132695. /** @hidden */
  132696. _getTimeQueryAvailability(query: WebGLQuery): any;
  132697. }
  132698. interface AbstractMesh {
  132699. /**
  132700. * Backing filed
  132701. * @hidden
  132702. */
  132703. __occlusionDataStorage: _OcclusionDataStorage;
  132704. /**
  132705. * Access property
  132706. * @hidden
  132707. */
  132708. _occlusionDataStorage: _OcclusionDataStorage;
  132709. /**
  132710. * 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.
  132711. * The default value is -1 which means don't break the query and wait till the result
  132712. * @see https://doc.babylonjs.com/features/occlusionquery
  132713. */
  132714. occlusionRetryCount: number;
  132715. /**
  132716. * 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:
  132717. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132718. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132719. * * 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.
  132720. * @see https://doc.babylonjs.com/features/occlusionquery
  132721. */
  132722. occlusionType: number;
  132723. /**
  132724. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132725. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132726. * * 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.
  132727. * @see https://doc.babylonjs.com/features/occlusionquery
  132728. */
  132729. occlusionQueryAlgorithmType: number;
  132730. /**
  132731. * 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
  132732. * @see https://doc.babylonjs.com/features/occlusionquery
  132733. */
  132734. isOccluded: boolean;
  132735. /**
  132736. * Flag to check the progress status of the query
  132737. * @see https://doc.babylonjs.com/features/occlusionquery
  132738. */
  132739. isOcclusionQueryInProgress: boolean;
  132740. }
  132741. }
  132742. declare module BABYLON {
  132743. /** @hidden */
  132744. export var _forceTransformFeedbackToBundle: boolean;
  132745. interface Engine {
  132746. /**
  132747. * Creates a webGL transform feedback object
  132748. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132749. * @returns the webGL transform feedback object
  132750. */
  132751. createTransformFeedback(): WebGLTransformFeedback;
  132752. /**
  132753. * Delete a webGL transform feedback object
  132754. * @param value defines the webGL transform feedback object to delete
  132755. */
  132756. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132757. /**
  132758. * Bind a webGL transform feedback object to the webgl context
  132759. * @param value defines the webGL transform feedback object to bind
  132760. */
  132761. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132762. /**
  132763. * Begins a transform feedback operation
  132764. * @param usePoints defines if points or triangles must be used
  132765. */
  132766. beginTransformFeedback(usePoints: boolean): void;
  132767. /**
  132768. * Ends a transform feedback operation
  132769. */
  132770. endTransformFeedback(): void;
  132771. /**
  132772. * Specify the varyings to use with transform feedback
  132773. * @param program defines the associated webGL program
  132774. * @param value defines the list of strings representing the varying names
  132775. */
  132776. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132777. /**
  132778. * Bind a webGL buffer for a transform feedback operation
  132779. * @param value defines the webGL buffer to bind
  132780. */
  132781. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132782. }
  132783. }
  132784. declare module BABYLON {
  132785. /**
  132786. * Class used to define an additional view for the engine
  132787. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132788. */
  132789. export class EngineView {
  132790. /** Defines the canvas where to render the view */
  132791. target: HTMLCanvasElement;
  132792. /** Defines an optional camera used to render the view (will use active camera else) */
  132793. camera?: Camera;
  132794. }
  132795. interface Engine {
  132796. /**
  132797. * Gets or sets the HTML element to use for attaching events
  132798. */
  132799. inputElement: Nullable<HTMLElement>;
  132800. /**
  132801. * Gets the current engine view
  132802. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132803. */
  132804. activeView: Nullable<EngineView>;
  132805. /** Gets or sets the list of views */
  132806. views: EngineView[];
  132807. /**
  132808. * Register a new child canvas
  132809. * @param canvas defines the canvas to register
  132810. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132811. * @returns the associated view
  132812. */
  132813. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132814. /**
  132815. * Remove a registered child canvas
  132816. * @param canvas defines the canvas to remove
  132817. * @returns the current engine
  132818. */
  132819. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132820. }
  132821. }
  132822. declare module BABYLON {
  132823. interface Engine {
  132824. /** @hidden */
  132825. _excludedCompressedTextures: string[];
  132826. /** @hidden */
  132827. _textureFormatInUse: string;
  132828. /**
  132829. * Gets the list of texture formats supported
  132830. */
  132831. readonly texturesSupported: Array<string>;
  132832. /**
  132833. * Gets the texture format in use
  132834. */
  132835. readonly textureFormatInUse: Nullable<string>;
  132836. /**
  132837. * Set the compressed texture extensions or file names to skip.
  132838. *
  132839. * @param skippedFiles defines the list of those texture files you want to skip
  132840. * Example: [".dds", ".env", "myfile.png"]
  132841. */
  132842. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132843. /**
  132844. * Set the compressed texture format to use, based on the formats you have, and the formats
  132845. * supported by the hardware / browser.
  132846. *
  132847. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132848. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132849. * to API arguments needed to compressed textures. This puts the burden on the container
  132850. * generator to house the arcane code for determining these for current & future formats.
  132851. *
  132852. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132853. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132854. *
  132855. * Note: The result of this call is not taken into account when a texture is base64.
  132856. *
  132857. * @param formatsAvailable defines the list of those format families you have created
  132858. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132859. *
  132860. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132861. * @returns The extension selected.
  132862. */
  132863. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132864. }
  132865. }
  132866. declare module BABYLON {
  132867. /**
  132868. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132869. */
  132870. export interface CubeMapInfo {
  132871. /**
  132872. * The pixel array for the front face.
  132873. * This is stored in format, left to right, up to down format.
  132874. */
  132875. front: Nullable<ArrayBufferView>;
  132876. /**
  132877. * The pixel array for the back face.
  132878. * This is stored in format, left to right, up to down format.
  132879. */
  132880. back: Nullable<ArrayBufferView>;
  132881. /**
  132882. * The pixel array for the left face.
  132883. * This is stored in format, left to right, up to down format.
  132884. */
  132885. left: Nullable<ArrayBufferView>;
  132886. /**
  132887. * The pixel array for the right face.
  132888. * This is stored in format, left to right, up to down format.
  132889. */
  132890. right: Nullable<ArrayBufferView>;
  132891. /**
  132892. * The pixel array for the up face.
  132893. * This is stored in format, left to right, up to down format.
  132894. */
  132895. up: Nullable<ArrayBufferView>;
  132896. /**
  132897. * The pixel array for the down face.
  132898. * This is stored in format, left to right, up to down format.
  132899. */
  132900. down: Nullable<ArrayBufferView>;
  132901. /**
  132902. * The size of the cubemap stored.
  132903. *
  132904. * Each faces will be size * size pixels.
  132905. */
  132906. size: number;
  132907. /**
  132908. * The format of the texture.
  132909. *
  132910. * RGBA, RGB.
  132911. */
  132912. format: number;
  132913. /**
  132914. * The type of the texture data.
  132915. *
  132916. * UNSIGNED_INT, FLOAT.
  132917. */
  132918. type: number;
  132919. /**
  132920. * Specifies whether the texture is in gamma space.
  132921. */
  132922. gammaSpace: boolean;
  132923. }
  132924. /**
  132925. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132926. */
  132927. export class PanoramaToCubeMapTools {
  132928. private static FACE_LEFT;
  132929. private static FACE_RIGHT;
  132930. private static FACE_FRONT;
  132931. private static FACE_BACK;
  132932. private static FACE_DOWN;
  132933. private static FACE_UP;
  132934. /**
  132935. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132936. *
  132937. * @param float32Array The source data.
  132938. * @param inputWidth The width of the input panorama.
  132939. * @param inputHeight The height of the input panorama.
  132940. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132941. * @return The cubemap data
  132942. */
  132943. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132944. private static CreateCubemapTexture;
  132945. private static CalcProjectionSpherical;
  132946. }
  132947. }
  132948. declare module BABYLON {
  132949. /**
  132950. * Helper class dealing with the extraction of spherical polynomial dataArray
  132951. * from a cube map.
  132952. */
  132953. export class CubeMapToSphericalPolynomialTools {
  132954. private static FileFaces;
  132955. /**
  132956. * Converts a texture to the according Spherical Polynomial data.
  132957. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132958. *
  132959. * @param texture The texture to extract the information from.
  132960. * @return The Spherical Polynomial data.
  132961. */
  132962. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132963. /**
  132964. * Converts a cubemap to the according Spherical Polynomial data.
  132965. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132966. *
  132967. * @param cubeInfo The Cube map to extract the information from.
  132968. * @return The Spherical Polynomial data.
  132969. */
  132970. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132971. }
  132972. }
  132973. declare module BABYLON {
  132974. interface BaseTexture {
  132975. /**
  132976. * Get the polynomial representation of the texture data.
  132977. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132978. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132979. */
  132980. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132981. }
  132982. }
  132983. declare module BABYLON {
  132984. /** @hidden */
  132985. export var rgbdEncodePixelShader: {
  132986. name: string;
  132987. shader: string;
  132988. };
  132989. }
  132990. declare module BABYLON {
  132991. /** @hidden */
  132992. export var rgbdDecodePixelShader: {
  132993. name: string;
  132994. shader: string;
  132995. };
  132996. }
  132997. declare module BABYLON {
  132998. /**
  132999. * Raw texture data and descriptor sufficient for WebGL texture upload
  133000. */
  133001. export interface EnvironmentTextureInfo {
  133002. /**
  133003. * Version of the environment map
  133004. */
  133005. version: number;
  133006. /**
  133007. * Width of image
  133008. */
  133009. width: number;
  133010. /**
  133011. * Irradiance information stored in the file.
  133012. */
  133013. irradiance: any;
  133014. /**
  133015. * Specular information stored in the file.
  133016. */
  133017. specular: any;
  133018. }
  133019. /**
  133020. * Defines One Image in the file. It requires only the position in the file
  133021. * as well as the length.
  133022. */
  133023. interface BufferImageData {
  133024. /**
  133025. * Length of the image data.
  133026. */
  133027. length: number;
  133028. /**
  133029. * Position of the data from the null terminator delimiting the end of the JSON.
  133030. */
  133031. position: number;
  133032. }
  133033. /**
  133034. * Defines the specular data enclosed in the file.
  133035. * This corresponds to the version 1 of the data.
  133036. */
  133037. export interface EnvironmentTextureSpecularInfoV1 {
  133038. /**
  133039. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133040. */
  133041. specularDataPosition?: number;
  133042. /**
  133043. * This contains all the images data needed to reconstruct the cubemap.
  133044. */
  133045. mipmaps: Array<BufferImageData>;
  133046. /**
  133047. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133048. */
  133049. lodGenerationScale: number;
  133050. }
  133051. /**
  133052. * Sets of helpers addressing the serialization and deserialization of environment texture
  133053. * stored in a BabylonJS env file.
  133054. * Those files are usually stored as .env files.
  133055. */
  133056. export class EnvironmentTextureTools {
  133057. /**
  133058. * Magic number identifying the env file.
  133059. */
  133060. private static _MagicBytes;
  133061. /**
  133062. * Gets the environment info from an env file.
  133063. * @param data The array buffer containing the .env bytes.
  133064. * @returns the environment file info (the json header) if successfully parsed.
  133065. */
  133066. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133067. /**
  133068. * Creates an environment texture from a loaded cube texture.
  133069. * @param texture defines the cube texture to convert in env file
  133070. * @return a promise containing the environment data if succesfull.
  133071. */
  133072. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133073. /**
  133074. * Creates a JSON representation of the spherical data.
  133075. * @param texture defines the texture containing the polynomials
  133076. * @return the JSON representation of the spherical info
  133077. */
  133078. private static _CreateEnvTextureIrradiance;
  133079. /**
  133080. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133081. * @param data the image data
  133082. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133083. * @return the views described by info providing access to the underlying buffer
  133084. */
  133085. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133086. /**
  133087. * Uploads the texture info contained in the env file to the GPU.
  133088. * @param texture defines the internal texture to upload to
  133089. * @param data defines the data to load
  133090. * @param info defines the texture info retrieved through the GetEnvInfo method
  133091. * @returns a promise
  133092. */
  133093. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133094. private static _OnImageReadyAsync;
  133095. /**
  133096. * Uploads the levels of image data to the GPU.
  133097. * @param texture defines the internal texture to upload to
  133098. * @param imageData defines the array buffer views of image data [mipmap][face]
  133099. * @returns a promise
  133100. */
  133101. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133102. /**
  133103. * Uploads spherical polynomials information to the texture.
  133104. * @param texture defines the texture we are trying to upload the information to
  133105. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133106. */
  133107. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133108. /** @hidden */
  133109. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133110. }
  133111. }
  133112. declare module BABYLON {
  133113. /**
  133114. * Class used to inline functions in shader code
  133115. */
  133116. export class ShaderCodeInliner {
  133117. private static readonly _RegexpFindFunctionNameAndType;
  133118. private _sourceCode;
  133119. private _functionDescr;
  133120. private _numMaxIterations;
  133121. /** Gets or sets the token used to mark the functions to inline */
  133122. inlineToken: string;
  133123. /** Gets or sets the debug mode */
  133124. debug: boolean;
  133125. /** Gets the code after the inlining process */
  133126. get code(): string;
  133127. /**
  133128. * Initializes the inliner
  133129. * @param sourceCode shader code source to inline
  133130. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133131. */
  133132. constructor(sourceCode: string, numMaxIterations?: number);
  133133. /**
  133134. * Start the processing of the shader code
  133135. */
  133136. processCode(): void;
  133137. private _collectFunctions;
  133138. private _processInlining;
  133139. private _extractBetweenMarkers;
  133140. private _skipWhitespaces;
  133141. private _removeComments;
  133142. private _replaceFunctionCallsByCode;
  133143. private _findBackward;
  133144. private _escapeRegExp;
  133145. private _replaceNames;
  133146. }
  133147. }
  133148. declare module BABYLON {
  133149. /**
  133150. * Container for accessors for natively-stored mesh data buffers.
  133151. */
  133152. class NativeDataBuffer extends DataBuffer {
  133153. /**
  133154. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133155. */
  133156. nativeIndexBuffer?: any;
  133157. /**
  133158. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133159. */
  133160. nativeVertexBuffer?: any;
  133161. }
  133162. /** @hidden */
  133163. class NativeTexture extends InternalTexture {
  133164. getInternalTexture(): InternalTexture;
  133165. getViewCount(): number;
  133166. }
  133167. /** @hidden */
  133168. export class NativeEngine extends Engine {
  133169. private readonly _native;
  133170. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133171. private readonly INVALID_HANDLE;
  133172. private _boundBuffersVertexArray;
  133173. private _currentDepthTest;
  133174. getHardwareScalingLevel(): number;
  133175. constructor();
  133176. dispose(): void;
  133177. /**
  133178. * Can be used to override the current requestAnimationFrame requester.
  133179. * @hidden
  133180. */
  133181. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133182. /**
  133183. * Override default engine behavior.
  133184. * @param color
  133185. * @param backBuffer
  133186. * @param depth
  133187. * @param stencil
  133188. */
  133189. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133190. /**
  133191. * Gets host document
  133192. * @returns the host document object
  133193. */
  133194. getHostDocument(): Nullable<Document>;
  133195. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133196. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133197. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133198. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133199. [key: string]: VertexBuffer;
  133200. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133201. bindBuffers(vertexBuffers: {
  133202. [key: string]: VertexBuffer;
  133203. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133204. recordVertexArrayObject(vertexBuffers: {
  133205. [key: string]: VertexBuffer;
  133206. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133207. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133208. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133209. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133210. /**
  133211. * Draw a list of indexed primitives
  133212. * @param fillMode defines the primitive to use
  133213. * @param indexStart defines the starting index
  133214. * @param indexCount defines the number of index to draw
  133215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133216. */
  133217. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133218. /**
  133219. * Draw a list of unindexed primitives
  133220. * @param fillMode defines the primitive to use
  133221. * @param verticesStart defines the index of first vertex to draw
  133222. * @param verticesCount defines the count of vertices to draw
  133223. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133224. */
  133225. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133226. createPipelineContext(): IPipelineContext;
  133227. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133228. /** @hidden */
  133229. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133230. /** @hidden */
  133231. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133232. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133233. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133234. protected _setProgram(program: WebGLProgram): void;
  133235. _releaseEffect(effect: Effect): void;
  133236. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133237. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133238. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133239. bindSamplers(effect: Effect): void;
  133240. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133241. getRenderWidth(useScreen?: boolean): number;
  133242. getRenderHeight(useScreen?: boolean): number;
  133243. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133244. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133245. /**
  133246. * Set the z offset to apply to current rendering
  133247. * @param value defines the offset to apply
  133248. */
  133249. setZOffset(value: number): void;
  133250. /**
  133251. * Gets the current value of the zOffset
  133252. * @returns the current zOffset state
  133253. */
  133254. getZOffset(): number;
  133255. /**
  133256. * Enable or disable depth buffering
  133257. * @param enable defines the state to set
  133258. */
  133259. setDepthBuffer(enable: boolean): void;
  133260. /**
  133261. * Gets a boolean indicating if depth writing is enabled
  133262. * @returns the current depth writing state
  133263. */
  133264. getDepthWrite(): boolean;
  133265. setDepthFunctionToGreater(): void;
  133266. setDepthFunctionToGreaterOrEqual(): void;
  133267. setDepthFunctionToLess(): void;
  133268. setDepthFunctionToLessOrEqual(): void;
  133269. /**
  133270. * Enable or disable depth writing
  133271. * @param enable defines the state to set
  133272. */
  133273. setDepthWrite(enable: boolean): void;
  133274. /**
  133275. * Enable or disable color writing
  133276. * @param enable defines the state to set
  133277. */
  133278. setColorWrite(enable: boolean): void;
  133279. /**
  133280. * Gets a boolean indicating if color writing is enabled
  133281. * @returns the current color writing state
  133282. */
  133283. getColorWrite(): boolean;
  133284. /**
  133285. * Sets alpha constants used by some alpha blending modes
  133286. * @param r defines the red component
  133287. * @param g defines the green component
  133288. * @param b defines the blue component
  133289. * @param a defines the alpha component
  133290. */
  133291. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133292. /**
  133293. * Sets the current alpha mode
  133294. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133295. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133296. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133297. */
  133298. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133299. /**
  133300. * Gets the current alpha mode
  133301. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133302. * @returns the current alpha mode
  133303. */
  133304. getAlphaMode(): number;
  133305. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133306. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133307. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133308. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133309. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133310. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133311. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133312. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133313. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133314. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133315. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133316. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133317. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133318. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133319. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133320. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133321. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133322. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133323. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133324. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133325. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133326. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133327. wipeCaches(bruteForce?: boolean): void;
  133328. _createTexture(): WebGLTexture;
  133329. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133330. /**
  133331. * Usually called from Texture.ts.
  133332. * Passed information to create a WebGLTexture
  133333. * @param url defines a value which contains one of the following:
  133334. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133335. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133336. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133337. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133338. * @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)
  133339. * @param scene needed for loading to the correct scene
  133340. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133341. * @param onLoad optional callback to be called upon successful completion
  133342. * @param onError optional callback to be called upon failure
  133343. * @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
  133344. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133345. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133346. * @param forcedExtension defines the extension to use to pick the right loader
  133347. * @param mimeType defines an optional mime type
  133348. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133349. */
  133350. 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;
  133351. /**
  133352. * Creates a cube texture
  133353. * @param rootUrl defines the url where the files to load is located
  133354. * @param scene defines the current scene
  133355. * @param files defines the list of files to load (1 per face)
  133356. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133357. * @param onLoad defines an optional callback raised when the texture is loaded
  133358. * @param onError defines an optional callback raised if there is an issue to load the texture
  133359. * @param format defines the format of the data
  133360. * @param forcedExtension defines the extension to use to pick the right loader
  133361. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133362. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133363. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133364. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133365. * @returns the cube texture as an InternalTexture
  133366. */
  133367. 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;
  133368. private _getSamplingFilter;
  133369. private static _GetNativeTextureFormat;
  133370. createRenderTargetTexture(size: number | {
  133371. width: number;
  133372. height: number;
  133373. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133374. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133375. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133376. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133377. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133378. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133379. /**
  133380. * Updates a dynamic vertex buffer.
  133381. * @param vertexBuffer the vertex buffer to update
  133382. * @param data the data used to update the vertex buffer
  133383. * @param byteOffset the byte offset of the data (optional)
  133384. * @param byteLength the byte length of the data (optional)
  133385. */
  133386. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133387. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133388. private _updateAnisotropicLevel;
  133389. private _getAddressMode;
  133390. /** @hidden */
  133391. _bindTexture(channel: number, texture: InternalTexture): void;
  133392. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133393. releaseEffects(): void;
  133394. /** @hidden */
  133395. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133396. /** @hidden */
  133397. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133398. /** @hidden */
  133399. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133400. /** @hidden */
  133401. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133402. }
  133403. }
  133404. declare module BABYLON {
  133405. /**
  133406. * Gather the list of clipboard event types as constants.
  133407. */
  133408. export class ClipboardEventTypes {
  133409. /**
  133410. * The clipboard event is fired when a copy command is active (pressed).
  133411. */
  133412. static readonly COPY: number;
  133413. /**
  133414. * The clipboard event is fired when a cut command is active (pressed).
  133415. */
  133416. static readonly CUT: number;
  133417. /**
  133418. * The clipboard event is fired when a paste command is active (pressed).
  133419. */
  133420. static readonly PASTE: number;
  133421. }
  133422. /**
  133423. * This class is used to store clipboard related info for the onClipboardObservable event.
  133424. */
  133425. export class ClipboardInfo {
  133426. /**
  133427. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133428. */
  133429. type: number;
  133430. /**
  133431. * Defines the related dom event
  133432. */
  133433. event: ClipboardEvent;
  133434. /**
  133435. *Creates an instance of ClipboardInfo.
  133436. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133437. * @param event Defines the related dom event
  133438. */
  133439. constructor(
  133440. /**
  133441. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133442. */
  133443. type: number,
  133444. /**
  133445. * Defines the related dom event
  133446. */
  133447. event: ClipboardEvent);
  133448. /**
  133449. * Get the clipboard event's type from the keycode.
  133450. * @param keyCode Defines the keyCode for the current keyboard event.
  133451. * @return {number}
  133452. */
  133453. static GetTypeFromCharacter(keyCode: number): number;
  133454. }
  133455. }
  133456. declare module BABYLON {
  133457. /**
  133458. * Google Daydream controller
  133459. */
  133460. export class DaydreamController extends WebVRController {
  133461. /**
  133462. * Base Url for the controller model.
  133463. */
  133464. static MODEL_BASE_URL: string;
  133465. /**
  133466. * File name for the controller model.
  133467. */
  133468. static MODEL_FILENAME: string;
  133469. /**
  133470. * Gamepad Id prefix used to identify Daydream Controller.
  133471. */
  133472. static readonly GAMEPAD_ID_PREFIX: string;
  133473. /**
  133474. * Creates a new DaydreamController from a gamepad
  133475. * @param vrGamepad the gamepad that the controller should be created from
  133476. */
  133477. constructor(vrGamepad: any);
  133478. /**
  133479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133480. * @param scene scene in which to add meshes
  133481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133482. */
  133483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133484. /**
  133485. * Called once for each button that changed state since the last frame
  133486. * @param buttonIdx Which button index changed
  133487. * @param state New state of the button
  133488. * @param changes Which properties on the state changed since last frame
  133489. */
  133490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133491. }
  133492. }
  133493. declare module BABYLON {
  133494. /**
  133495. * Gear VR Controller
  133496. */
  133497. export class GearVRController extends WebVRController {
  133498. /**
  133499. * Base Url for the controller model.
  133500. */
  133501. static MODEL_BASE_URL: string;
  133502. /**
  133503. * File name for the controller model.
  133504. */
  133505. static MODEL_FILENAME: string;
  133506. /**
  133507. * Gamepad Id prefix used to identify this controller.
  133508. */
  133509. static readonly GAMEPAD_ID_PREFIX: string;
  133510. private readonly _buttonIndexToObservableNameMap;
  133511. /**
  133512. * Creates a new GearVRController from a gamepad
  133513. * @param vrGamepad the gamepad that the controller should be created from
  133514. */
  133515. constructor(vrGamepad: any);
  133516. /**
  133517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133518. * @param scene scene in which to add meshes
  133519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133520. */
  133521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133522. /**
  133523. * Called once for each button that changed state since the last frame
  133524. * @param buttonIdx Which button index changed
  133525. * @param state New state of the button
  133526. * @param changes Which properties on the state changed since last frame
  133527. */
  133528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133529. }
  133530. }
  133531. declare module BABYLON {
  133532. /**
  133533. * Generic Controller
  133534. */
  133535. export class GenericController extends WebVRController {
  133536. /**
  133537. * Base Url for the controller model.
  133538. */
  133539. static readonly MODEL_BASE_URL: string;
  133540. /**
  133541. * File name for the controller model.
  133542. */
  133543. static readonly MODEL_FILENAME: string;
  133544. /**
  133545. * Creates a new GenericController from a gamepad
  133546. * @param vrGamepad the gamepad that the controller should be created from
  133547. */
  133548. constructor(vrGamepad: any);
  133549. /**
  133550. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133551. * @param scene scene in which to add meshes
  133552. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133553. */
  133554. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133555. /**
  133556. * Called once for each button that changed state since the last frame
  133557. * @param buttonIdx Which button index changed
  133558. * @param state New state of the button
  133559. * @param changes Which properties on the state changed since last frame
  133560. */
  133561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133562. }
  133563. }
  133564. declare module BABYLON {
  133565. /**
  133566. * Oculus Touch Controller
  133567. */
  133568. export class OculusTouchController extends WebVRController {
  133569. /**
  133570. * Base Url for the controller model.
  133571. */
  133572. static MODEL_BASE_URL: string;
  133573. /**
  133574. * File name for the left controller model.
  133575. */
  133576. static MODEL_LEFT_FILENAME: string;
  133577. /**
  133578. * File name for the right controller model.
  133579. */
  133580. static MODEL_RIGHT_FILENAME: string;
  133581. /**
  133582. * Base Url for the Quest controller model.
  133583. */
  133584. static QUEST_MODEL_BASE_URL: string;
  133585. /**
  133586. * @hidden
  133587. * If the controllers are running on a device that needs the updated Quest controller models
  133588. */
  133589. static _IsQuest: boolean;
  133590. /**
  133591. * Fired when the secondary trigger on this controller is modified
  133592. */
  133593. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133594. /**
  133595. * Fired when the thumb rest on this controller is modified
  133596. */
  133597. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133598. /**
  133599. * Creates a new OculusTouchController from a gamepad
  133600. * @param vrGamepad the gamepad that the controller should be created from
  133601. */
  133602. constructor(vrGamepad: any);
  133603. /**
  133604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133605. * @param scene scene in which to add meshes
  133606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133607. */
  133608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133609. /**
  133610. * Fired when the A button on this controller is modified
  133611. */
  133612. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133613. /**
  133614. * Fired when the B button on this controller is modified
  133615. */
  133616. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133617. /**
  133618. * Fired when the X button on this controller is modified
  133619. */
  133620. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133621. /**
  133622. * Fired when the Y button on this controller is modified
  133623. */
  133624. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133625. /**
  133626. * Called once for each button that changed state since the last frame
  133627. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133628. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133629. * 2) secondary trigger (same)
  133630. * 3) A (right) X (left), touch, pressed = value
  133631. * 4) B / Y
  133632. * 5) thumb rest
  133633. * @param buttonIdx Which button index changed
  133634. * @param state New state of the button
  133635. * @param changes Which properties on the state changed since last frame
  133636. */
  133637. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133638. }
  133639. }
  133640. declare module BABYLON {
  133641. /**
  133642. * Vive Controller
  133643. */
  133644. export class ViveController extends WebVRController {
  133645. /**
  133646. * Base Url for the controller model.
  133647. */
  133648. static MODEL_BASE_URL: string;
  133649. /**
  133650. * File name for the controller model.
  133651. */
  133652. static MODEL_FILENAME: string;
  133653. /**
  133654. * Creates a new ViveController from a gamepad
  133655. * @param vrGamepad the gamepad that the controller should be created from
  133656. */
  133657. constructor(vrGamepad: any);
  133658. /**
  133659. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133660. * @param scene scene in which to add meshes
  133661. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133662. */
  133663. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133664. /**
  133665. * Fired when the left button on this controller is modified
  133666. */
  133667. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133668. /**
  133669. * Fired when the right button on this controller is modified
  133670. */
  133671. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133672. /**
  133673. * Fired when the menu button on this controller is modified
  133674. */
  133675. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133676. /**
  133677. * Called once for each button that changed state since the last frame
  133678. * Vive mapping:
  133679. * 0: touchpad
  133680. * 1: trigger
  133681. * 2: left AND right buttons
  133682. * 3: menu button
  133683. * @param buttonIdx Which button index changed
  133684. * @param state New state of the button
  133685. * @param changes Which properties on the state changed since last frame
  133686. */
  133687. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133688. }
  133689. }
  133690. declare module BABYLON {
  133691. /**
  133692. * Defines the WindowsMotionController object that the state of the windows motion controller
  133693. */
  133694. export class WindowsMotionController extends WebVRController {
  133695. /**
  133696. * The base url used to load the left and right controller models
  133697. */
  133698. static MODEL_BASE_URL: string;
  133699. /**
  133700. * The name of the left controller model file
  133701. */
  133702. static MODEL_LEFT_FILENAME: string;
  133703. /**
  133704. * The name of the right controller model file
  133705. */
  133706. static MODEL_RIGHT_FILENAME: string;
  133707. /**
  133708. * The controller name prefix for this controller type
  133709. */
  133710. static readonly GAMEPAD_ID_PREFIX: string;
  133711. /**
  133712. * The controller id pattern for this controller type
  133713. */
  133714. private static readonly GAMEPAD_ID_PATTERN;
  133715. private _loadedMeshInfo;
  133716. protected readonly _mapping: {
  133717. buttons: string[];
  133718. buttonMeshNames: {
  133719. trigger: string;
  133720. menu: string;
  133721. grip: string;
  133722. thumbstick: string;
  133723. trackpad: string;
  133724. };
  133725. buttonObservableNames: {
  133726. trigger: string;
  133727. menu: string;
  133728. grip: string;
  133729. thumbstick: string;
  133730. trackpad: string;
  133731. };
  133732. axisMeshNames: string[];
  133733. pointingPoseMeshName: string;
  133734. };
  133735. /**
  133736. * Fired when the trackpad on this controller is clicked
  133737. */
  133738. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133739. /**
  133740. * Fired when the trackpad on this controller is modified
  133741. */
  133742. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133743. /**
  133744. * The current x and y values of this controller's trackpad
  133745. */
  133746. trackpad: StickValues;
  133747. /**
  133748. * Creates a new WindowsMotionController from a gamepad
  133749. * @param vrGamepad the gamepad that the controller should be created from
  133750. */
  133751. constructor(vrGamepad: any);
  133752. /**
  133753. * Fired when the trigger on this controller is modified
  133754. */
  133755. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133756. /**
  133757. * Fired when the menu button on this controller is modified
  133758. */
  133759. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133760. /**
  133761. * Fired when the grip button on this controller is modified
  133762. */
  133763. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133764. /**
  133765. * Fired when the thumbstick button on this controller is modified
  133766. */
  133767. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133768. /**
  133769. * Fired when the touchpad button on this controller is modified
  133770. */
  133771. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133772. /**
  133773. * Fired when the touchpad values on this controller are modified
  133774. */
  133775. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133776. protected _updateTrackpad(): void;
  133777. /**
  133778. * Called once per frame by the engine.
  133779. */
  133780. update(): void;
  133781. /**
  133782. * Called once for each button that changed state since the last frame
  133783. * @param buttonIdx Which button index changed
  133784. * @param state New state of the button
  133785. * @param changes Which properties on the state changed since last frame
  133786. */
  133787. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133788. /**
  133789. * Moves the buttons on the controller mesh based on their current state
  133790. * @param buttonName the name of the button to move
  133791. * @param buttonValue the value of the button which determines the buttons new position
  133792. */
  133793. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133794. /**
  133795. * Moves the axis on the controller mesh based on its current state
  133796. * @param axis the index of the axis
  133797. * @param axisValue the value of the axis which determines the meshes new position
  133798. * @hidden
  133799. */
  133800. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133801. /**
  133802. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133803. * @param scene scene in which to add meshes
  133804. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133805. */
  133806. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133807. /**
  133808. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133809. * can be transformed by button presses and axes values, based on this._mapping.
  133810. *
  133811. * @param scene scene in which the meshes exist
  133812. * @param meshes list of meshes that make up the controller model to process
  133813. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133814. */
  133815. private processModel;
  133816. private createMeshInfo;
  133817. /**
  133818. * Gets the ray of the controller in the direction the controller is pointing
  133819. * @param length the length the resulting ray should be
  133820. * @returns a ray in the direction the controller is pointing
  133821. */
  133822. getForwardRay(length?: number): Ray;
  133823. /**
  133824. * Disposes of the controller
  133825. */
  133826. dispose(): void;
  133827. }
  133828. /**
  133829. * This class represents a new windows motion controller in XR.
  133830. */
  133831. export class XRWindowsMotionController extends WindowsMotionController {
  133832. /**
  133833. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133834. */
  133835. protected readonly _mapping: {
  133836. buttons: string[];
  133837. buttonMeshNames: {
  133838. trigger: string;
  133839. menu: string;
  133840. grip: string;
  133841. thumbstick: string;
  133842. trackpad: string;
  133843. };
  133844. buttonObservableNames: {
  133845. trigger: string;
  133846. menu: string;
  133847. grip: string;
  133848. thumbstick: string;
  133849. trackpad: string;
  133850. };
  133851. axisMeshNames: string[];
  133852. pointingPoseMeshName: string;
  133853. };
  133854. /**
  133855. * Construct a new XR-Based windows motion controller
  133856. *
  133857. * @param gamepadInfo the gamepad object from the browser
  133858. */
  133859. constructor(gamepadInfo: any);
  133860. /**
  133861. * holds the thumbstick values (X,Y)
  133862. */
  133863. thumbstickValues: StickValues;
  133864. /**
  133865. * Fired when the thumbstick on this controller is clicked
  133866. */
  133867. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133868. /**
  133869. * Fired when the thumbstick on this controller is modified
  133870. */
  133871. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133872. /**
  133873. * Fired when the touchpad button on this controller is modified
  133874. */
  133875. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133876. /**
  133877. * Fired when the touchpad values on this controller are modified
  133878. */
  133879. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133880. /**
  133881. * Fired when the thumbstick button on this controller is modified
  133882. * here to prevent breaking changes
  133883. */
  133884. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133885. /**
  133886. * updating the thumbstick(!) and not the trackpad.
  133887. * This is named this way due to the difference between WebVR and XR and to avoid
  133888. * changing the parent class.
  133889. */
  133890. protected _updateTrackpad(): void;
  133891. /**
  133892. * Disposes the class with joy
  133893. */
  133894. dispose(): void;
  133895. }
  133896. }
  133897. declare module BABYLON {
  133898. /**
  133899. * Class containing static functions to help procedurally build meshes
  133900. */
  133901. export class PolyhedronBuilder {
  133902. /**
  133903. * Creates a polyhedron mesh
  133904. * * 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
  133905. * * The parameter `size` (positive float, default 1) sets the polygon size
  133906. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133907. * * 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`
  133908. * * 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
  133909. * * 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)`)
  133910. * * 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
  133911. * * 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
  133912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133915. * @param name defines the name of the mesh
  133916. * @param options defines the options used to create the mesh
  133917. * @param scene defines the hosting scene
  133918. * @returns the polyhedron mesh
  133919. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133920. */
  133921. static CreatePolyhedron(name: string, options: {
  133922. type?: number;
  133923. size?: number;
  133924. sizeX?: number;
  133925. sizeY?: number;
  133926. sizeZ?: number;
  133927. custom?: any;
  133928. faceUV?: Vector4[];
  133929. faceColors?: Color4[];
  133930. flat?: boolean;
  133931. updatable?: boolean;
  133932. sideOrientation?: number;
  133933. frontUVs?: Vector4;
  133934. backUVs?: Vector4;
  133935. }, scene?: Nullable<Scene>): Mesh;
  133936. }
  133937. }
  133938. declare module BABYLON {
  133939. /**
  133940. * Gizmo that enables scaling a mesh along 3 axis
  133941. */
  133942. export class ScaleGizmo extends Gizmo {
  133943. /**
  133944. * Internal gizmo used for interactions on the x axis
  133945. */
  133946. xGizmo: AxisScaleGizmo;
  133947. /**
  133948. * Internal gizmo used for interactions on the y axis
  133949. */
  133950. yGizmo: AxisScaleGizmo;
  133951. /**
  133952. * Internal gizmo used for interactions on the z axis
  133953. */
  133954. zGizmo: AxisScaleGizmo;
  133955. /**
  133956. * Internal gizmo used to scale all axis equally
  133957. */
  133958. uniformScaleGizmo: AxisScaleGizmo;
  133959. private _meshAttached;
  133960. private _nodeAttached;
  133961. private _snapDistance;
  133962. private _uniformScalingMesh;
  133963. private _octahedron;
  133964. private _sensitivity;
  133965. /** Fires an event when any of it's sub gizmos are dragged */
  133966. onDragStartObservable: Observable<unknown>;
  133967. /** Fires an event when any of it's sub gizmos are released from dragging */
  133968. onDragEndObservable: Observable<unknown>;
  133969. get attachedMesh(): Nullable<AbstractMesh>;
  133970. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133971. get attachedNode(): Nullable<Node>;
  133972. set attachedNode(node: Nullable<Node>);
  133973. /**
  133974. * True when the mouse pointer is hovering a gizmo mesh
  133975. */
  133976. get isHovered(): boolean;
  133977. /**
  133978. * Creates a ScaleGizmo
  133979. * @param gizmoLayer The utility layer the gizmo will be added to
  133980. * @param thickness display gizmo axis thickness
  133981. */
  133982. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133983. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133984. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133985. /**
  133986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133987. */
  133988. set snapDistance(value: number);
  133989. get snapDistance(): number;
  133990. /**
  133991. * Ratio for the scale of the gizmo (Default: 1)
  133992. */
  133993. set scaleRatio(value: number);
  133994. get scaleRatio(): number;
  133995. /**
  133996. * Sensitivity factor for dragging (Default: 1)
  133997. */
  133998. set sensitivity(value: number);
  133999. get sensitivity(): number;
  134000. /**
  134001. * Disposes of the gizmo
  134002. */
  134003. dispose(): void;
  134004. }
  134005. }
  134006. declare module BABYLON {
  134007. /**
  134008. * Single axis scale gizmo
  134009. */
  134010. export class AxisScaleGizmo extends Gizmo {
  134011. /**
  134012. * Drag behavior responsible for the gizmos dragging interactions
  134013. */
  134014. dragBehavior: PointerDragBehavior;
  134015. private _pointerObserver;
  134016. /**
  134017. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134018. */
  134019. snapDistance: number;
  134020. /**
  134021. * Event that fires each time the gizmo snaps to a new location.
  134022. * * snapDistance is the the change in distance
  134023. */
  134024. onSnapObservable: Observable<{
  134025. snapDistance: number;
  134026. }>;
  134027. /**
  134028. * If the scaling operation should be done on all axis (default: false)
  134029. */
  134030. uniformScaling: boolean;
  134031. /**
  134032. * Custom sensitivity value for the drag strength
  134033. */
  134034. sensitivity: number;
  134035. private _isEnabled;
  134036. private _parent;
  134037. private _arrow;
  134038. private _coloredMaterial;
  134039. private _hoverMaterial;
  134040. /**
  134041. * Creates an AxisScaleGizmo
  134042. * @param gizmoLayer The utility layer the gizmo will be added to
  134043. * @param dragAxis The axis which the gizmo will be able to scale on
  134044. * @param color The color of the gizmo
  134045. * @param thickness display gizmo axis thickness
  134046. */
  134047. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134048. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134049. /**
  134050. * If the gizmo is enabled
  134051. */
  134052. set isEnabled(value: boolean);
  134053. get isEnabled(): boolean;
  134054. /**
  134055. * Disposes of the gizmo
  134056. */
  134057. dispose(): void;
  134058. /**
  134059. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134060. * @param mesh The mesh to replace the default mesh of the gizmo
  134061. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134062. */
  134063. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134064. }
  134065. }
  134066. declare module BABYLON {
  134067. /**
  134068. * Bounding box gizmo
  134069. */
  134070. export class BoundingBoxGizmo extends Gizmo {
  134071. private _lineBoundingBox;
  134072. private _rotateSpheresParent;
  134073. private _scaleBoxesParent;
  134074. private _boundingDimensions;
  134075. private _renderObserver;
  134076. private _pointerObserver;
  134077. private _scaleDragSpeed;
  134078. private _tmpQuaternion;
  134079. private _tmpVector;
  134080. private _tmpRotationMatrix;
  134081. /**
  134082. * 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)
  134083. */
  134084. ignoreChildren: boolean;
  134085. /**
  134086. * 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)
  134087. */
  134088. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134089. /**
  134090. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134091. */
  134092. rotationSphereSize: number;
  134093. /**
  134094. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134095. */
  134096. scaleBoxSize: number;
  134097. /**
  134098. * 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)
  134099. */
  134100. fixedDragMeshScreenSize: boolean;
  134101. /**
  134102. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134103. */
  134104. fixedDragMeshScreenSizeDistanceFactor: number;
  134105. /**
  134106. * Fired when a rotation sphere or scale box is dragged
  134107. */
  134108. onDragStartObservable: Observable<{}>;
  134109. /**
  134110. * Fired when a scale box is dragged
  134111. */
  134112. onScaleBoxDragObservable: Observable<{}>;
  134113. /**
  134114. * Fired when a scale box drag is ended
  134115. */
  134116. onScaleBoxDragEndObservable: Observable<{}>;
  134117. /**
  134118. * Fired when a rotation sphere is dragged
  134119. */
  134120. onRotationSphereDragObservable: Observable<{}>;
  134121. /**
  134122. * Fired when a rotation sphere drag is ended
  134123. */
  134124. onRotationSphereDragEndObservable: Observable<{}>;
  134125. /**
  134126. * 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)
  134127. */
  134128. scalePivot: Nullable<Vector3>;
  134129. /**
  134130. * Mesh used as a pivot to rotate the attached node
  134131. */
  134132. private _anchorMesh;
  134133. private _existingMeshScale;
  134134. private _dragMesh;
  134135. private pointerDragBehavior;
  134136. private coloredMaterial;
  134137. private hoverColoredMaterial;
  134138. /**
  134139. * Sets the color of the bounding box gizmo
  134140. * @param color the color to set
  134141. */
  134142. setColor(color: Color3): void;
  134143. /**
  134144. * Creates an BoundingBoxGizmo
  134145. * @param gizmoLayer The utility layer the gizmo will be added to
  134146. * @param color The color of the gizmo
  134147. */
  134148. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134149. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134150. private _selectNode;
  134151. /**
  134152. * Updates the bounding box information for the Gizmo
  134153. */
  134154. updateBoundingBox(): void;
  134155. private _updateRotationSpheres;
  134156. private _updateScaleBoxes;
  134157. /**
  134158. * Enables rotation on the specified axis and disables rotation on the others
  134159. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134160. */
  134161. setEnabledRotationAxis(axis: string): void;
  134162. /**
  134163. * Enables/disables scaling
  134164. * @param enable if scaling should be enabled
  134165. * @param homogeneousScaling defines if scaling should only be homogeneous
  134166. */
  134167. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134168. private _updateDummy;
  134169. /**
  134170. * Enables a pointer drag behavior on the bounding box of the gizmo
  134171. */
  134172. enableDragBehavior(): void;
  134173. /**
  134174. * Disposes of the gizmo
  134175. */
  134176. dispose(): void;
  134177. /**
  134178. * 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)
  134179. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134180. * @returns the bounding box mesh with the passed in mesh as a child
  134181. */
  134182. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134183. /**
  134184. * CustomMeshes are not supported by this gizmo
  134185. * @param mesh The mesh to replace the default mesh of the gizmo
  134186. */
  134187. setCustomMesh(mesh: Mesh): void;
  134188. }
  134189. }
  134190. declare module BABYLON {
  134191. /**
  134192. * Single plane rotation gizmo
  134193. */
  134194. export class PlaneRotationGizmo extends Gizmo {
  134195. /**
  134196. * Drag behavior responsible for the gizmos dragging interactions
  134197. */
  134198. dragBehavior: PointerDragBehavior;
  134199. private _pointerObserver;
  134200. /**
  134201. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134202. */
  134203. snapDistance: number;
  134204. /**
  134205. * Event that fires each time the gizmo snaps to a new location.
  134206. * * snapDistance is the the change in distance
  134207. */
  134208. onSnapObservable: Observable<{
  134209. snapDistance: number;
  134210. }>;
  134211. private _isEnabled;
  134212. private _parent;
  134213. /**
  134214. * Creates a PlaneRotationGizmo
  134215. * @param gizmoLayer The utility layer the gizmo will be added to
  134216. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134217. * @param color The color of the gizmo
  134218. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134219. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134220. * @param thickness display gizmo axis thickness
  134221. */
  134222. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134223. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134224. /**
  134225. * If the gizmo is enabled
  134226. */
  134227. set isEnabled(value: boolean);
  134228. get isEnabled(): boolean;
  134229. /**
  134230. * Disposes of the gizmo
  134231. */
  134232. dispose(): void;
  134233. }
  134234. }
  134235. declare module BABYLON {
  134236. /**
  134237. * Gizmo that enables rotating a mesh along 3 axis
  134238. */
  134239. export class RotationGizmo extends Gizmo {
  134240. /**
  134241. * Internal gizmo used for interactions on the x axis
  134242. */
  134243. xGizmo: PlaneRotationGizmo;
  134244. /**
  134245. * Internal gizmo used for interactions on the y axis
  134246. */
  134247. yGizmo: PlaneRotationGizmo;
  134248. /**
  134249. * Internal gizmo used for interactions on the z axis
  134250. */
  134251. zGizmo: PlaneRotationGizmo;
  134252. /** Fires an event when any of it's sub gizmos are dragged */
  134253. onDragStartObservable: Observable<unknown>;
  134254. /** Fires an event when any of it's sub gizmos are released from dragging */
  134255. onDragEndObservable: Observable<unknown>;
  134256. private _meshAttached;
  134257. private _nodeAttached;
  134258. get attachedMesh(): Nullable<AbstractMesh>;
  134259. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134260. get attachedNode(): Nullable<Node>;
  134261. set attachedNode(node: Nullable<Node>);
  134262. /**
  134263. * True when the mouse pointer is hovering a gizmo mesh
  134264. */
  134265. get isHovered(): boolean;
  134266. /**
  134267. * Creates a RotationGizmo
  134268. * @param gizmoLayer The utility layer the gizmo will be added to
  134269. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134270. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134271. * @param thickness display gizmo axis thickness
  134272. */
  134273. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134274. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134275. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134276. /**
  134277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134278. */
  134279. set snapDistance(value: number);
  134280. get snapDistance(): number;
  134281. /**
  134282. * Ratio for the scale of the gizmo (Default: 1)
  134283. */
  134284. set scaleRatio(value: number);
  134285. get scaleRatio(): number;
  134286. /**
  134287. * Disposes of the gizmo
  134288. */
  134289. dispose(): void;
  134290. /**
  134291. * CustomMeshes are not supported by this gizmo
  134292. * @param mesh The mesh to replace the default mesh of the gizmo
  134293. */
  134294. setCustomMesh(mesh: Mesh): void;
  134295. }
  134296. }
  134297. declare module BABYLON {
  134298. /**
  134299. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134300. */
  134301. export class GizmoManager implements IDisposable {
  134302. private scene;
  134303. /**
  134304. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134305. */
  134306. gizmos: {
  134307. positionGizmo: Nullable<PositionGizmo>;
  134308. rotationGizmo: Nullable<RotationGizmo>;
  134309. scaleGizmo: Nullable<ScaleGizmo>;
  134310. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134311. };
  134312. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134313. clearGizmoOnEmptyPointerEvent: boolean;
  134314. /** Fires an event when the manager is attached to a mesh */
  134315. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134316. /** Fires an event when the manager is attached to a node */
  134317. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134318. private _gizmosEnabled;
  134319. private _pointerObserver;
  134320. private _attachedMesh;
  134321. private _attachedNode;
  134322. private _boundingBoxColor;
  134323. private _defaultUtilityLayer;
  134324. private _defaultKeepDepthUtilityLayer;
  134325. private _thickness;
  134326. /**
  134327. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134328. */
  134329. boundingBoxDragBehavior: SixDofDragBehavior;
  134330. /**
  134331. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134332. */
  134333. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134334. /**
  134335. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134336. */
  134337. attachableNodes: Nullable<Array<Node>>;
  134338. /**
  134339. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134340. */
  134341. usePointerToAttachGizmos: boolean;
  134342. /**
  134343. * Utility layer that the bounding box gizmo belongs to
  134344. */
  134345. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134346. /**
  134347. * Utility layer that all gizmos besides bounding box belong to
  134348. */
  134349. get utilityLayer(): UtilityLayerRenderer;
  134350. /**
  134351. * True when the mouse pointer is hovering a gizmo mesh
  134352. */
  134353. get isHovered(): boolean;
  134354. /**
  134355. * Instatiates a gizmo manager
  134356. * @param scene the scene to overlay the gizmos on top of
  134357. * @param thickness display gizmo axis thickness
  134358. */
  134359. constructor(scene: Scene, thickness?: number);
  134360. /**
  134361. * Attaches a set of gizmos to the specified mesh
  134362. * @param mesh The mesh the gizmo's should be attached to
  134363. */
  134364. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134365. /**
  134366. * Attaches a set of gizmos to the specified node
  134367. * @param node The node the gizmo's should be attached to
  134368. */
  134369. attachToNode(node: Nullable<Node>): void;
  134370. /**
  134371. * If the position gizmo is enabled
  134372. */
  134373. set positionGizmoEnabled(value: boolean);
  134374. get positionGizmoEnabled(): boolean;
  134375. /**
  134376. * If the rotation gizmo is enabled
  134377. */
  134378. set rotationGizmoEnabled(value: boolean);
  134379. get rotationGizmoEnabled(): boolean;
  134380. /**
  134381. * If the scale gizmo is enabled
  134382. */
  134383. set scaleGizmoEnabled(value: boolean);
  134384. get scaleGizmoEnabled(): boolean;
  134385. /**
  134386. * If the boundingBox gizmo is enabled
  134387. */
  134388. set boundingBoxGizmoEnabled(value: boolean);
  134389. get boundingBoxGizmoEnabled(): boolean;
  134390. /**
  134391. * Disposes of the gizmo manager
  134392. */
  134393. dispose(): void;
  134394. }
  134395. }
  134396. declare module BABYLON {
  134397. /**
  134398. * A directional light is defined by a direction (what a surprise!).
  134399. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134400. * 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.
  134401. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134402. */
  134403. export class DirectionalLight extends ShadowLight {
  134404. private _shadowFrustumSize;
  134405. /**
  134406. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134407. */
  134408. get shadowFrustumSize(): number;
  134409. /**
  134410. * Specifies a fix frustum size for the shadow generation.
  134411. */
  134412. set shadowFrustumSize(value: number);
  134413. private _shadowOrthoScale;
  134414. /**
  134415. * Gets the shadow projection scale against the optimal computed one.
  134416. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134417. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134418. */
  134419. get shadowOrthoScale(): number;
  134420. /**
  134421. * Sets the shadow projection scale against the optimal computed one.
  134422. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134423. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134424. */
  134425. set shadowOrthoScale(value: number);
  134426. /**
  134427. * Automatically compute the projection matrix to best fit (including all the casters)
  134428. * on each frame.
  134429. */
  134430. autoUpdateExtends: boolean;
  134431. /**
  134432. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134433. * on each frame. autoUpdateExtends must be set to true for this to work
  134434. */
  134435. autoCalcShadowZBounds: boolean;
  134436. private _orthoLeft;
  134437. private _orthoRight;
  134438. private _orthoTop;
  134439. private _orthoBottom;
  134440. /**
  134441. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134442. * The directional light is emitted from everywhere in the given direction.
  134443. * It can cast shadows.
  134444. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134445. * @param name The friendly name of the light
  134446. * @param direction The direction of the light
  134447. * @param scene The scene the light belongs to
  134448. */
  134449. constructor(name: string, direction: Vector3, scene: Scene);
  134450. /**
  134451. * Returns the string "DirectionalLight".
  134452. * @return The class name
  134453. */
  134454. getClassName(): string;
  134455. /**
  134456. * Returns the integer 1.
  134457. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134458. */
  134459. getTypeID(): number;
  134460. /**
  134461. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134462. * Returns the DirectionalLight Shadow projection matrix.
  134463. */
  134464. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134465. /**
  134466. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134467. * Returns the DirectionalLight Shadow projection matrix.
  134468. */
  134469. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134470. /**
  134471. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134472. * Returns the DirectionalLight Shadow projection matrix.
  134473. */
  134474. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134475. protected _buildUniformLayout(): void;
  134476. /**
  134477. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134478. * @param effect The effect to update
  134479. * @param lightIndex The index of the light in the effect to update
  134480. * @returns The directional light
  134481. */
  134482. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134483. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134484. /**
  134485. * Gets the minZ used for shadow according to both the scene and the light.
  134486. *
  134487. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134488. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134489. * @param activeCamera The camera we are returning the min for
  134490. * @returns the depth min z
  134491. */
  134492. getDepthMinZ(activeCamera: Camera): number;
  134493. /**
  134494. * Gets the maxZ used for shadow according to both the scene and the light.
  134495. *
  134496. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134497. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134498. * @param activeCamera The camera we are returning the max for
  134499. * @returns the depth max z
  134500. */
  134501. getDepthMaxZ(activeCamera: Camera): number;
  134502. /**
  134503. * Prepares the list of defines specific to the light type.
  134504. * @param defines the list of defines
  134505. * @param lightIndex defines the index of the light for the effect
  134506. */
  134507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134508. }
  134509. }
  134510. declare module BABYLON {
  134511. /**
  134512. * Class containing static functions to help procedurally build meshes
  134513. */
  134514. export class HemisphereBuilder {
  134515. /**
  134516. * Creates a hemisphere mesh
  134517. * @param name defines the name of the mesh
  134518. * @param options defines the options used to create the mesh
  134519. * @param scene defines the hosting scene
  134520. * @returns the hemisphere mesh
  134521. */
  134522. static CreateHemisphere(name: string, options: {
  134523. segments?: number;
  134524. diameter?: number;
  134525. sideOrientation?: number;
  134526. }, scene: any): Mesh;
  134527. }
  134528. }
  134529. declare module BABYLON {
  134530. /**
  134531. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134532. * These values define a cone of light starting from the position, emitting toward the direction.
  134533. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134534. * and the exponent defines the speed of the decay of the light with distance (reach).
  134535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134536. */
  134537. export class SpotLight extends ShadowLight {
  134538. private _angle;
  134539. private _innerAngle;
  134540. private _cosHalfAngle;
  134541. private _lightAngleScale;
  134542. private _lightAngleOffset;
  134543. /**
  134544. * Gets the cone angle of the spot light in Radians.
  134545. */
  134546. get angle(): number;
  134547. /**
  134548. * Sets the cone angle of the spot light in Radians.
  134549. */
  134550. set angle(value: number);
  134551. /**
  134552. * Only used in gltf falloff mode, this defines the angle where
  134553. * the directional falloff will start before cutting at angle which could be seen
  134554. * as outer angle.
  134555. */
  134556. get innerAngle(): number;
  134557. /**
  134558. * Only used in gltf falloff mode, this defines the angle where
  134559. * the directional falloff will start before cutting at angle which could be seen
  134560. * as outer angle.
  134561. */
  134562. set innerAngle(value: number);
  134563. private _shadowAngleScale;
  134564. /**
  134565. * Allows scaling the angle of the light for shadow generation only.
  134566. */
  134567. get shadowAngleScale(): number;
  134568. /**
  134569. * Allows scaling the angle of the light for shadow generation only.
  134570. */
  134571. set shadowAngleScale(value: number);
  134572. /**
  134573. * The light decay speed with the distance from the emission spot.
  134574. */
  134575. exponent: number;
  134576. private _projectionTextureMatrix;
  134577. /**
  134578. * Allows reading the projecton texture
  134579. */
  134580. get projectionTextureMatrix(): Matrix;
  134581. protected _projectionTextureLightNear: number;
  134582. /**
  134583. * Gets the near clip of the Spotlight for texture projection.
  134584. */
  134585. get projectionTextureLightNear(): number;
  134586. /**
  134587. * Sets the near clip of the Spotlight for texture projection.
  134588. */
  134589. set projectionTextureLightNear(value: number);
  134590. protected _projectionTextureLightFar: number;
  134591. /**
  134592. * Gets the far clip of the Spotlight for texture projection.
  134593. */
  134594. get projectionTextureLightFar(): number;
  134595. /**
  134596. * Sets the far clip of the Spotlight for texture projection.
  134597. */
  134598. set projectionTextureLightFar(value: number);
  134599. protected _projectionTextureUpDirection: Vector3;
  134600. /**
  134601. * Gets the Up vector of the Spotlight for texture projection.
  134602. */
  134603. get projectionTextureUpDirection(): Vector3;
  134604. /**
  134605. * Sets the Up vector of the Spotlight for texture projection.
  134606. */
  134607. set projectionTextureUpDirection(value: Vector3);
  134608. private _projectionTexture;
  134609. /**
  134610. * Gets the projection texture of the light.
  134611. */
  134612. get projectionTexture(): Nullable<BaseTexture>;
  134613. /**
  134614. * Sets the projection texture of the light.
  134615. */
  134616. set projectionTexture(value: Nullable<BaseTexture>);
  134617. private _projectionTextureViewLightDirty;
  134618. private _projectionTextureProjectionLightDirty;
  134619. private _projectionTextureDirty;
  134620. private _projectionTextureViewTargetVector;
  134621. private _projectionTextureViewLightMatrix;
  134622. private _projectionTextureProjectionLightMatrix;
  134623. private _projectionTextureScalingMatrix;
  134624. /**
  134625. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134626. * It can cast shadows.
  134627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134628. * @param name The light friendly name
  134629. * @param position The position of the spot light in the scene
  134630. * @param direction The direction of the light in the scene
  134631. * @param angle The cone angle of the light in Radians
  134632. * @param exponent The light decay speed with the distance from the emission spot
  134633. * @param scene The scene the lights belongs to
  134634. */
  134635. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134636. /**
  134637. * Returns the string "SpotLight".
  134638. * @returns the class name
  134639. */
  134640. getClassName(): string;
  134641. /**
  134642. * Returns the integer 2.
  134643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134644. */
  134645. getTypeID(): number;
  134646. /**
  134647. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134648. */
  134649. protected _setDirection(value: Vector3): void;
  134650. /**
  134651. * Overrides the position setter to recompute the projection texture view light Matrix.
  134652. */
  134653. protected _setPosition(value: Vector3): void;
  134654. /**
  134655. * 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.
  134656. * Returns the SpotLight.
  134657. */
  134658. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134659. protected _computeProjectionTextureViewLightMatrix(): void;
  134660. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134661. /**
  134662. * Main function for light texture projection matrix computing.
  134663. */
  134664. protected _computeProjectionTextureMatrix(): void;
  134665. protected _buildUniformLayout(): void;
  134666. private _computeAngleValues;
  134667. /**
  134668. * Sets the passed Effect "effect" with the Light textures.
  134669. * @param effect The effect to update
  134670. * @param lightIndex The index of the light in the effect to update
  134671. * @returns The light
  134672. */
  134673. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134674. /**
  134675. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134676. * @param effect The effect to update
  134677. * @param lightIndex The index of the light in the effect to update
  134678. * @returns The spot light
  134679. */
  134680. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134681. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134682. /**
  134683. * Disposes the light and the associated resources.
  134684. */
  134685. dispose(): void;
  134686. /**
  134687. * Prepares the list of defines specific to the light type.
  134688. * @param defines the list of defines
  134689. * @param lightIndex defines the index of the light for the effect
  134690. */
  134691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134692. }
  134693. }
  134694. declare module BABYLON {
  134695. /**
  134696. * Gizmo that enables viewing a light
  134697. */
  134698. export class LightGizmo extends Gizmo {
  134699. private _lightMesh;
  134700. private _material;
  134701. private _cachedPosition;
  134702. private _cachedForward;
  134703. private _attachedMeshParent;
  134704. private _pointerObserver;
  134705. /**
  134706. * Event that fires each time the gizmo is clicked
  134707. */
  134708. onClickedObservable: Observable<Light>;
  134709. /**
  134710. * Creates a LightGizmo
  134711. * @param gizmoLayer The utility layer the gizmo will be added to
  134712. */
  134713. constructor(gizmoLayer?: UtilityLayerRenderer);
  134714. private _light;
  134715. /**
  134716. * The light that the gizmo is attached to
  134717. */
  134718. set light(light: Nullable<Light>);
  134719. get light(): Nullable<Light>;
  134720. /**
  134721. * Gets the material used to render the light gizmo
  134722. */
  134723. get material(): StandardMaterial;
  134724. /**
  134725. * @hidden
  134726. * Updates the gizmo to match the attached mesh's position/rotation
  134727. */
  134728. protected _update(): void;
  134729. private static _Scale;
  134730. /**
  134731. * Creates the lines for a light mesh
  134732. */
  134733. private static _CreateLightLines;
  134734. /**
  134735. * Disposes of the light gizmo
  134736. */
  134737. dispose(): void;
  134738. private static _CreateHemisphericLightMesh;
  134739. private static _CreatePointLightMesh;
  134740. private static _CreateSpotLightMesh;
  134741. private static _CreateDirectionalLightMesh;
  134742. }
  134743. }
  134744. declare module BABYLON {
  134745. /**
  134746. * Gizmo that enables viewing a camera
  134747. */
  134748. export class CameraGizmo extends Gizmo {
  134749. private _cameraMesh;
  134750. private _cameraLinesMesh;
  134751. private _material;
  134752. private _pointerObserver;
  134753. /**
  134754. * Event that fires each time the gizmo is clicked
  134755. */
  134756. onClickedObservable: Observable<Camera>;
  134757. /**
  134758. * Creates a CameraGizmo
  134759. * @param gizmoLayer The utility layer the gizmo will be added to
  134760. */
  134761. constructor(gizmoLayer?: UtilityLayerRenderer);
  134762. private _camera;
  134763. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134764. get displayFrustum(): boolean;
  134765. set displayFrustum(value: boolean);
  134766. /**
  134767. * The camera that the gizmo is attached to
  134768. */
  134769. set camera(camera: Nullable<Camera>);
  134770. get camera(): Nullable<Camera>;
  134771. /**
  134772. * Gets the material used to render the camera gizmo
  134773. */
  134774. get material(): StandardMaterial;
  134775. /**
  134776. * @hidden
  134777. * Updates the gizmo to match the attached mesh's position/rotation
  134778. */
  134779. protected _update(): void;
  134780. private static _Scale;
  134781. private _invProjection;
  134782. /**
  134783. * Disposes of the camera gizmo
  134784. */
  134785. dispose(): void;
  134786. private static _CreateCameraMesh;
  134787. private static _CreateCameraFrustum;
  134788. }
  134789. }
  134790. declare module BABYLON {
  134791. /** @hidden */
  134792. export var backgroundFragmentDeclaration: {
  134793. name: string;
  134794. shader: string;
  134795. };
  134796. }
  134797. declare module BABYLON {
  134798. /** @hidden */
  134799. export var backgroundUboDeclaration: {
  134800. name: string;
  134801. shader: string;
  134802. };
  134803. }
  134804. declare module BABYLON {
  134805. /** @hidden */
  134806. export var backgroundPixelShader: {
  134807. name: string;
  134808. shader: string;
  134809. };
  134810. }
  134811. declare module BABYLON {
  134812. /** @hidden */
  134813. export var backgroundVertexDeclaration: {
  134814. name: string;
  134815. shader: string;
  134816. };
  134817. }
  134818. declare module BABYLON {
  134819. /** @hidden */
  134820. export var backgroundVertexShader: {
  134821. name: string;
  134822. shader: string;
  134823. };
  134824. }
  134825. declare module BABYLON {
  134826. /**
  134827. * Background material used to create an efficient environement around your scene.
  134828. */
  134829. export class BackgroundMaterial extends PushMaterial {
  134830. /**
  134831. * Standard reflectance value at parallel view angle.
  134832. */
  134833. static StandardReflectance0: number;
  134834. /**
  134835. * Standard reflectance value at grazing angle.
  134836. */
  134837. static StandardReflectance90: number;
  134838. protected _primaryColor: Color3;
  134839. /**
  134840. * Key light Color (multiply against the environement texture)
  134841. */
  134842. primaryColor: Color3;
  134843. protected __perceptualColor: Nullable<Color3>;
  134844. /**
  134845. * Experimental Internal Use Only.
  134846. *
  134847. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134848. * This acts as a helper to set the primary color to a more "human friendly" value.
  134849. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134850. * output color as close as possible from the chosen value.
  134851. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134852. * part of lighting setup.)
  134853. */
  134854. get _perceptualColor(): Nullable<Color3>;
  134855. set _perceptualColor(value: Nullable<Color3>);
  134856. protected _primaryColorShadowLevel: float;
  134857. /**
  134858. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134859. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134860. */
  134861. get primaryColorShadowLevel(): float;
  134862. set primaryColorShadowLevel(value: float);
  134863. protected _primaryColorHighlightLevel: float;
  134864. /**
  134865. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134866. * The primary color is used at the level chosen to define what the white area would look.
  134867. */
  134868. get primaryColorHighlightLevel(): float;
  134869. set primaryColorHighlightLevel(value: float);
  134870. protected _reflectionTexture: Nullable<BaseTexture>;
  134871. /**
  134872. * Reflection Texture used in the material.
  134873. * Should be author in a specific way for the best result (refer to the documentation).
  134874. */
  134875. reflectionTexture: Nullable<BaseTexture>;
  134876. protected _reflectionBlur: float;
  134877. /**
  134878. * Reflection Texture level of blur.
  134879. *
  134880. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134881. * texture twice.
  134882. */
  134883. reflectionBlur: float;
  134884. protected _diffuseTexture: Nullable<BaseTexture>;
  134885. /**
  134886. * Diffuse Texture used in the material.
  134887. * Should be author in a specific way for the best result (refer to the documentation).
  134888. */
  134889. diffuseTexture: Nullable<BaseTexture>;
  134890. protected _shadowLights: Nullable<IShadowLight[]>;
  134891. /**
  134892. * Specify the list of lights casting shadow on the material.
  134893. * All scene shadow lights will be included if null.
  134894. */
  134895. shadowLights: Nullable<IShadowLight[]>;
  134896. protected _shadowLevel: float;
  134897. /**
  134898. * Helps adjusting the shadow to a softer level if required.
  134899. * 0 means black shadows and 1 means no shadows.
  134900. */
  134901. shadowLevel: float;
  134902. protected _sceneCenter: Vector3;
  134903. /**
  134904. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134905. * It is usually zero but might be interesting to modify according to your setup.
  134906. */
  134907. sceneCenter: Vector3;
  134908. protected _opacityFresnel: boolean;
  134909. /**
  134910. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134911. * This helps ensuring a nice transition when the camera goes under the ground.
  134912. */
  134913. opacityFresnel: boolean;
  134914. protected _reflectionFresnel: boolean;
  134915. /**
  134916. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134917. * This helps adding a mirror texture on the ground.
  134918. */
  134919. reflectionFresnel: boolean;
  134920. protected _reflectionFalloffDistance: number;
  134921. /**
  134922. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134923. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134924. */
  134925. reflectionFalloffDistance: number;
  134926. protected _reflectionAmount: number;
  134927. /**
  134928. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134929. */
  134930. reflectionAmount: number;
  134931. protected _reflectionReflectance0: number;
  134932. /**
  134933. * This specifies the weight of the reflection at grazing angle.
  134934. */
  134935. reflectionReflectance0: number;
  134936. protected _reflectionReflectance90: number;
  134937. /**
  134938. * This specifies the weight of the reflection at a perpendicular point of view.
  134939. */
  134940. reflectionReflectance90: number;
  134941. /**
  134942. * Sets the reflection reflectance fresnel values according to the default standard
  134943. * empirically know to work well :-)
  134944. */
  134945. set reflectionStandardFresnelWeight(value: number);
  134946. protected _useRGBColor: boolean;
  134947. /**
  134948. * Helps to directly use the maps channels instead of their level.
  134949. */
  134950. useRGBColor: boolean;
  134951. protected _enableNoise: boolean;
  134952. /**
  134953. * This helps reducing the banding effect that could occur on the background.
  134954. */
  134955. enableNoise: boolean;
  134956. /**
  134957. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134958. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134959. * Recommended to be keep at 1.0 except for special cases.
  134960. */
  134961. get fovMultiplier(): number;
  134962. set fovMultiplier(value: number);
  134963. private _fovMultiplier;
  134964. /**
  134965. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134966. */
  134967. useEquirectangularFOV: boolean;
  134968. private _maxSimultaneousLights;
  134969. /**
  134970. * Number of Simultaneous lights allowed on the material.
  134971. */
  134972. maxSimultaneousLights: int;
  134973. private _shadowOnly;
  134974. /**
  134975. * Make the material only render shadows
  134976. */
  134977. shadowOnly: boolean;
  134978. /**
  134979. * Default configuration related to image processing available in the Background Material.
  134980. */
  134981. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134982. /**
  134983. * Keep track of the image processing observer to allow dispose and replace.
  134984. */
  134985. private _imageProcessingObserver;
  134986. /**
  134987. * Attaches a new image processing configuration to the PBR Material.
  134988. * @param configuration (if null the scene configuration will be use)
  134989. */
  134990. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134991. /**
  134992. * Gets the image processing configuration used either in this material.
  134993. */
  134994. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134995. /**
  134996. * Sets the Default image processing configuration used either in the this material.
  134997. *
  134998. * If sets to null, the scene one is in use.
  134999. */
  135000. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135001. /**
  135002. * Gets wether the color curves effect is enabled.
  135003. */
  135004. get cameraColorCurvesEnabled(): boolean;
  135005. /**
  135006. * Sets wether the color curves effect is enabled.
  135007. */
  135008. set cameraColorCurvesEnabled(value: boolean);
  135009. /**
  135010. * Gets wether the color grading effect is enabled.
  135011. */
  135012. get cameraColorGradingEnabled(): boolean;
  135013. /**
  135014. * Gets wether the color grading effect is enabled.
  135015. */
  135016. set cameraColorGradingEnabled(value: boolean);
  135017. /**
  135018. * Gets wether tonemapping is enabled or not.
  135019. */
  135020. get cameraToneMappingEnabled(): boolean;
  135021. /**
  135022. * Sets wether tonemapping is enabled or not
  135023. */
  135024. set cameraToneMappingEnabled(value: boolean);
  135025. /**
  135026. * The camera exposure used on this material.
  135027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135028. * This corresponds to a photographic exposure.
  135029. */
  135030. get cameraExposure(): float;
  135031. /**
  135032. * The camera exposure used on this material.
  135033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135034. * This corresponds to a photographic exposure.
  135035. */
  135036. set cameraExposure(value: float);
  135037. /**
  135038. * Gets The camera contrast used on this material.
  135039. */
  135040. get cameraContrast(): float;
  135041. /**
  135042. * Sets The camera contrast used on this material.
  135043. */
  135044. set cameraContrast(value: float);
  135045. /**
  135046. * Gets the Color Grading 2D Lookup Texture.
  135047. */
  135048. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135049. /**
  135050. * Sets the Color Grading 2D Lookup Texture.
  135051. */
  135052. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135053. /**
  135054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135056. * 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;
  135057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135058. */
  135059. get cameraColorCurves(): Nullable<ColorCurves>;
  135060. /**
  135061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135063. * 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;
  135064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135065. */
  135066. set cameraColorCurves(value: Nullable<ColorCurves>);
  135067. /**
  135068. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135069. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135070. */
  135071. switchToBGR: boolean;
  135072. private _renderTargets;
  135073. private _reflectionControls;
  135074. private _white;
  135075. private _primaryShadowColor;
  135076. private _primaryHighlightColor;
  135077. /**
  135078. * Instantiates a Background Material in the given scene
  135079. * @param name The friendly name of the material
  135080. * @param scene The scene to add the material to
  135081. */
  135082. constructor(name: string, scene: Scene);
  135083. /**
  135084. * Gets a boolean indicating that current material needs to register RTT
  135085. */
  135086. get hasRenderTargetTextures(): boolean;
  135087. /**
  135088. * The entire material has been created in order to prevent overdraw.
  135089. * @returns false
  135090. */
  135091. needAlphaTesting(): boolean;
  135092. /**
  135093. * The entire material has been created in order to prevent overdraw.
  135094. * @returns true if blending is enable
  135095. */
  135096. needAlphaBlending(): boolean;
  135097. /**
  135098. * Checks wether the material is ready to be rendered for a given mesh.
  135099. * @param mesh The mesh to render
  135100. * @param subMesh The submesh to check against
  135101. * @param useInstances Specify wether or not the material is used with instances
  135102. * @returns true if all the dependencies are ready (Textures, Effects...)
  135103. */
  135104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135105. /**
  135106. * Compute the primary color according to the chosen perceptual color.
  135107. */
  135108. private _computePrimaryColorFromPerceptualColor;
  135109. /**
  135110. * Compute the highlights and shadow colors according to their chosen levels.
  135111. */
  135112. private _computePrimaryColors;
  135113. /**
  135114. * Build the uniform buffer used in the material.
  135115. */
  135116. buildUniformLayout(): void;
  135117. /**
  135118. * Unbind the material.
  135119. */
  135120. unbind(): void;
  135121. /**
  135122. * Bind only the world matrix to the material.
  135123. * @param world The world matrix to bind.
  135124. */
  135125. bindOnlyWorldMatrix(world: Matrix): void;
  135126. /**
  135127. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135128. * @param world The world matrix to bind.
  135129. * @param subMesh The submesh to bind for.
  135130. */
  135131. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135132. /**
  135133. * Checks to see if a texture is used in the material.
  135134. * @param texture - Base texture to use.
  135135. * @returns - Boolean specifying if a texture is used in the material.
  135136. */
  135137. hasTexture(texture: BaseTexture): boolean;
  135138. /**
  135139. * Dispose the material.
  135140. * @param forceDisposeEffect Force disposal of the associated effect.
  135141. * @param forceDisposeTextures Force disposal of the associated textures.
  135142. */
  135143. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135144. /**
  135145. * Clones the material.
  135146. * @param name The cloned name.
  135147. * @returns The cloned material.
  135148. */
  135149. clone(name: string): BackgroundMaterial;
  135150. /**
  135151. * Serializes the current material to its JSON representation.
  135152. * @returns The JSON representation.
  135153. */
  135154. serialize(): any;
  135155. /**
  135156. * Gets the class name of the material
  135157. * @returns "BackgroundMaterial"
  135158. */
  135159. getClassName(): string;
  135160. /**
  135161. * Parse a JSON input to create back a background material.
  135162. * @param source The JSON data to parse
  135163. * @param scene The scene to create the parsed material in
  135164. * @param rootUrl The root url of the assets the material depends upon
  135165. * @returns the instantiated BackgroundMaterial.
  135166. */
  135167. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135168. }
  135169. }
  135170. declare module BABYLON {
  135171. /**
  135172. * Represents the different options available during the creation of
  135173. * a Environment helper.
  135174. *
  135175. * This can control the default ground, skybox and image processing setup of your scene.
  135176. */
  135177. export interface IEnvironmentHelperOptions {
  135178. /**
  135179. * Specifies whether or not to create a ground.
  135180. * True by default.
  135181. */
  135182. createGround: boolean;
  135183. /**
  135184. * Specifies the ground size.
  135185. * 15 by default.
  135186. */
  135187. groundSize: number;
  135188. /**
  135189. * The texture used on the ground for the main color.
  135190. * Comes from the BabylonJS CDN by default.
  135191. *
  135192. * Remarks: Can be either a texture or a url.
  135193. */
  135194. groundTexture: string | BaseTexture;
  135195. /**
  135196. * The color mixed in the ground texture by default.
  135197. * BabylonJS clearColor by default.
  135198. */
  135199. groundColor: Color3;
  135200. /**
  135201. * Specifies the ground opacity.
  135202. * 1 by default.
  135203. */
  135204. groundOpacity: number;
  135205. /**
  135206. * Enables the ground to receive shadows.
  135207. * True by default.
  135208. */
  135209. enableGroundShadow: boolean;
  135210. /**
  135211. * Helps preventing the shadow to be fully black on the ground.
  135212. * 0.5 by default.
  135213. */
  135214. groundShadowLevel: number;
  135215. /**
  135216. * Creates a mirror texture attach to the ground.
  135217. * false by default.
  135218. */
  135219. enableGroundMirror: boolean;
  135220. /**
  135221. * Specifies the ground mirror size ratio.
  135222. * 0.3 by default as the default kernel is 64.
  135223. */
  135224. groundMirrorSizeRatio: number;
  135225. /**
  135226. * Specifies the ground mirror blur kernel size.
  135227. * 64 by default.
  135228. */
  135229. groundMirrorBlurKernel: number;
  135230. /**
  135231. * Specifies the ground mirror visibility amount.
  135232. * 1 by default
  135233. */
  135234. groundMirrorAmount: number;
  135235. /**
  135236. * Specifies the ground mirror reflectance weight.
  135237. * This uses the standard weight of the background material to setup the fresnel effect
  135238. * of the mirror.
  135239. * 1 by default.
  135240. */
  135241. groundMirrorFresnelWeight: number;
  135242. /**
  135243. * Specifies the ground mirror Falloff distance.
  135244. * This can helps reducing the size of the reflection.
  135245. * 0 by Default.
  135246. */
  135247. groundMirrorFallOffDistance: number;
  135248. /**
  135249. * Specifies the ground mirror texture type.
  135250. * Unsigned Int by Default.
  135251. */
  135252. groundMirrorTextureType: number;
  135253. /**
  135254. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135255. * the shown objects.
  135256. */
  135257. groundYBias: number;
  135258. /**
  135259. * Specifies whether or not to create a skybox.
  135260. * True by default.
  135261. */
  135262. createSkybox: boolean;
  135263. /**
  135264. * Specifies the skybox size.
  135265. * 20 by default.
  135266. */
  135267. skyboxSize: number;
  135268. /**
  135269. * The texture used on the skybox for the main color.
  135270. * Comes from the BabylonJS CDN by default.
  135271. *
  135272. * Remarks: Can be either a texture or a url.
  135273. */
  135274. skyboxTexture: string | BaseTexture;
  135275. /**
  135276. * The color mixed in the skybox texture by default.
  135277. * BabylonJS clearColor by default.
  135278. */
  135279. skyboxColor: Color3;
  135280. /**
  135281. * The background rotation around the Y axis of the scene.
  135282. * This helps aligning the key lights of your scene with the background.
  135283. * 0 by default.
  135284. */
  135285. backgroundYRotation: number;
  135286. /**
  135287. * Compute automatically the size of the elements to best fit with the scene.
  135288. */
  135289. sizeAuto: boolean;
  135290. /**
  135291. * Default position of the rootMesh if autoSize is not true.
  135292. */
  135293. rootPosition: Vector3;
  135294. /**
  135295. * Sets up the image processing in the scene.
  135296. * true by default.
  135297. */
  135298. setupImageProcessing: boolean;
  135299. /**
  135300. * The texture used as your environment texture in the scene.
  135301. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135302. *
  135303. * Remarks: Can be either a texture or a url.
  135304. */
  135305. environmentTexture: string | BaseTexture;
  135306. /**
  135307. * The value of the exposure to apply to the scene.
  135308. * 0.6 by default if setupImageProcessing is true.
  135309. */
  135310. cameraExposure: number;
  135311. /**
  135312. * The value of the contrast to apply to the scene.
  135313. * 1.6 by default if setupImageProcessing is true.
  135314. */
  135315. cameraContrast: number;
  135316. /**
  135317. * Specifies whether or not tonemapping should be enabled in the scene.
  135318. * true by default if setupImageProcessing is true.
  135319. */
  135320. toneMappingEnabled: boolean;
  135321. }
  135322. /**
  135323. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135324. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135325. * It also helps with the default setup of your imageProcessing configuration.
  135326. */
  135327. export class EnvironmentHelper {
  135328. /**
  135329. * Default ground texture URL.
  135330. */
  135331. private static _groundTextureCDNUrl;
  135332. /**
  135333. * Default skybox texture URL.
  135334. */
  135335. private static _skyboxTextureCDNUrl;
  135336. /**
  135337. * Default environment texture URL.
  135338. */
  135339. private static _environmentTextureCDNUrl;
  135340. /**
  135341. * Creates the default options for the helper.
  135342. */
  135343. private static _getDefaultOptions;
  135344. private _rootMesh;
  135345. /**
  135346. * Gets the root mesh created by the helper.
  135347. */
  135348. get rootMesh(): Mesh;
  135349. private _skybox;
  135350. /**
  135351. * Gets the skybox created by the helper.
  135352. */
  135353. get skybox(): Nullable<Mesh>;
  135354. private _skyboxTexture;
  135355. /**
  135356. * Gets the skybox texture created by the helper.
  135357. */
  135358. get skyboxTexture(): Nullable<BaseTexture>;
  135359. private _skyboxMaterial;
  135360. /**
  135361. * Gets the skybox material created by the helper.
  135362. */
  135363. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135364. private _ground;
  135365. /**
  135366. * Gets the ground mesh created by the helper.
  135367. */
  135368. get ground(): Nullable<Mesh>;
  135369. private _groundTexture;
  135370. /**
  135371. * Gets the ground texture created by the helper.
  135372. */
  135373. get groundTexture(): Nullable<BaseTexture>;
  135374. private _groundMirror;
  135375. /**
  135376. * Gets the ground mirror created by the helper.
  135377. */
  135378. get groundMirror(): Nullable<MirrorTexture>;
  135379. /**
  135380. * Gets the ground mirror render list to helps pushing the meshes
  135381. * you wish in the ground reflection.
  135382. */
  135383. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135384. private _groundMaterial;
  135385. /**
  135386. * Gets the ground material created by the helper.
  135387. */
  135388. get groundMaterial(): Nullable<BackgroundMaterial>;
  135389. /**
  135390. * Stores the creation options.
  135391. */
  135392. private readonly _scene;
  135393. private _options;
  135394. /**
  135395. * This observable will be notified with any error during the creation of the environment,
  135396. * mainly texture creation errors.
  135397. */
  135398. onErrorObservable: Observable<{
  135399. message?: string;
  135400. exception?: any;
  135401. }>;
  135402. /**
  135403. * constructor
  135404. * @param options Defines the options we want to customize the helper
  135405. * @param scene The scene to add the material to
  135406. */
  135407. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135408. /**
  135409. * Updates the background according to the new options
  135410. * @param options
  135411. */
  135412. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135413. /**
  135414. * Sets the primary color of all the available elements.
  135415. * @param color the main color to affect to the ground and the background
  135416. */
  135417. setMainColor(color: Color3): void;
  135418. /**
  135419. * Setup the image processing according to the specified options.
  135420. */
  135421. private _setupImageProcessing;
  135422. /**
  135423. * Setup the environment texture according to the specified options.
  135424. */
  135425. private _setupEnvironmentTexture;
  135426. /**
  135427. * Setup the background according to the specified options.
  135428. */
  135429. private _setupBackground;
  135430. /**
  135431. * Get the scene sizes according to the setup.
  135432. */
  135433. private _getSceneSize;
  135434. /**
  135435. * Setup the ground according to the specified options.
  135436. */
  135437. private _setupGround;
  135438. /**
  135439. * Setup the ground material according to the specified options.
  135440. */
  135441. private _setupGroundMaterial;
  135442. /**
  135443. * Setup the ground diffuse texture according to the specified options.
  135444. */
  135445. private _setupGroundDiffuseTexture;
  135446. /**
  135447. * Setup the ground mirror texture according to the specified options.
  135448. */
  135449. private _setupGroundMirrorTexture;
  135450. /**
  135451. * Setup the ground to receive the mirror texture.
  135452. */
  135453. private _setupMirrorInGroundMaterial;
  135454. /**
  135455. * Setup the skybox according to the specified options.
  135456. */
  135457. private _setupSkybox;
  135458. /**
  135459. * Setup the skybox material according to the specified options.
  135460. */
  135461. private _setupSkyboxMaterial;
  135462. /**
  135463. * Setup the skybox reflection texture according to the specified options.
  135464. */
  135465. private _setupSkyboxReflectionTexture;
  135466. private _errorHandler;
  135467. /**
  135468. * Dispose all the elements created by the Helper.
  135469. */
  135470. dispose(): void;
  135471. }
  135472. }
  135473. declare module BABYLON {
  135474. /**
  135475. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135476. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135477. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135478. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135479. */
  135480. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135481. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135482. /**
  135483. * Define the source as a Monoscopic panoramic 360/180.
  135484. */
  135485. static readonly MODE_MONOSCOPIC: number;
  135486. /**
  135487. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135488. */
  135489. static readonly MODE_TOPBOTTOM: number;
  135490. /**
  135491. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135492. */
  135493. static readonly MODE_SIDEBYSIDE: number;
  135494. private _halfDome;
  135495. protected _useDirectMapping: boolean;
  135496. /**
  135497. * The texture being displayed on the sphere
  135498. */
  135499. protected _texture: T;
  135500. /**
  135501. * Gets the texture being displayed on the sphere
  135502. */
  135503. get texture(): T;
  135504. /**
  135505. * Sets the texture being displayed on the sphere
  135506. */
  135507. set texture(newTexture: T);
  135508. /**
  135509. * The skybox material
  135510. */
  135511. protected _material: BackgroundMaterial;
  135512. /**
  135513. * The surface used for the dome
  135514. */
  135515. protected _mesh: Mesh;
  135516. /**
  135517. * Gets the mesh used for the dome.
  135518. */
  135519. get mesh(): Mesh;
  135520. /**
  135521. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135522. */
  135523. private _halfDomeMask;
  135524. /**
  135525. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135526. * Also see the options.resolution property.
  135527. */
  135528. get fovMultiplier(): number;
  135529. set fovMultiplier(value: number);
  135530. protected _textureMode: number;
  135531. /**
  135532. * Gets or set the current texture mode for the texture. It can be:
  135533. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135534. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135535. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135536. */
  135537. get textureMode(): number;
  135538. /**
  135539. * Sets the current texture mode for the texture. It can be:
  135540. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135541. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135542. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135543. */
  135544. set textureMode(value: number);
  135545. /**
  135546. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135547. */
  135548. get halfDome(): boolean;
  135549. /**
  135550. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135551. */
  135552. set halfDome(enabled: boolean);
  135553. /**
  135554. * Oberserver used in Stereoscopic VR Mode.
  135555. */
  135556. private _onBeforeCameraRenderObserver;
  135557. /**
  135558. * Observable raised when an error occured while loading the 360 image
  135559. */
  135560. onLoadErrorObservable: Observable<string>;
  135561. /**
  135562. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135563. * @param name Element's name, child elements will append suffixes for their own names.
  135564. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135565. * @param options An object containing optional or exposed sub element properties
  135566. */
  135567. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135568. resolution?: number;
  135569. clickToPlay?: boolean;
  135570. autoPlay?: boolean;
  135571. loop?: boolean;
  135572. size?: number;
  135573. poster?: string;
  135574. faceForward?: boolean;
  135575. useDirectMapping?: boolean;
  135576. halfDomeMode?: boolean;
  135577. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135578. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135579. protected _changeTextureMode(value: number): void;
  135580. /**
  135581. * Releases resources associated with this node.
  135582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135584. */
  135585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135586. }
  135587. }
  135588. declare module BABYLON {
  135589. /**
  135590. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135591. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135592. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135593. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135594. */
  135595. export class PhotoDome extends TextureDome<Texture> {
  135596. /**
  135597. * Define the image as a Monoscopic panoramic 360 image.
  135598. */
  135599. static readonly MODE_MONOSCOPIC: number;
  135600. /**
  135601. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135602. */
  135603. static readonly MODE_TOPBOTTOM: number;
  135604. /**
  135605. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135606. */
  135607. static readonly MODE_SIDEBYSIDE: number;
  135608. /**
  135609. * Gets or sets the texture being displayed on the sphere
  135610. */
  135611. get photoTexture(): Texture;
  135612. /**
  135613. * sets the texture being displayed on the sphere
  135614. */
  135615. set photoTexture(value: Texture);
  135616. /**
  135617. * Gets the current video mode for the video. It can be:
  135618. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135619. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135620. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135621. */
  135622. get imageMode(): number;
  135623. /**
  135624. * Sets the current video mode for the video. It can be:
  135625. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135626. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135627. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135628. */
  135629. set imageMode(value: number);
  135630. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135631. }
  135632. }
  135633. declare module BABYLON {
  135634. /**
  135635. * Class used to host RGBD texture specific utilities
  135636. */
  135637. export class RGBDTextureTools {
  135638. /**
  135639. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135640. * @param texture the texture to expand.
  135641. */
  135642. static ExpandRGBDTexture(texture: Texture): void;
  135643. }
  135644. }
  135645. declare module BABYLON {
  135646. /**
  135647. * Class used to host texture specific utilities
  135648. */
  135649. export class BRDFTextureTools {
  135650. /**
  135651. * Prevents texture cache collision
  135652. */
  135653. private static _instanceNumber;
  135654. /**
  135655. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135656. * @param scene defines the hosting scene
  135657. * @returns the environment BRDF texture
  135658. */
  135659. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135660. private static _environmentBRDFBase64Texture;
  135661. }
  135662. }
  135663. declare module BABYLON {
  135664. /**
  135665. * @hidden
  135666. */
  135667. export interface IMaterialClearCoatDefines {
  135668. CLEARCOAT: boolean;
  135669. CLEARCOAT_DEFAULTIOR: boolean;
  135670. CLEARCOAT_TEXTURE: boolean;
  135671. CLEARCOAT_TEXTUREDIRECTUV: number;
  135672. CLEARCOAT_BUMP: boolean;
  135673. CLEARCOAT_BUMPDIRECTUV: number;
  135674. CLEARCOAT_TINT: boolean;
  135675. CLEARCOAT_TINT_TEXTURE: boolean;
  135676. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135677. /** @hidden */
  135678. _areTexturesDirty: boolean;
  135679. }
  135680. /**
  135681. * Define the code related to the clear coat parameters of the pbr material.
  135682. */
  135683. export class PBRClearCoatConfiguration {
  135684. /**
  135685. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135686. * The default fits with a polyurethane material.
  135687. */
  135688. private static readonly _DefaultIndexOfRefraction;
  135689. private _isEnabled;
  135690. /**
  135691. * Defines if the clear coat is enabled in the material.
  135692. */
  135693. isEnabled: boolean;
  135694. /**
  135695. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135696. */
  135697. intensity: number;
  135698. /**
  135699. * Defines the clear coat layer roughness.
  135700. */
  135701. roughness: number;
  135702. private _indexOfRefraction;
  135703. /**
  135704. * Defines the index of refraction of the clear coat.
  135705. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135706. * The default fits with a polyurethane material.
  135707. * Changing the default value is more performance intensive.
  135708. */
  135709. indexOfRefraction: number;
  135710. private _texture;
  135711. /**
  135712. * Stores the clear coat values in a texture.
  135713. */
  135714. texture: Nullable<BaseTexture>;
  135715. private _bumpTexture;
  135716. /**
  135717. * Define the clear coat specific bump texture.
  135718. */
  135719. bumpTexture: Nullable<BaseTexture>;
  135720. private _isTintEnabled;
  135721. /**
  135722. * Defines if the clear coat tint is enabled in the material.
  135723. */
  135724. isTintEnabled: boolean;
  135725. /**
  135726. * Defines the clear coat tint of the material.
  135727. * This is only use if tint is enabled
  135728. */
  135729. tintColor: Color3;
  135730. /**
  135731. * Defines the distance at which the tint color should be found in the
  135732. * clear coat media.
  135733. * This is only use if tint is enabled
  135734. */
  135735. tintColorAtDistance: number;
  135736. /**
  135737. * Defines the clear coat layer thickness.
  135738. * This is only use if tint is enabled
  135739. */
  135740. tintThickness: number;
  135741. private _tintTexture;
  135742. /**
  135743. * Stores the clear tint values in a texture.
  135744. * rgb is tint
  135745. * a is a thickness factor
  135746. */
  135747. tintTexture: Nullable<BaseTexture>;
  135748. /** @hidden */
  135749. private _internalMarkAllSubMeshesAsTexturesDirty;
  135750. /** @hidden */
  135751. _markAllSubMeshesAsTexturesDirty(): void;
  135752. /**
  135753. * Instantiate a new istance of clear coat configuration.
  135754. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135755. */
  135756. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135757. /**
  135758. * Gets wehter the submesh is ready to be used or not.
  135759. * @param defines the list of "defines" to update.
  135760. * @param scene defines the scene the material belongs to.
  135761. * @param engine defines the engine the material belongs to.
  135762. * @param disableBumpMap defines wether the material disables bump or not.
  135763. * @returns - boolean indicating that the submesh is ready or not.
  135764. */
  135765. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135766. /**
  135767. * Checks to see if a texture is used in the material.
  135768. * @param defines the list of "defines" to update.
  135769. * @param scene defines the scene to the material belongs to.
  135770. */
  135771. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135772. /**
  135773. * Binds the material data.
  135774. * @param uniformBuffer defines the Uniform buffer to fill in.
  135775. * @param scene defines the scene the material belongs to.
  135776. * @param engine defines the engine the material belongs to.
  135777. * @param disableBumpMap defines wether the material disables bump or not.
  135778. * @param isFrozen defines wether the material is frozen or not.
  135779. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135780. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135781. */
  135782. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135783. /**
  135784. * Checks to see if a texture is used in the material.
  135785. * @param texture - Base texture to use.
  135786. * @returns - Boolean specifying if a texture is used in the material.
  135787. */
  135788. hasTexture(texture: BaseTexture): boolean;
  135789. /**
  135790. * Returns an array of the actively used textures.
  135791. * @param activeTextures Array of BaseTextures
  135792. */
  135793. getActiveTextures(activeTextures: BaseTexture[]): void;
  135794. /**
  135795. * Returns the animatable textures.
  135796. * @param animatables Array of animatable textures.
  135797. */
  135798. getAnimatables(animatables: IAnimatable[]): void;
  135799. /**
  135800. * Disposes the resources of the material.
  135801. * @param forceDisposeTextures - Forces the disposal of all textures.
  135802. */
  135803. dispose(forceDisposeTextures?: boolean): void;
  135804. /**
  135805. * Get the current class name of the texture useful for serialization or dynamic coding.
  135806. * @returns "PBRClearCoatConfiguration"
  135807. */
  135808. getClassName(): string;
  135809. /**
  135810. * Add fallbacks to the effect fallbacks list.
  135811. * @param defines defines the Base texture to use.
  135812. * @param fallbacks defines the current fallback list.
  135813. * @param currentRank defines the current fallback rank.
  135814. * @returns the new fallback rank.
  135815. */
  135816. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135817. /**
  135818. * Add the required uniforms to the current list.
  135819. * @param uniforms defines the current uniform list.
  135820. */
  135821. static AddUniforms(uniforms: string[]): void;
  135822. /**
  135823. * Add the required samplers to the current list.
  135824. * @param samplers defines the current sampler list.
  135825. */
  135826. static AddSamplers(samplers: string[]): void;
  135827. /**
  135828. * Add the required uniforms to the current buffer.
  135829. * @param uniformBuffer defines the current uniform buffer.
  135830. */
  135831. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135832. /**
  135833. * Makes a duplicate of the current configuration into another one.
  135834. * @param clearCoatConfiguration define the config where to copy the info
  135835. */
  135836. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135837. /**
  135838. * Serializes this clear coat configuration.
  135839. * @returns - An object with the serialized config.
  135840. */
  135841. serialize(): any;
  135842. /**
  135843. * Parses a anisotropy Configuration from a serialized object.
  135844. * @param source - Serialized object.
  135845. * @param scene Defines the scene we are parsing for
  135846. * @param rootUrl Defines the rootUrl to load from
  135847. */
  135848. parse(source: any, scene: Scene, rootUrl: string): void;
  135849. }
  135850. }
  135851. declare module BABYLON {
  135852. /**
  135853. * @hidden
  135854. */
  135855. export interface IMaterialAnisotropicDefines {
  135856. ANISOTROPIC: boolean;
  135857. ANISOTROPIC_TEXTURE: boolean;
  135858. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135859. MAINUV1: boolean;
  135860. _areTexturesDirty: boolean;
  135861. _needUVs: boolean;
  135862. }
  135863. /**
  135864. * Define the code related to the anisotropic parameters of the pbr material.
  135865. */
  135866. export class PBRAnisotropicConfiguration {
  135867. private _isEnabled;
  135868. /**
  135869. * Defines if the anisotropy is enabled in the material.
  135870. */
  135871. isEnabled: boolean;
  135872. /**
  135873. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135874. */
  135875. intensity: number;
  135876. /**
  135877. * Defines if the effect is along the tangents, bitangents or in between.
  135878. * By default, the effect is "strectching" the highlights along the tangents.
  135879. */
  135880. direction: Vector2;
  135881. private _texture;
  135882. /**
  135883. * Stores the anisotropy values in a texture.
  135884. * rg is direction (like normal from -1 to 1)
  135885. * b is a intensity
  135886. */
  135887. texture: Nullable<BaseTexture>;
  135888. /** @hidden */
  135889. private _internalMarkAllSubMeshesAsTexturesDirty;
  135890. /** @hidden */
  135891. _markAllSubMeshesAsTexturesDirty(): void;
  135892. /**
  135893. * Instantiate a new istance of anisotropy configuration.
  135894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135895. */
  135896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135897. /**
  135898. * Specifies that the submesh is ready to be used.
  135899. * @param defines the list of "defines" to update.
  135900. * @param scene defines the scene the material belongs to.
  135901. * @returns - boolean indicating that the submesh is ready or not.
  135902. */
  135903. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135904. /**
  135905. * Checks to see if a texture is used in the material.
  135906. * @param defines the list of "defines" to update.
  135907. * @param mesh the mesh we are preparing the defines for.
  135908. * @param scene defines the scene the material belongs to.
  135909. */
  135910. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135911. /**
  135912. * Binds the material data.
  135913. * @param uniformBuffer defines the Uniform buffer to fill in.
  135914. * @param scene defines the scene the material belongs to.
  135915. * @param isFrozen defines wether the material is frozen or not.
  135916. */
  135917. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135918. /**
  135919. * Checks to see if a texture is used in the material.
  135920. * @param texture - Base texture to use.
  135921. * @returns - Boolean specifying if a texture is used in the material.
  135922. */
  135923. hasTexture(texture: BaseTexture): boolean;
  135924. /**
  135925. * Returns an array of the actively used textures.
  135926. * @param activeTextures Array of BaseTextures
  135927. */
  135928. getActiveTextures(activeTextures: BaseTexture[]): void;
  135929. /**
  135930. * Returns the animatable textures.
  135931. * @param animatables Array of animatable textures.
  135932. */
  135933. getAnimatables(animatables: IAnimatable[]): void;
  135934. /**
  135935. * Disposes the resources of the material.
  135936. * @param forceDisposeTextures - Forces the disposal of all textures.
  135937. */
  135938. dispose(forceDisposeTextures?: boolean): void;
  135939. /**
  135940. * Get the current class name of the texture useful for serialization or dynamic coding.
  135941. * @returns "PBRAnisotropicConfiguration"
  135942. */
  135943. getClassName(): string;
  135944. /**
  135945. * Add fallbacks to the effect fallbacks list.
  135946. * @param defines defines the Base texture to use.
  135947. * @param fallbacks defines the current fallback list.
  135948. * @param currentRank defines the current fallback rank.
  135949. * @returns the new fallback rank.
  135950. */
  135951. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135952. /**
  135953. * Add the required uniforms to the current list.
  135954. * @param uniforms defines the current uniform list.
  135955. */
  135956. static AddUniforms(uniforms: string[]): void;
  135957. /**
  135958. * Add the required uniforms to the current buffer.
  135959. * @param uniformBuffer defines the current uniform buffer.
  135960. */
  135961. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135962. /**
  135963. * Add the required samplers to the current list.
  135964. * @param samplers defines the current sampler list.
  135965. */
  135966. static AddSamplers(samplers: string[]): void;
  135967. /**
  135968. * Makes a duplicate of the current configuration into another one.
  135969. * @param anisotropicConfiguration define the config where to copy the info
  135970. */
  135971. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135972. /**
  135973. * Serializes this anisotropy configuration.
  135974. * @returns - An object with the serialized config.
  135975. */
  135976. serialize(): any;
  135977. /**
  135978. * Parses a anisotropy Configuration from a serialized object.
  135979. * @param source - Serialized object.
  135980. * @param scene Defines the scene we are parsing for
  135981. * @param rootUrl Defines the rootUrl to load from
  135982. */
  135983. parse(source: any, scene: Scene, rootUrl: string): void;
  135984. }
  135985. }
  135986. declare module BABYLON {
  135987. /**
  135988. * @hidden
  135989. */
  135990. export interface IMaterialBRDFDefines {
  135991. BRDF_V_HEIGHT_CORRELATED: boolean;
  135992. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135993. SPHERICAL_HARMONICS: boolean;
  135994. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135995. /** @hidden */
  135996. _areMiscDirty: boolean;
  135997. }
  135998. /**
  135999. * Define the code related to the BRDF parameters of the pbr material.
  136000. */
  136001. export class PBRBRDFConfiguration {
  136002. /**
  136003. * Default value used for the energy conservation.
  136004. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136005. */
  136006. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136007. /**
  136008. * Default value used for the Smith Visibility Height Correlated mode.
  136009. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136010. */
  136011. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136012. /**
  136013. * Default value used for the IBL diffuse part.
  136014. * This can help switching back to the polynomials mode globally which is a tiny bit
  136015. * less GPU intensive at the drawback of a lower quality.
  136016. */
  136017. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136018. /**
  136019. * Default value used for activating energy conservation for the specular workflow.
  136020. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136021. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136022. */
  136023. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136024. private _useEnergyConservation;
  136025. /**
  136026. * Defines if the material uses energy conservation.
  136027. */
  136028. useEnergyConservation: boolean;
  136029. private _useSmithVisibilityHeightCorrelated;
  136030. /**
  136031. * LEGACY Mode set to false
  136032. * Defines if the material uses height smith correlated visibility term.
  136033. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136034. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136035. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136036. * Not relying on height correlated will also disable energy conservation.
  136037. */
  136038. useSmithVisibilityHeightCorrelated: boolean;
  136039. private _useSphericalHarmonics;
  136040. /**
  136041. * LEGACY Mode set to false
  136042. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136043. * diffuse part of the IBL.
  136044. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136045. * to the ground truth.
  136046. */
  136047. useSphericalHarmonics: boolean;
  136048. private _useSpecularGlossinessInputEnergyConservation;
  136049. /**
  136050. * Defines if the material uses energy conservation, when the specular workflow is active.
  136051. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136052. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136053. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136054. */
  136055. useSpecularGlossinessInputEnergyConservation: boolean;
  136056. /** @hidden */
  136057. private _internalMarkAllSubMeshesAsMiscDirty;
  136058. /** @hidden */
  136059. _markAllSubMeshesAsMiscDirty(): void;
  136060. /**
  136061. * Instantiate a new istance of clear coat configuration.
  136062. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136063. */
  136064. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136065. /**
  136066. * Checks to see if a texture is used in the material.
  136067. * @param defines the list of "defines" to update.
  136068. */
  136069. prepareDefines(defines: IMaterialBRDFDefines): void;
  136070. /**
  136071. * Get the current class name of the texture useful for serialization or dynamic coding.
  136072. * @returns "PBRClearCoatConfiguration"
  136073. */
  136074. getClassName(): string;
  136075. /**
  136076. * Makes a duplicate of the current configuration into another one.
  136077. * @param brdfConfiguration define the config where to copy the info
  136078. */
  136079. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136080. /**
  136081. * Serializes this BRDF configuration.
  136082. * @returns - An object with the serialized config.
  136083. */
  136084. serialize(): any;
  136085. /**
  136086. * Parses a anisotropy Configuration from a serialized object.
  136087. * @param source - Serialized object.
  136088. * @param scene Defines the scene we are parsing for
  136089. * @param rootUrl Defines the rootUrl to load from
  136090. */
  136091. parse(source: any, scene: Scene, rootUrl: string): void;
  136092. }
  136093. }
  136094. declare module BABYLON {
  136095. /**
  136096. * @hidden
  136097. */
  136098. export interface IMaterialSheenDefines {
  136099. SHEEN: boolean;
  136100. SHEEN_TEXTURE: boolean;
  136101. SHEEN_TEXTUREDIRECTUV: number;
  136102. SHEEN_LINKWITHALBEDO: boolean;
  136103. SHEEN_ROUGHNESS: boolean;
  136104. SHEEN_ALBEDOSCALING: boolean;
  136105. /** @hidden */
  136106. _areTexturesDirty: boolean;
  136107. }
  136108. /**
  136109. * Define the code related to the Sheen parameters of the pbr material.
  136110. */
  136111. export class PBRSheenConfiguration {
  136112. private _isEnabled;
  136113. /**
  136114. * Defines if the material uses sheen.
  136115. */
  136116. isEnabled: boolean;
  136117. private _linkSheenWithAlbedo;
  136118. /**
  136119. * Defines if the sheen is linked to the sheen color.
  136120. */
  136121. linkSheenWithAlbedo: boolean;
  136122. /**
  136123. * Defines the sheen intensity.
  136124. */
  136125. intensity: number;
  136126. /**
  136127. * Defines the sheen color.
  136128. */
  136129. color: Color3;
  136130. private _texture;
  136131. /**
  136132. * Stores the sheen tint values in a texture.
  136133. * rgb is tint
  136134. * a is a intensity or roughness if roughness has been defined
  136135. */
  136136. texture: Nullable<BaseTexture>;
  136137. private _roughness;
  136138. /**
  136139. * Defines the sheen roughness.
  136140. * It is not taken into account if linkSheenWithAlbedo is true.
  136141. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136142. */
  136143. roughness: Nullable<number>;
  136144. private _albedoScaling;
  136145. /**
  136146. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136147. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136148. * making it easier to setup and tweak the effect
  136149. */
  136150. albedoScaling: boolean;
  136151. /** @hidden */
  136152. private _internalMarkAllSubMeshesAsTexturesDirty;
  136153. /** @hidden */
  136154. _markAllSubMeshesAsTexturesDirty(): void;
  136155. /**
  136156. * Instantiate a new istance of clear coat configuration.
  136157. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136158. */
  136159. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136160. /**
  136161. * Specifies that the submesh is ready to be used.
  136162. * @param defines the list of "defines" to update.
  136163. * @param scene defines the scene the material belongs to.
  136164. * @returns - boolean indicating that the submesh is ready or not.
  136165. */
  136166. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136167. /**
  136168. * Checks to see if a texture is used in the material.
  136169. * @param defines the list of "defines" to update.
  136170. * @param scene defines the scene the material belongs to.
  136171. */
  136172. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136173. /**
  136174. * Binds the material data.
  136175. * @param uniformBuffer defines the Uniform buffer to fill in.
  136176. * @param scene defines the scene the material belongs to.
  136177. * @param isFrozen defines wether the material is frozen or not.
  136178. */
  136179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136180. /**
  136181. * Checks to see if a texture is used in the material.
  136182. * @param texture - Base texture to use.
  136183. * @returns - Boolean specifying if a texture is used in the material.
  136184. */
  136185. hasTexture(texture: BaseTexture): boolean;
  136186. /**
  136187. * Returns an array of the actively used textures.
  136188. * @param activeTextures Array of BaseTextures
  136189. */
  136190. getActiveTextures(activeTextures: BaseTexture[]): void;
  136191. /**
  136192. * Returns the animatable textures.
  136193. * @param animatables Array of animatable textures.
  136194. */
  136195. getAnimatables(animatables: IAnimatable[]): void;
  136196. /**
  136197. * Disposes the resources of the material.
  136198. * @param forceDisposeTextures - Forces the disposal of all textures.
  136199. */
  136200. dispose(forceDisposeTextures?: boolean): void;
  136201. /**
  136202. * Get the current class name of the texture useful for serialization or dynamic coding.
  136203. * @returns "PBRSheenConfiguration"
  136204. */
  136205. getClassName(): string;
  136206. /**
  136207. * Add fallbacks to the effect fallbacks list.
  136208. * @param defines defines the Base texture to use.
  136209. * @param fallbacks defines the current fallback list.
  136210. * @param currentRank defines the current fallback rank.
  136211. * @returns the new fallback rank.
  136212. */
  136213. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136214. /**
  136215. * Add the required uniforms to the current list.
  136216. * @param uniforms defines the current uniform list.
  136217. */
  136218. static AddUniforms(uniforms: string[]): void;
  136219. /**
  136220. * Add the required uniforms to the current buffer.
  136221. * @param uniformBuffer defines the current uniform buffer.
  136222. */
  136223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136224. /**
  136225. * Add the required samplers to the current list.
  136226. * @param samplers defines the current sampler list.
  136227. */
  136228. static AddSamplers(samplers: string[]): void;
  136229. /**
  136230. * Makes a duplicate of the current configuration into another one.
  136231. * @param sheenConfiguration define the config where to copy the info
  136232. */
  136233. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136234. /**
  136235. * Serializes this BRDF configuration.
  136236. * @returns - An object with the serialized config.
  136237. */
  136238. serialize(): any;
  136239. /**
  136240. * Parses a anisotropy Configuration from a serialized object.
  136241. * @param source - Serialized object.
  136242. * @param scene Defines the scene we are parsing for
  136243. * @param rootUrl Defines the rootUrl to load from
  136244. */
  136245. parse(source: any, scene: Scene, rootUrl: string): void;
  136246. }
  136247. }
  136248. declare module BABYLON {
  136249. /**
  136250. * @hidden
  136251. */
  136252. export interface IMaterialSubSurfaceDefines {
  136253. SUBSURFACE: boolean;
  136254. SS_REFRACTION: boolean;
  136255. SS_TRANSLUCENCY: boolean;
  136256. SS_SCATTERING: boolean;
  136257. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136258. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136259. SS_REFRACTIONMAP_3D: boolean;
  136260. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136261. SS_LODINREFRACTIONALPHA: boolean;
  136262. SS_GAMMAREFRACTION: boolean;
  136263. SS_RGBDREFRACTION: boolean;
  136264. SS_LINEARSPECULARREFRACTION: boolean;
  136265. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136266. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136267. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136268. /** @hidden */
  136269. _areTexturesDirty: boolean;
  136270. }
  136271. /**
  136272. * Define the code related to the sub surface parameters of the pbr material.
  136273. */
  136274. export class PBRSubSurfaceConfiguration {
  136275. private _isRefractionEnabled;
  136276. /**
  136277. * Defines if the refraction is enabled in the material.
  136278. */
  136279. isRefractionEnabled: boolean;
  136280. private _isTranslucencyEnabled;
  136281. /**
  136282. * Defines if the translucency is enabled in the material.
  136283. */
  136284. isTranslucencyEnabled: boolean;
  136285. private _isScatteringEnabled;
  136286. /**
  136287. * Defines if the sub surface scattering is enabled in the material.
  136288. */
  136289. isScatteringEnabled: boolean;
  136290. private _scatteringDiffusionProfileIndex;
  136291. /**
  136292. * Diffusion profile for subsurface scattering.
  136293. * Useful for better scattering in the skins or foliages.
  136294. */
  136295. get scatteringDiffusionProfile(): Nullable<Color3>;
  136296. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136297. /**
  136298. * Defines the refraction intensity of the material.
  136299. * The refraction when enabled replaces the Diffuse part of the material.
  136300. * The intensity helps transitionning between diffuse and refraction.
  136301. */
  136302. refractionIntensity: number;
  136303. /**
  136304. * Defines the translucency intensity of the material.
  136305. * When translucency has been enabled, this defines how much of the "translucency"
  136306. * is addded to the diffuse part of the material.
  136307. */
  136308. translucencyIntensity: number;
  136309. /**
  136310. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136311. */
  136312. useAlbedoToTintRefraction: boolean;
  136313. private _thicknessTexture;
  136314. /**
  136315. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136316. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136317. * 0 would mean minimumThickness
  136318. * 1 would mean maximumThickness
  136319. * The other channels might be use as a mask to vary the different effects intensity.
  136320. */
  136321. thicknessTexture: Nullable<BaseTexture>;
  136322. private _refractionTexture;
  136323. /**
  136324. * Defines the texture to use for refraction.
  136325. */
  136326. refractionTexture: Nullable<BaseTexture>;
  136327. private _indexOfRefraction;
  136328. /**
  136329. * Index of refraction of the material base layer.
  136330. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136331. *
  136332. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136333. *
  136334. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136335. */
  136336. indexOfRefraction: number;
  136337. private _volumeIndexOfRefraction;
  136338. /**
  136339. * Index of refraction of the material's volume.
  136340. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136341. *
  136342. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136343. * the volume will use the same IOR as the surface.
  136344. */
  136345. get volumeIndexOfRefraction(): number;
  136346. set volumeIndexOfRefraction(value: number);
  136347. private _invertRefractionY;
  136348. /**
  136349. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136350. */
  136351. invertRefractionY: boolean;
  136352. private _linkRefractionWithTransparency;
  136353. /**
  136354. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136355. * Materials half opaque for instance using refraction could benefit from this control.
  136356. */
  136357. linkRefractionWithTransparency: boolean;
  136358. /**
  136359. * Defines the minimum thickness stored in the thickness map.
  136360. * If no thickness map is defined, this value will be used to simulate thickness.
  136361. */
  136362. minimumThickness: number;
  136363. /**
  136364. * Defines the maximum thickness stored in the thickness map.
  136365. */
  136366. maximumThickness: number;
  136367. /**
  136368. * Defines the volume tint of the material.
  136369. * This is used for both translucency and scattering.
  136370. */
  136371. tintColor: Color3;
  136372. /**
  136373. * Defines the distance at which the tint color should be found in the media.
  136374. * This is used for refraction only.
  136375. */
  136376. tintColorAtDistance: number;
  136377. /**
  136378. * Defines how far each channel transmit through the media.
  136379. * It is defined as a color to simplify it selection.
  136380. */
  136381. diffusionDistance: Color3;
  136382. private _useMaskFromThicknessTexture;
  136383. /**
  136384. * Stores the intensity of the different subsurface effects in the thickness texture.
  136385. * * the green channel is the translucency intensity.
  136386. * * the blue channel is the scattering intensity.
  136387. * * the alpha channel is the refraction intensity.
  136388. */
  136389. useMaskFromThicknessTexture: boolean;
  136390. private _scene;
  136391. /** @hidden */
  136392. private _internalMarkAllSubMeshesAsTexturesDirty;
  136393. private _internalMarkScenePrePassDirty;
  136394. /** @hidden */
  136395. _markAllSubMeshesAsTexturesDirty(): void;
  136396. /** @hidden */
  136397. _markScenePrePassDirty(): void;
  136398. /**
  136399. * Instantiate a new istance of sub surface configuration.
  136400. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136401. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136402. * @param scene The scene
  136403. */
  136404. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136405. /**
  136406. * Gets wehter the submesh is ready to be used or not.
  136407. * @param defines the list of "defines" to update.
  136408. * @param scene defines the scene the material belongs to.
  136409. * @returns - boolean indicating that the submesh is ready or not.
  136410. */
  136411. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136412. /**
  136413. * Checks to see if a texture is used in the material.
  136414. * @param defines the list of "defines" to update.
  136415. * @param scene defines the scene to the material belongs to.
  136416. */
  136417. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136418. /**
  136419. * Binds the material data.
  136420. * @param uniformBuffer defines the Uniform buffer to fill in.
  136421. * @param scene defines the scene the material belongs to.
  136422. * @param engine defines the engine the material belongs to.
  136423. * @param isFrozen defines whether the material is frozen or not.
  136424. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136425. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136426. */
  136427. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136428. /**
  136429. * Unbinds the material from the mesh.
  136430. * @param activeEffect defines the effect that should be unbound from.
  136431. * @returns true if unbound, otherwise false
  136432. */
  136433. unbind(activeEffect: Effect): boolean;
  136434. /**
  136435. * Returns the texture used for refraction or null if none is used.
  136436. * @param scene defines the scene the material belongs to.
  136437. * @returns - Refraction texture if present. If no refraction texture and refraction
  136438. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136439. */
  136440. private _getRefractionTexture;
  136441. /**
  136442. * Returns true if alpha blending should be disabled.
  136443. */
  136444. get disableAlphaBlending(): boolean;
  136445. /**
  136446. * Fills the list of render target textures.
  136447. * @param renderTargets the list of render targets to update
  136448. */
  136449. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136450. /**
  136451. * Checks to see if a texture is used in the material.
  136452. * @param texture - Base texture to use.
  136453. * @returns - Boolean specifying if a texture is used in the material.
  136454. */
  136455. hasTexture(texture: BaseTexture): boolean;
  136456. /**
  136457. * Gets a boolean indicating that current material needs to register RTT
  136458. * @returns true if this uses a render target otherwise false.
  136459. */
  136460. hasRenderTargetTextures(): boolean;
  136461. /**
  136462. * Returns an array of the actively used textures.
  136463. * @param activeTextures Array of BaseTextures
  136464. */
  136465. getActiveTextures(activeTextures: BaseTexture[]): void;
  136466. /**
  136467. * Returns the animatable textures.
  136468. * @param animatables Array of animatable textures.
  136469. */
  136470. getAnimatables(animatables: IAnimatable[]): void;
  136471. /**
  136472. * Disposes the resources of the material.
  136473. * @param forceDisposeTextures - Forces the disposal of all textures.
  136474. */
  136475. dispose(forceDisposeTextures?: boolean): void;
  136476. /**
  136477. * Get the current class name of the texture useful for serialization or dynamic coding.
  136478. * @returns "PBRSubSurfaceConfiguration"
  136479. */
  136480. getClassName(): string;
  136481. /**
  136482. * Add fallbacks to the effect fallbacks list.
  136483. * @param defines defines the Base texture to use.
  136484. * @param fallbacks defines the current fallback list.
  136485. * @param currentRank defines the current fallback rank.
  136486. * @returns the new fallback rank.
  136487. */
  136488. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136489. /**
  136490. * Add the required uniforms to the current list.
  136491. * @param uniforms defines the current uniform list.
  136492. */
  136493. static AddUniforms(uniforms: string[]): void;
  136494. /**
  136495. * Add the required samplers to the current list.
  136496. * @param samplers defines the current sampler list.
  136497. */
  136498. static AddSamplers(samplers: string[]): void;
  136499. /**
  136500. * Add the required uniforms to the current buffer.
  136501. * @param uniformBuffer defines the current uniform buffer.
  136502. */
  136503. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136504. /**
  136505. * Makes a duplicate of the current configuration into another one.
  136506. * @param configuration define the config where to copy the info
  136507. */
  136508. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136509. /**
  136510. * Serializes this Sub Surface configuration.
  136511. * @returns - An object with the serialized config.
  136512. */
  136513. serialize(): any;
  136514. /**
  136515. * Parses a anisotropy Configuration from a serialized object.
  136516. * @param source - Serialized object.
  136517. * @param scene Defines the scene we are parsing for
  136518. * @param rootUrl Defines the rootUrl to load from
  136519. */
  136520. parse(source: any, scene: Scene, rootUrl: string): void;
  136521. }
  136522. }
  136523. declare module BABYLON {
  136524. /** @hidden */
  136525. export var pbrFragmentDeclaration: {
  136526. name: string;
  136527. shader: string;
  136528. };
  136529. }
  136530. declare module BABYLON {
  136531. /** @hidden */
  136532. export var pbrUboDeclaration: {
  136533. name: string;
  136534. shader: string;
  136535. };
  136536. }
  136537. declare module BABYLON {
  136538. /** @hidden */
  136539. export var pbrFragmentExtraDeclaration: {
  136540. name: string;
  136541. shader: string;
  136542. };
  136543. }
  136544. declare module BABYLON {
  136545. /** @hidden */
  136546. export var pbrFragmentSamplersDeclaration: {
  136547. name: string;
  136548. shader: string;
  136549. };
  136550. }
  136551. declare module BABYLON {
  136552. /** @hidden */
  136553. export var subSurfaceScatteringFunctions: {
  136554. name: string;
  136555. shader: string;
  136556. };
  136557. }
  136558. declare module BABYLON {
  136559. /** @hidden */
  136560. export var importanceSampling: {
  136561. name: string;
  136562. shader: string;
  136563. };
  136564. }
  136565. declare module BABYLON {
  136566. /** @hidden */
  136567. export var pbrHelperFunctions: {
  136568. name: string;
  136569. shader: string;
  136570. };
  136571. }
  136572. declare module BABYLON {
  136573. /** @hidden */
  136574. export var harmonicsFunctions: {
  136575. name: string;
  136576. shader: string;
  136577. };
  136578. }
  136579. declare module BABYLON {
  136580. /** @hidden */
  136581. export var pbrDirectLightingSetupFunctions: {
  136582. name: string;
  136583. shader: string;
  136584. };
  136585. }
  136586. declare module BABYLON {
  136587. /** @hidden */
  136588. export var pbrDirectLightingFalloffFunctions: {
  136589. name: string;
  136590. shader: string;
  136591. };
  136592. }
  136593. declare module BABYLON {
  136594. /** @hidden */
  136595. export var pbrBRDFFunctions: {
  136596. name: string;
  136597. shader: string;
  136598. };
  136599. }
  136600. declare module BABYLON {
  136601. /** @hidden */
  136602. export var hdrFilteringFunctions: {
  136603. name: string;
  136604. shader: string;
  136605. };
  136606. }
  136607. declare module BABYLON {
  136608. /** @hidden */
  136609. export var pbrDirectLightingFunctions: {
  136610. name: string;
  136611. shader: string;
  136612. };
  136613. }
  136614. declare module BABYLON {
  136615. /** @hidden */
  136616. export var pbrIBLFunctions: {
  136617. name: string;
  136618. shader: string;
  136619. };
  136620. }
  136621. declare module BABYLON {
  136622. /** @hidden */
  136623. export var pbrBlockAlbedoOpacity: {
  136624. name: string;
  136625. shader: string;
  136626. };
  136627. }
  136628. declare module BABYLON {
  136629. /** @hidden */
  136630. export var pbrBlockReflectivity: {
  136631. name: string;
  136632. shader: string;
  136633. };
  136634. }
  136635. declare module BABYLON {
  136636. /** @hidden */
  136637. export var pbrBlockAmbientOcclusion: {
  136638. name: string;
  136639. shader: string;
  136640. };
  136641. }
  136642. declare module BABYLON {
  136643. /** @hidden */
  136644. export var pbrBlockAlphaFresnel: {
  136645. name: string;
  136646. shader: string;
  136647. };
  136648. }
  136649. declare module BABYLON {
  136650. /** @hidden */
  136651. export var pbrBlockAnisotropic: {
  136652. name: string;
  136653. shader: string;
  136654. };
  136655. }
  136656. declare module BABYLON {
  136657. /** @hidden */
  136658. export var pbrBlockReflection: {
  136659. name: string;
  136660. shader: string;
  136661. };
  136662. }
  136663. declare module BABYLON {
  136664. /** @hidden */
  136665. export var pbrBlockSheen: {
  136666. name: string;
  136667. shader: string;
  136668. };
  136669. }
  136670. declare module BABYLON {
  136671. /** @hidden */
  136672. export var pbrBlockClearcoat: {
  136673. name: string;
  136674. shader: string;
  136675. };
  136676. }
  136677. declare module BABYLON {
  136678. /** @hidden */
  136679. export var pbrBlockSubSurface: {
  136680. name: string;
  136681. shader: string;
  136682. };
  136683. }
  136684. declare module BABYLON {
  136685. /** @hidden */
  136686. export var pbrBlockNormalGeometric: {
  136687. name: string;
  136688. shader: string;
  136689. };
  136690. }
  136691. declare module BABYLON {
  136692. /** @hidden */
  136693. export var pbrBlockNormalFinal: {
  136694. name: string;
  136695. shader: string;
  136696. };
  136697. }
  136698. declare module BABYLON {
  136699. /** @hidden */
  136700. export var pbrBlockLightmapInit: {
  136701. name: string;
  136702. shader: string;
  136703. };
  136704. }
  136705. declare module BABYLON {
  136706. /** @hidden */
  136707. export var pbrBlockGeometryInfo: {
  136708. name: string;
  136709. shader: string;
  136710. };
  136711. }
  136712. declare module BABYLON {
  136713. /** @hidden */
  136714. export var pbrBlockReflectance0: {
  136715. name: string;
  136716. shader: string;
  136717. };
  136718. }
  136719. declare module BABYLON {
  136720. /** @hidden */
  136721. export var pbrBlockReflectance: {
  136722. name: string;
  136723. shader: string;
  136724. };
  136725. }
  136726. declare module BABYLON {
  136727. /** @hidden */
  136728. export var pbrBlockDirectLighting: {
  136729. name: string;
  136730. shader: string;
  136731. };
  136732. }
  136733. declare module BABYLON {
  136734. /** @hidden */
  136735. export var pbrBlockFinalLitComponents: {
  136736. name: string;
  136737. shader: string;
  136738. };
  136739. }
  136740. declare module BABYLON {
  136741. /** @hidden */
  136742. export var pbrBlockFinalUnlitComponents: {
  136743. name: string;
  136744. shader: string;
  136745. };
  136746. }
  136747. declare module BABYLON {
  136748. /** @hidden */
  136749. export var pbrBlockFinalColorComposition: {
  136750. name: string;
  136751. shader: string;
  136752. };
  136753. }
  136754. declare module BABYLON {
  136755. /** @hidden */
  136756. export var pbrBlockImageProcessing: {
  136757. name: string;
  136758. shader: string;
  136759. };
  136760. }
  136761. declare module BABYLON {
  136762. /** @hidden */
  136763. export var pbrDebug: {
  136764. name: string;
  136765. shader: string;
  136766. };
  136767. }
  136768. declare module BABYLON {
  136769. /** @hidden */
  136770. export var pbrPixelShader: {
  136771. name: string;
  136772. shader: string;
  136773. };
  136774. }
  136775. declare module BABYLON {
  136776. /** @hidden */
  136777. export var pbrVertexDeclaration: {
  136778. name: string;
  136779. shader: string;
  136780. };
  136781. }
  136782. declare module BABYLON {
  136783. /** @hidden */
  136784. export var pbrVertexShader: {
  136785. name: string;
  136786. shader: string;
  136787. };
  136788. }
  136789. declare module BABYLON {
  136790. /**
  136791. * Manages the defines for the PBR Material.
  136792. * @hidden
  136793. */
  136794. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136795. PBR: boolean;
  136796. NUM_SAMPLES: string;
  136797. REALTIME_FILTERING: boolean;
  136798. MAINUV1: boolean;
  136799. MAINUV2: boolean;
  136800. UV1: boolean;
  136801. UV2: boolean;
  136802. ALBEDO: boolean;
  136803. GAMMAALBEDO: boolean;
  136804. ALBEDODIRECTUV: number;
  136805. VERTEXCOLOR: boolean;
  136806. DETAIL: boolean;
  136807. DETAILDIRECTUV: number;
  136808. DETAIL_NORMALBLENDMETHOD: number;
  136809. AMBIENT: boolean;
  136810. AMBIENTDIRECTUV: number;
  136811. AMBIENTINGRAYSCALE: boolean;
  136812. OPACITY: boolean;
  136813. VERTEXALPHA: boolean;
  136814. OPACITYDIRECTUV: number;
  136815. OPACITYRGB: boolean;
  136816. ALPHATEST: boolean;
  136817. DEPTHPREPASS: boolean;
  136818. ALPHABLEND: boolean;
  136819. ALPHAFROMALBEDO: boolean;
  136820. ALPHATESTVALUE: string;
  136821. SPECULAROVERALPHA: boolean;
  136822. RADIANCEOVERALPHA: boolean;
  136823. ALPHAFRESNEL: boolean;
  136824. LINEARALPHAFRESNEL: boolean;
  136825. PREMULTIPLYALPHA: boolean;
  136826. EMISSIVE: boolean;
  136827. EMISSIVEDIRECTUV: number;
  136828. REFLECTIVITY: boolean;
  136829. REFLECTIVITYDIRECTUV: number;
  136830. SPECULARTERM: boolean;
  136831. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136832. MICROSURFACEAUTOMATIC: boolean;
  136833. LODBASEDMICROSFURACE: boolean;
  136834. MICROSURFACEMAP: boolean;
  136835. MICROSURFACEMAPDIRECTUV: number;
  136836. METALLICWORKFLOW: boolean;
  136837. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136838. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136839. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136840. AOSTOREINMETALMAPRED: boolean;
  136841. METALLIC_REFLECTANCE: boolean;
  136842. METALLIC_REFLECTANCEDIRECTUV: number;
  136843. ENVIRONMENTBRDF: boolean;
  136844. ENVIRONMENTBRDF_RGBD: boolean;
  136845. NORMAL: boolean;
  136846. TANGENT: boolean;
  136847. BUMP: boolean;
  136848. BUMPDIRECTUV: number;
  136849. OBJECTSPACE_NORMALMAP: boolean;
  136850. PARALLAX: boolean;
  136851. PARALLAXOCCLUSION: boolean;
  136852. NORMALXYSCALE: boolean;
  136853. LIGHTMAP: boolean;
  136854. LIGHTMAPDIRECTUV: number;
  136855. USELIGHTMAPASSHADOWMAP: boolean;
  136856. GAMMALIGHTMAP: boolean;
  136857. RGBDLIGHTMAP: boolean;
  136858. REFLECTION: boolean;
  136859. REFLECTIONMAP_3D: boolean;
  136860. REFLECTIONMAP_SPHERICAL: boolean;
  136861. REFLECTIONMAP_PLANAR: boolean;
  136862. REFLECTIONMAP_CUBIC: boolean;
  136863. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136864. REFLECTIONMAP_PROJECTION: boolean;
  136865. REFLECTIONMAP_SKYBOX: boolean;
  136866. REFLECTIONMAP_EXPLICIT: boolean;
  136867. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136868. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136869. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136870. INVERTCUBICMAP: boolean;
  136871. USESPHERICALFROMREFLECTIONMAP: boolean;
  136872. USEIRRADIANCEMAP: boolean;
  136873. SPHERICAL_HARMONICS: boolean;
  136874. USESPHERICALINVERTEX: boolean;
  136875. REFLECTIONMAP_OPPOSITEZ: boolean;
  136876. LODINREFLECTIONALPHA: boolean;
  136877. GAMMAREFLECTION: boolean;
  136878. RGBDREFLECTION: boolean;
  136879. LINEARSPECULARREFLECTION: boolean;
  136880. RADIANCEOCCLUSION: boolean;
  136881. HORIZONOCCLUSION: boolean;
  136882. INSTANCES: boolean;
  136883. THIN_INSTANCES: boolean;
  136884. PREPASS: boolean;
  136885. PREPASS_IRRADIANCE: boolean;
  136886. PREPASS_IRRADIANCE_INDEX: number;
  136887. PREPASS_ALBEDO: boolean;
  136888. PREPASS_ALBEDO_INDEX: number;
  136889. PREPASS_DEPTHNORMAL: boolean;
  136890. PREPASS_DEPTHNORMAL_INDEX: number;
  136891. SCENE_MRT_COUNT: number;
  136892. NUM_BONE_INFLUENCERS: number;
  136893. BonesPerMesh: number;
  136894. BONETEXTURE: boolean;
  136895. NONUNIFORMSCALING: boolean;
  136896. MORPHTARGETS: boolean;
  136897. MORPHTARGETS_NORMAL: boolean;
  136898. MORPHTARGETS_TANGENT: boolean;
  136899. MORPHTARGETS_UV: boolean;
  136900. NUM_MORPH_INFLUENCERS: number;
  136901. IMAGEPROCESSING: boolean;
  136902. VIGNETTE: boolean;
  136903. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136904. VIGNETTEBLENDMODEOPAQUE: boolean;
  136905. TONEMAPPING: boolean;
  136906. TONEMAPPING_ACES: boolean;
  136907. CONTRAST: boolean;
  136908. COLORCURVES: boolean;
  136909. COLORGRADING: boolean;
  136910. COLORGRADING3D: boolean;
  136911. SAMPLER3DGREENDEPTH: boolean;
  136912. SAMPLER3DBGRMAP: boolean;
  136913. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136914. EXPOSURE: boolean;
  136915. MULTIVIEW: boolean;
  136916. USEPHYSICALLIGHTFALLOFF: boolean;
  136917. USEGLTFLIGHTFALLOFF: boolean;
  136918. TWOSIDEDLIGHTING: boolean;
  136919. SHADOWFLOAT: boolean;
  136920. CLIPPLANE: boolean;
  136921. CLIPPLANE2: boolean;
  136922. CLIPPLANE3: boolean;
  136923. CLIPPLANE4: boolean;
  136924. CLIPPLANE5: boolean;
  136925. CLIPPLANE6: boolean;
  136926. POINTSIZE: boolean;
  136927. FOG: boolean;
  136928. LOGARITHMICDEPTH: boolean;
  136929. FORCENORMALFORWARD: boolean;
  136930. SPECULARAA: boolean;
  136931. CLEARCOAT: boolean;
  136932. CLEARCOAT_DEFAULTIOR: boolean;
  136933. CLEARCOAT_TEXTURE: boolean;
  136934. CLEARCOAT_TEXTUREDIRECTUV: number;
  136935. CLEARCOAT_BUMP: boolean;
  136936. CLEARCOAT_BUMPDIRECTUV: number;
  136937. CLEARCOAT_TINT: boolean;
  136938. CLEARCOAT_TINT_TEXTURE: boolean;
  136939. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136940. ANISOTROPIC: boolean;
  136941. ANISOTROPIC_TEXTURE: boolean;
  136942. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136943. BRDF_V_HEIGHT_CORRELATED: boolean;
  136944. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136945. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136946. SHEEN: boolean;
  136947. SHEEN_TEXTURE: boolean;
  136948. SHEEN_TEXTUREDIRECTUV: number;
  136949. SHEEN_LINKWITHALBEDO: boolean;
  136950. SHEEN_ROUGHNESS: boolean;
  136951. SHEEN_ALBEDOSCALING: boolean;
  136952. SUBSURFACE: boolean;
  136953. SS_REFRACTION: boolean;
  136954. SS_TRANSLUCENCY: boolean;
  136955. SS_SCATTERING: boolean;
  136956. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136957. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136958. SS_REFRACTIONMAP_3D: boolean;
  136959. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136960. SS_LODINREFRACTIONALPHA: boolean;
  136961. SS_GAMMAREFRACTION: boolean;
  136962. SS_RGBDREFRACTION: boolean;
  136963. SS_LINEARSPECULARREFRACTION: boolean;
  136964. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136965. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136966. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136967. UNLIT: boolean;
  136968. DEBUGMODE: number;
  136969. /**
  136970. * Initializes the PBR Material defines.
  136971. */
  136972. constructor();
  136973. /**
  136974. * Resets the PBR Material defines.
  136975. */
  136976. reset(): void;
  136977. }
  136978. /**
  136979. * The Physically based material base class of BJS.
  136980. *
  136981. * This offers the main features of a standard PBR material.
  136982. * For more information, please refer to the documentation :
  136983. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136984. */
  136985. export abstract class PBRBaseMaterial extends PushMaterial {
  136986. /**
  136987. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136988. */
  136989. static readonly PBRMATERIAL_OPAQUE: number;
  136990. /**
  136991. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136992. */
  136993. static readonly PBRMATERIAL_ALPHATEST: number;
  136994. /**
  136995. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136996. */
  136997. static readonly PBRMATERIAL_ALPHABLEND: number;
  136998. /**
  136999. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137000. * They are also discarded below the alpha cutoff threshold to improve performances.
  137001. */
  137002. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137003. /**
  137004. * Defines the default value of how much AO map is occluding the analytical lights
  137005. * (point spot...).
  137006. */
  137007. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137008. /**
  137009. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137010. */
  137011. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137012. /**
  137013. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137014. * to enhance interoperability with other engines.
  137015. */
  137016. static readonly LIGHTFALLOFF_GLTF: number;
  137017. /**
  137018. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137019. * to enhance interoperability with other materials.
  137020. */
  137021. static readonly LIGHTFALLOFF_STANDARD: number;
  137022. /**
  137023. * Intensity of the direct lights e.g. the four lights available in your scene.
  137024. * This impacts both the direct diffuse and specular highlights.
  137025. */
  137026. protected _directIntensity: number;
  137027. /**
  137028. * Intensity of the emissive part of the material.
  137029. * This helps controlling the emissive effect without modifying the emissive color.
  137030. */
  137031. protected _emissiveIntensity: number;
  137032. /**
  137033. * Intensity of the environment e.g. how much the environment will light the object
  137034. * either through harmonics for rough material or through the refelction for shiny ones.
  137035. */
  137036. protected _environmentIntensity: number;
  137037. /**
  137038. * This is a special control allowing the reduction of the specular highlights coming from the
  137039. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137040. */
  137041. protected _specularIntensity: number;
  137042. /**
  137043. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137044. */
  137045. private _lightingInfos;
  137046. /**
  137047. * Debug Control allowing disabling the bump map on this material.
  137048. */
  137049. protected _disableBumpMap: boolean;
  137050. /**
  137051. * AKA Diffuse Texture in standard nomenclature.
  137052. */
  137053. protected _albedoTexture: Nullable<BaseTexture>;
  137054. /**
  137055. * AKA Occlusion Texture in other nomenclature.
  137056. */
  137057. protected _ambientTexture: Nullable<BaseTexture>;
  137058. /**
  137059. * AKA Occlusion Texture Intensity in other nomenclature.
  137060. */
  137061. protected _ambientTextureStrength: number;
  137062. /**
  137063. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137064. * 1 means it completely occludes it
  137065. * 0 mean it has no impact
  137066. */
  137067. protected _ambientTextureImpactOnAnalyticalLights: number;
  137068. /**
  137069. * Stores the alpha values in a texture.
  137070. */
  137071. protected _opacityTexture: Nullable<BaseTexture>;
  137072. /**
  137073. * Stores the reflection values in a texture.
  137074. */
  137075. protected _reflectionTexture: Nullable<BaseTexture>;
  137076. /**
  137077. * Stores the emissive values in a texture.
  137078. */
  137079. protected _emissiveTexture: Nullable<BaseTexture>;
  137080. /**
  137081. * AKA Specular texture in other nomenclature.
  137082. */
  137083. protected _reflectivityTexture: Nullable<BaseTexture>;
  137084. /**
  137085. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137086. */
  137087. protected _metallicTexture: Nullable<BaseTexture>;
  137088. /**
  137089. * Specifies the metallic scalar of the metallic/roughness workflow.
  137090. * Can also be used to scale the metalness values of the metallic texture.
  137091. */
  137092. protected _metallic: Nullable<number>;
  137093. /**
  137094. * Specifies the roughness scalar of the metallic/roughness workflow.
  137095. * Can also be used to scale the roughness values of the metallic texture.
  137096. */
  137097. protected _roughness: Nullable<number>;
  137098. /**
  137099. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137100. * By default the indexOfrefraction is used to compute F0;
  137101. *
  137102. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137103. *
  137104. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137105. * F90 = metallicReflectanceColor;
  137106. */
  137107. protected _metallicF0Factor: number;
  137108. /**
  137109. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137110. * By default the F90 is always 1;
  137111. *
  137112. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137113. *
  137114. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137115. * F90 = metallicReflectanceColor;
  137116. */
  137117. protected _metallicReflectanceColor: Color3;
  137118. /**
  137119. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137120. * This is multiply against the scalar values defined in the material.
  137121. */
  137122. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137123. /**
  137124. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137125. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137126. */
  137127. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137128. /**
  137129. * Stores surface normal data used to displace a mesh in a texture.
  137130. */
  137131. protected _bumpTexture: Nullable<BaseTexture>;
  137132. /**
  137133. * Stores the pre-calculated light information of a mesh in a texture.
  137134. */
  137135. protected _lightmapTexture: Nullable<BaseTexture>;
  137136. /**
  137137. * The color of a material in ambient lighting.
  137138. */
  137139. protected _ambientColor: Color3;
  137140. /**
  137141. * AKA Diffuse Color in other nomenclature.
  137142. */
  137143. protected _albedoColor: Color3;
  137144. /**
  137145. * AKA Specular Color in other nomenclature.
  137146. */
  137147. protected _reflectivityColor: Color3;
  137148. /**
  137149. * The color applied when light is reflected from a material.
  137150. */
  137151. protected _reflectionColor: Color3;
  137152. /**
  137153. * The color applied when light is emitted from a material.
  137154. */
  137155. protected _emissiveColor: Color3;
  137156. /**
  137157. * AKA Glossiness in other nomenclature.
  137158. */
  137159. protected _microSurface: number;
  137160. /**
  137161. * Specifies that the material will use the light map as a show map.
  137162. */
  137163. protected _useLightmapAsShadowmap: boolean;
  137164. /**
  137165. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137166. * makes the reflect vector face the model (under horizon).
  137167. */
  137168. protected _useHorizonOcclusion: boolean;
  137169. /**
  137170. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137171. * too much the area relying on ambient texture to define their ambient occlusion.
  137172. */
  137173. protected _useRadianceOcclusion: boolean;
  137174. /**
  137175. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137176. */
  137177. protected _useAlphaFromAlbedoTexture: boolean;
  137178. /**
  137179. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137180. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137181. */
  137182. protected _useSpecularOverAlpha: boolean;
  137183. /**
  137184. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137185. */
  137186. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137187. /**
  137188. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137189. */
  137190. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137191. /**
  137192. * Specifies if the metallic texture contains the roughness information in its green channel.
  137193. */
  137194. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137195. /**
  137196. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137197. */
  137198. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137199. /**
  137200. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137201. */
  137202. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137203. /**
  137204. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137205. */
  137206. protected _useAmbientInGrayScale: boolean;
  137207. /**
  137208. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137209. * The material will try to infer what glossiness each pixel should be.
  137210. */
  137211. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137212. /**
  137213. * Defines the falloff type used in this material.
  137214. * It by default is Physical.
  137215. */
  137216. protected _lightFalloff: number;
  137217. /**
  137218. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137219. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137220. */
  137221. protected _useRadianceOverAlpha: boolean;
  137222. /**
  137223. * Allows using an object space normal map (instead of tangent space).
  137224. */
  137225. protected _useObjectSpaceNormalMap: boolean;
  137226. /**
  137227. * Allows using the bump map in parallax mode.
  137228. */
  137229. protected _useParallax: boolean;
  137230. /**
  137231. * Allows using the bump map in parallax occlusion mode.
  137232. */
  137233. protected _useParallaxOcclusion: boolean;
  137234. /**
  137235. * Controls the scale bias of the parallax mode.
  137236. */
  137237. protected _parallaxScaleBias: number;
  137238. /**
  137239. * If sets to true, disables all the lights affecting the material.
  137240. */
  137241. protected _disableLighting: boolean;
  137242. /**
  137243. * Number of Simultaneous lights allowed on the material.
  137244. */
  137245. protected _maxSimultaneousLights: number;
  137246. /**
  137247. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137248. */
  137249. protected _invertNormalMapX: boolean;
  137250. /**
  137251. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137252. */
  137253. protected _invertNormalMapY: boolean;
  137254. /**
  137255. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137256. */
  137257. protected _twoSidedLighting: boolean;
  137258. /**
  137259. * Defines the alpha limits in alpha test mode.
  137260. */
  137261. protected _alphaCutOff: number;
  137262. /**
  137263. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137264. */
  137265. protected _forceAlphaTest: boolean;
  137266. /**
  137267. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137268. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137269. */
  137270. protected _useAlphaFresnel: boolean;
  137271. /**
  137272. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137273. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137274. */
  137275. protected _useLinearAlphaFresnel: boolean;
  137276. /**
  137277. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137278. * from cos thetav and roughness:
  137279. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137280. */
  137281. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137282. /**
  137283. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137284. */
  137285. protected _forceIrradianceInFragment: boolean;
  137286. private _realTimeFiltering;
  137287. /**
  137288. * Enables realtime filtering on the texture.
  137289. */
  137290. get realTimeFiltering(): boolean;
  137291. set realTimeFiltering(b: boolean);
  137292. private _realTimeFilteringQuality;
  137293. /**
  137294. * Quality switch for realtime filtering
  137295. */
  137296. get realTimeFilteringQuality(): number;
  137297. set realTimeFilteringQuality(n: number);
  137298. /**
  137299. * Can this material render to several textures at once
  137300. */
  137301. get canRenderToMRT(): boolean;
  137302. /**
  137303. * Force normal to face away from face.
  137304. */
  137305. protected _forceNormalForward: boolean;
  137306. /**
  137307. * Enables specular anti aliasing in the PBR shader.
  137308. * It will both interacts on the Geometry for analytical and IBL lighting.
  137309. * It also prefilter the roughness map based on the bump values.
  137310. */
  137311. protected _enableSpecularAntiAliasing: boolean;
  137312. /**
  137313. * Default configuration related to image processing available in the PBR Material.
  137314. */
  137315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137316. /**
  137317. * Keep track of the image processing observer to allow dispose and replace.
  137318. */
  137319. private _imageProcessingObserver;
  137320. /**
  137321. * Attaches a new image processing configuration to the PBR Material.
  137322. * @param configuration
  137323. */
  137324. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137325. /**
  137326. * Stores the available render targets.
  137327. */
  137328. private _renderTargets;
  137329. /**
  137330. * Sets the global ambient color for the material used in lighting calculations.
  137331. */
  137332. private _globalAmbientColor;
  137333. /**
  137334. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137335. */
  137336. private _useLogarithmicDepth;
  137337. /**
  137338. * If set to true, no lighting calculations will be applied.
  137339. */
  137340. private _unlit;
  137341. private _debugMode;
  137342. /**
  137343. * @hidden
  137344. * This is reserved for the inspector.
  137345. * Defines the material debug mode.
  137346. * It helps seeing only some components of the material while troubleshooting.
  137347. */
  137348. debugMode: number;
  137349. /**
  137350. * @hidden
  137351. * This is reserved for the inspector.
  137352. * Specify from where on screen the debug mode should start.
  137353. * The value goes from -1 (full screen) to 1 (not visible)
  137354. * It helps with side by side comparison against the final render
  137355. * This defaults to -1
  137356. */
  137357. private debugLimit;
  137358. /**
  137359. * @hidden
  137360. * This is reserved for the inspector.
  137361. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137362. * You can use the factor to better multiply the final value.
  137363. */
  137364. private debugFactor;
  137365. /**
  137366. * Defines the clear coat layer parameters for the material.
  137367. */
  137368. readonly clearCoat: PBRClearCoatConfiguration;
  137369. /**
  137370. * Defines the anisotropic parameters for the material.
  137371. */
  137372. readonly anisotropy: PBRAnisotropicConfiguration;
  137373. /**
  137374. * Defines the BRDF parameters for the material.
  137375. */
  137376. readonly brdf: PBRBRDFConfiguration;
  137377. /**
  137378. * Defines the Sheen parameters for the material.
  137379. */
  137380. readonly sheen: PBRSheenConfiguration;
  137381. /**
  137382. * Defines the SubSurface parameters for the material.
  137383. */
  137384. readonly subSurface: PBRSubSurfaceConfiguration;
  137385. /**
  137386. * Defines the detail map parameters for the material.
  137387. */
  137388. readonly detailMap: DetailMapConfiguration;
  137389. protected _rebuildInParallel: boolean;
  137390. /**
  137391. * Instantiates a new PBRMaterial instance.
  137392. *
  137393. * @param name The material name
  137394. * @param scene The scene the material will be use in.
  137395. */
  137396. constructor(name: string, scene: Scene);
  137397. /**
  137398. * Gets a boolean indicating that current material needs to register RTT
  137399. */
  137400. get hasRenderTargetTextures(): boolean;
  137401. /**
  137402. * Gets the name of the material class.
  137403. */
  137404. getClassName(): string;
  137405. /**
  137406. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137407. */
  137408. get useLogarithmicDepth(): boolean;
  137409. /**
  137410. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137411. */
  137412. set useLogarithmicDepth(value: boolean);
  137413. /**
  137414. * Returns true if alpha blending should be disabled.
  137415. */
  137416. protected get _disableAlphaBlending(): boolean;
  137417. /**
  137418. * Specifies whether or not this material should be rendered in alpha blend mode.
  137419. */
  137420. needAlphaBlending(): boolean;
  137421. /**
  137422. * Specifies whether or not this material should be rendered in alpha test mode.
  137423. */
  137424. needAlphaTesting(): boolean;
  137425. /**
  137426. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137427. */
  137428. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137429. /**
  137430. * Gets the texture used for the alpha test.
  137431. */
  137432. getAlphaTestTexture(): Nullable<BaseTexture>;
  137433. /**
  137434. * Specifies that the submesh is ready to be used.
  137435. * @param mesh - BJS mesh.
  137436. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137437. * @param useInstances - Specifies that instances should be used.
  137438. * @returns - boolean indicating that the submesh is ready or not.
  137439. */
  137440. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137441. /**
  137442. * Specifies if the material uses metallic roughness workflow.
  137443. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137444. */
  137445. isMetallicWorkflow(): boolean;
  137446. private _prepareEffect;
  137447. private _prepareDefines;
  137448. /**
  137449. * Force shader compilation
  137450. */
  137451. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137452. /**
  137453. * Initializes the uniform buffer layout for the shader.
  137454. */
  137455. buildUniformLayout(): void;
  137456. /**
  137457. * Unbinds the material from the mesh
  137458. */
  137459. unbind(): void;
  137460. /**
  137461. * Binds the submesh data.
  137462. * @param world - The world matrix.
  137463. * @param mesh - The BJS mesh.
  137464. * @param subMesh - A submesh of the BJS mesh.
  137465. */
  137466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137467. /**
  137468. * Returns the animatable textures.
  137469. * @returns - Array of animatable textures.
  137470. */
  137471. getAnimatables(): IAnimatable[];
  137472. /**
  137473. * Returns the texture used for reflections.
  137474. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137475. */
  137476. private _getReflectionTexture;
  137477. /**
  137478. * Returns an array of the actively used textures.
  137479. * @returns - Array of BaseTextures
  137480. */
  137481. getActiveTextures(): BaseTexture[];
  137482. /**
  137483. * Checks to see if a texture is used in the material.
  137484. * @param texture - Base texture to use.
  137485. * @returns - Boolean specifying if a texture is used in the material.
  137486. */
  137487. hasTexture(texture: BaseTexture): boolean;
  137488. /**
  137489. * Sets the required values to the prepass renderer.
  137490. * @param prePassRenderer defines the prepass renderer to setup
  137491. */
  137492. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137493. /**
  137494. * Disposes the resources of the material.
  137495. * @param forceDisposeEffect - Forces the disposal of effects.
  137496. * @param forceDisposeTextures - Forces the disposal of all textures.
  137497. */
  137498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137499. }
  137500. }
  137501. declare module BABYLON {
  137502. /**
  137503. * The Physically based material of BJS.
  137504. *
  137505. * This offers the main features of a standard PBR material.
  137506. * For more information, please refer to the documentation :
  137507. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137508. */
  137509. export class PBRMaterial extends PBRBaseMaterial {
  137510. /**
  137511. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137512. */
  137513. static readonly PBRMATERIAL_OPAQUE: number;
  137514. /**
  137515. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137516. */
  137517. static readonly PBRMATERIAL_ALPHATEST: number;
  137518. /**
  137519. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137520. */
  137521. static readonly PBRMATERIAL_ALPHABLEND: number;
  137522. /**
  137523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137524. * They are also discarded below the alpha cutoff threshold to improve performances.
  137525. */
  137526. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137527. /**
  137528. * Defines the default value of how much AO map is occluding the analytical lights
  137529. * (point spot...).
  137530. */
  137531. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137532. /**
  137533. * Intensity of the direct lights e.g. the four lights available in your scene.
  137534. * This impacts both the direct diffuse and specular highlights.
  137535. */
  137536. directIntensity: number;
  137537. /**
  137538. * Intensity of the emissive part of the material.
  137539. * This helps controlling the emissive effect without modifying the emissive color.
  137540. */
  137541. emissiveIntensity: number;
  137542. /**
  137543. * Intensity of the environment e.g. how much the environment will light the object
  137544. * either through harmonics for rough material or through the refelction for shiny ones.
  137545. */
  137546. environmentIntensity: number;
  137547. /**
  137548. * This is a special control allowing the reduction of the specular highlights coming from the
  137549. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137550. */
  137551. specularIntensity: number;
  137552. /**
  137553. * Debug Control allowing disabling the bump map on this material.
  137554. */
  137555. disableBumpMap: boolean;
  137556. /**
  137557. * AKA Diffuse Texture in standard nomenclature.
  137558. */
  137559. albedoTexture: BaseTexture;
  137560. /**
  137561. * AKA Occlusion Texture in other nomenclature.
  137562. */
  137563. ambientTexture: BaseTexture;
  137564. /**
  137565. * AKA Occlusion Texture Intensity in other nomenclature.
  137566. */
  137567. ambientTextureStrength: number;
  137568. /**
  137569. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137570. * 1 means it completely occludes it
  137571. * 0 mean it has no impact
  137572. */
  137573. ambientTextureImpactOnAnalyticalLights: number;
  137574. /**
  137575. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137576. */
  137577. opacityTexture: BaseTexture;
  137578. /**
  137579. * Stores the reflection values in a texture.
  137580. */
  137581. reflectionTexture: Nullable<BaseTexture>;
  137582. /**
  137583. * Stores the emissive values in a texture.
  137584. */
  137585. emissiveTexture: BaseTexture;
  137586. /**
  137587. * AKA Specular texture in other nomenclature.
  137588. */
  137589. reflectivityTexture: BaseTexture;
  137590. /**
  137591. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137592. */
  137593. metallicTexture: BaseTexture;
  137594. /**
  137595. * Specifies the metallic scalar of the metallic/roughness workflow.
  137596. * Can also be used to scale the metalness values of the metallic texture.
  137597. */
  137598. metallic: Nullable<number>;
  137599. /**
  137600. * Specifies the roughness scalar of the metallic/roughness workflow.
  137601. * Can also be used to scale the roughness values of the metallic texture.
  137602. */
  137603. roughness: Nullable<number>;
  137604. /**
  137605. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137606. * By default the indexOfrefraction is used to compute F0;
  137607. *
  137608. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137609. *
  137610. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137611. * F90 = metallicReflectanceColor;
  137612. */
  137613. metallicF0Factor: number;
  137614. /**
  137615. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137616. * By default the F90 is always 1;
  137617. *
  137618. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137619. *
  137620. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137621. * F90 = metallicReflectanceColor;
  137622. */
  137623. metallicReflectanceColor: Color3;
  137624. /**
  137625. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137626. * This is multiply against the scalar values defined in the material.
  137627. */
  137628. metallicReflectanceTexture: Nullable<BaseTexture>;
  137629. /**
  137630. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137631. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137632. */
  137633. microSurfaceTexture: BaseTexture;
  137634. /**
  137635. * Stores surface normal data used to displace a mesh in a texture.
  137636. */
  137637. bumpTexture: BaseTexture;
  137638. /**
  137639. * Stores the pre-calculated light information of a mesh in a texture.
  137640. */
  137641. lightmapTexture: BaseTexture;
  137642. /**
  137643. * Stores the refracted light information in a texture.
  137644. */
  137645. get refractionTexture(): Nullable<BaseTexture>;
  137646. set refractionTexture(value: Nullable<BaseTexture>);
  137647. /**
  137648. * The color of a material in ambient lighting.
  137649. */
  137650. ambientColor: Color3;
  137651. /**
  137652. * AKA Diffuse Color in other nomenclature.
  137653. */
  137654. albedoColor: Color3;
  137655. /**
  137656. * AKA Specular Color in other nomenclature.
  137657. */
  137658. reflectivityColor: Color3;
  137659. /**
  137660. * The color reflected from the material.
  137661. */
  137662. reflectionColor: Color3;
  137663. /**
  137664. * The color emitted from the material.
  137665. */
  137666. emissiveColor: Color3;
  137667. /**
  137668. * AKA Glossiness in other nomenclature.
  137669. */
  137670. microSurface: number;
  137671. /**
  137672. * Index of refraction of the material base layer.
  137673. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137674. *
  137675. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137676. *
  137677. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137678. */
  137679. get indexOfRefraction(): number;
  137680. set indexOfRefraction(value: number);
  137681. /**
  137682. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137683. */
  137684. get invertRefractionY(): boolean;
  137685. set invertRefractionY(value: boolean);
  137686. /**
  137687. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137688. * Materials half opaque for instance using refraction could benefit from this control.
  137689. */
  137690. get linkRefractionWithTransparency(): boolean;
  137691. set linkRefractionWithTransparency(value: boolean);
  137692. /**
  137693. * If true, the light map contains occlusion information instead of lighting info.
  137694. */
  137695. useLightmapAsShadowmap: boolean;
  137696. /**
  137697. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137698. */
  137699. useAlphaFromAlbedoTexture: boolean;
  137700. /**
  137701. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137702. */
  137703. forceAlphaTest: boolean;
  137704. /**
  137705. * Defines the alpha limits in alpha test mode.
  137706. */
  137707. alphaCutOff: number;
  137708. /**
  137709. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137710. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137711. */
  137712. useSpecularOverAlpha: boolean;
  137713. /**
  137714. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137715. */
  137716. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137717. /**
  137718. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137719. */
  137720. useRoughnessFromMetallicTextureAlpha: boolean;
  137721. /**
  137722. * Specifies if the metallic texture contains the roughness information in its green channel.
  137723. */
  137724. useRoughnessFromMetallicTextureGreen: boolean;
  137725. /**
  137726. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137727. */
  137728. useMetallnessFromMetallicTextureBlue: boolean;
  137729. /**
  137730. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137731. */
  137732. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137733. /**
  137734. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137735. */
  137736. useAmbientInGrayScale: boolean;
  137737. /**
  137738. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137739. * The material will try to infer what glossiness each pixel should be.
  137740. */
  137741. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137742. /**
  137743. * BJS is using an harcoded light falloff based on a manually sets up range.
  137744. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137745. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137746. */
  137747. get usePhysicalLightFalloff(): boolean;
  137748. /**
  137749. * BJS is using an harcoded light falloff based on a manually sets up range.
  137750. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137751. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137752. */
  137753. set usePhysicalLightFalloff(value: boolean);
  137754. /**
  137755. * In order to support the falloff compatibility with gltf, a special mode has been added
  137756. * to reproduce the gltf light falloff.
  137757. */
  137758. get useGLTFLightFalloff(): boolean;
  137759. /**
  137760. * In order to support the falloff compatibility with gltf, a special mode has been added
  137761. * to reproduce the gltf light falloff.
  137762. */
  137763. set useGLTFLightFalloff(value: boolean);
  137764. /**
  137765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137767. */
  137768. useRadianceOverAlpha: boolean;
  137769. /**
  137770. * Allows using an object space normal map (instead of tangent space).
  137771. */
  137772. useObjectSpaceNormalMap: boolean;
  137773. /**
  137774. * Allows using the bump map in parallax mode.
  137775. */
  137776. useParallax: boolean;
  137777. /**
  137778. * Allows using the bump map in parallax occlusion mode.
  137779. */
  137780. useParallaxOcclusion: boolean;
  137781. /**
  137782. * Controls the scale bias of the parallax mode.
  137783. */
  137784. parallaxScaleBias: number;
  137785. /**
  137786. * If sets to true, disables all the lights affecting the material.
  137787. */
  137788. disableLighting: boolean;
  137789. /**
  137790. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137791. */
  137792. forceIrradianceInFragment: boolean;
  137793. /**
  137794. * Number of Simultaneous lights allowed on the material.
  137795. */
  137796. maxSimultaneousLights: number;
  137797. /**
  137798. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137799. */
  137800. invertNormalMapX: boolean;
  137801. /**
  137802. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137803. */
  137804. invertNormalMapY: boolean;
  137805. /**
  137806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137807. */
  137808. twoSidedLighting: boolean;
  137809. /**
  137810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137811. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137812. */
  137813. useAlphaFresnel: boolean;
  137814. /**
  137815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137816. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137817. */
  137818. useLinearAlphaFresnel: boolean;
  137819. /**
  137820. * Let user defines the brdf lookup texture used for IBL.
  137821. * A default 8bit version is embedded but you could point at :
  137822. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137823. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137824. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137825. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137826. */
  137827. environmentBRDFTexture: Nullable<BaseTexture>;
  137828. /**
  137829. * Force normal to face away from face.
  137830. */
  137831. forceNormalForward: boolean;
  137832. /**
  137833. * Enables specular anti aliasing in the PBR shader.
  137834. * It will both interacts on the Geometry for analytical and IBL lighting.
  137835. * It also prefilter the roughness map based on the bump values.
  137836. */
  137837. enableSpecularAntiAliasing: boolean;
  137838. /**
  137839. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137840. * makes the reflect vector face the model (under horizon).
  137841. */
  137842. useHorizonOcclusion: boolean;
  137843. /**
  137844. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137845. * too much the area relying on ambient texture to define their ambient occlusion.
  137846. */
  137847. useRadianceOcclusion: boolean;
  137848. /**
  137849. * If set to true, no lighting calculations will be applied.
  137850. */
  137851. unlit: boolean;
  137852. /**
  137853. * Gets the image processing configuration used either in this material.
  137854. */
  137855. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137856. /**
  137857. * Sets the Default image processing configuration used either in the this material.
  137858. *
  137859. * If sets to null, the scene one is in use.
  137860. */
  137861. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137862. /**
  137863. * Gets wether the color curves effect is enabled.
  137864. */
  137865. get cameraColorCurvesEnabled(): boolean;
  137866. /**
  137867. * Sets wether the color curves effect is enabled.
  137868. */
  137869. set cameraColorCurvesEnabled(value: boolean);
  137870. /**
  137871. * Gets wether the color grading effect is enabled.
  137872. */
  137873. get cameraColorGradingEnabled(): boolean;
  137874. /**
  137875. * Gets wether the color grading effect is enabled.
  137876. */
  137877. set cameraColorGradingEnabled(value: boolean);
  137878. /**
  137879. * Gets wether tonemapping is enabled or not.
  137880. */
  137881. get cameraToneMappingEnabled(): boolean;
  137882. /**
  137883. * Sets wether tonemapping is enabled or not
  137884. */
  137885. set cameraToneMappingEnabled(value: boolean);
  137886. /**
  137887. * The camera exposure used on this material.
  137888. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137889. * This corresponds to a photographic exposure.
  137890. */
  137891. get cameraExposure(): number;
  137892. /**
  137893. * The camera exposure used on this material.
  137894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137895. * This corresponds to a photographic exposure.
  137896. */
  137897. set cameraExposure(value: number);
  137898. /**
  137899. * Gets The camera contrast used on this material.
  137900. */
  137901. get cameraContrast(): number;
  137902. /**
  137903. * Sets The camera contrast used on this material.
  137904. */
  137905. set cameraContrast(value: number);
  137906. /**
  137907. * Gets the Color Grading 2D Lookup Texture.
  137908. */
  137909. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137910. /**
  137911. * Sets the Color Grading 2D Lookup Texture.
  137912. */
  137913. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137914. /**
  137915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137917. * 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;
  137918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137919. */
  137920. get cameraColorCurves(): Nullable<ColorCurves>;
  137921. /**
  137922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137924. * 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;
  137925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137926. */
  137927. set cameraColorCurves(value: Nullable<ColorCurves>);
  137928. /**
  137929. * Instantiates a new PBRMaterial instance.
  137930. *
  137931. * @param name The material name
  137932. * @param scene The scene the material will be use in.
  137933. */
  137934. constructor(name: string, scene: Scene);
  137935. /**
  137936. * Returns the name of this material class.
  137937. */
  137938. getClassName(): string;
  137939. /**
  137940. * Makes a duplicate of the current material.
  137941. * @param name - name to use for the new material.
  137942. */
  137943. clone(name: string): PBRMaterial;
  137944. /**
  137945. * Serializes this PBR Material.
  137946. * @returns - An object with the serialized material.
  137947. */
  137948. serialize(): any;
  137949. /**
  137950. * Parses a PBR Material from a serialized object.
  137951. * @param source - Serialized object.
  137952. * @param scene - BJS scene instance.
  137953. * @param rootUrl - url for the scene object
  137954. * @returns - PBRMaterial
  137955. */
  137956. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137957. }
  137958. }
  137959. declare module BABYLON {
  137960. /**
  137961. * Direct draw surface info
  137962. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137963. */
  137964. export interface DDSInfo {
  137965. /**
  137966. * Width of the texture
  137967. */
  137968. width: number;
  137969. /**
  137970. * Width of the texture
  137971. */
  137972. height: number;
  137973. /**
  137974. * Number of Mipmaps for the texture
  137975. * @see https://en.wikipedia.org/wiki/Mipmap
  137976. */
  137977. mipmapCount: number;
  137978. /**
  137979. * If the textures format is a known fourCC format
  137980. * @see https://www.fourcc.org/
  137981. */
  137982. isFourCC: boolean;
  137983. /**
  137984. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137985. */
  137986. isRGB: boolean;
  137987. /**
  137988. * If the texture is a lumincance format
  137989. */
  137990. isLuminance: boolean;
  137991. /**
  137992. * If this is a cube texture
  137993. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137994. */
  137995. isCube: boolean;
  137996. /**
  137997. * If the texture is a compressed format eg. FOURCC_DXT1
  137998. */
  137999. isCompressed: boolean;
  138000. /**
  138001. * The dxgiFormat of the texture
  138002. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138003. */
  138004. dxgiFormat: number;
  138005. /**
  138006. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138007. */
  138008. textureType: number;
  138009. /**
  138010. * Sphericle polynomial created for the dds texture
  138011. */
  138012. sphericalPolynomial?: SphericalPolynomial;
  138013. }
  138014. /**
  138015. * Class used to provide DDS decompression tools
  138016. */
  138017. export class DDSTools {
  138018. /**
  138019. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138020. */
  138021. static StoreLODInAlphaChannel: boolean;
  138022. /**
  138023. * Gets DDS information from an array buffer
  138024. * @param data defines the array buffer view to read data from
  138025. * @returns the DDS information
  138026. */
  138027. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138028. private static _FloatView;
  138029. private static _Int32View;
  138030. private static _ToHalfFloat;
  138031. private static _FromHalfFloat;
  138032. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138033. private static _GetHalfFloatRGBAArrayBuffer;
  138034. private static _GetFloatRGBAArrayBuffer;
  138035. private static _GetFloatAsUIntRGBAArrayBuffer;
  138036. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138037. private static _GetRGBAArrayBuffer;
  138038. private static _ExtractLongWordOrder;
  138039. private static _GetRGBArrayBuffer;
  138040. private static _GetLuminanceArrayBuffer;
  138041. /**
  138042. * Uploads DDS Levels to a Babylon Texture
  138043. * @hidden
  138044. */
  138045. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138046. }
  138047. interface ThinEngine {
  138048. /**
  138049. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138050. * @param rootUrl defines the url where the file to load is located
  138051. * @param scene defines the current scene
  138052. * @param lodScale defines scale to apply to the mip map selection
  138053. * @param lodOffset defines offset to apply to the mip map selection
  138054. * @param onLoad defines an optional callback raised when the texture is loaded
  138055. * @param onError defines an optional callback raised if there is an issue to load the texture
  138056. * @param format defines the format of the data
  138057. * @param forcedExtension defines the extension to use to pick the right loader
  138058. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138059. * @returns the cube texture as an InternalTexture
  138060. */
  138061. 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;
  138062. }
  138063. }
  138064. declare module BABYLON {
  138065. /**
  138066. * Implementation of the DDS Texture Loader.
  138067. * @hidden
  138068. */
  138069. export class _DDSTextureLoader implements IInternalTextureLoader {
  138070. /**
  138071. * Defines wether the loader supports cascade loading the different faces.
  138072. */
  138073. readonly supportCascades: boolean;
  138074. /**
  138075. * This returns if the loader support the current file information.
  138076. * @param extension defines the file extension of the file being loaded
  138077. * @returns true if the loader can load the specified file
  138078. */
  138079. canLoad(extension: string): boolean;
  138080. /**
  138081. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138082. * @param data contains the texture data
  138083. * @param texture defines the BabylonJS internal texture
  138084. * @param createPolynomials will be true if polynomials have been requested
  138085. * @param onLoad defines the callback to trigger once the texture is ready
  138086. * @param onError defines the callback to trigger in case of error
  138087. */
  138088. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138089. /**
  138090. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138091. * @param data contains the texture data
  138092. * @param texture defines the BabylonJS internal texture
  138093. * @param callback defines the method to call once ready to upload
  138094. */
  138095. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138096. }
  138097. }
  138098. declare module BABYLON {
  138099. /**
  138100. * Implementation of the ENV Texture Loader.
  138101. * @hidden
  138102. */
  138103. export class _ENVTextureLoader implements IInternalTextureLoader {
  138104. /**
  138105. * Defines wether the loader supports cascade loading the different faces.
  138106. */
  138107. readonly supportCascades: boolean;
  138108. /**
  138109. * This returns if the loader support the current file information.
  138110. * @param extension defines the file extension of the file being loaded
  138111. * @returns true if the loader can load the specified file
  138112. */
  138113. canLoad(extension: string): boolean;
  138114. /**
  138115. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138116. * @param data contains the texture data
  138117. * @param texture defines the BabylonJS internal texture
  138118. * @param createPolynomials will be true if polynomials have been requested
  138119. * @param onLoad defines the callback to trigger once the texture is ready
  138120. * @param onError defines the callback to trigger in case of error
  138121. */
  138122. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138123. /**
  138124. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138125. * @param data contains the texture data
  138126. * @param texture defines the BabylonJS internal texture
  138127. * @param callback defines the method to call once ready to upload
  138128. */
  138129. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138130. }
  138131. }
  138132. declare module BABYLON {
  138133. /**
  138134. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138135. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138136. */
  138137. export class KhronosTextureContainer {
  138138. /** contents of the KTX container file */
  138139. data: ArrayBufferView;
  138140. private static HEADER_LEN;
  138141. private static COMPRESSED_2D;
  138142. private static COMPRESSED_3D;
  138143. private static TEX_2D;
  138144. private static TEX_3D;
  138145. /**
  138146. * Gets the openGL type
  138147. */
  138148. glType: number;
  138149. /**
  138150. * Gets the openGL type size
  138151. */
  138152. glTypeSize: number;
  138153. /**
  138154. * Gets the openGL format
  138155. */
  138156. glFormat: number;
  138157. /**
  138158. * Gets the openGL internal format
  138159. */
  138160. glInternalFormat: number;
  138161. /**
  138162. * Gets the base internal format
  138163. */
  138164. glBaseInternalFormat: number;
  138165. /**
  138166. * Gets image width in pixel
  138167. */
  138168. pixelWidth: number;
  138169. /**
  138170. * Gets image height in pixel
  138171. */
  138172. pixelHeight: number;
  138173. /**
  138174. * Gets image depth in pixels
  138175. */
  138176. pixelDepth: number;
  138177. /**
  138178. * Gets the number of array elements
  138179. */
  138180. numberOfArrayElements: number;
  138181. /**
  138182. * Gets the number of faces
  138183. */
  138184. numberOfFaces: number;
  138185. /**
  138186. * Gets the number of mipmap levels
  138187. */
  138188. numberOfMipmapLevels: number;
  138189. /**
  138190. * Gets the bytes of key value data
  138191. */
  138192. bytesOfKeyValueData: number;
  138193. /**
  138194. * Gets the load type
  138195. */
  138196. loadType: number;
  138197. /**
  138198. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138199. */
  138200. isInvalid: boolean;
  138201. /**
  138202. * Creates a new KhronosTextureContainer
  138203. * @param data contents of the KTX container file
  138204. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138205. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138206. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138207. */
  138208. constructor(
  138209. /** contents of the KTX container file */
  138210. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138211. /**
  138212. * Uploads KTX content to a Babylon Texture.
  138213. * It is assumed that the texture has already been created & is currently bound
  138214. * @hidden
  138215. */
  138216. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138217. private _upload2DCompressedLevels;
  138218. /**
  138219. * Checks if the given data starts with a KTX file identifier.
  138220. * @param data the data to check
  138221. * @returns true if the data is a KTX file or false otherwise
  138222. */
  138223. static IsValid(data: ArrayBufferView): boolean;
  138224. }
  138225. }
  138226. declare module BABYLON {
  138227. /**
  138228. * Helper class to push actions to a pool of workers.
  138229. */
  138230. export class WorkerPool implements IDisposable {
  138231. private _workerInfos;
  138232. private _pendingActions;
  138233. /**
  138234. * Constructor
  138235. * @param workers Array of workers to use for actions
  138236. */
  138237. constructor(workers: Array<Worker>);
  138238. /**
  138239. * Terminates all workers and clears any pending actions.
  138240. */
  138241. dispose(): void;
  138242. /**
  138243. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138244. * pended until a worker has completed its action.
  138245. * @param action The action to perform. Call onComplete when the action is complete.
  138246. */
  138247. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138248. private _execute;
  138249. }
  138250. }
  138251. declare module BABYLON {
  138252. /**
  138253. * Class for loading KTX2 files
  138254. * @hidden
  138255. */
  138256. export class KhronosTextureContainer2 {
  138257. private static _WorkerPoolPromise?;
  138258. private static _Initialized;
  138259. private static _Ktx2Decoder;
  138260. /**
  138261. * URL to use when loading the KTX2 decoder module
  138262. */
  138263. static JSModuleURL: string;
  138264. /**
  138265. * Default number of workers used to handle data decoding
  138266. */
  138267. static DefaultNumWorkers: number;
  138268. private static GetDefaultNumWorkers;
  138269. private _engine;
  138270. private static _CreateWorkerPool;
  138271. /**
  138272. * Constructor
  138273. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138274. */
  138275. constructor(engine: ThinEngine, numWorkers?: number);
  138276. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138277. /**
  138278. * Stop all async operations and release resources.
  138279. */
  138280. dispose(): void;
  138281. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138282. /**
  138283. * Checks if the given data starts with a KTX2 file identifier.
  138284. * @param data the data to check
  138285. * @returns true if the data is a KTX2 file or false otherwise
  138286. */
  138287. static IsValid(data: ArrayBufferView): boolean;
  138288. }
  138289. export function workerFunc(): void;
  138290. }
  138291. declare module BABYLON {
  138292. /**
  138293. * Implementation of the KTX Texture Loader.
  138294. * @hidden
  138295. */
  138296. export class _KTXTextureLoader implements IInternalTextureLoader {
  138297. /**
  138298. * Defines wether the loader supports cascade loading the different faces.
  138299. */
  138300. readonly supportCascades: boolean;
  138301. /**
  138302. * This returns if the loader support the current file information.
  138303. * @param extension defines the file extension of the file being loaded
  138304. * @param mimeType defines the optional mime type of the file being loaded
  138305. * @returns true if the loader can load the specified file
  138306. */
  138307. canLoad(extension: string, mimeType?: string): boolean;
  138308. /**
  138309. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138310. * @param data contains the texture data
  138311. * @param texture defines the BabylonJS internal texture
  138312. * @param createPolynomials will be true if polynomials have been requested
  138313. * @param onLoad defines the callback to trigger once the texture is ready
  138314. * @param onError defines the callback to trigger in case of error
  138315. */
  138316. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138317. /**
  138318. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138319. * @param data contains the texture data
  138320. * @param texture defines the BabylonJS internal texture
  138321. * @param callback defines the method to call once ready to upload
  138322. */
  138323. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138324. }
  138325. }
  138326. declare module BABYLON {
  138327. /** @hidden */
  138328. export var _forceSceneHelpersToBundle: boolean;
  138329. interface Scene {
  138330. /**
  138331. * Creates a default light for the scene.
  138332. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138333. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138334. */
  138335. createDefaultLight(replace?: boolean): void;
  138336. /**
  138337. * Creates a default camera for the scene.
  138338. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138339. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138340. * @param replace has default false, when true replaces the active camera in the scene
  138341. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138342. */
  138343. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138344. /**
  138345. * Creates a default camera and a default light.
  138346. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138347. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138348. * @param replace has the default false, when true replaces the active camera/light in the scene
  138349. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138350. */
  138351. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138352. /**
  138353. * Creates a new sky box
  138354. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138355. * @param environmentTexture defines the texture to use as environment texture
  138356. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138357. * @param scale defines the overall scale of the skybox
  138358. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138359. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138360. * @returns a new mesh holding the sky box
  138361. */
  138362. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138363. /**
  138364. * Creates a new environment
  138365. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138366. * @param options defines the options you can use to configure the environment
  138367. * @returns the new EnvironmentHelper
  138368. */
  138369. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138370. /**
  138371. * Creates a new VREXperienceHelper
  138372. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138373. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138374. * @returns a new VREXperienceHelper
  138375. */
  138376. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138377. /**
  138378. * Creates a new WebXRDefaultExperience
  138379. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138380. * @param options experience options
  138381. * @returns a promise for a new WebXRDefaultExperience
  138382. */
  138383. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138384. }
  138385. }
  138386. declare module BABYLON {
  138387. /**
  138388. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138389. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138390. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138391. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138392. */
  138393. export class VideoDome extends TextureDome<VideoTexture> {
  138394. /**
  138395. * Define the video source as a Monoscopic panoramic 360 video.
  138396. */
  138397. static readonly MODE_MONOSCOPIC: number;
  138398. /**
  138399. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138400. */
  138401. static readonly MODE_TOPBOTTOM: number;
  138402. /**
  138403. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138404. */
  138405. static readonly MODE_SIDEBYSIDE: number;
  138406. /**
  138407. * Get the video texture associated with this video dome
  138408. */
  138409. get videoTexture(): VideoTexture;
  138410. /**
  138411. * Get the video mode of this dome
  138412. */
  138413. get videoMode(): number;
  138414. /**
  138415. * Set the video mode of this dome.
  138416. * @see textureMode
  138417. */
  138418. set videoMode(value: number);
  138419. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138420. }
  138421. }
  138422. declare module BABYLON {
  138423. /**
  138424. * This class can be used to get instrumentation data from a Babylon engine
  138425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138426. */
  138427. export class EngineInstrumentation implements IDisposable {
  138428. /**
  138429. * Define the instrumented engine.
  138430. */
  138431. engine: Engine;
  138432. private _captureGPUFrameTime;
  138433. private _gpuFrameTimeToken;
  138434. private _gpuFrameTime;
  138435. private _captureShaderCompilationTime;
  138436. private _shaderCompilationTime;
  138437. private _onBeginFrameObserver;
  138438. private _onEndFrameObserver;
  138439. private _onBeforeShaderCompilationObserver;
  138440. private _onAfterShaderCompilationObserver;
  138441. /**
  138442. * Gets the perf counter used for GPU frame time
  138443. */
  138444. get gpuFrameTimeCounter(): PerfCounter;
  138445. /**
  138446. * Gets the GPU frame time capture status
  138447. */
  138448. get captureGPUFrameTime(): boolean;
  138449. /**
  138450. * Enable or disable the GPU frame time capture
  138451. */
  138452. set captureGPUFrameTime(value: boolean);
  138453. /**
  138454. * Gets the perf counter used for shader compilation time
  138455. */
  138456. get shaderCompilationTimeCounter(): PerfCounter;
  138457. /**
  138458. * Gets the shader compilation time capture status
  138459. */
  138460. get captureShaderCompilationTime(): boolean;
  138461. /**
  138462. * Enable or disable the shader compilation time capture
  138463. */
  138464. set captureShaderCompilationTime(value: boolean);
  138465. /**
  138466. * Instantiates a new engine instrumentation.
  138467. * This class can be used to get instrumentation data from a Babylon engine
  138468. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138469. * @param engine Defines the engine to instrument
  138470. */
  138471. constructor(
  138472. /**
  138473. * Define the instrumented engine.
  138474. */
  138475. engine: Engine);
  138476. /**
  138477. * Dispose and release associated resources.
  138478. */
  138479. dispose(): void;
  138480. }
  138481. }
  138482. declare module BABYLON {
  138483. /**
  138484. * This class can be used to get instrumentation data from a Babylon engine
  138485. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138486. */
  138487. export class SceneInstrumentation implements IDisposable {
  138488. /**
  138489. * Defines the scene to instrument
  138490. */
  138491. scene: Scene;
  138492. private _captureActiveMeshesEvaluationTime;
  138493. private _activeMeshesEvaluationTime;
  138494. private _captureRenderTargetsRenderTime;
  138495. private _renderTargetsRenderTime;
  138496. private _captureFrameTime;
  138497. private _frameTime;
  138498. private _captureRenderTime;
  138499. private _renderTime;
  138500. private _captureInterFrameTime;
  138501. private _interFrameTime;
  138502. private _captureParticlesRenderTime;
  138503. private _particlesRenderTime;
  138504. private _captureSpritesRenderTime;
  138505. private _spritesRenderTime;
  138506. private _capturePhysicsTime;
  138507. private _physicsTime;
  138508. private _captureAnimationsTime;
  138509. private _animationsTime;
  138510. private _captureCameraRenderTime;
  138511. private _cameraRenderTime;
  138512. private _onBeforeActiveMeshesEvaluationObserver;
  138513. private _onAfterActiveMeshesEvaluationObserver;
  138514. private _onBeforeRenderTargetsRenderObserver;
  138515. private _onAfterRenderTargetsRenderObserver;
  138516. private _onAfterRenderObserver;
  138517. private _onBeforeDrawPhaseObserver;
  138518. private _onAfterDrawPhaseObserver;
  138519. private _onBeforeAnimationsObserver;
  138520. private _onBeforeParticlesRenderingObserver;
  138521. private _onAfterParticlesRenderingObserver;
  138522. private _onBeforeSpritesRenderingObserver;
  138523. private _onAfterSpritesRenderingObserver;
  138524. private _onBeforePhysicsObserver;
  138525. private _onAfterPhysicsObserver;
  138526. private _onAfterAnimationsObserver;
  138527. private _onBeforeCameraRenderObserver;
  138528. private _onAfterCameraRenderObserver;
  138529. /**
  138530. * Gets the perf counter used for active meshes evaluation time
  138531. */
  138532. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138533. /**
  138534. * Gets the active meshes evaluation time capture status
  138535. */
  138536. get captureActiveMeshesEvaluationTime(): boolean;
  138537. /**
  138538. * Enable or disable the active meshes evaluation time capture
  138539. */
  138540. set captureActiveMeshesEvaluationTime(value: boolean);
  138541. /**
  138542. * Gets the perf counter used for render targets render time
  138543. */
  138544. get renderTargetsRenderTimeCounter(): PerfCounter;
  138545. /**
  138546. * Gets the render targets render time capture status
  138547. */
  138548. get captureRenderTargetsRenderTime(): boolean;
  138549. /**
  138550. * Enable or disable the render targets render time capture
  138551. */
  138552. set captureRenderTargetsRenderTime(value: boolean);
  138553. /**
  138554. * Gets the perf counter used for particles render time
  138555. */
  138556. get particlesRenderTimeCounter(): PerfCounter;
  138557. /**
  138558. * Gets the particles render time capture status
  138559. */
  138560. get captureParticlesRenderTime(): boolean;
  138561. /**
  138562. * Enable or disable the particles render time capture
  138563. */
  138564. set captureParticlesRenderTime(value: boolean);
  138565. /**
  138566. * Gets the perf counter used for sprites render time
  138567. */
  138568. get spritesRenderTimeCounter(): PerfCounter;
  138569. /**
  138570. * Gets the sprites render time capture status
  138571. */
  138572. get captureSpritesRenderTime(): boolean;
  138573. /**
  138574. * Enable or disable the sprites render time capture
  138575. */
  138576. set captureSpritesRenderTime(value: boolean);
  138577. /**
  138578. * Gets the perf counter used for physics time
  138579. */
  138580. get physicsTimeCounter(): PerfCounter;
  138581. /**
  138582. * Gets the physics time capture status
  138583. */
  138584. get capturePhysicsTime(): boolean;
  138585. /**
  138586. * Enable or disable the physics time capture
  138587. */
  138588. set capturePhysicsTime(value: boolean);
  138589. /**
  138590. * Gets the perf counter used for animations time
  138591. */
  138592. get animationsTimeCounter(): PerfCounter;
  138593. /**
  138594. * Gets the animations time capture status
  138595. */
  138596. get captureAnimationsTime(): boolean;
  138597. /**
  138598. * Enable or disable the animations time capture
  138599. */
  138600. set captureAnimationsTime(value: boolean);
  138601. /**
  138602. * Gets the perf counter used for frame time capture
  138603. */
  138604. get frameTimeCounter(): PerfCounter;
  138605. /**
  138606. * Gets the frame time capture status
  138607. */
  138608. get captureFrameTime(): boolean;
  138609. /**
  138610. * Enable or disable the frame time capture
  138611. */
  138612. set captureFrameTime(value: boolean);
  138613. /**
  138614. * Gets the perf counter used for inter-frames time capture
  138615. */
  138616. get interFrameTimeCounter(): PerfCounter;
  138617. /**
  138618. * Gets the inter-frames time capture status
  138619. */
  138620. get captureInterFrameTime(): boolean;
  138621. /**
  138622. * Enable or disable the inter-frames time capture
  138623. */
  138624. set captureInterFrameTime(value: boolean);
  138625. /**
  138626. * Gets the perf counter used for render time capture
  138627. */
  138628. get renderTimeCounter(): PerfCounter;
  138629. /**
  138630. * Gets the render time capture status
  138631. */
  138632. get captureRenderTime(): boolean;
  138633. /**
  138634. * Enable or disable the render time capture
  138635. */
  138636. set captureRenderTime(value: boolean);
  138637. /**
  138638. * Gets the perf counter used for camera render time capture
  138639. */
  138640. get cameraRenderTimeCounter(): PerfCounter;
  138641. /**
  138642. * Gets the camera render time capture status
  138643. */
  138644. get captureCameraRenderTime(): boolean;
  138645. /**
  138646. * Enable or disable the camera render time capture
  138647. */
  138648. set captureCameraRenderTime(value: boolean);
  138649. /**
  138650. * Gets the perf counter used for draw calls
  138651. */
  138652. get drawCallsCounter(): PerfCounter;
  138653. /**
  138654. * Instantiates a new scene instrumentation.
  138655. * This class can be used to get instrumentation data from a Babylon engine
  138656. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138657. * @param scene Defines the scene to instrument
  138658. */
  138659. constructor(
  138660. /**
  138661. * Defines the scene to instrument
  138662. */
  138663. scene: Scene);
  138664. /**
  138665. * Dispose and release associated resources.
  138666. */
  138667. dispose(): void;
  138668. }
  138669. }
  138670. declare module BABYLON {
  138671. /** @hidden */
  138672. export var glowMapGenerationPixelShader: {
  138673. name: string;
  138674. shader: string;
  138675. };
  138676. }
  138677. declare module BABYLON {
  138678. /** @hidden */
  138679. export var glowMapGenerationVertexShader: {
  138680. name: string;
  138681. shader: string;
  138682. };
  138683. }
  138684. declare module BABYLON {
  138685. /**
  138686. * Effect layer options. This helps customizing the behaviour
  138687. * of the effect layer.
  138688. */
  138689. export interface IEffectLayerOptions {
  138690. /**
  138691. * Multiplication factor apply to the canvas size to compute the render target size
  138692. * used to generated the objects (the smaller the faster).
  138693. */
  138694. mainTextureRatio: number;
  138695. /**
  138696. * Enforces a fixed size texture to ensure effect stability across devices.
  138697. */
  138698. mainTextureFixedSize?: number;
  138699. /**
  138700. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138701. */
  138702. alphaBlendingMode: number;
  138703. /**
  138704. * The camera attached to the layer.
  138705. */
  138706. camera: Nullable<Camera>;
  138707. /**
  138708. * The rendering group to draw the layer in.
  138709. */
  138710. renderingGroupId: number;
  138711. }
  138712. /**
  138713. * The effect layer Helps adding post process effect blended with the main pass.
  138714. *
  138715. * This can be for instance use to generate glow or higlight effects on the scene.
  138716. *
  138717. * The effect layer class can not be used directly and is intented to inherited from to be
  138718. * customized per effects.
  138719. */
  138720. export abstract class EffectLayer {
  138721. private _vertexBuffers;
  138722. private _indexBuffer;
  138723. private _cachedDefines;
  138724. private _effectLayerMapGenerationEffect;
  138725. private _effectLayerOptions;
  138726. private _mergeEffect;
  138727. protected _scene: Scene;
  138728. protected _engine: Engine;
  138729. protected _maxSize: number;
  138730. protected _mainTextureDesiredSize: ISize;
  138731. protected _mainTexture: RenderTargetTexture;
  138732. protected _shouldRender: boolean;
  138733. protected _postProcesses: PostProcess[];
  138734. protected _textures: BaseTexture[];
  138735. protected _emissiveTextureAndColor: {
  138736. texture: Nullable<BaseTexture>;
  138737. color: Color4;
  138738. };
  138739. /**
  138740. * The name of the layer
  138741. */
  138742. name: string;
  138743. /**
  138744. * The clear color of the texture used to generate the glow map.
  138745. */
  138746. neutralColor: Color4;
  138747. /**
  138748. * Specifies whether the highlight layer is enabled or not.
  138749. */
  138750. isEnabled: boolean;
  138751. /**
  138752. * Gets the camera attached to the layer.
  138753. */
  138754. get camera(): Nullable<Camera>;
  138755. /**
  138756. * Gets the rendering group id the layer should render in.
  138757. */
  138758. get renderingGroupId(): number;
  138759. set renderingGroupId(renderingGroupId: number);
  138760. /**
  138761. * An event triggered when the effect layer has been disposed.
  138762. */
  138763. onDisposeObservable: Observable<EffectLayer>;
  138764. /**
  138765. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138766. */
  138767. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138768. /**
  138769. * An event triggered when the generated texture is being merged in the scene.
  138770. */
  138771. onBeforeComposeObservable: Observable<EffectLayer>;
  138772. /**
  138773. * An event triggered when the mesh is rendered into the effect render target.
  138774. */
  138775. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138776. /**
  138777. * An event triggered after the mesh has been rendered into the effect render target.
  138778. */
  138779. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138780. /**
  138781. * An event triggered when the generated texture has been merged in the scene.
  138782. */
  138783. onAfterComposeObservable: Observable<EffectLayer>;
  138784. /**
  138785. * An event triggered when the efffect layer changes its size.
  138786. */
  138787. onSizeChangedObservable: Observable<EffectLayer>;
  138788. /** @hidden */
  138789. static _SceneComponentInitialization: (scene: Scene) => void;
  138790. /**
  138791. * Instantiates a new effect Layer and references it in the scene.
  138792. * @param name The name of the layer
  138793. * @param scene The scene to use the layer in
  138794. */
  138795. constructor(
  138796. /** The Friendly of the effect in the scene */
  138797. name: string, scene: Scene);
  138798. /**
  138799. * Get the effect name of the layer.
  138800. * @return The effect name
  138801. */
  138802. abstract getEffectName(): string;
  138803. /**
  138804. * Checks for the readiness of the element composing the layer.
  138805. * @param subMesh the mesh to check for
  138806. * @param useInstances specify whether or not to use instances to render the mesh
  138807. * @return true if ready otherwise, false
  138808. */
  138809. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138810. /**
  138811. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138812. * @returns true if the effect requires stencil during the main canvas render pass.
  138813. */
  138814. abstract needStencil(): boolean;
  138815. /**
  138816. * Create the merge effect. This is the shader use to blit the information back
  138817. * to the main canvas at the end of the scene rendering.
  138818. * @returns The effect containing the shader used to merge the effect on the main canvas
  138819. */
  138820. protected abstract _createMergeEffect(): Effect;
  138821. /**
  138822. * Creates the render target textures and post processes used in the effect layer.
  138823. */
  138824. protected abstract _createTextureAndPostProcesses(): void;
  138825. /**
  138826. * Implementation specific of rendering the generating effect on the main canvas.
  138827. * @param effect The effect used to render through
  138828. */
  138829. protected abstract _internalRender(effect: Effect): void;
  138830. /**
  138831. * Sets the required values for both the emissive texture and and the main color.
  138832. */
  138833. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138834. /**
  138835. * Free any resources and references associated to a mesh.
  138836. * Internal use
  138837. * @param mesh The mesh to free.
  138838. */
  138839. abstract _disposeMesh(mesh: Mesh): void;
  138840. /**
  138841. * Serializes this layer (Glow or Highlight for example)
  138842. * @returns a serialized layer object
  138843. */
  138844. abstract serialize?(): any;
  138845. /**
  138846. * Initializes the effect layer with the required options.
  138847. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138848. */
  138849. protected _init(options: Partial<IEffectLayerOptions>): void;
  138850. /**
  138851. * Generates the index buffer of the full screen quad blending to the main canvas.
  138852. */
  138853. private _generateIndexBuffer;
  138854. /**
  138855. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138856. */
  138857. private _generateVertexBuffer;
  138858. /**
  138859. * Sets the main texture desired size which is the closest power of two
  138860. * of the engine canvas size.
  138861. */
  138862. private _setMainTextureSize;
  138863. /**
  138864. * Creates the main texture for the effect layer.
  138865. */
  138866. protected _createMainTexture(): void;
  138867. /**
  138868. * Adds specific effects defines.
  138869. * @param defines The defines to add specifics to.
  138870. */
  138871. protected _addCustomEffectDefines(defines: string[]): void;
  138872. /**
  138873. * Checks for the readiness of the element composing the layer.
  138874. * @param subMesh the mesh to check for
  138875. * @param useInstances specify whether or not to use instances to render the mesh
  138876. * @param emissiveTexture the associated emissive texture used to generate the glow
  138877. * @return true if ready otherwise, false
  138878. */
  138879. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138880. /**
  138881. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138882. */
  138883. render(): void;
  138884. /**
  138885. * Determine if a given mesh will be used in the current effect.
  138886. * @param mesh mesh to test
  138887. * @returns true if the mesh will be used
  138888. */
  138889. hasMesh(mesh: AbstractMesh): boolean;
  138890. /**
  138891. * Returns true if the layer contains information to display, otherwise false.
  138892. * @returns true if the glow layer should be rendered
  138893. */
  138894. shouldRender(): boolean;
  138895. /**
  138896. * Returns true if the mesh should render, otherwise false.
  138897. * @param mesh The mesh to render
  138898. * @returns true if it should render otherwise false
  138899. */
  138900. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138901. /**
  138902. * Returns true if the mesh can be rendered, otherwise false.
  138903. * @param mesh The mesh to render
  138904. * @param material The material used on the mesh
  138905. * @returns true if it can be rendered otherwise false
  138906. */
  138907. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138908. /**
  138909. * Returns true if the mesh should render, otherwise false.
  138910. * @param mesh The mesh to render
  138911. * @returns true if it should render otherwise false
  138912. */
  138913. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138914. /**
  138915. * Renders the submesh passed in parameter to the generation map.
  138916. */
  138917. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138918. /**
  138919. * Defines whether the current material of the mesh should be use to render the effect.
  138920. * @param mesh defines the current mesh to render
  138921. */
  138922. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138923. /**
  138924. * Rebuild the required buffers.
  138925. * @hidden Internal use only.
  138926. */
  138927. _rebuild(): void;
  138928. /**
  138929. * Dispose only the render target textures and post process.
  138930. */
  138931. private _disposeTextureAndPostProcesses;
  138932. /**
  138933. * Dispose the highlight layer and free resources.
  138934. */
  138935. dispose(): void;
  138936. /**
  138937. * Gets the class name of the effect layer
  138938. * @returns the string with the class name of the effect layer
  138939. */
  138940. getClassName(): string;
  138941. /**
  138942. * Creates an effect layer from parsed effect layer data
  138943. * @param parsedEffectLayer defines effect layer data
  138944. * @param scene defines the current scene
  138945. * @param rootUrl defines the root URL containing the effect layer information
  138946. * @returns a parsed effect Layer
  138947. */
  138948. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138949. }
  138950. }
  138951. declare module BABYLON {
  138952. interface AbstractScene {
  138953. /**
  138954. * The list of effect layers (highlights/glow) added to the scene
  138955. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138956. * @see https://doc.babylonjs.com/how_to/glow_layer
  138957. */
  138958. effectLayers: Array<EffectLayer>;
  138959. /**
  138960. * Removes the given effect layer from this scene.
  138961. * @param toRemove defines the effect layer to remove
  138962. * @returns the index of the removed effect layer
  138963. */
  138964. removeEffectLayer(toRemove: EffectLayer): number;
  138965. /**
  138966. * Adds the given effect layer to this scene
  138967. * @param newEffectLayer defines the effect layer to add
  138968. */
  138969. addEffectLayer(newEffectLayer: EffectLayer): void;
  138970. }
  138971. /**
  138972. * Defines the layer scene component responsible to manage any effect layers
  138973. * in a given scene.
  138974. */
  138975. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138976. /**
  138977. * The component name helpfull to identify the component in the list of scene components.
  138978. */
  138979. readonly name: string;
  138980. /**
  138981. * The scene the component belongs to.
  138982. */
  138983. scene: Scene;
  138984. private _engine;
  138985. private _renderEffects;
  138986. private _needStencil;
  138987. private _previousStencilState;
  138988. /**
  138989. * Creates a new instance of the component for the given scene
  138990. * @param scene Defines the scene to register the component in
  138991. */
  138992. constructor(scene: Scene);
  138993. /**
  138994. * Registers the component in a given scene
  138995. */
  138996. register(): void;
  138997. /**
  138998. * Rebuilds the elements related to this component in case of
  138999. * context lost for instance.
  139000. */
  139001. rebuild(): void;
  139002. /**
  139003. * Serializes the component data to the specified json object
  139004. * @param serializationObject The object to serialize to
  139005. */
  139006. serialize(serializationObject: any): void;
  139007. /**
  139008. * Adds all the elements from the container to the scene
  139009. * @param container the container holding the elements
  139010. */
  139011. addFromContainer(container: AbstractScene): void;
  139012. /**
  139013. * Removes all the elements in the container from the scene
  139014. * @param container contains the elements to remove
  139015. * @param dispose if the removed element should be disposed (default: false)
  139016. */
  139017. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139018. /**
  139019. * Disposes the component and the associated ressources.
  139020. */
  139021. dispose(): void;
  139022. private _isReadyForMesh;
  139023. private _renderMainTexture;
  139024. private _setStencil;
  139025. private _setStencilBack;
  139026. private _draw;
  139027. private _drawCamera;
  139028. private _drawRenderingGroup;
  139029. }
  139030. }
  139031. declare module BABYLON {
  139032. /** @hidden */
  139033. export var glowMapMergePixelShader: {
  139034. name: string;
  139035. shader: string;
  139036. };
  139037. }
  139038. declare module BABYLON {
  139039. /** @hidden */
  139040. export var glowMapMergeVertexShader: {
  139041. name: string;
  139042. shader: string;
  139043. };
  139044. }
  139045. declare module BABYLON {
  139046. interface AbstractScene {
  139047. /**
  139048. * Return a the first highlight layer of the scene with a given name.
  139049. * @param name The name of the highlight layer to look for.
  139050. * @return The highlight layer if found otherwise null.
  139051. */
  139052. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139053. }
  139054. /**
  139055. * Glow layer options. This helps customizing the behaviour
  139056. * of the glow layer.
  139057. */
  139058. export interface IGlowLayerOptions {
  139059. /**
  139060. * Multiplication factor apply to the canvas size to compute the render target size
  139061. * used to generated the glowing objects (the smaller the faster).
  139062. */
  139063. mainTextureRatio: number;
  139064. /**
  139065. * Enforces a fixed size texture to ensure resize independant blur.
  139066. */
  139067. mainTextureFixedSize?: number;
  139068. /**
  139069. * How big is the kernel of the blur texture.
  139070. */
  139071. blurKernelSize: number;
  139072. /**
  139073. * The camera attached to the layer.
  139074. */
  139075. camera: Nullable<Camera>;
  139076. /**
  139077. * Enable MSAA by chosing the number of samples.
  139078. */
  139079. mainTextureSamples?: number;
  139080. /**
  139081. * The rendering group to draw the layer in.
  139082. */
  139083. renderingGroupId: number;
  139084. }
  139085. /**
  139086. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139087. *
  139088. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139089. *
  139090. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139091. */
  139092. export class GlowLayer extends EffectLayer {
  139093. /**
  139094. * Effect Name of the layer.
  139095. */
  139096. static readonly EffectName: string;
  139097. /**
  139098. * The default blur kernel size used for the glow.
  139099. */
  139100. static DefaultBlurKernelSize: number;
  139101. /**
  139102. * The default texture size ratio used for the glow.
  139103. */
  139104. static DefaultTextureRatio: number;
  139105. /**
  139106. * Sets the kernel size of the blur.
  139107. */
  139108. set blurKernelSize(value: number);
  139109. /**
  139110. * Gets the kernel size of the blur.
  139111. */
  139112. get blurKernelSize(): number;
  139113. /**
  139114. * Sets the glow intensity.
  139115. */
  139116. set intensity(value: number);
  139117. /**
  139118. * Gets the glow intensity.
  139119. */
  139120. get intensity(): number;
  139121. private _options;
  139122. private _intensity;
  139123. private _horizontalBlurPostprocess1;
  139124. private _verticalBlurPostprocess1;
  139125. private _horizontalBlurPostprocess2;
  139126. private _verticalBlurPostprocess2;
  139127. private _blurTexture1;
  139128. private _blurTexture2;
  139129. private _postProcesses1;
  139130. private _postProcesses2;
  139131. private _includedOnlyMeshes;
  139132. private _excludedMeshes;
  139133. private _meshesUsingTheirOwnMaterials;
  139134. /**
  139135. * Callback used to let the user override the color selection on a per mesh basis
  139136. */
  139137. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139138. /**
  139139. * Callback used to let the user override the texture selection on a per mesh basis
  139140. */
  139141. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139142. /**
  139143. * Instantiates a new glow Layer and references it to the scene.
  139144. * @param name The name of the layer
  139145. * @param scene The scene to use the layer in
  139146. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139147. */
  139148. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139149. /**
  139150. * Get the effect name of the layer.
  139151. * @return The effect name
  139152. */
  139153. getEffectName(): string;
  139154. /**
  139155. * Create the merge effect. This is the shader use to blit the information back
  139156. * to the main canvas at the end of the scene rendering.
  139157. */
  139158. protected _createMergeEffect(): Effect;
  139159. /**
  139160. * Creates the render target textures and post processes used in the glow layer.
  139161. */
  139162. protected _createTextureAndPostProcesses(): void;
  139163. /**
  139164. * Checks for the readiness of the element composing the layer.
  139165. * @param subMesh the mesh to check for
  139166. * @param useInstances specify wether or not to use instances to render the mesh
  139167. * @param emissiveTexture the associated emissive texture used to generate the glow
  139168. * @return true if ready otherwise, false
  139169. */
  139170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139171. /**
  139172. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139173. */
  139174. needStencil(): boolean;
  139175. /**
  139176. * Returns true if the mesh can be rendered, otherwise false.
  139177. * @param mesh The mesh to render
  139178. * @param material The material used on the mesh
  139179. * @returns true if it can be rendered otherwise false
  139180. */
  139181. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139182. /**
  139183. * Implementation specific of rendering the generating effect on the main canvas.
  139184. * @param effect The effect used to render through
  139185. */
  139186. protected _internalRender(effect: Effect): void;
  139187. /**
  139188. * Sets the required values for both the emissive texture and and the main color.
  139189. */
  139190. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139191. /**
  139192. * Returns true if the mesh should render, otherwise false.
  139193. * @param mesh The mesh to render
  139194. * @returns true if it should render otherwise false
  139195. */
  139196. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139197. /**
  139198. * Adds specific effects defines.
  139199. * @param defines The defines to add specifics to.
  139200. */
  139201. protected _addCustomEffectDefines(defines: string[]): void;
  139202. /**
  139203. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139204. * @param mesh The mesh to exclude from the glow layer
  139205. */
  139206. addExcludedMesh(mesh: Mesh): void;
  139207. /**
  139208. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139209. * @param mesh The mesh to remove
  139210. */
  139211. removeExcludedMesh(mesh: Mesh): void;
  139212. /**
  139213. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139214. * @param mesh The mesh to include in the glow layer
  139215. */
  139216. addIncludedOnlyMesh(mesh: Mesh): void;
  139217. /**
  139218. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139219. * @param mesh The mesh to remove
  139220. */
  139221. removeIncludedOnlyMesh(mesh: Mesh): void;
  139222. /**
  139223. * Determine if a given mesh will be used in the glow layer
  139224. * @param mesh The mesh to test
  139225. * @returns true if the mesh will be highlighted by the current glow layer
  139226. */
  139227. hasMesh(mesh: AbstractMesh): boolean;
  139228. /**
  139229. * Defines whether the current material of the mesh should be use to render the effect.
  139230. * @param mesh defines the current mesh to render
  139231. */
  139232. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139233. /**
  139234. * Add a mesh to be rendered through its own material and not with emissive only.
  139235. * @param mesh The mesh for which we need to use its material
  139236. */
  139237. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139238. /**
  139239. * Remove a mesh from being rendered through its own material and not with emissive only.
  139240. * @param mesh The mesh for which we need to not use its material
  139241. */
  139242. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139243. /**
  139244. * Free any resources and references associated to a mesh.
  139245. * Internal use
  139246. * @param mesh The mesh to free.
  139247. * @hidden
  139248. */
  139249. _disposeMesh(mesh: Mesh): void;
  139250. /**
  139251. * Gets the class name of the effect layer
  139252. * @returns the string with the class name of the effect layer
  139253. */
  139254. getClassName(): string;
  139255. /**
  139256. * Serializes this glow layer
  139257. * @returns a serialized glow layer object
  139258. */
  139259. serialize(): any;
  139260. /**
  139261. * Creates a Glow Layer from parsed glow layer data
  139262. * @param parsedGlowLayer defines glow layer data
  139263. * @param scene defines the current scene
  139264. * @param rootUrl defines the root URL containing the glow layer information
  139265. * @returns a parsed Glow Layer
  139266. */
  139267. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139268. }
  139269. }
  139270. declare module BABYLON {
  139271. /** @hidden */
  139272. export var glowBlurPostProcessPixelShader: {
  139273. name: string;
  139274. shader: string;
  139275. };
  139276. }
  139277. declare module BABYLON {
  139278. interface AbstractScene {
  139279. /**
  139280. * Return a the first highlight layer of the scene with a given name.
  139281. * @param name The name of the highlight layer to look for.
  139282. * @return The highlight layer if found otherwise null.
  139283. */
  139284. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139285. }
  139286. /**
  139287. * Highlight layer options. This helps customizing the behaviour
  139288. * of the highlight layer.
  139289. */
  139290. export interface IHighlightLayerOptions {
  139291. /**
  139292. * Multiplication factor apply to the canvas size to compute the render target size
  139293. * used to generated the glowing objects (the smaller the faster).
  139294. */
  139295. mainTextureRatio: number;
  139296. /**
  139297. * Enforces a fixed size texture to ensure resize independant blur.
  139298. */
  139299. mainTextureFixedSize?: number;
  139300. /**
  139301. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139302. * of the picture to blur (the smaller the faster).
  139303. */
  139304. blurTextureSizeRatio: number;
  139305. /**
  139306. * How big in texel of the blur texture is the vertical blur.
  139307. */
  139308. blurVerticalSize: number;
  139309. /**
  139310. * How big in texel of the blur texture is the horizontal blur.
  139311. */
  139312. blurHorizontalSize: number;
  139313. /**
  139314. * Alpha blending mode used to apply the blur. Default is combine.
  139315. */
  139316. alphaBlendingMode: number;
  139317. /**
  139318. * The camera attached to the layer.
  139319. */
  139320. camera: Nullable<Camera>;
  139321. /**
  139322. * Should we display highlight as a solid stroke?
  139323. */
  139324. isStroke?: boolean;
  139325. /**
  139326. * The rendering group to draw the layer in.
  139327. */
  139328. renderingGroupId: number;
  139329. }
  139330. /**
  139331. * The highlight layer Helps adding a glow effect around a mesh.
  139332. *
  139333. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139334. * glowy meshes to your scene.
  139335. *
  139336. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139337. */
  139338. export class HighlightLayer extends EffectLayer {
  139339. name: string;
  139340. /**
  139341. * Effect Name of the highlight layer.
  139342. */
  139343. static readonly EffectName: string;
  139344. /**
  139345. * The neutral color used during the preparation of the glow effect.
  139346. * This is black by default as the blend operation is a blend operation.
  139347. */
  139348. static NeutralColor: Color4;
  139349. /**
  139350. * Stencil value used for glowing meshes.
  139351. */
  139352. static GlowingMeshStencilReference: number;
  139353. /**
  139354. * Stencil value used for the other meshes in the scene.
  139355. */
  139356. static NormalMeshStencilReference: number;
  139357. /**
  139358. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139359. */
  139360. innerGlow: boolean;
  139361. /**
  139362. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139363. */
  139364. outerGlow: boolean;
  139365. /**
  139366. * Specifies the horizontal size of the blur.
  139367. */
  139368. set blurHorizontalSize(value: number);
  139369. /**
  139370. * Specifies the vertical size of the blur.
  139371. */
  139372. set blurVerticalSize(value: number);
  139373. /**
  139374. * Gets the horizontal size of the blur.
  139375. */
  139376. get blurHorizontalSize(): number;
  139377. /**
  139378. * Gets the vertical size of the blur.
  139379. */
  139380. get blurVerticalSize(): number;
  139381. /**
  139382. * An event triggered when the highlight layer is being blurred.
  139383. */
  139384. onBeforeBlurObservable: Observable<HighlightLayer>;
  139385. /**
  139386. * An event triggered when the highlight layer has been blurred.
  139387. */
  139388. onAfterBlurObservable: Observable<HighlightLayer>;
  139389. private _instanceGlowingMeshStencilReference;
  139390. private _options;
  139391. private _downSamplePostprocess;
  139392. private _horizontalBlurPostprocess;
  139393. private _verticalBlurPostprocess;
  139394. private _blurTexture;
  139395. private _meshes;
  139396. private _excludedMeshes;
  139397. /**
  139398. * Instantiates a new highlight Layer and references it to the scene..
  139399. * @param name The name of the layer
  139400. * @param scene The scene to use the layer in
  139401. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139402. */
  139403. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139404. /**
  139405. * Get the effect name of the layer.
  139406. * @return The effect name
  139407. */
  139408. getEffectName(): string;
  139409. /**
  139410. * Create the merge effect. This is the shader use to blit the information back
  139411. * to the main canvas at the end of the scene rendering.
  139412. */
  139413. protected _createMergeEffect(): Effect;
  139414. /**
  139415. * Creates the render target textures and post processes used in the highlight layer.
  139416. */
  139417. protected _createTextureAndPostProcesses(): void;
  139418. /**
  139419. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139420. */
  139421. needStencil(): boolean;
  139422. /**
  139423. * Checks for the readiness of the element composing the layer.
  139424. * @param subMesh the mesh to check for
  139425. * @param useInstances specify wether or not to use instances to render the mesh
  139426. * @param emissiveTexture the associated emissive texture used to generate the glow
  139427. * @return true if ready otherwise, false
  139428. */
  139429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139430. /**
  139431. * Implementation specific of rendering the generating effect on the main canvas.
  139432. * @param effect The effect used to render through
  139433. */
  139434. protected _internalRender(effect: Effect): void;
  139435. /**
  139436. * Returns true if the layer contains information to display, otherwise false.
  139437. */
  139438. shouldRender(): boolean;
  139439. /**
  139440. * Returns true if the mesh should render, otherwise false.
  139441. * @param mesh The mesh to render
  139442. * @returns true if it should render otherwise false
  139443. */
  139444. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139445. /**
  139446. * Returns true if the mesh can be rendered, otherwise false.
  139447. * @param mesh The mesh to render
  139448. * @param material The material used on the mesh
  139449. * @returns true if it can be rendered otherwise false
  139450. */
  139451. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139452. /**
  139453. * Adds specific effects defines.
  139454. * @param defines The defines to add specifics to.
  139455. */
  139456. protected _addCustomEffectDefines(defines: string[]): void;
  139457. /**
  139458. * Sets the required values for both the emissive texture and and the main color.
  139459. */
  139460. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139461. /**
  139462. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139463. * @param mesh The mesh to exclude from the highlight layer
  139464. */
  139465. addExcludedMesh(mesh: Mesh): void;
  139466. /**
  139467. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139468. * @param mesh The mesh to highlight
  139469. */
  139470. removeExcludedMesh(mesh: Mesh): void;
  139471. /**
  139472. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139473. * @param mesh mesh to test
  139474. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139475. */
  139476. hasMesh(mesh: AbstractMesh): boolean;
  139477. /**
  139478. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139479. * @param mesh The mesh to highlight
  139480. * @param color The color of the highlight
  139481. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139482. */
  139483. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139484. /**
  139485. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139486. * @param mesh The mesh to highlight
  139487. */
  139488. removeMesh(mesh: Mesh): void;
  139489. /**
  139490. * Remove all the meshes currently referenced in the highlight layer
  139491. */
  139492. removeAllMeshes(): void;
  139493. /**
  139494. * Force the stencil to the normal expected value for none glowing parts
  139495. */
  139496. private _defaultStencilReference;
  139497. /**
  139498. * Free any resources and references associated to a mesh.
  139499. * Internal use
  139500. * @param mesh The mesh to free.
  139501. * @hidden
  139502. */
  139503. _disposeMesh(mesh: Mesh): void;
  139504. /**
  139505. * Dispose the highlight layer and free resources.
  139506. */
  139507. dispose(): void;
  139508. /**
  139509. * Gets the class name of the effect layer
  139510. * @returns the string with the class name of the effect layer
  139511. */
  139512. getClassName(): string;
  139513. /**
  139514. * Serializes this Highlight layer
  139515. * @returns a serialized Highlight layer object
  139516. */
  139517. serialize(): any;
  139518. /**
  139519. * Creates a Highlight layer from parsed Highlight layer data
  139520. * @param parsedHightlightLayer defines the Highlight layer data
  139521. * @param scene defines the current scene
  139522. * @param rootUrl defines the root URL containing the Highlight layer information
  139523. * @returns a parsed Highlight layer
  139524. */
  139525. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139526. }
  139527. }
  139528. declare module BABYLON {
  139529. interface AbstractScene {
  139530. /**
  139531. * The list of layers (background and foreground) of the scene
  139532. */
  139533. layers: Array<Layer>;
  139534. }
  139535. /**
  139536. * Defines the layer scene component responsible to manage any layers
  139537. * in a given scene.
  139538. */
  139539. export class LayerSceneComponent implements ISceneComponent {
  139540. /**
  139541. * The component name helpfull to identify the component in the list of scene components.
  139542. */
  139543. readonly name: string;
  139544. /**
  139545. * The scene the component belongs to.
  139546. */
  139547. scene: Scene;
  139548. private _engine;
  139549. /**
  139550. * Creates a new instance of the component for the given scene
  139551. * @param scene Defines the scene to register the component in
  139552. */
  139553. constructor(scene: Scene);
  139554. /**
  139555. * Registers the component in a given scene
  139556. */
  139557. register(): void;
  139558. /**
  139559. * Rebuilds the elements related to this component in case of
  139560. * context lost for instance.
  139561. */
  139562. rebuild(): void;
  139563. /**
  139564. * Disposes the component and the associated ressources.
  139565. */
  139566. dispose(): void;
  139567. private _draw;
  139568. private _drawCameraPredicate;
  139569. private _drawCameraBackground;
  139570. private _drawCameraForeground;
  139571. private _drawRenderTargetPredicate;
  139572. private _drawRenderTargetBackground;
  139573. private _drawRenderTargetForeground;
  139574. /**
  139575. * Adds all the elements from the container to the scene
  139576. * @param container the container holding the elements
  139577. */
  139578. addFromContainer(container: AbstractScene): void;
  139579. /**
  139580. * Removes all the elements in the container from the scene
  139581. * @param container contains the elements to remove
  139582. * @param dispose if the removed element should be disposed (default: false)
  139583. */
  139584. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139585. }
  139586. }
  139587. declare module BABYLON {
  139588. /** @hidden */
  139589. export var layerPixelShader: {
  139590. name: string;
  139591. shader: string;
  139592. };
  139593. }
  139594. declare module BABYLON {
  139595. /** @hidden */
  139596. export var layerVertexShader: {
  139597. name: string;
  139598. shader: string;
  139599. };
  139600. }
  139601. declare module BABYLON {
  139602. /**
  139603. * This represents a full screen 2d layer.
  139604. * This can be useful to display a picture in the background of your scene for instance.
  139605. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139606. */
  139607. export class Layer {
  139608. /**
  139609. * Define the name of the layer.
  139610. */
  139611. name: string;
  139612. /**
  139613. * Define the texture the layer should display.
  139614. */
  139615. texture: Nullable<Texture>;
  139616. /**
  139617. * Is the layer in background or foreground.
  139618. */
  139619. isBackground: boolean;
  139620. /**
  139621. * Define the color of the layer (instead of texture).
  139622. */
  139623. color: Color4;
  139624. /**
  139625. * Define the scale of the layer in order to zoom in out of the texture.
  139626. */
  139627. scale: Vector2;
  139628. /**
  139629. * Define an offset for the layer in order to shift the texture.
  139630. */
  139631. offset: Vector2;
  139632. /**
  139633. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139634. */
  139635. alphaBlendingMode: number;
  139636. /**
  139637. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139638. * Alpha test will not mix with the background color in case of transparency.
  139639. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139640. */
  139641. alphaTest: boolean;
  139642. /**
  139643. * Define a mask to restrict the layer to only some of the scene cameras.
  139644. */
  139645. layerMask: number;
  139646. /**
  139647. * Define the list of render target the layer is visible into.
  139648. */
  139649. renderTargetTextures: RenderTargetTexture[];
  139650. /**
  139651. * Define if the layer is only used in renderTarget or if it also
  139652. * renders in the main frame buffer of the canvas.
  139653. */
  139654. renderOnlyInRenderTargetTextures: boolean;
  139655. private _scene;
  139656. private _vertexBuffers;
  139657. private _indexBuffer;
  139658. private _effect;
  139659. private _previousDefines;
  139660. /**
  139661. * An event triggered when the layer is disposed.
  139662. */
  139663. onDisposeObservable: Observable<Layer>;
  139664. private _onDisposeObserver;
  139665. /**
  139666. * Back compatibility with callback before the onDisposeObservable existed.
  139667. * The set callback will be triggered when the layer has been disposed.
  139668. */
  139669. set onDispose(callback: () => void);
  139670. /**
  139671. * An event triggered before rendering the scene
  139672. */
  139673. onBeforeRenderObservable: Observable<Layer>;
  139674. private _onBeforeRenderObserver;
  139675. /**
  139676. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139677. * The set callback will be triggered just before rendering the layer.
  139678. */
  139679. set onBeforeRender(callback: () => void);
  139680. /**
  139681. * An event triggered after rendering the scene
  139682. */
  139683. onAfterRenderObservable: Observable<Layer>;
  139684. private _onAfterRenderObserver;
  139685. /**
  139686. * Back compatibility with callback before the onAfterRenderObservable existed.
  139687. * The set callback will be triggered just after rendering the layer.
  139688. */
  139689. set onAfterRender(callback: () => void);
  139690. /**
  139691. * Instantiates a new layer.
  139692. * This represents a full screen 2d layer.
  139693. * This can be useful to display a picture in the background of your scene for instance.
  139694. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139695. * @param name Define the name of the layer in the scene
  139696. * @param imgUrl Define the url of the texture to display in the layer
  139697. * @param scene Define the scene the layer belongs to
  139698. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139699. * @param color Defines a color for the layer
  139700. */
  139701. constructor(
  139702. /**
  139703. * Define the name of the layer.
  139704. */
  139705. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139706. private _createIndexBuffer;
  139707. /** @hidden */
  139708. _rebuild(): void;
  139709. /**
  139710. * Renders the layer in the scene.
  139711. */
  139712. render(): void;
  139713. /**
  139714. * Disposes and releases the associated ressources.
  139715. */
  139716. dispose(): void;
  139717. }
  139718. }
  139719. declare module BABYLON {
  139720. /** @hidden */
  139721. export var lensFlarePixelShader: {
  139722. name: string;
  139723. shader: string;
  139724. };
  139725. }
  139726. declare module BABYLON {
  139727. /** @hidden */
  139728. export var lensFlareVertexShader: {
  139729. name: string;
  139730. shader: string;
  139731. };
  139732. }
  139733. declare module BABYLON {
  139734. /**
  139735. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139736. * It is usually composed of several `lensFlare`.
  139737. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139738. */
  139739. export class LensFlareSystem {
  139740. /**
  139741. * Define the name of the lens flare system
  139742. */
  139743. name: string;
  139744. /**
  139745. * List of lens flares used in this system.
  139746. */
  139747. lensFlares: LensFlare[];
  139748. /**
  139749. * Define a limit from the border the lens flare can be visible.
  139750. */
  139751. borderLimit: number;
  139752. /**
  139753. * Define a viewport border we do not want to see the lens flare in.
  139754. */
  139755. viewportBorder: number;
  139756. /**
  139757. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139758. */
  139759. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139760. /**
  139761. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139762. */
  139763. layerMask: number;
  139764. /**
  139765. * Define the id of the lens flare system in the scene.
  139766. * (equal to name by default)
  139767. */
  139768. id: string;
  139769. private _scene;
  139770. private _emitter;
  139771. private _vertexBuffers;
  139772. private _indexBuffer;
  139773. private _effect;
  139774. private _positionX;
  139775. private _positionY;
  139776. private _isEnabled;
  139777. /** @hidden */
  139778. static _SceneComponentInitialization: (scene: Scene) => void;
  139779. /**
  139780. * Instantiates a lens flare system.
  139781. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139782. * It is usually composed of several `lensFlare`.
  139783. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139784. * @param name Define the name of the lens flare system in the scene
  139785. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139786. * @param scene Define the scene the lens flare system belongs to
  139787. */
  139788. constructor(
  139789. /**
  139790. * Define the name of the lens flare system
  139791. */
  139792. name: string, emitter: any, scene: Scene);
  139793. /**
  139794. * Define if the lens flare system is enabled.
  139795. */
  139796. get isEnabled(): boolean;
  139797. set isEnabled(value: boolean);
  139798. /**
  139799. * Get the scene the effects belongs to.
  139800. * @returns the scene holding the lens flare system
  139801. */
  139802. getScene(): Scene;
  139803. /**
  139804. * Get the emitter of the lens flare system.
  139805. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139806. * @returns the emitter of the lens flare system
  139807. */
  139808. getEmitter(): any;
  139809. /**
  139810. * Set the emitter of the lens flare system.
  139811. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139812. * @param newEmitter Define the new emitter of the system
  139813. */
  139814. setEmitter(newEmitter: any): void;
  139815. /**
  139816. * Get the lens flare system emitter position.
  139817. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139818. * @returns the position
  139819. */
  139820. getEmitterPosition(): Vector3;
  139821. /**
  139822. * @hidden
  139823. */
  139824. computeEffectivePosition(globalViewport: Viewport): boolean;
  139825. /** @hidden */
  139826. _isVisible(): boolean;
  139827. /**
  139828. * @hidden
  139829. */
  139830. render(): boolean;
  139831. /**
  139832. * Dispose and release the lens flare with its associated resources.
  139833. */
  139834. dispose(): void;
  139835. /**
  139836. * Parse a lens flare system from a JSON repressentation
  139837. * @param parsedLensFlareSystem Define the JSON to parse
  139838. * @param scene Define the scene the parsed system should be instantiated in
  139839. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139840. * @returns the parsed system
  139841. */
  139842. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139843. /**
  139844. * Serialize the current Lens Flare System into a JSON representation.
  139845. * @returns the serialized JSON
  139846. */
  139847. serialize(): any;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. /**
  139852. * This represents one of the lens effect in a `lensFlareSystem`.
  139853. * It controls one of the indiviual texture used in the effect.
  139854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139855. */
  139856. export class LensFlare {
  139857. /**
  139858. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139859. */
  139860. size: number;
  139861. /**
  139862. * 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.
  139863. */
  139864. position: number;
  139865. /**
  139866. * Define the lens color.
  139867. */
  139868. color: Color3;
  139869. /**
  139870. * Define the lens texture.
  139871. */
  139872. texture: Nullable<Texture>;
  139873. /**
  139874. * Define the alpha mode to render this particular lens.
  139875. */
  139876. alphaMode: number;
  139877. private _system;
  139878. /**
  139879. * Creates a new Lens Flare.
  139880. * This represents one of the lens effect in a `lensFlareSystem`.
  139881. * It controls one of the indiviual texture used in the effect.
  139882. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139883. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139884. * @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.
  139885. * @param color Define the lens color
  139886. * @param imgUrl Define the lens texture url
  139887. * @param system Define the `lensFlareSystem` this flare is part of
  139888. * @returns The newly created Lens Flare
  139889. */
  139890. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139891. /**
  139892. * Instantiates a new Lens Flare.
  139893. * This represents one of the lens effect in a `lensFlareSystem`.
  139894. * It controls one of the indiviual texture used in the effect.
  139895. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139896. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139897. * @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.
  139898. * @param color Define the lens color
  139899. * @param imgUrl Define the lens texture url
  139900. * @param system Define the `lensFlareSystem` this flare is part of
  139901. */
  139902. constructor(
  139903. /**
  139904. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139905. */
  139906. size: number,
  139907. /**
  139908. * 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.
  139909. */
  139910. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139911. /**
  139912. * Dispose and release the lens flare with its associated resources.
  139913. */
  139914. dispose(): void;
  139915. }
  139916. }
  139917. declare module BABYLON {
  139918. interface AbstractScene {
  139919. /**
  139920. * The list of lens flare system added to the scene
  139921. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139922. */
  139923. lensFlareSystems: Array<LensFlareSystem>;
  139924. /**
  139925. * Removes the given lens flare system from this scene.
  139926. * @param toRemove The lens flare system to remove
  139927. * @returns The index of the removed lens flare system
  139928. */
  139929. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139930. /**
  139931. * Adds the given lens flare system to this scene
  139932. * @param newLensFlareSystem The lens flare system to add
  139933. */
  139934. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139935. /**
  139936. * Gets a lens flare system using its name
  139937. * @param name defines the name to look for
  139938. * @returns the lens flare system or null if not found
  139939. */
  139940. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139941. /**
  139942. * Gets a lens flare system using its id
  139943. * @param id defines the id to look for
  139944. * @returns the lens flare system or null if not found
  139945. */
  139946. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139947. }
  139948. /**
  139949. * Defines the lens flare scene component responsible to manage any lens flares
  139950. * in a given scene.
  139951. */
  139952. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139953. /**
  139954. * The component name helpfull to identify the component in the list of scene components.
  139955. */
  139956. readonly name: string;
  139957. /**
  139958. * The scene the component belongs to.
  139959. */
  139960. scene: Scene;
  139961. /**
  139962. * Creates a new instance of the component for the given scene
  139963. * @param scene Defines the scene to register the component in
  139964. */
  139965. constructor(scene: Scene);
  139966. /**
  139967. * Registers the component in a given scene
  139968. */
  139969. register(): void;
  139970. /**
  139971. * Rebuilds the elements related to this component in case of
  139972. * context lost for instance.
  139973. */
  139974. rebuild(): void;
  139975. /**
  139976. * Adds all the elements from the container to the scene
  139977. * @param container the container holding the elements
  139978. */
  139979. addFromContainer(container: AbstractScene): void;
  139980. /**
  139981. * Removes all the elements in the container from the scene
  139982. * @param container contains the elements to remove
  139983. * @param dispose if the removed element should be disposed (default: false)
  139984. */
  139985. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139986. /**
  139987. * Serializes the component data to the specified json object
  139988. * @param serializationObject The object to serialize to
  139989. */
  139990. serialize(serializationObject: any): void;
  139991. /**
  139992. * Disposes the component and the associated ressources.
  139993. */
  139994. dispose(): void;
  139995. private _draw;
  139996. }
  139997. }
  139998. declare module BABYLON {
  139999. /** @hidden */
  140000. export var depthPixelShader: {
  140001. name: string;
  140002. shader: string;
  140003. };
  140004. }
  140005. declare module BABYLON {
  140006. /** @hidden */
  140007. export var depthVertexShader: {
  140008. name: string;
  140009. shader: string;
  140010. };
  140011. }
  140012. declare module BABYLON {
  140013. /**
  140014. * This represents a depth renderer in Babylon.
  140015. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140016. */
  140017. export class DepthRenderer {
  140018. private _scene;
  140019. private _depthMap;
  140020. private _effect;
  140021. private readonly _storeNonLinearDepth;
  140022. private readonly _clearColor;
  140023. /** Get if the depth renderer is using packed depth or not */
  140024. readonly isPacked: boolean;
  140025. private _cachedDefines;
  140026. private _camera;
  140027. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140028. enabled: boolean;
  140029. /**
  140030. * Specifiess that the depth renderer will only be used within
  140031. * the camera it is created for.
  140032. * This can help forcing its rendering during the camera processing.
  140033. */
  140034. useOnlyInActiveCamera: boolean;
  140035. /** @hidden */
  140036. static _SceneComponentInitialization: (scene: Scene) => void;
  140037. /**
  140038. * Instantiates a depth renderer
  140039. * @param scene The scene the renderer belongs to
  140040. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140041. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140042. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140043. */
  140044. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140045. /**
  140046. * Creates the depth rendering effect and checks if the effect is ready.
  140047. * @param subMesh The submesh to be used to render the depth map of
  140048. * @param useInstances If multiple world instances should be used
  140049. * @returns if the depth renderer is ready to render the depth map
  140050. */
  140051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140052. /**
  140053. * Gets the texture which the depth map will be written to.
  140054. * @returns The depth map texture
  140055. */
  140056. getDepthMap(): RenderTargetTexture;
  140057. /**
  140058. * Disposes of the depth renderer.
  140059. */
  140060. dispose(): void;
  140061. }
  140062. }
  140063. declare module BABYLON {
  140064. /** @hidden */
  140065. export var minmaxReduxPixelShader: {
  140066. name: string;
  140067. shader: string;
  140068. };
  140069. }
  140070. declare module BABYLON {
  140071. /**
  140072. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140073. * and maximum values from all values of the texture.
  140074. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140075. * The source values are read from the red channel of the texture.
  140076. */
  140077. export class MinMaxReducer {
  140078. /**
  140079. * Observable triggered when the computation has been performed
  140080. */
  140081. onAfterReductionPerformed: Observable<{
  140082. min: number;
  140083. max: number;
  140084. }>;
  140085. protected _camera: Camera;
  140086. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140087. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140088. protected _postProcessManager: PostProcessManager;
  140089. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140090. protected _forceFullscreenViewport: boolean;
  140091. /**
  140092. * Creates a min/max reducer
  140093. * @param camera The camera to use for the post processes
  140094. */
  140095. constructor(camera: Camera);
  140096. /**
  140097. * Gets the texture used to read the values from.
  140098. */
  140099. get sourceTexture(): Nullable<RenderTargetTexture>;
  140100. /**
  140101. * Sets the source texture to read the values from.
  140102. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140103. * because in such textures '1' value must not be taken into account to compute the maximum
  140104. * as this value is used to clear the texture.
  140105. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140106. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140107. * @param depthRedux Indicates if the texture is a depth texture or not
  140108. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140109. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140110. */
  140111. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140112. /**
  140113. * Defines the refresh rate of the computation.
  140114. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140115. */
  140116. get refreshRate(): number;
  140117. set refreshRate(value: number);
  140118. protected _activated: boolean;
  140119. /**
  140120. * Gets the activation status of the reducer
  140121. */
  140122. get activated(): boolean;
  140123. /**
  140124. * Activates the reduction computation.
  140125. * When activated, the observers registered in onAfterReductionPerformed are
  140126. * called after the compuation is performed
  140127. */
  140128. activate(): void;
  140129. /**
  140130. * Deactivates the reduction computation.
  140131. */
  140132. deactivate(): void;
  140133. /**
  140134. * Disposes the min/max reducer
  140135. * @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.
  140136. */
  140137. dispose(disposeAll?: boolean): void;
  140138. }
  140139. }
  140140. declare module BABYLON {
  140141. /**
  140142. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140143. */
  140144. export class DepthReducer extends MinMaxReducer {
  140145. private _depthRenderer;
  140146. private _depthRendererId;
  140147. /**
  140148. * Gets the depth renderer used for the computation.
  140149. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140150. */
  140151. get depthRenderer(): Nullable<DepthRenderer>;
  140152. /**
  140153. * Creates a depth reducer
  140154. * @param camera The camera used to render the depth texture
  140155. */
  140156. constructor(camera: Camera);
  140157. /**
  140158. * Sets the depth renderer to use to generate the depth map
  140159. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140160. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140161. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140162. */
  140163. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140164. /** @hidden */
  140165. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140166. /**
  140167. * Activates the reduction computation.
  140168. * When activated, the observers registered in onAfterReductionPerformed are
  140169. * called after the compuation is performed
  140170. */
  140171. activate(): void;
  140172. /**
  140173. * Deactivates the reduction computation.
  140174. */
  140175. deactivate(): void;
  140176. /**
  140177. * Disposes the depth reducer
  140178. * @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.
  140179. */
  140180. dispose(disposeAll?: boolean): void;
  140181. }
  140182. }
  140183. declare module BABYLON {
  140184. /**
  140185. * A CSM implementation allowing casting shadows on large scenes.
  140186. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140187. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140188. */
  140189. export class CascadedShadowGenerator extends ShadowGenerator {
  140190. private static readonly frustumCornersNDCSpace;
  140191. /**
  140192. * Name of the CSM class
  140193. */
  140194. static CLASSNAME: string;
  140195. /**
  140196. * Defines the default number of cascades used by the CSM.
  140197. */
  140198. static readonly DEFAULT_CASCADES_COUNT: number;
  140199. /**
  140200. * Defines the minimum number of cascades used by the CSM.
  140201. */
  140202. static readonly MIN_CASCADES_COUNT: number;
  140203. /**
  140204. * Defines the maximum number of cascades used by the CSM.
  140205. */
  140206. static readonly MAX_CASCADES_COUNT: number;
  140207. protected _validateFilter(filter: number): number;
  140208. /**
  140209. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140210. */
  140211. penumbraDarkness: number;
  140212. private _numCascades;
  140213. /**
  140214. * Gets or set the number of cascades used by the CSM.
  140215. */
  140216. get numCascades(): number;
  140217. set numCascades(value: number);
  140218. /**
  140219. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140220. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140221. */
  140222. stabilizeCascades: boolean;
  140223. private _freezeShadowCastersBoundingInfo;
  140224. private _freezeShadowCastersBoundingInfoObservable;
  140225. /**
  140226. * Enables or disables the shadow casters bounding info computation.
  140227. * If your shadow casters don't move, you can disable this feature.
  140228. * If it is enabled, the bounding box computation is done every frame.
  140229. */
  140230. get freezeShadowCastersBoundingInfo(): boolean;
  140231. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140232. private _scbiMin;
  140233. private _scbiMax;
  140234. protected _computeShadowCastersBoundingInfo(): void;
  140235. protected _shadowCastersBoundingInfo: BoundingInfo;
  140236. /**
  140237. * Gets or sets the shadow casters bounding info.
  140238. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140239. * so that the system won't overwrite the bounds you provide
  140240. */
  140241. get shadowCastersBoundingInfo(): BoundingInfo;
  140242. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140243. protected _breaksAreDirty: boolean;
  140244. protected _minDistance: number;
  140245. protected _maxDistance: number;
  140246. /**
  140247. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140248. *
  140249. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140250. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140251. * @param min minimal distance for the breaks (default to 0.)
  140252. * @param max maximal distance for the breaks (default to 1.)
  140253. */
  140254. setMinMaxDistance(min: number, max: number): void;
  140255. /** Gets the minimal distance used in the cascade break computation */
  140256. get minDistance(): number;
  140257. /** Gets the maximal distance used in the cascade break computation */
  140258. get maxDistance(): number;
  140259. /**
  140260. * Gets the class name of that object
  140261. * @returns "CascadedShadowGenerator"
  140262. */
  140263. getClassName(): string;
  140264. private _cascadeMinExtents;
  140265. private _cascadeMaxExtents;
  140266. /**
  140267. * Gets a cascade minimum extents
  140268. * @param cascadeIndex index of the cascade
  140269. * @returns the minimum cascade extents
  140270. */
  140271. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140272. /**
  140273. * Gets a cascade maximum extents
  140274. * @param cascadeIndex index of the cascade
  140275. * @returns the maximum cascade extents
  140276. */
  140277. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140278. private _cascades;
  140279. private _currentLayer;
  140280. private _viewSpaceFrustumsZ;
  140281. private _viewMatrices;
  140282. private _projectionMatrices;
  140283. private _transformMatrices;
  140284. private _transformMatricesAsArray;
  140285. private _frustumLengths;
  140286. private _lightSizeUVCorrection;
  140287. private _depthCorrection;
  140288. private _frustumCornersWorldSpace;
  140289. private _frustumCenter;
  140290. private _shadowCameraPos;
  140291. private _shadowMaxZ;
  140292. /**
  140293. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140294. * It defaults to camera.maxZ
  140295. */
  140296. get shadowMaxZ(): number;
  140297. /**
  140298. * Sets the shadow max z distance.
  140299. */
  140300. set shadowMaxZ(value: number);
  140301. protected _debug: boolean;
  140302. /**
  140303. * Gets or sets the debug flag.
  140304. * When enabled, the cascades are materialized by different colors on the screen.
  140305. */
  140306. get debug(): boolean;
  140307. set debug(dbg: boolean);
  140308. private _depthClamp;
  140309. /**
  140310. * Gets or sets the depth clamping value.
  140311. *
  140312. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140313. * to account for the shadow casters far away.
  140314. *
  140315. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140316. */
  140317. get depthClamp(): boolean;
  140318. set depthClamp(value: boolean);
  140319. private _cascadeBlendPercentage;
  140320. /**
  140321. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140322. * It defaults to 0.1 (10% blending).
  140323. */
  140324. get cascadeBlendPercentage(): number;
  140325. set cascadeBlendPercentage(value: number);
  140326. private _lambda;
  140327. /**
  140328. * Gets or set the lambda parameter.
  140329. * This parameter is used to split the camera frustum and create the cascades.
  140330. * 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.
  140331. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140332. */
  140333. get lambda(): number;
  140334. set lambda(value: number);
  140335. /**
  140336. * Gets the view matrix corresponding to a given cascade
  140337. * @param cascadeNum cascade to retrieve the view matrix from
  140338. * @returns the cascade view matrix
  140339. */
  140340. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140341. /**
  140342. * Gets the projection matrix corresponding to a given cascade
  140343. * @param cascadeNum cascade to retrieve the projection matrix from
  140344. * @returns the cascade projection matrix
  140345. */
  140346. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140347. /**
  140348. * Gets the transformation matrix corresponding to a given cascade
  140349. * @param cascadeNum cascade to retrieve the transformation matrix from
  140350. * @returns the cascade transformation matrix
  140351. */
  140352. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140353. private _depthRenderer;
  140354. /**
  140355. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140356. *
  140357. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140358. *
  140359. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140360. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140361. * @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
  140362. */
  140363. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140364. private _depthReducer;
  140365. private _autoCalcDepthBounds;
  140366. /**
  140367. * Gets or sets the autoCalcDepthBounds property.
  140368. *
  140369. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140370. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140371. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140372. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140373. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140374. */
  140375. get autoCalcDepthBounds(): boolean;
  140376. set autoCalcDepthBounds(value: boolean);
  140377. /**
  140378. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140379. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140380. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140381. * for setting the refresh rate on the renderer yourself!
  140382. */
  140383. get autoCalcDepthBoundsRefreshRate(): number;
  140384. set autoCalcDepthBoundsRefreshRate(value: number);
  140385. /**
  140386. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140387. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140388. * you change the camera near/far planes!
  140389. */
  140390. splitFrustum(): void;
  140391. private _splitFrustum;
  140392. private _computeMatrices;
  140393. private _computeFrustumInWorldSpace;
  140394. private _computeCascadeFrustum;
  140395. /**
  140396. * Support test.
  140397. */
  140398. static get IsSupported(): boolean;
  140399. /** @hidden */
  140400. static _SceneComponentInitialization: (scene: Scene) => void;
  140401. /**
  140402. * Creates a Cascaded Shadow Generator object.
  140403. * A ShadowGenerator is the required tool to use the shadows.
  140404. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140405. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140406. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140407. * @param light The directional light object generating the shadows.
  140408. * @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.
  140409. */
  140410. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140411. protected _initializeGenerator(): void;
  140412. protected _createTargetRenderTexture(): void;
  140413. protected _initializeShadowMap(): void;
  140414. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140415. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140416. /**
  140417. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140418. * @param defines Defines of the material we want to update
  140419. * @param lightIndex Index of the light in the enabled light list of the material
  140420. */
  140421. prepareDefines(defines: any, lightIndex: number): void;
  140422. /**
  140423. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140424. * defined in the generator but impacting the effect).
  140425. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140426. * @param effect The effect we are binfing the information for
  140427. */
  140428. bindShadowLight(lightIndex: string, effect: Effect): void;
  140429. /**
  140430. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140431. * (eq to view projection * shadow projection matrices)
  140432. * @returns The transform matrix used to create the shadow map
  140433. */
  140434. getTransformMatrix(): Matrix;
  140435. /**
  140436. * Disposes the ShadowGenerator.
  140437. * Returns nothing.
  140438. */
  140439. dispose(): void;
  140440. /**
  140441. * Serializes the shadow generator setup to a json object.
  140442. * @returns The serialized JSON object
  140443. */
  140444. serialize(): any;
  140445. /**
  140446. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140447. * @param parsedShadowGenerator The JSON object to parse
  140448. * @param scene The scene to create the shadow map for
  140449. * @returns The parsed shadow generator
  140450. */
  140451. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140452. }
  140453. }
  140454. declare module BABYLON {
  140455. /**
  140456. * Defines the shadow generator component responsible to manage any shadow generators
  140457. * in a given scene.
  140458. */
  140459. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140460. /**
  140461. * The component name helpfull to identify the component in the list of scene components.
  140462. */
  140463. readonly name: string;
  140464. /**
  140465. * The scene the component belongs to.
  140466. */
  140467. scene: Scene;
  140468. /**
  140469. * Creates a new instance of the component for the given scene
  140470. * @param scene Defines the scene to register the component in
  140471. */
  140472. constructor(scene: Scene);
  140473. /**
  140474. * Registers the component in a given scene
  140475. */
  140476. register(): void;
  140477. /**
  140478. * Rebuilds the elements related to this component in case of
  140479. * context lost for instance.
  140480. */
  140481. rebuild(): void;
  140482. /**
  140483. * Serializes the component data to the specified json object
  140484. * @param serializationObject The object to serialize to
  140485. */
  140486. serialize(serializationObject: any): void;
  140487. /**
  140488. * Adds all the elements from the container to the scene
  140489. * @param container the container holding the elements
  140490. */
  140491. addFromContainer(container: AbstractScene): void;
  140492. /**
  140493. * Removes all the elements in the container from the scene
  140494. * @param container contains the elements to remove
  140495. * @param dispose if the removed element should be disposed (default: false)
  140496. */
  140497. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140498. /**
  140499. * Rebuilds the elements related to this component in case of
  140500. * context lost for instance.
  140501. */
  140502. dispose(): void;
  140503. private _gatherRenderTargets;
  140504. }
  140505. }
  140506. declare module BABYLON {
  140507. /**
  140508. * A point light is a light defined by an unique point in world space.
  140509. * The light is emitted in every direction from this point.
  140510. * A good example of a point light is a standard light bulb.
  140511. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140512. */
  140513. export class PointLight extends ShadowLight {
  140514. private _shadowAngle;
  140515. /**
  140516. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140517. * This specifies what angle the shadow will use to be created.
  140518. *
  140519. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140520. */
  140521. get shadowAngle(): number;
  140522. /**
  140523. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140524. * This specifies what angle the shadow will use to be created.
  140525. *
  140526. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140527. */
  140528. set shadowAngle(value: number);
  140529. /**
  140530. * Gets the direction if it has been set.
  140531. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140532. */
  140533. get direction(): Vector3;
  140534. /**
  140535. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140536. */
  140537. set direction(value: Vector3);
  140538. /**
  140539. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140540. * A PointLight emits the light in every direction.
  140541. * It can cast shadows.
  140542. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140543. * ```javascript
  140544. * var pointLight = new PointLight("pl", camera.position, scene);
  140545. * ```
  140546. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140547. * @param name The light friendly name
  140548. * @param position The position of the point light in the scene
  140549. * @param scene The scene the lights belongs to
  140550. */
  140551. constructor(name: string, position: Vector3, scene: Scene);
  140552. /**
  140553. * Returns the string "PointLight"
  140554. * @returns the class name
  140555. */
  140556. getClassName(): string;
  140557. /**
  140558. * Returns the integer 0.
  140559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140560. */
  140561. getTypeID(): number;
  140562. /**
  140563. * Specifies wether or not the shadowmap should be a cube texture.
  140564. * @returns true if the shadowmap needs to be a cube texture.
  140565. */
  140566. needCube(): boolean;
  140567. /**
  140568. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140569. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140570. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140571. */
  140572. getShadowDirection(faceIndex?: number): Vector3;
  140573. /**
  140574. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140575. * - fov = PI / 2
  140576. * - aspect ratio : 1.0
  140577. * - z-near and far equal to the active camera minZ and maxZ.
  140578. * Returns the PointLight.
  140579. */
  140580. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140581. protected _buildUniformLayout(): void;
  140582. /**
  140583. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140584. * @param effect The effect to update
  140585. * @param lightIndex The index of the light in the effect to update
  140586. * @returns The point light
  140587. */
  140588. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140589. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140590. /**
  140591. * Prepares the list of defines specific to the light type.
  140592. * @param defines the list of defines
  140593. * @param lightIndex defines the index of the light for the effect
  140594. */
  140595. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140596. }
  140597. }
  140598. declare module BABYLON {
  140599. /**
  140600. * Header information of HDR texture files.
  140601. */
  140602. export interface HDRInfo {
  140603. /**
  140604. * The height of the texture in pixels.
  140605. */
  140606. height: number;
  140607. /**
  140608. * The width of the texture in pixels.
  140609. */
  140610. width: number;
  140611. /**
  140612. * The index of the beginning of the data in the binary file.
  140613. */
  140614. dataPosition: number;
  140615. }
  140616. /**
  140617. * This groups tools to convert HDR texture to native colors array.
  140618. */
  140619. export class HDRTools {
  140620. private static Ldexp;
  140621. private static Rgbe2float;
  140622. private static readStringLine;
  140623. /**
  140624. * Reads header information from an RGBE texture stored in a native array.
  140625. * More information on this format are available here:
  140626. * https://en.wikipedia.org/wiki/RGBE_image_format
  140627. *
  140628. * @param uint8array The binary file stored in native array.
  140629. * @return The header information.
  140630. */
  140631. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140632. /**
  140633. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140634. * This RGBE texture needs to store the information as a panorama.
  140635. *
  140636. * More information on this format are available here:
  140637. * https://en.wikipedia.org/wiki/RGBE_image_format
  140638. *
  140639. * @param buffer The binary file stored in an array buffer.
  140640. * @param size The expected size of the extracted cubemap.
  140641. * @return The Cube Map information.
  140642. */
  140643. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140644. /**
  140645. * Returns the pixels data extracted from an RGBE texture.
  140646. * This pixels will be stored left to right up to down in the R G B order in one array.
  140647. *
  140648. * More information on this format are available here:
  140649. * https://en.wikipedia.org/wiki/RGBE_image_format
  140650. *
  140651. * @param uint8array The binary file stored in an array buffer.
  140652. * @param hdrInfo The header information of the file.
  140653. * @return The pixels data in RGB right to left up to down order.
  140654. */
  140655. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140656. private static RGBE_ReadPixels_RLE;
  140657. private static RGBE_ReadPixels_NOT_RLE;
  140658. }
  140659. }
  140660. declare module BABYLON {
  140661. /**
  140662. * Effect Render Options
  140663. */
  140664. export interface IEffectRendererOptions {
  140665. /**
  140666. * Defines the vertices positions.
  140667. */
  140668. positions?: number[];
  140669. /**
  140670. * Defines the indices.
  140671. */
  140672. indices?: number[];
  140673. }
  140674. /**
  140675. * Helper class to render one or more effects.
  140676. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140677. */
  140678. export class EffectRenderer {
  140679. private engine;
  140680. private static _DefaultOptions;
  140681. private _vertexBuffers;
  140682. private _indexBuffer;
  140683. private _fullscreenViewport;
  140684. /**
  140685. * Creates an effect renderer
  140686. * @param engine the engine to use for rendering
  140687. * @param options defines the options of the effect renderer
  140688. */
  140689. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140690. /**
  140691. * Sets the current viewport in normalized coordinates 0-1
  140692. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140693. */
  140694. setViewport(viewport?: Viewport): void;
  140695. /**
  140696. * Binds the embedded attributes buffer to the effect.
  140697. * @param effect Defines the effect to bind the attributes for
  140698. */
  140699. bindBuffers(effect: Effect): void;
  140700. /**
  140701. * Sets the current effect wrapper to use during draw.
  140702. * The effect needs to be ready before calling this api.
  140703. * This also sets the default full screen position attribute.
  140704. * @param effectWrapper Defines the effect to draw with
  140705. */
  140706. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140707. /**
  140708. * Restores engine states
  140709. */
  140710. restoreStates(): void;
  140711. /**
  140712. * Draws a full screen quad.
  140713. */
  140714. draw(): void;
  140715. private isRenderTargetTexture;
  140716. /**
  140717. * renders one or more effects to a specified texture
  140718. * @param effectWrapper the effect to renderer
  140719. * @param outputTexture texture to draw to, if null it will render to the screen.
  140720. */
  140721. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140722. /**
  140723. * Disposes of the effect renderer
  140724. */
  140725. dispose(): void;
  140726. }
  140727. /**
  140728. * Options to create an EffectWrapper
  140729. */
  140730. interface EffectWrapperCreationOptions {
  140731. /**
  140732. * Engine to use to create the effect
  140733. */
  140734. engine: ThinEngine;
  140735. /**
  140736. * Fragment shader for the effect
  140737. */
  140738. fragmentShader: string;
  140739. /**
  140740. * Use the shader store instead of direct source code
  140741. */
  140742. useShaderStore?: boolean;
  140743. /**
  140744. * Vertex shader for the effect
  140745. */
  140746. vertexShader?: string;
  140747. /**
  140748. * Attributes to use in the shader
  140749. */
  140750. attributeNames?: Array<string>;
  140751. /**
  140752. * Uniforms to use in the shader
  140753. */
  140754. uniformNames?: Array<string>;
  140755. /**
  140756. * Texture sampler names to use in the shader
  140757. */
  140758. samplerNames?: Array<string>;
  140759. /**
  140760. * Defines to use in the shader
  140761. */
  140762. defines?: Array<string>;
  140763. /**
  140764. * Callback when effect is compiled
  140765. */
  140766. onCompiled?: Nullable<(effect: Effect) => void>;
  140767. /**
  140768. * The friendly name of the effect displayed in Spector.
  140769. */
  140770. name?: string;
  140771. }
  140772. /**
  140773. * Wraps an effect to be used for rendering
  140774. */
  140775. export class EffectWrapper {
  140776. /**
  140777. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140778. */
  140779. onApplyObservable: Observable<{}>;
  140780. /**
  140781. * The underlying effect
  140782. */
  140783. effect: Effect;
  140784. /**
  140785. * Creates an effect to be renderer
  140786. * @param creationOptions options to create the effect
  140787. */
  140788. constructor(creationOptions: EffectWrapperCreationOptions);
  140789. /**
  140790. * Disposes of the effect wrapper
  140791. */
  140792. dispose(): void;
  140793. }
  140794. }
  140795. declare module BABYLON {
  140796. /** @hidden */
  140797. export var hdrFilteringVertexShader: {
  140798. name: string;
  140799. shader: string;
  140800. };
  140801. }
  140802. declare module BABYLON {
  140803. /** @hidden */
  140804. export var hdrFilteringPixelShader: {
  140805. name: string;
  140806. shader: string;
  140807. };
  140808. }
  140809. declare module BABYLON {
  140810. /**
  140811. * Options for texture filtering
  140812. */
  140813. interface IHDRFilteringOptions {
  140814. /**
  140815. * Scales pixel intensity for the input HDR map.
  140816. */
  140817. hdrScale?: number;
  140818. /**
  140819. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140820. */
  140821. quality?: number;
  140822. }
  140823. /**
  140824. * Filters HDR maps to get correct renderings of PBR reflections
  140825. */
  140826. export class HDRFiltering {
  140827. private _engine;
  140828. private _effectRenderer;
  140829. private _effectWrapper;
  140830. private _lodGenerationOffset;
  140831. private _lodGenerationScale;
  140832. /**
  140833. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140834. * you care about baking speed.
  140835. */
  140836. quality: number;
  140837. /**
  140838. * Scales pixel intensity for the input HDR map.
  140839. */
  140840. hdrScale: number;
  140841. /**
  140842. * Instantiates HDR filter for reflection maps
  140843. *
  140844. * @param engine Thin engine
  140845. * @param options Options
  140846. */
  140847. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140848. private _createRenderTarget;
  140849. private _prefilterInternal;
  140850. private _createEffect;
  140851. /**
  140852. * Get a value indicating if the filter is ready to be used
  140853. * @param texture Texture to filter
  140854. * @returns true if the filter is ready
  140855. */
  140856. isReady(texture: BaseTexture): boolean;
  140857. /**
  140858. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140859. * Prefiltering will be invoked at the end of next rendering pass.
  140860. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140861. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140862. * @param texture Texture to filter
  140863. * @param onFinished Callback when filtering is done
  140864. * @return Promise called when prefiltering is done
  140865. */
  140866. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140867. }
  140868. }
  140869. declare module BABYLON {
  140870. /**
  140871. * This represents a texture coming from an HDR input.
  140872. *
  140873. * The only supported format is currently panorama picture stored in RGBE format.
  140874. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140875. */
  140876. export class HDRCubeTexture extends BaseTexture {
  140877. private static _facesMapping;
  140878. private _generateHarmonics;
  140879. private _noMipmap;
  140880. private _prefilterOnLoad;
  140881. private _textureMatrix;
  140882. private _size;
  140883. private _onLoad;
  140884. private _onError;
  140885. /**
  140886. * The texture URL.
  140887. */
  140888. url: string;
  140889. protected _isBlocking: boolean;
  140890. /**
  140891. * Sets wether or not the texture is blocking during loading.
  140892. */
  140893. set isBlocking(value: boolean);
  140894. /**
  140895. * Gets wether or not the texture is blocking during loading.
  140896. */
  140897. get isBlocking(): boolean;
  140898. protected _rotationY: number;
  140899. /**
  140900. * Sets texture matrix rotation angle around Y axis in radians.
  140901. */
  140902. set rotationY(value: number);
  140903. /**
  140904. * Gets texture matrix rotation angle around Y axis radians.
  140905. */
  140906. get rotationY(): number;
  140907. /**
  140908. * Gets or sets the center of the bounding box associated with the cube texture
  140909. * It must define where the camera used to render the texture was set
  140910. */
  140911. boundingBoxPosition: Vector3;
  140912. private _boundingBoxSize;
  140913. /**
  140914. * Gets or sets the size of the bounding box associated with the cube texture
  140915. * When defined, the cubemap will switch to local mode
  140916. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140917. * @example https://www.babylonjs-playground.com/#RNASML
  140918. */
  140919. set boundingBoxSize(value: Vector3);
  140920. get boundingBoxSize(): Vector3;
  140921. /**
  140922. * Instantiates an HDRTexture from the following parameters.
  140923. *
  140924. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140925. * @param sceneOrEngine The scene or engine the texture will be used in
  140926. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140927. * @param noMipmap Forces to not generate the mipmap if true
  140928. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140929. * @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)
  140930. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140931. */
  140932. 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>);
  140933. /**
  140934. * Get the current class name of the texture useful for serialization or dynamic coding.
  140935. * @returns "HDRCubeTexture"
  140936. */
  140937. getClassName(): string;
  140938. /**
  140939. * Occurs when the file is raw .hdr file.
  140940. */
  140941. private loadTexture;
  140942. clone(): HDRCubeTexture;
  140943. delayLoad(): void;
  140944. /**
  140945. * Get the texture reflection matrix used to rotate/transform the reflection.
  140946. * @returns the reflection matrix
  140947. */
  140948. getReflectionTextureMatrix(): Matrix;
  140949. /**
  140950. * Set the texture reflection matrix used to rotate/transform the reflection.
  140951. * @param value Define the reflection matrix to set
  140952. */
  140953. setReflectionTextureMatrix(value: Matrix): void;
  140954. /**
  140955. * Parses a JSON representation of an HDR Texture in order to create the texture
  140956. * @param parsedTexture Define the JSON representation
  140957. * @param scene Define the scene the texture should be created in
  140958. * @param rootUrl Define the root url in case we need to load relative dependencies
  140959. * @returns the newly created texture after parsing
  140960. */
  140961. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140962. serialize(): any;
  140963. }
  140964. }
  140965. declare module BABYLON {
  140966. /**
  140967. * Class used to control physics engine
  140968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140969. */
  140970. export class PhysicsEngine implements IPhysicsEngine {
  140971. private _physicsPlugin;
  140972. /**
  140973. * Global value used to control the smallest number supported by the simulation
  140974. */
  140975. static Epsilon: number;
  140976. private _impostors;
  140977. private _joints;
  140978. private _subTimeStep;
  140979. /**
  140980. * Gets the gravity vector used by the simulation
  140981. */
  140982. gravity: Vector3;
  140983. /**
  140984. * Factory used to create the default physics plugin.
  140985. * @returns The default physics plugin
  140986. */
  140987. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140988. /**
  140989. * Creates a new Physics Engine
  140990. * @param gravity defines the gravity vector used by the simulation
  140991. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140992. */
  140993. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140994. /**
  140995. * Sets the gravity vector used by the simulation
  140996. * @param gravity defines the gravity vector to use
  140997. */
  140998. setGravity(gravity: Vector3): void;
  140999. /**
  141000. * Set the time step of the physics engine.
  141001. * Default is 1/60.
  141002. * To slow it down, enter 1/600 for example.
  141003. * To speed it up, 1/30
  141004. * @param newTimeStep defines the new timestep to apply to this world.
  141005. */
  141006. setTimeStep(newTimeStep?: number): void;
  141007. /**
  141008. * Get the time step of the physics engine.
  141009. * @returns the current time step
  141010. */
  141011. getTimeStep(): number;
  141012. /**
  141013. * Set the sub time step of the physics engine.
  141014. * Default is 0 meaning there is no sub steps
  141015. * To increase physics resolution precision, set a small value (like 1 ms)
  141016. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141017. */
  141018. setSubTimeStep(subTimeStep?: number): void;
  141019. /**
  141020. * Get the sub time step of the physics engine.
  141021. * @returns the current sub time step
  141022. */
  141023. getSubTimeStep(): number;
  141024. /**
  141025. * Release all resources
  141026. */
  141027. dispose(): void;
  141028. /**
  141029. * Gets the name of the current physics plugin
  141030. * @returns the name of the plugin
  141031. */
  141032. getPhysicsPluginName(): string;
  141033. /**
  141034. * Adding a new impostor for the impostor tracking.
  141035. * This will be done by the impostor itself.
  141036. * @param impostor the impostor to add
  141037. */
  141038. addImpostor(impostor: PhysicsImpostor): void;
  141039. /**
  141040. * Remove an impostor from the engine.
  141041. * This impostor and its mesh will not longer be updated by the physics engine.
  141042. * @param impostor the impostor to remove
  141043. */
  141044. removeImpostor(impostor: PhysicsImpostor): void;
  141045. /**
  141046. * Add a joint to the physics engine
  141047. * @param mainImpostor defines the main impostor to which the joint is added.
  141048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141049. * @param joint defines the joint that will connect both impostors.
  141050. */
  141051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141052. /**
  141053. * Removes a joint from the simulation
  141054. * @param mainImpostor defines the impostor used with the joint
  141055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141056. * @param joint defines the joint to remove
  141057. */
  141058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141059. /**
  141060. * Called by the scene. No need to call it.
  141061. * @param delta defines the timespam between frames
  141062. */
  141063. _step(delta: number): void;
  141064. /**
  141065. * Gets the current plugin used to run the simulation
  141066. * @returns current plugin
  141067. */
  141068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141069. /**
  141070. * Gets the list of physic impostors
  141071. * @returns an array of PhysicsImpostor
  141072. */
  141073. getImpostors(): Array<PhysicsImpostor>;
  141074. /**
  141075. * Gets the impostor for a physics enabled object
  141076. * @param object defines the object impersonated by the impostor
  141077. * @returns the PhysicsImpostor or null if not found
  141078. */
  141079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141080. /**
  141081. * Gets the impostor for a physics body object
  141082. * @param body defines physics body used by the impostor
  141083. * @returns the PhysicsImpostor or null if not found
  141084. */
  141085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141086. /**
  141087. * Does a raycast in the physics world
  141088. * @param from when should the ray start?
  141089. * @param to when should the ray end?
  141090. * @returns PhysicsRaycastResult
  141091. */
  141092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141093. }
  141094. }
  141095. declare module BABYLON {
  141096. /** @hidden */
  141097. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141098. private _useDeltaForWorldStep;
  141099. world: any;
  141100. name: string;
  141101. private _physicsMaterials;
  141102. private _fixedTimeStep;
  141103. private _cannonRaycastResult;
  141104. private _raycastResult;
  141105. private _physicsBodysToRemoveAfterStep;
  141106. private _firstFrame;
  141107. BJSCANNON: any;
  141108. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141109. setGravity(gravity: Vector3): void;
  141110. setTimeStep(timeStep: number): void;
  141111. getTimeStep(): number;
  141112. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141113. private _removeMarkedPhysicsBodiesFromWorld;
  141114. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141115. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141116. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141117. private _processChildMeshes;
  141118. removePhysicsBody(impostor: PhysicsImpostor): void;
  141119. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141120. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141121. private _addMaterial;
  141122. private _checkWithEpsilon;
  141123. private _createShape;
  141124. private _createHeightmap;
  141125. private _minus90X;
  141126. private _plus90X;
  141127. private _tmpPosition;
  141128. private _tmpDeltaPosition;
  141129. private _tmpUnityRotation;
  141130. private _updatePhysicsBodyTransformation;
  141131. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141132. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141133. isSupported(): boolean;
  141134. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141135. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141136. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141137. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141138. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141139. getBodyMass(impostor: PhysicsImpostor): number;
  141140. getBodyFriction(impostor: PhysicsImpostor): number;
  141141. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141142. getBodyRestitution(impostor: PhysicsImpostor): number;
  141143. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141144. sleepBody(impostor: PhysicsImpostor): void;
  141145. wakeUpBody(impostor: PhysicsImpostor): void;
  141146. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141147. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141148. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141149. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141150. getRadius(impostor: PhysicsImpostor): number;
  141151. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141152. dispose(): void;
  141153. private _extendNamespace;
  141154. /**
  141155. * Does a raycast in the physics world
  141156. * @param from when should the ray start?
  141157. * @param to when should the ray end?
  141158. * @returns PhysicsRaycastResult
  141159. */
  141160. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141161. }
  141162. }
  141163. declare module BABYLON {
  141164. /** @hidden */
  141165. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141166. private _useDeltaForWorldStep;
  141167. world: any;
  141168. name: string;
  141169. BJSOIMO: any;
  141170. private _raycastResult;
  141171. private _fixedTimeStep;
  141172. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141173. setGravity(gravity: Vector3): void;
  141174. setTimeStep(timeStep: number): void;
  141175. getTimeStep(): number;
  141176. private _tmpImpostorsArray;
  141177. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141178. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141179. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141180. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141181. private _tmpPositionVector;
  141182. removePhysicsBody(impostor: PhysicsImpostor): void;
  141183. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141184. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141185. isSupported(): boolean;
  141186. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141187. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141188. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141189. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141190. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141191. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141192. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141193. getBodyMass(impostor: PhysicsImpostor): number;
  141194. getBodyFriction(impostor: PhysicsImpostor): number;
  141195. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141196. getBodyRestitution(impostor: PhysicsImpostor): number;
  141197. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141198. sleepBody(impostor: PhysicsImpostor): void;
  141199. wakeUpBody(impostor: PhysicsImpostor): void;
  141200. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141201. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141202. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141203. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141204. getRadius(impostor: PhysicsImpostor): number;
  141205. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141206. dispose(): void;
  141207. /**
  141208. * Does a raycast in the physics world
  141209. * @param from when should the ray start?
  141210. * @param to when should the ray end?
  141211. * @returns PhysicsRaycastResult
  141212. */
  141213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141214. }
  141215. }
  141216. declare module BABYLON {
  141217. /**
  141218. * AmmoJS Physics plugin
  141219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141220. * @see https://github.com/kripken/ammo.js/
  141221. */
  141222. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141223. private _useDeltaForWorldStep;
  141224. /**
  141225. * Reference to the Ammo library
  141226. */
  141227. bjsAMMO: any;
  141228. /**
  141229. * Created ammoJS world which physics bodies are added to
  141230. */
  141231. world: any;
  141232. /**
  141233. * Name of the plugin
  141234. */
  141235. name: string;
  141236. private _timeStep;
  141237. private _fixedTimeStep;
  141238. private _maxSteps;
  141239. private _tmpQuaternion;
  141240. private _tmpAmmoTransform;
  141241. private _tmpAmmoQuaternion;
  141242. private _tmpAmmoConcreteContactResultCallback;
  141243. private _collisionConfiguration;
  141244. private _dispatcher;
  141245. private _overlappingPairCache;
  141246. private _solver;
  141247. private _softBodySolver;
  141248. private _tmpAmmoVectorA;
  141249. private _tmpAmmoVectorB;
  141250. private _tmpAmmoVectorC;
  141251. private _tmpAmmoVectorD;
  141252. private _tmpContactCallbackResult;
  141253. private _tmpAmmoVectorRCA;
  141254. private _tmpAmmoVectorRCB;
  141255. private _raycastResult;
  141256. private static readonly DISABLE_COLLISION_FLAG;
  141257. private static readonly KINEMATIC_FLAG;
  141258. private static readonly DISABLE_DEACTIVATION_FLAG;
  141259. /**
  141260. * Initializes the ammoJS plugin
  141261. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141262. * @param ammoInjection can be used to inject your own ammo reference
  141263. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141264. */
  141265. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141266. /**
  141267. * Sets the gravity of the physics world (m/(s^2))
  141268. * @param gravity Gravity to set
  141269. */
  141270. setGravity(gravity: Vector3): void;
  141271. /**
  141272. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141273. * @param timeStep timestep to use in seconds
  141274. */
  141275. setTimeStep(timeStep: number): void;
  141276. /**
  141277. * 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)
  141278. * @param fixedTimeStep fixedTimeStep to use in seconds
  141279. */
  141280. setFixedTimeStep(fixedTimeStep: number): void;
  141281. /**
  141282. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141283. * @param maxSteps the maximum number of steps by the physics engine per frame
  141284. */
  141285. setMaxSteps(maxSteps: number): void;
  141286. /**
  141287. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141288. * @returns the current timestep in seconds
  141289. */
  141290. getTimeStep(): number;
  141291. /**
  141292. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141293. */
  141294. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141295. private _isImpostorInContact;
  141296. private _isImpostorPairInContact;
  141297. private _stepSimulation;
  141298. /**
  141299. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141300. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141301. * After the step the babylon meshes are set to the position of the physics imposters
  141302. * @param delta amount of time to step forward
  141303. * @param impostors array of imposters to update before/after the step
  141304. */
  141305. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141306. /**
  141307. * Update babylon mesh to match physics world object
  141308. * @param impostor imposter to match
  141309. */
  141310. private _afterSoftStep;
  141311. /**
  141312. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141313. * @param impostor imposter to match
  141314. */
  141315. private _ropeStep;
  141316. /**
  141317. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141318. * @param impostor imposter to match
  141319. */
  141320. private _softbodyOrClothStep;
  141321. private _tmpMatrix;
  141322. /**
  141323. * Applies an impulse on the imposter
  141324. * @param impostor imposter to apply impulse to
  141325. * @param force amount of force to be applied to the imposter
  141326. * @param contactPoint the location to apply the impulse on the imposter
  141327. */
  141328. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141329. /**
  141330. * Applies a force on the imposter
  141331. * @param impostor imposter to apply force
  141332. * @param force amount of force to be applied to the imposter
  141333. * @param contactPoint the location to apply the force on the imposter
  141334. */
  141335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141336. /**
  141337. * Creates a physics body using the plugin
  141338. * @param impostor the imposter to create the physics body on
  141339. */
  141340. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141341. /**
  141342. * Removes the physics body from the imposter and disposes of the body's memory
  141343. * @param impostor imposter to remove the physics body from
  141344. */
  141345. removePhysicsBody(impostor: PhysicsImpostor): void;
  141346. /**
  141347. * Generates a joint
  141348. * @param impostorJoint the imposter joint to create the joint with
  141349. */
  141350. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141351. /**
  141352. * Removes a joint
  141353. * @param impostorJoint the imposter joint to remove the joint from
  141354. */
  141355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141356. private _addMeshVerts;
  141357. /**
  141358. * Initialise the soft body vertices to match its object's (mesh) vertices
  141359. * Softbody vertices (nodes) are in world space and to match this
  141360. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141361. * @param impostor to create the softbody for
  141362. */
  141363. private _softVertexData;
  141364. /**
  141365. * Create an impostor's soft body
  141366. * @param impostor to create the softbody for
  141367. */
  141368. private _createSoftbody;
  141369. /**
  141370. * Create cloth for an impostor
  141371. * @param impostor to create the softbody for
  141372. */
  141373. private _createCloth;
  141374. /**
  141375. * Create rope for an impostor
  141376. * @param impostor to create the softbody for
  141377. */
  141378. private _createRope;
  141379. /**
  141380. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141381. * @param impostor to create the custom physics shape for
  141382. */
  141383. private _createCustom;
  141384. private _addHullVerts;
  141385. private _createShape;
  141386. /**
  141387. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141388. * @param impostor imposter containing the physics body and babylon object
  141389. */
  141390. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141391. /**
  141392. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141393. * @param impostor imposter containing the physics body and babylon object
  141394. * @param newPosition new position
  141395. * @param newRotation new rotation
  141396. */
  141397. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141398. /**
  141399. * If this plugin is supported
  141400. * @returns true if its supported
  141401. */
  141402. isSupported(): boolean;
  141403. /**
  141404. * Sets the linear velocity of the physics body
  141405. * @param impostor imposter to set the velocity on
  141406. * @param velocity velocity to set
  141407. */
  141408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141409. /**
  141410. * Sets the angular velocity of the physics body
  141411. * @param impostor imposter to set the velocity on
  141412. * @param velocity velocity to set
  141413. */
  141414. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141415. /**
  141416. * gets the linear velocity
  141417. * @param impostor imposter to get linear velocity from
  141418. * @returns linear velocity
  141419. */
  141420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141421. /**
  141422. * gets the angular velocity
  141423. * @param impostor imposter to get angular velocity from
  141424. * @returns angular velocity
  141425. */
  141426. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141427. /**
  141428. * Sets the mass of physics body
  141429. * @param impostor imposter to set the mass on
  141430. * @param mass mass to set
  141431. */
  141432. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141433. /**
  141434. * Gets the mass of the physics body
  141435. * @param impostor imposter to get the mass from
  141436. * @returns mass
  141437. */
  141438. getBodyMass(impostor: PhysicsImpostor): number;
  141439. /**
  141440. * Gets friction of the impostor
  141441. * @param impostor impostor to get friction from
  141442. * @returns friction value
  141443. */
  141444. getBodyFriction(impostor: PhysicsImpostor): number;
  141445. /**
  141446. * Sets friction of the impostor
  141447. * @param impostor impostor to set friction on
  141448. * @param friction friction value
  141449. */
  141450. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141451. /**
  141452. * Gets restitution of the impostor
  141453. * @param impostor impostor to get restitution from
  141454. * @returns restitution value
  141455. */
  141456. getBodyRestitution(impostor: PhysicsImpostor): number;
  141457. /**
  141458. * Sets resitution of the impostor
  141459. * @param impostor impostor to set resitution on
  141460. * @param restitution resitution value
  141461. */
  141462. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141463. /**
  141464. * Gets pressure inside the impostor
  141465. * @param impostor impostor to get pressure from
  141466. * @returns pressure value
  141467. */
  141468. getBodyPressure(impostor: PhysicsImpostor): number;
  141469. /**
  141470. * Sets pressure inside a soft body impostor
  141471. * Cloth and rope must remain 0 pressure
  141472. * @param impostor impostor to set pressure on
  141473. * @param pressure pressure value
  141474. */
  141475. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141476. /**
  141477. * Gets stiffness of the impostor
  141478. * @param impostor impostor to get stiffness from
  141479. * @returns pressure value
  141480. */
  141481. getBodyStiffness(impostor: PhysicsImpostor): number;
  141482. /**
  141483. * Sets stiffness of the impostor
  141484. * @param impostor impostor to set stiffness on
  141485. * @param stiffness stiffness value from 0 to 1
  141486. */
  141487. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141488. /**
  141489. * Gets velocityIterations of the impostor
  141490. * @param impostor impostor to get velocity iterations from
  141491. * @returns velocityIterations value
  141492. */
  141493. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141494. /**
  141495. * Sets velocityIterations of the impostor
  141496. * @param impostor impostor to set velocity iterations on
  141497. * @param velocityIterations velocityIterations value
  141498. */
  141499. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141500. /**
  141501. * Gets positionIterations of the impostor
  141502. * @param impostor impostor to get position iterations from
  141503. * @returns positionIterations value
  141504. */
  141505. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141506. /**
  141507. * Sets positionIterations of the impostor
  141508. * @param impostor impostor to set position on
  141509. * @param positionIterations positionIterations value
  141510. */
  141511. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141512. /**
  141513. * Append an anchor to a cloth object
  141514. * @param impostor is the cloth impostor to add anchor to
  141515. * @param otherImpostor is the rigid impostor to anchor to
  141516. * @param width ratio across width from 0 to 1
  141517. * @param height ratio up height from 0 to 1
  141518. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141519. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141520. */
  141521. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141522. /**
  141523. * Append an hook to a rope object
  141524. * @param impostor is the rope impostor to add hook to
  141525. * @param otherImpostor is the rigid impostor to hook to
  141526. * @param length ratio along the rope from 0 to 1
  141527. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141528. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141529. */
  141530. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141531. /**
  141532. * Sleeps the physics body and stops it from being active
  141533. * @param impostor impostor to sleep
  141534. */
  141535. sleepBody(impostor: PhysicsImpostor): void;
  141536. /**
  141537. * Activates the physics body
  141538. * @param impostor impostor to activate
  141539. */
  141540. wakeUpBody(impostor: PhysicsImpostor): void;
  141541. /**
  141542. * Updates the distance parameters of the joint
  141543. * @param joint joint to update
  141544. * @param maxDistance maximum distance of the joint
  141545. * @param minDistance minimum distance of the joint
  141546. */
  141547. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141548. /**
  141549. * Sets a motor on the joint
  141550. * @param joint joint to set motor on
  141551. * @param speed speed of the motor
  141552. * @param maxForce maximum force of the motor
  141553. * @param motorIndex index of the motor
  141554. */
  141555. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141556. /**
  141557. * Sets the motors limit
  141558. * @param joint joint to set limit on
  141559. * @param upperLimit upper limit
  141560. * @param lowerLimit lower limit
  141561. */
  141562. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141563. /**
  141564. * Syncs the position and rotation of a mesh with the impostor
  141565. * @param mesh mesh to sync
  141566. * @param impostor impostor to update the mesh with
  141567. */
  141568. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141569. /**
  141570. * Gets the radius of the impostor
  141571. * @param impostor impostor to get radius from
  141572. * @returns the radius
  141573. */
  141574. getRadius(impostor: PhysicsImpostor): number;
  141575. /**
  141576. * Gets the box size of the impostor
  141577. * @param impostor impostor to get box size from
  141578. * @param result the resulting box size
  141579. */
  141580. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141581. /**
  141582. * Disposes of the impostor
  141583. */
  141584. dispose(): void;
  141585. /**
  141586. * Does a raycast in the physics world
  141587. * @param from when should the ray start?
  141588. * @param to when should the ray end?
  141589. * @returns PhysicsRaycastResult
  141590. */
  141591. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141592. }
  141593. }
  141594. declare module BABYLON {
  141595. interface AbstractScene {
  141596. /**
  141597. * The list of reflection probes added to the scene
  141598. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141599. */
  141600. reflectionProbes: Array<ReflectionProbe>;
  141601. /**
  141602. * Removes the given reflection probe from this scene.
  141603. * @param toRemove The reflection probe to remove
  141604. * @returns The index of the removed reflection probe
  141605. */
  141606. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141607. /**
  141608. * Adds the given reflection probe to this scene.
  141609. * @param newReflectionProbe The reflection probe to add
  141610. */
  141611. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141612. }
  141613. /**
  141614. * Class used to generate realtime reflection / refraction cube textures
  141615. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141616. */
  141617. export class ReflectionProbe {
  141618. /** defines the name of the probe */
  141619. name: string;
  141620. private _scene;
  141621. private _renderTargetTexture;
  141622. private _projectionMatrix;
  141623. private _viewMatrix;
  141624. private _target;
  141625. private _add;
  141626. private _attachedMesh;
  141627. private _invertYAxis;
  141628. /** Gets or sets probe position (center of the cube map) */
  141629. position: Vector3;
  141630. /**
  141631. * Creates a new reflection probe
  141632. * @param name defines the name of the probe
  141633. * @param size defines the texture resolution (for each face)
  141634. * @param scene defines the hosting scene
  141635. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141636. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141637. */
  141638. constructor(
  141639. /** defines the name of the probe */
  141640. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141641. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141642. get samples(): number;
  141643. set samples(value: number);
  141644. /** Gets or sets the refresh rate to use (on every frame by default) */
  141645. get refreshRate(): number;
  141646. set refreshRate(value: number);
  141647. /**
  141648. * Gets the hosting scene
  141649. * @returns a Scene
  141650. */
  141651. getScene(): Scene;
  141652. /** Gets the internal CubeTexture used to render to */
  141653. get cubeTexture(): RenderTargetTexture;
  141654. /** Gets the list of meshes to render */
  141655. get renderList(): Nullable<AbstractMesh[]>;
  141656. /**
  141657. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141658. * @param mesh defines the mesh to attach to
  141659. */
  141660. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141661. /**
  141662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141663. * @param renderingGroupId The rendering group id corresponding to its index
  141664. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141665. */
  141666. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141667. /**
  141668. * Clean all associated resources
  141669. */
  141670. dispose(): void;
  141671. /**
  141672. * Converts the reflection probe information to a readable string for debug purpose.
  141673. * @param fullDetails Supports for multiple levels of logging within scene loading
  141674. * @returns the human readable reflection probe info
  141675. */
  141676. toString(fullDetails?: boolean): string;
  141677. /**
  141678. * Get the class name of the relfection probe.
  141679. * @returns "ReflectionProbe"
  141680. */
  141681. getClassName(): string;
  141682. /**
  141683. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141684. * @returns The JSON representation of the texture
  141685. */
  141686. serialize(): any;
  141687. /**
  141688. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141689. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141690. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141691. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141692. * @returns The parsed reflection probe if successful
  141693. */
  141694. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141695. }
  141696. }
  141697. declare module BABYLON {
  141698. /** @hidden */
  141699. export var _BabylonLoaderRegistered: boolean;
  141700. /**
  141701. * Helps setting up some configuration for the babylon file loader.
  141702. */
  141703. export class BabylonFileLoaderConfiguration {
  141704. /**
  141705. * The loader does not allow injecting custom physix engine into the plugins.
  141706. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141707. * So you could set this variable to your engine import to make it work.
  141708. */
  141709. static LoaderInjectedPhysicsEngine: any;
  141710. }
  141711. }
  141712. declare module BABYLON {
  141713. /**
  141714. * The Physically based simple base material of BJS.
  141715. *
  141716. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141717. * It is used as the base class for both the specGloss and metalRough conventions.
  141718. */
  141719. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141720. /**
  141721. * Number of Simultaneous lights allowed on the material.
  141722. */
  141723. maxSimultaneousLights: number;
  141724. /**
  141725. * If sets to true, disables all the lights affecting the material.
  141726. */
  141727. disableLighting: boolean;
  141728. /**
  141729. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141730. */
  141731. environmentTexture: BaseTexture;
  141732. /**
  141733. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141734. */
  141735. invertNormalMapX: boolean;
  141736. /**
  141737. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141738. */
  141739. invertNormalMapY: boolean;
  141740. /**
  141741. * Normal map used in the model.
  141742. */
  141743. normalTexture: BaseTexture;
  141744. /**
  141745. * Emissivie color used to self-illuminate the model.
  141746. */
  141747. emissiveColor: Color3;
  141748. /**
  141749. * Emissivie texture used to self-illuminate the model.
  141750. */
  141751. emissiveTexture: BaseTexture;
  141752. /**
  141753. * Occlusion Channel Strenght.
  141754. */
  141755. occlusionStrength: number;
  141756. /**
  141757. * Occlusion Texture of the material (adding extra occlusion effects).
  141758. */
  141759. occlusionTexture: BaseTexture;
  141760. /**
  141761. * Defines the alpha limits in alpha test mode.
  141762. */
  141763. alphaCutOff: number;
  141764. /**
  141765. * Gets the current double sided mode.
  141766. */
  141767. get doubleSided(): boolean;
  141768. /**
  141769. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141770. */
  141771. set doubleSided(value: boolean);
  141772. /**
  141773. * Stores the pre-calculated light information of a mesh in a texture.
  141774. */
  141775. lightmapTexture: BaseTexture;
  141776. /**
  141777. * If true, the light map contains occlusion information instead of lighting info.
  141778. */
  141779. useLightmapAsShadowmap: boolean;
  141780. /**
  141781. * Instantiates a new PBRMaterial instance.
  141782. *
  141783. * @param name The material name
  141784. * @param scene The scene the material will be use in.
  141785. */
  141786. constructor(name: string, scene: Scene);
  141787. getClassName(): string;
  141788. }
  141789. }
  141790. declare module BABYLON {
  141791. /**
  141792. * The PBR material of BJS following the metal roughness convention.
  141793. *
  141794. * This fits to the PBR convention in the GLTF definition:
  141795. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141796. */
  141797. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141798. /**
  141799. * The base color has two different interpretations depending on the value of metalness.
  141800. * When the material is a metal, the base color is the specific measured reflectance value
  141801. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141802. * of the material.
  141803. */
  141804. baseColor: Color3;
  141805. /**
  141806. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141807. * well as opacity information in the alpha channel.
  141808. */
  141809. baseTexture: BaseTexture;
  141810. /**
  141811. * Specifies the metallic scalar value of the material.
  141812. * Can also be used to scale the metalness values of the metallic texture.
  141813. */
  141814. metallic: number;
  141815. /**
  141816. * Specifies the roughness scalar value of the material.
  141817. * Can also be used to scale the roughness values of the metallic texture.
  141818. */
  141819. roughness: number;
  141820. /**
  141821. * Texture containing both the metallic value in the B channel and the
  141822. * roughness value in the G channel to keep better precision.
  141823. */
  141824. metallicRoughnessTexture: BaseTexture;
  141825. /**
  141826. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141827. *
  141828. * @param name The material name
  141829. * @param scene The scene the material will be use in.
  141830. */
  141831. constructor(name: string, scene: Scene);
  141832. /**
  141833. * Return the currrent class name of the material.
  141834. */
  141835. getClassName(): string;
  141836. /**
  141837. * Makes a duplicate of the current material.
  141838. * @param name - name to use for the new material.
  141839. */
  141840. clone(name: string): PBRMetallicRoughnessMaterial;
  141841. /**
  141842. * Serialize the material to a parsable JSON object.
  141843. */
  141844. serialize(): any;
  141845. /**
  141846. * Parses a JSON object correponding to the serialize function.
  141847. */
  141848. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141849. }
  141850. }
  141851. declare module BABYLON {
  141852. /**
  141853. * The PBR material of BJS following the specular glossiness convention.
  141854. *
  141855. * This fits to the PBR convention in the GLTF definition:
  141856. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141857. */
  141858. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141859. /**
  141860. * Specifies the diffuse color of the material.
  141861. */
  141862. diffuseColor: Color3;
  141863. /**
  141864. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141865. * channel.
  141866. */
  141867. diffuseTexture: BaseTexture;
  141868. /**
  141869. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141870. */
  141871. specularColor: Color3;
  141872. /**
  141873. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141874. */
  141875. glossiness: number;
  141876. /**
  141877. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141878. */
  141879. specularGlossinessTexture: BaseTexture;
  141880. /**
  141881. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141882. *
  141883. * @param name The material name
  141884. * @param scene The scene the material will be use in.
  141885. */
  141886. constructor(name: string, scene: Scene);
  141887. /**
  141888. * Return the currrent class name of the material.
  141889. */
  141890. getClassName(): string;
  141891. /**
  141892. * Makes a duplicate of the current material.
  141893. * @param name - name to use for the new material.
  141894. */
  141895. clone(name: string): PBRSpecularGlossinessMaterial;
  141896. /**
  141897. * Serialize the material to a parsable JSON object.
  141898. */
  141899. serialize(): any;
  141900. /**
  141901. * Parses a JSON object correponding to the serialize function.
  141902. */
  141903. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141904. }
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141909. * It can help converting any input color in a desired output one. This can then be used to create effects
  141910. * from sepia, black and white to sixties or futuristic rendering...
  141911. *
  141912. * The only supported format is currently 3dl.
  141913. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141914. */
  141915. export class ColorGradingTexture extends BaseTexture {
  141916. /**
  141917. * The texture URL.
  141918. */
  141919. url: string;
  141920. /**
  141921. * Empty line regex stored for GC.
  141922. */
  141923. private static _noneEmptyLineRegex;
  141924. private _textureMatrix;
  141925. private _onLoad;
  141926. /**
  141927. * Instantiates a ColorGradingTexture from the following parameters.
  141928. *
  141929. * @param url The location of the color gradind data (currently only supporting 3dl)
  141930. * @param sceneOrEngine The scene or engine the texture will be used in
  141931. * @param onLoad defines a callback triggered when the texture has been loaded
  141932. */
  141933. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141934. /**
  141935. * Fires the onload event from the constructor if requested.
  141936. */
  141937. private _triggerOnLoad;
  141938. /**
  141939. * Returns the texture matrix used in most of the material.
  141940. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141941. */
  141942. getTextureMatrix(): Matrix;
  141943. /**
  141944. * Occurs when the file being loaded is a .3dl LUT file.
  141945. */
  141946. private load3dlTexture;
  141947. /**
  141948. * Starts the loading process of the texture.
  141949. */
  141950. private loadTexture;
  141951. /**
  141952. * Clones the color gradind texture.
  141953. */
  141954. clone(): ColorGradingTexture;
  141955. /**
  141956. * Called during delayed load for textures.
  141957. */
  141958. delayLoad(): void;
  141959. /**
  141960. * Parses a color grading texture serialized by Babylon.
  141961. * @param parsedTexture The texture information being parsedTexture
  141962. * @param scene The scene to load the texture in
  141963. * @param rootUrl The root url of the data assets to load
  141964. * @return A color gradind texture
  141965. */
  141966. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141967. /**
  141968. * Serializes the LUT texture to json format.
  141969. */
  141970. serialize(): any;
  141971. }
  141972. }
  141973. declare module BABYLON {
  141974. /**
  141975. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141976. */
  141977. export class EquiRectangularCubeTexture extends BaseTexture {
  141978. /** The six faces of the cube. */
  141979. private static _FacesMapping;
  141980. private _noMipmap;
  141981. private _onLoad;
  141982. private _onError;
  141983. /** The size of the cubemap. */
  141984. private _size;
  141985. /** The buffer of the image. */
  141986. private _buffer;
  141987. /** The width of the input image. */
  141988. private _width;
  141989. /** The height of the input image. */
  141990. private _height;
  141991. /** The URL to the image. */
  141992. url: string;
  141993. /**
  141994. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141995. * @param url The location of the image
  141996. * @param scene The scene the texture will be used in
  141997. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141998. * @param noMipmap Forces to not generate the mipmap if true
  141999. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142000. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142001. * @param onLoad — defines a callback called when texture is loaded
  142002. * @param onError — defines a callback called if there is an error
  142003. */
  142004. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142005. /**
  142006. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142007. */
  142008. private loadImage;
  142009. /**
  142010. * Convert the image buffer into a cubemap and create a CubeTexture.
  142011. */
  142012. private loadTexture;
  142013. /**
  142014. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142015. * @param buffer The ArrayBuffer that should be converted.
  142016. * @returns The buffer as Float32Array.
  142017. */
  142018. private getFloat32ArrayFromArrayBuffer;
  142019. /**
  142020. * Get the current class name of the texture useful for serialization or dynamic coding.
  142021. * @returns "EquiRectangularCubeTexture"
  142022. */
  142023. getClassName(): string;
  142024. /**
  142025. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142026. * @returns A clone of the current EquiRectangularCubeTexture.
  142027. */
  142028. clone(): EquiRectangularCubeTexture;
  142029. }
  142030. }
  142031. declare module BABYLON {
  142032. /**
  142033. * Defines the options related to the creation of an HtmlElementTexture
  142034. */
  142035. export interface IHtmlElementTextureOptions {
  142036. /**
  142037. * Defines wether mip maps should be created or not.
  142038. */
  142039. generateMipMaps?: boolean;
  142040. /**
  142041. * Defines the sampling mode of the texture.
  142042. */
  142043. samplingMode?: number;
  142044. /**
  142045. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142046. */
  142047. engine: Nullable<ThinEngine>;
  142048. /**
  142049. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142050. */
  142051. scene: Nullable<Scene>;
  142052. }
  142053. /**
  142054. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142055. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142056. * is automatically managed.
  142057. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142058. * in your application.
  142059. *
  142060. * As the update is not automatic, you need to call them manually.
  142061. */
  142062. export class HtmlElementTexture extends BaseTexture {
  142063. /**
  142064. * The texture URL.
  142065. */
  142066. element: HTMLVideoElement | HTMLCanvasElement;
  142067. private static readonly DefaultOptions;
  142068. private _textureMatrix;
  142069. private _isVideo;
  142070. private _generateMipMaps;
  142071. private _samplingMode;
  142072. /**
  142073. * Instantiates a HtmlElementTexture from the following parameters.
  142074. *
  142075. * @param name Defines the name of the texture
  142076. * @param element Defines the video or canvas the texture is filled with
  142077. * @param options Defines the other none mandatory texture creation options
  142078. */
  142079. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142080. private _createInternalTexture;
  142081. /**
  142082. * Returns the texture matrix used in most of the material.
  142083. */
  142084. getTextureMatrix(): Matrix;
  142085. /**
  142086. * Updates the content of the texture.
  142087. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142088. */
  142089. update(invertY?: Nullable<boolean>): void;
  142090. }
  142091. }
  142092. declare module BABYLON {
  142093. /**
  142094. * Based on jsTGALoader - Javascript loader for TGA file
  142095. * By Vincent Thibault
  142096. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142097. */
  142098. export class TGATools {
  142099. private static _TYPE_INDEXED;
  142100. private static _TYPE_RGB;
  142101. private static _TYPE_GREY;
  142102. private static _TYPE_RLE_INDEXED;
  142103. private static _TYPE_RLE_RGB;
  142104. private static _TYPE_RLE_GREY;
  142105. private static _ORIGIN_MASK;
  142106. private static _ORIGIN_SHIFT;
  142107. private static _ORIGIN_BL;
  142108. private static _ORIGIN_BR;
  142109. private static _ORIGIN_UL;
  142110. private static _ORIGIN_UR;
  142111. /**
  142112. * Gets the header of a TGA file
  142113. * @param data defines the TGA data
  142114. * @returns the header
  142115. */
  142116. static GetTGAHeader(data: Uint8Array): any;
  142117. /**
  142118. * Uploads TGA content to a Babylon Texture
  142119. * @hidden
  142120. */
  142121. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142122. /** @hidden */
  142123. 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;
  142124. /** @hidden */
  142125. 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;
  142126. /** @hidden */
  142127. 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;
  142128. /** @hidden */
  142129. 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;
  142130. /** @hidden */
  142131. 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;
  142132. /** @hidden */
  142133. 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;
  142134. }
  142135. }
  142136. declare module BABYLON {
  142137. /**
  142138. * Implementation of the TGA Texture Loader.
  142139. * @hidden
  142140. */
  142141. export class _TGATextureLoader implements IInternalTextureLoader {
  142142. /**
  142143. * Defines wether the loader supports cascade loading the different faces.
  142144. */
  142145. readonly supportCascades: boolean;
  142146. /**
  142147. * This returns if the loader support the current file information.
  142148. * @param extension defines the file extension of the file being loaded
  142149. * @returns true if the loader can load the specified file
  142150. */
  142151. canLoad(extension: string): boolean;
  142152. /**
  142153. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142154. * @param data contains the texture data
  142155. * @param texture defines the BabylonJS internal texture
  142156. * @param createPolynomials will be true if polynomials have been requested
  142157. * @param onLoad defines the callback to trigger once the texture is ready
  142158. * @param onError defines the callback to trigger in case of error
  142159. */
  142160. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142161. /**
  142162. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142163. * @param data contains the texture data
  142164. * @param texture defines the BabylonJS internal texture
  142165. * @param callback defines the method to call once ready to upload
  142166. */
  142167. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142168. }
  142169. }
  142170. declare module BABYLON {
  142171. /**
  142172. * Info about the .basis files
  142173. */
  142174. class BasisFileInfo {
  142175. /**
  142176. * If the file has alpha
  142177. */
  142178. hasAlpha: boolean;
  142179. /**
  142180. * Info about each image of the basis file
  142181. */
  142182. images: Array<{
  142183. levels: Array<{
  142184. width: number;
  142185. height: number;
  142186. transcodedPixels: ArrayBufferView;
  142187. }>;
  142188. }>;
  142189. }
  142190. /**
  142191. * Result of transcoding a basis file
  142192. */
  142193. class TranscodeResult {
  142194. /**
  142195. * Info about the .basis file
  142196. */
  142197. fileInfo: BasisFileInfo;
  142198. /**
  142199. * Format to use when loading the file
  142200. */
  142201. format: number;
  142202. }
  142203. /**
  142204. * Configuration options for the Basis transcoder
  142205. */
  142206. export class BasisTranscodeConfiguration {
  142207. /**
  142208. * Supported compression formats used to determine the supported output format of the transcoder
  142209. */
  142210. supportedCompressionFormats?: {
  142211. /**
  142212. * etc1 compression format
  142213. */
  142214. etc1?: boolean;
  142215. /**
  142216. * s3tc compression format
  142217. */
  142218. s3tc?: boolean;
  142219. /**
  142220. * pvrtc compression format
  142221. */
  142222. pvrtc?: boolean;
  142223. /**
  142224. * etc2 compression format
  142225. */
  142226. etc2?: boolean;
  142227. };
  142228. /**
  142229. * If mipmap levels should be loaded for transcoded images (Default: true)
  142230. */
  142231. loadMipmapLevels?: boolean;
  142232. /**
  142233. * Index of a single image to load (Default: all images)
  142234. */
  142235. loadSingleImage?: number;
  142236. }
  142237. /**
  142238. * Used to load .Basis files
  142239. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142240. */
  142241. export class BasisTools {
  142242. private static _IgnoreSupportedFormats;
  142243. /**
  142244. * URL to use when loading the basis transcoder
  142245. */
  142246. static JSModuleURL: string;
  142247. /**
  142248. * URL to use when loading the wasm module for the transcoder
  142249. */
  142250. static WasmModuleURL: string;
  142251. /**
  142252. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142253. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142254. * @returns internal format corresponding to the Basis format
  142255. */
  142256. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142257. private static _WorkerPromise;
  142258. private static _Worker;
  142259. private static _actionId;
  142260. private static _CreateWorkerAsync;
  142261. /**
  142262. * Transcodes a loaded image file to compressed pixel data
  142263. * @param data image data to transcode
  142264. * @param config configuration options for the transcoding
  142265. * @returns a promise resulting in the transcoded image
  142266. */
  142267. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142268. /**
  142269. * Loads a texture from the transcode result
  142270. * @param texture texture load to
  142271. * @param transcodeResult the result of transcoding the basis file to load from
  142272. */
  142273. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142274. }
  142275. }
  142276. declare module BABYLON {
  142277. /**
  142278. * Loader for .basis file format
  142279. */
  142280. export class _BasisTextureLoader implements IInternalTextureLoader {
  142281. /**
  142282. * Defines whether the loader supports cascade loading the different faces.
  142283. */
  142284. readonly supportCascades: boolean;
  142285. /**
  142286. * This returns if the loader support the current file information.
  142287. * @param extension defines the file extension of the file being loaded
  142288. * @returns true if the loader can load the specified file
  142289. */
  142290. canLoad(extension: string): boolean;
  142291. /**
  142292. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142293. * @param data contains the texture data
  142294. * @param texture defines the BabylonJS internal texture
  142295. * @param createPolynomials will be true if polynomials have been requested
  142296. * @param onLoad defines the callback to trigger once the texture is ready
  142297. * @param onError defines the callback to trigger in case of error
  142298. */
  142299. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142300. /**
  142301. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142302. * @param data contains the texture data
  142303. * @param texture defines the BabylonJS internal texture
  142304. * @param callback defines the method to call once ready to upload
  142305. */
  142306. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142307. }
  142308. }
  142309. declare module BABYLON {
  142310. /**
  142311. * Defines the basic options interface of a TexturePacker Frame
  142312. */
  142313. export interface ITexturePackerFrame {
  142314. /**
  142315. * The frame ID
  142316. */
  142317. id: number;
  142318. /**
  142319. * The frames Scale
  142320. */
  142321. scale: Vector2;
  142322. /**
  142323. * The Frames offset
  142324. */
  142325. offset: Vector2;
  142326. }
  142327. /**
  142328. * This is a support class for frame Data on texture packer sets.
  142329. */
  142330. export class TexturePackerFrame implements ITexturePackerFrame {
  142331. /**
  142332. * The frame ID
  142333. */
  142334. id: number;
  142335. /**
  142336. * The frames Scale
  142337. */
  142338. scale: Vector2;
  142339. /**
  142340. * The Frames offset
  142341. */
  142342. offset: Vector2;
  142343. /**
  142344. * Initializes a texture package frame.
  142345. * @param id The numerical frame identifier
  142346. * @param scale Scalar Vector2 for UV frame
  142347. * @param offset Vector2 for the frame position in UV units.
  142348. * @returns TexturePackerFrame
  142349. */
  142350. constructor(id: number, scale: Vector2, offset: Vector2);
  142351. }
  142352. }
  142353. declare module BABYLON {
  142354. /**
  142355. * Defines the basic options interface of a TexturePacker
  142356. */
  142357. export interface ITexturePackerOptions {
  142358. /**
  142359. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142360. */
  142361. map?: string[];
  142362. /**
  142363. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142364. */
  142365. uvsIn?: string;
  142366. /**
  142367. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142368. */
  142369. uvsOut?: string;
  142370. /**
  142371. * number representing the layout style. Defaults to LAYOUT_STRIP
  142372. */
  142373. layout?: number;
  142374. /**
  142375. * number of columns if using custom column count layout(2). This defaults to 4.
  142376. */
  142377. colnum?: number;
  142378. /**
  142379. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142380. */
  142381. updateInputMeshes?: boolean;
  142382. /**
  142383. * boolean flag to dispose all the source textures. Defaults to true.
  142384. */
  142385. disposeSources?: boolean;
  142386. /**
  142387. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142388. */
  142389. fillBlanks?: boolean;
  142390. /**
  142391. * string value representing the context fill style color. Defaults to 'black'.
  142392. */
  142393. customFillColor?: string;
  142394. /**
  142395. * Width and Height Value of each Frame in the TexturePacker Sets
  142396. */
  142397. frameSize?: number;
  142398. /**
  142399. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142400. */
  142401. paddingRatio?: number;
  142402. /**
  142403. * Number that declares the fill method for the padding gutter.
  142404. */
  142405. paddingMode?: number;
  142406. /**
  142407. * If in SUBUV_COLOR padding mode what color to use.
  142408. */
  142409. paddingColor?: Color3 | Color4;
  142410. }
  142411. /**
  142412. * Defines the basic interface of a TexturePacker JSON File
  142413. */
  142414. export interface ITexturePackerJSON {
  142415. /**
  142416. * The frame ID
  142417. */
  142418. name: string;
  142419. /**
  142420. * The base64 channel data
  142421. */
  142422. sets: any;
  142423. /**
  142424. * The options of the Packer
  142425. */
  142426. options: ITexturePackerOptions;
  142427. /**
  142428. * The frame data of the Packer
  142429. */
  142430. frames: Array<number>;
  142431. }
  142432. /**
  142433. * This is a support class that generates a series of packed texture sets.
  142434. * @see https://doc.babylonjs.com/babylon101/materials
  142435. */
  142436. export class TexturePacker {
  142437. /** Packer Layout Constant 0 */
  142438. static readonly LAYOUT_STRIP: number;
  142439. /** Packer Layout Constant 1 */
  142440. static readonly LAYOUT_POWER2: number;
  142441. /** Packer Layout Constant 2 */
  142442. static readonly LAYOUT_COLNUM: number;
  142443. /** Packer Layout Constant 0 */
  142444. static readonly SUBUV_WRAP: number;
  142445. /** Packer Layout Constant 1 */
  142446. static readonly SUBUV_EXTEND: number;
  142447. /** Packer Layout Constant 2 */
  142448. static readonly SUBUV_COLOR: number;
  142449. /** The Name of the Texture Package */
  142450. name: string;
  142451. /** The scene scope of the TexturePacker */
  142452. scene: Scene;
  142453. /** The Meshes to target */
  142454. meshes: AbstractMesh[];
  142455. /** Arguments passed with the Constructor */
  142456. options: ITexturePackerOptions;
  142457. /** The promise that is started upon initialization */
  142458. promise: Nullable<Promise<TexturePacker | string>>;
  142459. /** The Container object for the channel sets that are generated */
  142460. sets: object;
  142461. /** The Container array for the frames that are generated */
  142462. frames: TexturePackerFrame[];
  142463. /** The expected number of textures the system is parsing. */
  142464. private _expecting;
  142465. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142466. private _paddingValue;
  142467. /**
  142468. * Initializes a texture package series from an array of meshes or a single mesh.
  142469. * @param name The name of the package
  142470. * @param meshes The target meshes to compose the package from
  142471. * @param options The arguments that texture packer should follow while building.
  142472. * @param scene The scene which the textures are scoped to.
  142473. * @returns TexturePacker
  142474. */
  142475. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142476. /**
  142477. * Starts the package process
  142478. * @param resolve The promises resolution function
  142479. * @returns TexturePacker
  142480. */
  142481. private _createFrames;
  142482. /**
  142483. * Calculates the Size of the Channel Sets
  142484. * @returns Vector2
  142485. */
  142486. private _calculateSize;
  142487. /**
  142488. * Calculates the UV data for the frames.
  142489. * @param baseSize the base frameSize
  142490. * @param padding the base frame padding
  142491. * @param dtSize size of the Dynamic Texture for that channel
  142492. * @param dtUnits is 1/dtSize
  142493. * @param update flag to update the input meshes
  142494. */
  142495. private _calculateMeshUVFrames;
  142496. /**
  142497. * Calculates the frames Offset.
  142498. * @param index of the frame
  142499. * @returns Vector2
  142500. */
  142501. private _getFrameOffset;
  142502. /**
  142503. * Updates a Mesh to the frame data
  142504. * @param mesh that is the target
  142505. * @param frameID or the frame index
  142506. */
  142507. private _updateMeshUV;
  142508. /**
  142509. * Updates a Meshes materials to use the texture packer channels
  142510. * @param m is the mesh to target
  142511. * @param force all channels on the packer to be set.
  142512. */
  142513. private _updateTextureReferences;
  142514. /**
  142515. * Public method to set a Mesh to a frame
  142516. * @param m that is the target
  142517. * @param frameID or the frame index
  142518. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142519. */
  142520. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142521. /**
  142522. * Starts the async promise to compile the texture packer.
  142523. * @returns Promise<void>
  142524. */
  142525. processAsync(): Promise<void>;
  142526. /**
  142527. * Disposes all textures associated with this packer
  142528. */
  142529. dispose(): void;
  142530. /**
  142531. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142532. * @param imageType is the image type to use.
  142533. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142534. */
  142535. download(imageType?: string, quality?: number): void;
  142536. /**
  142537. * Public method to load a texturePacker JSON file.
  142538. * @param data of the JSON file in string format.
  142539. */
  142540. updateFromJSON(data: string): void;
  142541. }
  142542. }
  142543. declare module BABYLON {
  142544. /**
  142545. * 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.
  142546. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142547. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142548. */
  142549. export class CustomProceduralTexture extends ProceduralTexture {
  142550. private _animate;
  142551. private _time;
  142552. private _config;
  142553. private _texturePath;
  142554. /**
  142555. * Instantiates a new Custom Procedural Texture.
  142556. * 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.
  142557. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142558. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142559. * @param name Define the name of the texture
  142560. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142561. * @param size Define the size of the texture to create
  142562. * @param scene Define the scene the texture belongs to
  142563. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142564. * @param generateMipMaps Define if the texture should creates mip maps or not
  142565. */
  142566. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142567. private _loadJson;
  142568. /**
  142569. * Is the texture ready to be used ? (rendered at least once)
  142570. * @returns true if ready, otherwise, false.
  142571. */
  142572. isReady(): boolean;
  142573. /**
  142574. * Render the texture to its associated render target.
  142575. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142576. */
  142577. render(useCameraPostProcess?: boolean): void;
  142578. /**
  142579. * Update the list of dependant textures samplers in the shader.
  142580. */
  142581. updateTextures(): void;
  142582. /**
  142583. * Update the uniform values of the procedural texture in the shader.
  142584. */
  142585. updateShaderUniforms(): void;
  142586. /**
  142587. * Define if the texture animates or not.
  142588. */
  142589. get animate(): boolean;
  142590. set animate(value: boolean);
  142591. }
  142592. }
  142593. declare module BABYLON {
  142594. /** @hidden */
  142595. export var noisePixelShader: {
  142596. name: string;
  142597. shader: string;
  142598. };
  142599. }
  142600. declare module BABYLON {
  142601. /**
  142602. * Class used to generate noise procedural textures
  142603. */
  142604. export class NoiseProceduralTexture extends ProceduralTexture {
  142605. /** Gets or sets the start time (default is 0) */
  142606. time: number;
  142607. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142608. brightness: number;
  142609. /** Defines the number of octaves to process */
  142610. octaves: number;
  142611. /** Defines the level of persistence (0.8 by default) */
  142612. persistence: number;
  142613. /** Gets or sets animation speed factor (default is 1) */
  142614. animationSpeedFactor: number;
  142615. /**
  142616. * Creates a new NoiseProceduralTexture
  142617. * @param name defines the name fo the texture
  142618. * @param size defines the size of the texture (default is 256)
  142619. * @param scene defines the hosting scene
  142620. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142621. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142622. */
  142623. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142624. private _updateShaderUniforms;
  142625. protected _getDefines(): string;
  142626. /** Generate the current state of the procedural texture */
  142627. render(useCameraPostProcess?: boolean): void;
  142628. /**
  142629. * Serializes this noise procedural texture
  142630. * @returns a serialized noise procedural texture object
  142631. */
  142632. serialize(): any;
  142633. /**
  142634. * Clone the texture.
  142635. * @returns the cloned texture
  142636. */
  142637. clone(): NoiseProceduralTexture;
  142638. /**
  142639. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142640. * @param parsedTexture defines parsed texture data
  142641. * @param scene defines the current scene
  142642. * @param rootUrl defines the root URL containing noise procedural texture information
  142643. * @returns a parsed NoiseProceduralTexture
  142644. */
  142645. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142646. }
  142647. }
  142648. declare module BABYLON {
  142649. /**
  142650. * Raw cube texture where the raw buffers are passed in
  142651. */
  142652. export class RawCubeTexture extends CubeTexture {
  142653. /**
  142654. * Creates a cube texture where the raw buffers are passed in.
  142655. * @param scene defines the scene the texture is attached to
  142656. * @param data defines the array of data to use to create each face
  142657. * @param size defines the size of the textures
  142658. * @param format defines the format of the data
  142659. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142660. * @param generateMipMaps defines if the engine should generate the mip levels
  142661. * @param invertY defines if data must be stored with Y axis inverted
  142662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142663. * @param compression defines the compression used (null by default)
  142664. */
  142665. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142666. /**
  142667. * Updates the raw cube texture.
  142668. * @param data defines the data to store
  142669. * @param format defines the data format
  142670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142671. * @param invertY defines if data must be stored with Y axis inverted
  142672. * @param compression defines the compression used (null by default)
  142673. * @param level defines which level of the texture to update
  142674. */
  142675. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142676. /**
  142677. * Updates a raw cube texture with RGBD encoded data.
  142678. * @param data defines the array of data [mipmap][face] to use to create each face
  142679. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142682. * @returns a promsie that resolves when the operation is complete
  142683. */
  142684. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142685. /**
  142686. * Clones the raw cube texture.
  142687. * @return a new cube texture
  142688. */
  142689. clone(): CubeTexture;
  142690. /** @hidden */
  142691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142692. }
  142693. }
  142694. declare module BABYLON {
  142695. /**
  142696. * Class used to store 2D array textures containing user data
  142697. */
  142698. export class RawTexture2DArray extends Texture {
  142699. /** Gets or sets the texture format to use */
  142700. format: number;
  142701. /**
  142702. * Create a new RawTexture2DArray
  142703. * @param data defines the data of the texture
  142704. * @param width defines the width of the texture
  142705. * @param height defines the height of the texture
  142706. * @param depth defines the number of layers of the texture
  142707. * @param format defines the texture format to use
  142708. * @param scene defines the hosting scene
  142709. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142710. * @param invertY defines if texture must be stored with Y axis inverted
  142711. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142712. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142713. */
  142714. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142715. /** Gets or sets the texture format to use */
  142716. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142717. /**
  142718. * Update the texture with new data
  142719. * @param data defines the data to store in the texture
  142720. */
  142721. update(data: ArrayBufferView): void;
  142722. }
  142723. }
  142724. declare module BABYLON {
  142725. /**
  142726. * Class used to store 3D textures containing user data
  142727. */
  142728. export class RawTexture3D extends Texture {
  142729. /** Gets or sets the texture format to use */
  142730. format: number;
  142731. /**
  142732. * Create a new RawTexture3D
  142733. * @param data defines the data of the texture
  142734. * @param width defines the width of the texture
  142735. * @param height defines the height of the texture
  142736. * @param depth defines the depth of the texture
  142737. * @param format defines the texture format to use
  142738. * @param scene defines the hosting scene
  142739. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142740. * @param invertY defines if texture must be stored with Y axis inverted
  142741. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142742. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142743. */
  142744. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142745. /** Gets or sets the texture format to use */
  142746. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142747. /**
  142748. * Update the texture with new data
  142749. * @param data defines the data to store in the texture
  142750. */
  142751. update(data: ArrayBufferView): void;
  142752. }
  142753. }
  142754. declare module BABYLON {
  142755. /**
  142756. * Creates a refraction texture used by refraction channel of the standard material.
  142757. * It is like a mirror but to see through a material.
  142758. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142759. */
  142760. export class RefractionTexture extends RenderTargetTexture {
  142761. /**
  142762. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142763. * 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.
  142764. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142765. */
  142766. refractionPlane: Plane;
  142767. /**
  142768. * Define how deep under the surface we should see.
  142769. */
  142770. depth: number;
  142771. /**
  142772. * Creates a refraction texture used by refraction channel of the standard material.
  142773. * It is like a mirror but to see through a material.
  142774. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142775. * @param name Define the texture name
  142776. * @param size Define the size of the underlying texture
  142777. * @param scene Define the scene the refraction belongs to
  142778. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142779. */
  142780. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142781. /**
  142782. * Clone the refraction texture.
  142783. * @returns the cloned texture
  142784. */
  142785. clone(): RefractionTexture;
  142786. /**
  142787. * Serialize the texture to a JSON representation you could use in Parse later on
  142788. * @returns the serialized JSON representation
  142789. */
  142790. serialize(): any;
  142791. }
  142792. }
  142793. declare module BABYLON {
  142794. /**
  142795. * Block used to add support for vertex skinning (bones)
  142796. */
  142797. export class BonesBlock extends NodeMaterialBlock {
  142798. /**
  142799. * Creates a new BonesBlock
  142800. * @param name defines the block name
  142801. */
  142802. constructor(name: string);
  142803. /**
  142804. * Initialize the block and prepare the context for build
  142805. * @param state defines the state that will be used for the build
  142806. */
  142807. initialize(state: NodeMaterialBuildState): void;
  142808. /**
  142809. * Gets the current class name
  142810. * @returns the class name
  142811. */
  142812. getClassName(): string;
  142813. /**
  142814. * Gets the matrix indices input component
  142815. */
  142816. get matricesIndices(): NodeMaterialConnectionPoint;
  142817. /**
  142818. * Gets the matrix weights input component
  142819. */
  142820. get matricesWeights(): NodeMaterialConnectionPoint;
  142821. /**
  142822. * Gets the extra matrix indices input component
  142823. */
  142824. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142825. /**
  142826. * Gets the extra matrix weights input component
  142827. */
  142828. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142829. /**
  142830. * Gets the world input component
  142831. */
  142832. get world(): NodeMaterialConnectionPoint;
  142833. /**
  142834. * Gets the output component
  142835. */
  142836. get output(): NodeMaterialConnectionPoint;
  142837. autoConfigure(material: NodeMaterial): void;
  142838. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142839. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142841. protected _buildBlock(state: NodeMaterialBuildState): this;
  142842. }
  142843. }
  142844. declare module BABYLON {
  142845. /**
  142846. * Block used to add support for instances
  142847. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142848. */
  142849. export class InstancesBlock extends NodeMaterialBlock {
  142850. /**
  142851. * Creates a new InstancesBlock
  142852. * @param name defines the block name
  142853. */
  142854. constructor(name: string);
  142855. /**
  142856. * Gets the current class name
  142857. * @returns the class name
  142858. */
  142859. getClassName(): string;
  142860. /**
  142861. * Gets the first world row input component
  142862. */
  142863. get world0(): NodeMaterialConnectionPoint;
  142864. /**
  142865. * Gets the second world row input component
  142866. */
  142867. get world1(): NodeMaterialConnectionPoint;
  142868. /**
  142869. * Gets the third world row input component
  142870. */
  142871. get world2(): NodeMaterialConnectionPoint;
  142872. /**
  142873. * Gets the forth world row input component
  142874. */
  142875. get world3(): NodeMaterialConnectionPoint;
  142876. /**
  142877. * Gets the world input component
  142878. */
  142879. get world(): NodeMaterialConnectionPoint;
  142880. /**
  142881. * Gets the output component
  142882. */
  142883. get output(): NodeMaterialConnectionPoint;
  142884. /**
  142885. * Gets the isntanceID component
  142886. */
  142887. get instanceID(): NodeMaterialConnectionPoint;
  142888. autoConfigure(material: NodeMaterial): void;
  142889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142890. protected _buildBlock(state: NodeMaterialBuildState): this;
  142891. }
  142892. }
  142893. declare module BABYLON {
  142894. /**
  142895. * Block used to add morph targets support to vertex shader
  142896. */
  142897. export class MorphTargetsBlock extends NodeMaterialBlock {
  142898. private _repeatableContentAnchor;
  142899. /**
  142900. * Create a new MorphTargetsBlock
  142901. * @param name defines the block name
  142902. */
  142903. constructor(name: string);
  142904. /**
  142905. * Gets the current class name
  142906. * @returns the class name
  142907. */
  142908. getClassName(): string;
  142909. /**
  142910. * Gets the position input component
  142911. */
  142912. get position(): NodeMaterialConnectionPoint;
  142913. /**
  142914. * Gets the normal input component
  142915. */
  142916. get normal(): NodeMaterialConnectionPoint;
  142917. /**
  142918. * Gets the tangent input component
  142919. */
  142920. get tangent(): NodeMaterialConnectionPoint;
  142921. /**
  142922. * Gets the tangent input component
  142923. */
  142924. get uv(): NodeMaterialConnectionPoint;
  142925. /**
  142926. * Gets the position output component
  142927. */
  142928. get positionOutput(): NodeMaterialConnectionPoint;
  142929. /**
  142930. * Gets the normal output component
  142931. */
  142932. get normalOutput(): NodeMaterialConnectionPoint;
  142933. /**
  142934. * Gets the tangent output component
  142935. */
  142936. get tangentOutput(): NodeMaterialConnectionPoint;
  142937. /**
  142938. * Gets the tangent output component
  142939. */
  142940. get uvOutput(): NodeMaterialConnectionPoint;
  142941. initialize(state: NodeMaterialBuildState): void;
  142942. autoConfigure(material: NodeMaterial): void;
  142943. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142945. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142946. protected _buildBlock(state: NodeMaterialBuildState): this;
  142947. }
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * Block used to get data information from a light
  142952. */
  142953. export class LightInformationBlock extends NodeMaterialBlock {
  142954. private _lightDataUniformName;
  142955. private _lightColorUniformName;
  142956. private _lightTypeDefineName;
  142957. /**
  142958. * Gets or sets the light associated with this block
  142959. */
  142960. light: Nullable<Light>;
  142961. /**
  142962. * Creates a new LightInformationBlock
  142963. * @param name defines the block name
  142964. */
  142965. constructor(name: string);
  142966. /**
  142967. * Gets the current class name
  142968. * @returns the class name
  142969. */
  142970. getClassName(): string;
  142971. /**
  142972. * Gets the world position input component
  142973. */
  142974. get worldPosition(): NodeMaterialConnectionPoint;
  142975. /**
  142976. * Gets the direction output component
  142977. */
  142978. get direction(): NodeMaterialConnectionPoint;
  142979. /**
  142980. * Gets the direction output component
  142981. */
  142982. get color(): NodeMaterialConnectionPoint;
  142983. /**
  142984. * Gets the direction output component
  142985. */
  142986. get intensity(): NodeMaterialConnectionPoint;
  142987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142989. protected _buildBlock(state: NodeMaterialBuildState): this;
  142990. serialize(): any;
  142991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142992. }
  142993. }
  142994. declare module BABYLON {
  142995. /**
  142996. * Block used to add image processing support to fragment shader
  142997. */
  142998. export class ImageProcessingBlock extends NodeMaterialBlock {
  142999. /**
  143000. * Create a new ImageProcessingBlock
  143001. * @param name defines the block name
  143002. */
  143003. constructor(name: string);
  143004. /**
  143005. * Gets the current class name
  143006. * @returns the class name
  143007. */
  143008. getClassName(): string;
  143009. /**
  143010. * Gets the color input component
  143011. */
  143012. get color(): NodeMaterialConnectionPoint;
  143013. /**
  143014. * Gets the output component
  143015. */
  143016. get output(): NodeMaterialConnectionPoint;
  143017. /**
  143018. * Initialize the block and prepare the context for build
  143019. * @param state defines the state that will be used for the build
  143020. */
  143021. initialize(state: NodeMaterialBuildState): void;
  143022. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143025. protected _buildBlock(state: NodeMaterialBuildState): this;
  143026. }
  143027. }
  143028. declare module BABYLON {
  143029. /**
  143030. * Block used to pertub normals based on a normal map
  143031. */
  143032. export class PerturbNormalBlock extends NodeMaterialBlock {
  143033. private _tangentSpaceParameterName;
  143034. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143035. invertX: boolean;
  143036. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143037. invertY: boolean;
  143038. /**
  143039. * Create a new PerturbNormalBlock
  143040. * @param name defines the block name
  143041. */
  143042. constructor(name: string);
  143043. /**
  143044. * Gets the current class name
  143045. * @returns the class name
  143046. */
  143047. getClassName(): string;
  143048. /**
  143049. * Gets the world position input component
  143050. */
  143051. get worldPosition(): NodeMaterialConnectionPoint;
  143052. /**
  143053. * Gets the world normal input component
  143054. */
  143055. get worldNormal(): NodeMaterialConnectionPoint;
  143056. /**
  143057. * Gets the world tangent input component
  143058. */
  143059. get worldTangent(): NodeMaterialConnectionPoint;
  143060. /**
  143061. * Gets the uv input component
  143062. */
  143063. get uv(): NodeMaterialConnectionPoint;
  143064. /**
  143065. * Gets the normal map color input component
  143066. */
  143067. get normalMapColor(): NodeMaterialConnectionPoint;
  143068. /**
  143069. * Gets the strength input component
  143070. */
  143071. get strength(): NodeMaterialConnectionPoint;
  143072. /**
  143073. * Gets the output component
  143074. */
  143075. get output(): NodeMaterialConnectionPoint;
  143076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143078. autoConfigure(material: NodeMaterial): void;
  143079. protected _buildBlock(state: NodeMaterialBuildState): this;
  143080. protected _dumpPropertiesCode(): string;
  143081. serialize(): any;
  143082. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143083. }
  143084. }
  143085. declare module BABYLON {
  143086. /**
  143087. * Block used to discard a pixel if a value is smaller than a cutoff
  143088. */
  143089. export class DiscardBlock extends NodeMaterialBlock {
  143090. /**
  143091. * Create a new DiscardBlock
  143092. * @param name defines the block name
  143093. */
  143094. constructor(name: string);
  143095. /**
  143096. * Gets the current class name
  143097. * @returns the class name
  143098. */
  143099. getClassName(): string;
  143100. /**
  143101. * Gets the color input component
  143102. */
  143103. get value(): NodeMaterialConnectionPoint;
  143104. /**
  143105. * Gets the cutoff input component
  143106. */
  143107. get cutoff(): NodeMaterialConnectionPoint;
  143108. protected _buildBlock(state: NodeMaterialBuildState): this;
  143109. }
  143110. }
  143111. declare module BABYLON {
  143112. /**
  143113. * Block used to test if the fragment shader is front facing
  143114. */
  143115. export class FrontFacingBlock extends NodeMaterialBlock {
  143116. /**
  143117. * Creates a new FrontFacingBlock
  143118. * @param name defines the block name
  143119. */
  143120. constructor(name: string);
  143121. /**
  143122. * Gets the current class name
  143123. * @returns the class name
  143124. */
  143125. getClassName(): string;
  143126. /**
  143127. * Gets the output component
  143128. */
  143129. get output(): NodeMaterialConnectionPoint;
  143130. protected _buildBlock(state: NodeMaterialBuildState): this;
  143131. }
  143132. }
  143133. declare module BABYLON {
  143134. /**
  143135. * Block used to get the derivative value on x and y of a given input
  143136. */
  143137. export class DerivativeBlock extends NodeMaterialBlock {
  143138. /**
  143139. * Create a new DerivativeBlock
  143140. * @param name defines the block name
  143141. */
  143142. constructor(name: string);
  143143. /**
  143144. * Gets the current class name
  143145. * @returns the class name
  143146. */
  143147. getClassName(): string;
  143148. /**
  143149. * Gets the input component
  143150. */
  143151. get input(): NodeMaterialConnectionPoint;
  143152. /**
  143153. * Gets the derivative output on x
  143154. */
  143155. get dx(): NodeMaterialConnectionPoint;
  143156. /**
  143157. * Gets the derivative output on y
  143158. */
  143159. get dy(): NodeMaterialConnectionPoint;
  143160. protected _buildBlock(state: NodeMaterialBuildState): this;
  143161. }
  143162. }
  143163. declare module BABYLON {
  143164. /**
  143165. * Block used to make gl_FragCoord available
  143166. */
  143167. export class FragCoordBlock extends NodeMaterialBlock {
  143168. /**
  143169. * Creates a new FragCoordBlock
  143170. * @param name defines the block name
  143171. */
  143172. constructor(name: string);
  143173. /**
  143174. * Gets the current class name
  143175. * @returns the class name
  143176. */
  143177. getClassName(): string;
  143178. /**
  143179. * Gets the xy component
  143180. */
  143181. get xy(): NodeMaterialConnectionPoint;
  143182. /**
  143183. * Gets the xyz component
  143184. */
  143185. get xyz(): NodeMaterialConnectionPoint;
  143186. /**
  143187. * Gets the xyzw component
  143188. */
  143189. get xyzw(): NodeMaterialConnectionPoint;
  143190. /**
  143191. * Gets the x component
  143192. */
  143193. get x(): NodeMaterialConnectionPoint;
  143194. /**
  143195. * Gets the y component
  143196. */
  143197. get y(): NodeMaterialConnectionPoint;
  143198. /**
  143199. * Gets the z component
  143200. */
  143201. get z(): NodeMaterialConnectionPoint;
  143202. /**
  143203. * Gets the w component
  143204. */
  143205. get output(): NodeMaterialConnectionPoint;
  143206. protected writeOutputs(state: NodeMaterialBuildState): string;
  143207. protected _buildBlock(state: NodeMaterialBuildState): this;
  143208. }
  143209. }
  143210. declare module BABYLON {
  143211. /**
  143212. * Block used to get the screen sizes
  143213. */
  143214. export class ScreenSizeBlock extends NodeMaterialBlock {
  143215. private _varName;
  143216. private _scene;
  143217. /**
  143218. * Creates a new ScreenSizeBlock
  143219. * @param name defines the block name
  143220. */
  143221. constructor(name: string);
  143222. /**
  143223. * Gets the current class name
  143224. * @returns the class name
  143225. */
  143226. getClassName(): string;
  143227. /**
  143228. * Gets the xy component
  143229. */
  143230. get xy(): NodeMaterialConnectionPoint;
  143231. /**
  143232. * Gets the x component
  143233. */
  143234. get x(): NodeMaterialConnectionPoint;
  143235. /**
  143236. * Gets the y component
  143237. */
  143238. get y(): NodeMaterialConnectionPoint;
  143239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143240. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143241. protected _buildBlock(state: NodeMaterialBuildState): this;
  143242. }
  143243. }
  143244. declare module BABYLON {
  143245. /**
  143246. * Block used to add support for scene fog
  143247. */
  143248. export class FogBlock extends NodeMaterialBlock {
  143249. private _fogDistanceName;
  143250. private _fogParameters;
  143251. /**
  143252. * Create a new FogBlock
  143253. * @param name defines the block name
  143254. */
  143255. constructor(name: string);
  143256. /**
  143257. * Gets the current class name
  143258. * @returns the class name
  143259. */
  143260. getClassName(): string;
  143261. /**
  143262. * Gets the world position input component
  143263. */
  143264. get worldPosition(): NodeMaterialConnectionPoint;
  143265. /**
  143266. * Gets the view input component
  143267. */
  143268. get view(): NodeMaterialConnectionPoint;
  143269. /**
  143270. * Gets the color input component
  143271. */
  143272. get input(): NodeMaterialConnectionPoint;
  143273. /**
  143274. * Gets the fog color input component
  143275. */
  143276. get fogColor(): NodeMaterialConnectionPoint;
  143277. /**
  143278. * Gets the output component
  143279. */
  143280. get output(): NodeMaterialConnectionPoint;
  143281. autoConfigure(material: NodeMaterial): void;
  143282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143284. protected _buildBlock(state: NodeMaterialBuildState): this;
  143285. }
  143286. }
  143287. declare module BABYLON {
  143288. /**
  143289. * Block used to add light in the fragment shader
  143290. */
  143291. export class LightBlock extends NodeMaterialBlock {
  143292. private _lightId;
  143293. /**
  143294. * Gets or sets the light associated with this block
  143295. */
  143296. light: Nullable<Light>;
  143297. /**
  143298. * Create a new LightBlock
  143299. * @param name defines the block name
  143300. */
  143301. constructor(name: string);
  143302. /**
  143303. * Gets the current class name
  143304. * @returns the class name
  143305. */
  143306. getClassName(): string;
  143307. /**
  143308. * Gets the world position input component
  143309. */
  143310. get worldPosition(): NodeMaterialConnectionPoint;
  143311. /**
  143312. * Gets the world normal input component
  143313. */
  143314. get worldNormal(): NodeMaterialConnectionPoint;
  143315. /**
  143316. * Gets the camera (or eye) position component
  143317. */
  143318. get cameraPosition(): NodeMaterialConnectionPoint;
  143319. /**
  143320. * Gets the glossiness component
  143321. */
  143322. get glossiness(): NodeMaterialConnectionPoint;
  143323. /**
  143324. * Gets the glossinness power component
  143325. */
  143326. get glossPower(): NodeMaterialConnectionPoint;
  143327. /**
  143328. * Gets the diffuse color component
  143329. */
  143330. get diffuseColor(): NodeMaterialConnectionPoint;
  143331. /**
  143332. * Gets the specular color component
  143333. */
  143334. get specularColor(): NodeMaterialConnectionPoint;
  143335. /**
  143336. * Gets the diffuse output component
  143337. */
  143338. get diffuseOutput(): NodeMaterialConnectionPoint;
  143339. /**
  143340. * Gets the specular output component
  143341. */
  143342. get specularOutput(): NodeMaterialConnectionPoint;
  143343. /**
  143344. * Gets the shadow output component
  143345. */
  143346. get shadow(): NodeMaterialConnectionPoint;
  143347. autoConfigure(material: NodeMaterial): void;
  143348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143349. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143351. private _injectVertexCode;
  143352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143353. serialize(): any;
  143354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143355. }
  143356. }
  143357. declare module BABYLON {
  143358. /**
  143359. * Block used to read a reflection texture from a sampler
  143360. */
  143361. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143362. /**
  143363. * Create a new ReflectionTextureBlock
  143364. * @param name defines the block name
  143365. */
  143366. constructor(name: string);
  143367. /**
  143368. * Gets the current class name
  143369. * @returns the class name
  143370. */
  143371. getClassName(): string;
  143372. /**
  143373. * Gets the world position input component
  143374. */
  143375. get position(): NodeMaterialConnectionPoint;
  143376. /**
  143377. * Gets the world position input component
  143378. */
  143379. get worldPosition(): NodeMaterialConnectionPoint;
  143380. /**
  143381. * Gets the world normal input component
  143382. */
  143383. get worldNormal(): NodeMaterialConnectionPoint;
  143384. /**
  143385. * Gets the world input component
  143386. */
  143387. get world(): NodeMaterialConnectionPoint;
  143388. /**
  143389. * Gets the camera (or eye) position component
  143390. */
  143391. get cameraPosition(): NodeMaterialConnectionPoint;
  143392. /**
  143393. * Gets the view input component
  143394. */
  143395. get view(): NodeMaterialConnectionPoint;
  143396. /**
  143397. * Gets the rgb output component
  143398. */
  143399. get rgb(): NodeMaterialConnectionPoint;
  143400. /**
  143401. * Gets the rgba output component
  143402. */
  143403. get rgba(): NodeMaterialConnectionPoint;
  143404. /**
  143405. * Gets the r output component
  143406. */
  143407. get r(): NodeMaterialConnectionPoint;
  143408. /**
  143409. * Gets the g output component
  143410. */
  143411. get g(): NodeMaterialConnectionPoint;
  143412. /**
  143413. * Gets the b output component
  143414. */
  143415. get b(): NodeMaterialConnectionPoint;
  143416. /**
  143417. * Gets the a output component
  143418. */
  143419. get a(): NodeMaterialConnectionPoint;
  143420. autoConfigure(material: NodeMaterial): void;
  143421. protected _buildBlock(state: NodeMaterialBuildState): this;
  143422. }
  143423. }
  143424. declare module BABYLON {
  143425. /**
  143426. * Block used to add 2 vectors
  143427. */
  143428. export class AddBlock extends NodeMaterialBlock {
  143429. /**
  143430. * Creates a new AddBlock
  143431. * @param name defines the block name
  143432. */
  143433. constructor(name: string);
  143434. /**
  143435. * Gets the current class name
  143436. * @returns the class name
  143437. */
  143438. getClassName(): string;
  143439. /**
  143440. * Gets the left operand input component
  143441. */
  143442. get left(): NodeMaterialConnectionPoint;
  143443. /**
  143444. * Gets the right operand input component
  143445. */
  143446. get right(): NodeMaterialConnectionPoint;
  143447. /**
  143448. * Gets the output component
  143449. */
  143450. get output(): NodeMaterialConnectionPoint;
  143451. protected _buildBlock(state: NodeMaterialBuildState): this;
  143452. }
  143453. }
  143454. declare module BABYLON {
  143455. /**
  143456. * Block used to scale a vector by a float
  143457. */
  143458. export class ScaleBlock extends NodeMaterialBlock {
  143459. /**
  143460. * Creates a new ScaleBlock
  143461. * @param name defines the block name
  143462. */
  143463. constructor(name: string);
  143464. /**
  143465. * Gets the current class name
  143466. * @returns the class name
  143467. */
  143468. getClassName(): string;
  143469. /**
  143470. * Gets the input component
  143471. */
  143472. get input(): NodeMaterialConnectionPoint;
  143473. /**
  143474. * Gets the factor input component
  143475. */
  143476. get factor(): NodeMaterialConnectionPoint;
  143477. /**
  143478. * Gets the output component
  143479. */
  143480. get output(): NodeMaterialConnectionPoint;
  143481. protected _buildBlock(state: NodeMaterialBuildState): this;
  143482. }
  143483. }
  143484. declare module BABYLON {
  143485. /**
  143486. * Block used to clamp a float
  143487. */
  143488. export class ClampBlock extends NodeMaterialBlock {
  143489. /** Gets or sets the minimum range */
  143490. minimum: number;
  143491. /** Gets or sets the maximum range */
  143492. maximum: number;
  143493. /**
  143494. * Creates a new ClampBlock
  143495. * @param name defines the block name
  143496. */
  143497. constructor(name: string);
  143498. /**
  143499. * Gets the current class name
  143500. * @returns the class name
  143501. */
  143502. getClassName(): string;
  143503. /**
  143504. * Gets the value input component
  143505. */
  143506. get value(): NodeMaterialConnectionPoint;
  143507. /**
  143508. * Gets the output component
  143509. */
  143510. get output(): NodeMaterialConnectionPoint;
  143511. protected _buildBlock(state: NodeMaterialBuildState): this;
  143512. protected _dumpPropertiesCode(): string;
  143513. serialize(): any;
  143514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143515. }
  143516. }
  143517. declare module BABYLON {
  143518. /**
  143519. * Block used to apply a cross product between 2 vectors
  143520. */
  143521. export class CrossBlock extends NodeMaterialBlock {
  143522. /**
  143523. * Creates a new CrossBlock
  143524. * @param name defines the block name
  143525. */
  143526. constructor(name: string);
  143527. /**
  143528. * Gets the current class name
  143529. * @returns the class name
  143530. */
  143531. getClassName(): string;
  143532. /**
  143533. * Gets the left operand input component
  143534. */
  143535. get left(): NodeMaterialConnectionPoint;
  143536. /**
  143537. * Gets the right operand input component
  143538. */
  143539. get right(): NodeMaterialConnectionPoint;
  143540. /**
  143541. * Gets the output component
  143542. */
  143543. get output(): NodeMaterialConnectionPoint;
  143544. protected _buildBlock(state: NodeMaterialBuildState): this;
  143545. }
  143546. }
  143547. declare module BABYLON {
  143548. /**
  143549. * Block used to apply a dot product between 2 vectors
  143550. */
  143551. export class DotBlock extends NodeMaterialBlock {
  143552. /**
  143553. * Creates a new DotBlock
  143554. * @param name defines the block name
  143555. */
  143556. constructor(name: string);
  143557. /**
  143558. * Gets the current class name
  143559. * @returns the class name
  143560. */
  143561. getClassName(): string;
  143562. /**
  143563. * Gets the left operand input component
  143564. */
  143565. get left(): NodeMaterialConnectionPoint;
  143566. /**
  143567. * Gets the right operand input component
  143568. */
  143569. get right(): NodeMaterialConnectionPoint;
  143570. /**
  143571. * Gets the output component
  143572. */
  143573. get output(): NodeMaterialConnectionPoint;
  143574. protected _buildBlock(state: NodeMaterialBuildState): this;
  143575. }
  143576. }
  143577. declare module BABYLON {
  143578. /**
  143579. * Block used to normalize a vector
  143580. */
  143581. export class NormalizeBlock extends NodeMaterialBlock {
  143582. /**
  143583. * Creates a new NormalizeBlock
  143584. * @param name defines the block name
  143585. */
  143586. constructor(name: string);
  143587. /**
  143588. * Gets the current class name
  143589. * @returns the class name
  143590. */
  143591. getClassName(): string;
  143592. /**
  143593. * Gets the input component
  143594. */
  143595. get input(): NodeMaterialConnectionPoint;
  143596. /**
  143597. * Gets the output component
  143598. */
  143599. get output(): NodeMaterialConnectionPoint;
  143600. protected _buildBlock(state: NodeMaterialBuildState): this;
  143601. }
  143602. }
  143603. declare module BABYLON {
  143604. /**
  143605. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143606. */
  143607. export class ColorMergerBlock extends NodeMaterialBlock {
  143608. /**
  143609. * Create a new ColorMergerBlock
  143610. * @param name defines the block name
  143611. */
  143612. constructor(name: string);
  143613. /**
  143614. * Gets the current class name
  143615. * @returns the class name
  143616. */
  143617. getClassName(): string;
  143618. /**
  143619. * Gets the rgb component (input)
  143620. */
  143621. get rgbIn(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the r component (input)
  143624. */
  143625. get r(): NodeMaterialConnectionPoint;
  143626. /**
  143627. * Gets the g component (input)
  143628. */
  143629. get g(): NodeMaterialConnectionPoint;
  143630. /**
  143631. * Gets the b component (input)
  143632. */
  143633. get b(): NodeMaterialConnectionPoint;
  143634. /**
  143635. * Gets the a component (input)
  143636. */
  143637. get a(): NodeMaterialConnectionPoint;
  143638. /**
  143639. * Gets the rgba component (output)
  143640. */
  143641. get rgba(): NodeMaterialConnectionPoint;
  143642. /**
  143643. * Gets the rgb component (output)
  143644. */
  143645. get rgbOut(): NodeMaterialConnectionPoint;
  143646. /**
  143647. * Gets the rgb component (output)
  143648. * @deprecated Please use rgbOut instead.
  143649. */
  143650. get rgb(): NodeMaterialConnectionPoint;
  143651. protected _buildBlock(state: NodeMaterialBuildState): this;
  143652. }
  143653. }
  143654. declare module BABYLON {
  143655. /**
  143656. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143657. */
  143658. export class VectorSplitterBlock extends NodeMaterialBlock {
  143659. /**
  143660. * Create a new VectorSplitterBlock
  143661. * @param name defines the block name
  143662. */
  143663. constructor(name: string);
  143664. /**
  143665. * Gets the current class name
  143666. * @returns the class name
  143667. */
  143668. getClassName(): string;
  143669. /**
  143670. * Gets the xyzw component (input)
  143671. */
  143672. get xyzw(): NodeMaterialConnectionPoint;
  143673. /**
  143674. * Gets the xyz component (input)
  143675. */
  143676. get xyzIn(): NodeMaterialConnectionPoint;
  143677. /**
  143678. * Gets the xy component (input)
  143679. */
  143680. get xyIn(): NodeMaterialConnectionPoint;
  143681. /**
  143682. * Gets the xyz component (output)
  143683. */
  143684. get xyzOut(): NodeMaterialConnectionPoint;
  143685. /**
  143686. * Gets the xy component (output)
  143687. */
  143688. get xyOut(): NodeMaterialConnectionPoint;
  143689. /**
  143690. * Gets the x component (output)
  143691. */
  143692. get x(): NodeMaterialConnectionPoint;
  143693. /**
  143694. * Gets the y component (output)
  143695. */
  143696. get y(): NodeMaterialConnectionPoint;
  143697. /**
  143698. * Gets the z component (output)
  143699. */
  143700. get z(): NodeMaterialConnectionPoint;
  143701. /**
  143702. * Gets the w component (output)
  143703. */
  143704. get w(): NodeMaterialConnectionPoint;
  143705. protected _inputRename(name: string): string;
  143706. protected _outputRename(name: string): string;
  143707. protected _buildBlock(state: NodeMaterialBuildState): this;
  143708. }
  143709. }
  143710. declare module BABYLON {
  143711. /**
  143712. * Block used to lerp between 2 values
  143713. */
  143714. export class LerpBlock extends NodeMaterialBlock {
  143715. /**
  143716. * Creates a new LerpBlock
  143717. * @param name defines the block name
  143718. */
  143719. constructor(name: string);
  143720. /**
  143721. * Gets the current class name
  143722. * @returns the class name
  143723. */
  143724. getClassName(): string;
  143725. /**
  143726. * Gets the left operand input component
  143727. */
  143728. get left(): NodeMaterialConnectionPoint;
  143729. /**
  143730. * Gets the right operand input component
  143731. */
  143732. get right(): NodeMaterialConnectionPoint;
  143733. /**
  143734. * Gets the gradient operand input component
  143735. */
  143736. get gradient(): NodeMaterialConnectionPoint;
  143737. /**
  143738. * Gets the output component
  143739. */
  143740. get output(): NodeMaterialConnectionPoint;
  143741. protected _buildBlock(state: NodeMaterialBuildState): this;
  143742. }
  143743. }
  143744. declare module BABYLON {
  143745. /**
  143746. * Block used to divide 2 vectors
  143747. */
  143748. export class DivideBlock extends NodeMaterialBlock {
  143749. /**
  143750. * Creates a new DivideBlock
  143751. * @param name defines the block name
  143752. */
  143753. constructor(name: string);
  143754. /**
  143755. * Gets the current class name
  143756. * @returns the class name
  143757. */
  143758. getClassName(): string;
  143759. /**
  143760. * Gets the left operand input component
  143761. */
  143762. get left(): NodeMaterialConnectionPoint;
  143763. /**
  143764. * Gets the right operand input component
  143765. */
  143766. get right(): NodeMaterialConnectionPoint;
  143767. /**
  143768. * Gets the output component
  143769. */
  143770. get output(): NodeMaterialConnectionPoint;
  143771. protected _buildBlock(state: NodeMaterialBuildState): this;
  143772. }
  143773. }
  143774. declare module BABYLON {
  143775. /**
  143776. * Block used to subtract 2 vectors
  143777. */
  143778. export class SubtractBlock extends NodeMaterialBlock {
  143779. /**
  143780. * Creates a new SubtractBlock
  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 left operand input component
  143791. */
  143792. get left(): NodeMaterialConnectionPoint;
  143793. /**
  143794. * Gets the right operand input component
  143795. */
  143796. get right(): 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. * Block used to step a value
  143807. */
  143808. export class StepBlock extends NodeMaterialBlock {
  143809. /**
  143810. * Creates a new StepBlock
  143811. * @param name defines the block name
  143812. */
  143813. constructor(name: string);
  143814. /**
  143815. * Gets the current class name
  143816. * @returns the class name
  143817. */
  143818. getClassName(): string;
  143819. /**
  143820. * Gets the value operand input component
  143821. */
  143822. get value(): NodeMaterialConnectionPoint;
  143823. /**
  143824. * Gets the edge operand input component
  143825. */
  143826. get edge(): NodeMaterialConnectionPoint;
  143827. /**
  143828. * Gets the output component
  143829. */
  143830. get output(): NodeMaterialConnectionPoint;
  143831. protected _buildBlock(state: NodeMaterialBuildState): this;
  143832. }
  143833. }
  143834. declare module BABYLON {
  143835. /**
  143836. * Block used to get the opposite (1 - x) of a value
  143837. */
  143838. export class OneMinusBlock extends NodeMaterialBlock {
  143839. /**
  143840. * Creates a new OneMinusBlock
  143841. * @param name defines the block name
  143842. */
  143843. constructor(name: string);
  143844. /**
  143845. * Gets the current class name
  143846. * @returns the class name
  143847. */
  143848. getClassName(): string;
  143849. /**
  143850. * Gets the input component
  143851. */
  143852. get input(): NodeMaterialConnectionPoint;
  143853. /**
  143854. * Gets the output component
  143855. */
  143856. get output(): NodeMaterialConnectionPoint;
  143857. protected _buildBlock(state: NodeMaterialBuildState): this;
  143858. }
  143859. }
  143860. declare module BABYLON {
  143861. /**
  143862. * Block used to get the view direction
  143863. */
  143864. export class ViewDirectionBlock extends NodeMaterialBlock {
  143865. /**
  143866. * Creates a new ViewDirectionBlock
  143867. * @param name defines the block name
  143868. */
  143869. constructor(name: string);
  143870. /**
  143871. * Gets the current class name
  143872. * @returns the class name
  143873. */
  143874. getClassName(): string;
  143875. /**
  143876. * Gets the world position component
  143877. */
  143878. get worldPosition(): NodeMaterialConnectionPoint;
  143879. /**
  143880. * Gets the camera position component
  143881. */
  143882. get cameraPosition(): NodeMaterialConnectionPoint;
  143883. /**
  143884. * Gets the output component
  143885. */
  143886. get output(): NodeMaterialConnectionPoint;
  143887. autoConfigure(material: NodeMaterial): void;
  143888. protected _buildBlock(state: NodeMaterialBuildState): this;
  143889. }
  143890. }
  143891. declare module BABYLON {
  143892. /**
  143893. * Block used to compute fresnel value
  143894. */
  143895. export class FresnelBlock extends NodeMaterialBlock {
  143896. /**
  143897. * Create a new FresnelBlock
  143898. * @param name defines the block name
  143899. */
  143900. constructor(name: string);
  143901. /**
  143902. * Gets the current class name
  143903. * @returns the class name
  143904. */
  143905. getClassName(): string;
  143906. /**
  143907. * Gets the world normal input component
  143908. */
  143909. get worldNormal(): NodeMaterialConnectionPoint;
  143910. /**
  143911. * Gets the view direction input component
  143912. */
  143913. get viewDirection(): NodeMaterialConnectionPoint;
  143914. /**
  143915. * Gets the bias input component
  143916. */
  143917. get bias(): NodeMaterialConnectionPoint;
  143918. /**
  143919. * Gets the camera (or eye) position component
  143920. */
  143921. get power(): NodeMaterialConnectionPoint;
  143922. /**
  143923. * Gets the fresnel output component
  143924. */
  143925. get fresnel(): NodeMaterialConnectionPoint;
  143926. autoConfigure(material: NodeMaterial): void;
  143927. protected _buildBlock(state: NodeMaterialBuildState): this;
  143928. }
  143929. }
  143930. declare module BABYLON {
  143931. /**
  143932. * Block used to get the max of 2 values
  143933. */
  143934. export class MaxBlock extends NodeMaterialBlock {
  143935. /**
  143936. * Creates a new MaxBlock
  143937. * @param name defines the block name
  143938. */
  143939. constructor(name: string);
  143940. /**
  143941. * Gets the current class name
  143942. * @returns the class name
  143943. */
  143944. getClassName(): string;
  143945. /**
  143946. * Gets the left operand input component
  143947. */
  143948. get left(): NodeMaterialConnectionPoint;
  143949. /**
  143950. * Gets the right operand input component
  143951. */
  143952. get right(): NodeMaterialConnectionPoint;
  143953. /**
  143954. * Gets the output component
  143955. */
  143956. get output(): NodeMaterialConnectionPoint;
  143957. protected _buildBlock(state: NodeMaterialBuildState): this;
  143958. }
  143959. }
  143960. declare module BABYLON {
  143961. /**
  143962. * Block used to get the min of 2 values
  143963. */
  143964. export class MinBlock extends NodeMaterialBlock {
  143965. /**
  143966. * Creates a new MinBlock
  143967. * @param name defines the block name
  143968. */
  143969. constructor(name: string);
  143970. /**
  143971. * Gets the current class name
  143972. * @returns the class name
  143973. */
  143974. getClassName(): string;
  143975. /**
  143976. * Gets the left operand input component
  143977. */
  143978. get left(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the right operand input component
  143981. */
  143982. get right(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the output component
  143985. */
  143986. get output(): NodeMaterialConnectionPoint;
  143987. protected _buildBlock(state: NodeMaterialBuildState): this;
  143988. }
  143989. }
  143990. declare module BABYLON {
  143991. /**
  143992. * Block used to get the distance between 2 values
  143993. */
  143994. export class DistanceBlock extends NodeMaterialBlock {
  143995. /**
  143996. * Creates a new DistanceBlock
  143997. * @param name defines the block name
  143998. */
  143999. constructor(name: string);
  144000. /**
  144001. * Gets the current class name
  144002. * @returns the class name
  144003. */
  144004. getClassName(): string;
  144005. /**
  144006. * Gets the left operand input component
  144007. */
  144008. get left(): NodeMaterialConnectionPoint;
  144009. /**
  144010. * Gets the right operand input component
  144011. */
  144012. get right(): NodeMaterialConnectionPoint;
  144013. /**
  144014. * Gets the output component
  144015. */
  144016. get output(): NodeMaterialConnectionPoint;
  144017. protected _buildBlock(state: NodeMaterialBuildState): this;
  144018. }
  144019. }
  144020. declare module BABYLON {
  144021. /**
  144022. * Block used to get the length of a vector
  144023. */
  144024. export class LengthBlock extends NodeMaterialBlock {
  144025. /**
  144026. * Creates a new LengthBlock
  144027. * @param name defines the block name
  144028. */
  144029. constructor(name: string);
  144030. /**
  144031. * Gets the current class name
  144032. * @returns the class name
  144033. */
  144034. getClassName(): string;
  144035. /**
  144036. * Gets the value input component
  144037. */
  144038. get value(): NodeMaterialConnectionPoint;
  144039. /**
  144040. * Gets the output component
  144041. */
  144042. get output(): NodeMaterialConnectionPoint;
  144043. protected _buildBlock(state: NodeMaterialBuildState): this;
  144044. }
  144045. }
  144046. declare module BABYLON {
  144047. /**
  144048. * Block used to get negative version of a value (i.e. x * -1)
  144049. */
  144050. export class NegateBlock extends NodeMaterialBlock {
  144051. /**
  144052. * Creates a new NegateBlock
  144053. * @param name defines the block name
  144054. */
  144055. constructor(name: string);
  144056. /**
  144057. * Gets the current class name
  144058. * @returns the class name
  144059. */
  144060. getClassName(): string;
  144061. /**
  144062. * Gets the value input component
  144063. */
  144064. get value(): NodeMaterialConnectionPoint;
  144065. /**
  144066. * Gets the output component
  144067. */
  144068. get output(): NodeMaterialConnectionPoint;
  144069. protected _buildBlock(state: NodeMaterialBuildState): this;
  144070. }
  144071. }
  144072. declare module BABYLON {
  144073. /**
  144074. * Block used to get the value of the first parameter raised to the power of the second
  144075. */
  144076. export class PowBlock extends NodeMaterialBlock {
  144077. /**
  144078. * Creates a new PowBlock
  144079. * @param name defines the block name
  144080. */
  144081. constructor(name: string);
  144082. /**
  144083. * Gets the current class name
  144084. * @returns the class name
  144085. */
  144086. getClassName(): string;
  144087. /**
  144088. * Gets the value operand input component
  144089. */
  144090. get value(): NodeMaterialConnectionPoint;
  144091. /**
  144092. * Gets the power operand input component
  144093. */
  144094. get power(): NodeMaterialConnectionPoint;
  144095. /**
  144096. * Gets the output component
  144097. */
  144098. get output(): NodeMaterialConnectionPoint;
  144099. protected _buildBlock(state: NodeMaterialBuildState): this;
  144100. }
  144101. }
  144102. declare module BABYLON {
  144103. /**
  144104. * Block used to get a random number
  144105. */
  144106. export class RandomNumberBlock extends NodeMaterialBlock {
  144107. /**
  144108. * Creates a new RandomNumberBlock
  144109. * @param name defines the block name
  144110. */
  144111. constructor(name: string);
  144112. /**
  144113. * Gets the current class name
  144114. * @returns the class name
  144115. */
  144116. getClassName(): string;
  144117. /**
  144118. * Gets the seed input component
  144119. */
  144120. get seed(): NodeMaterialConnectionPoint;
  144121. /**
  144122. * Gets the output component
  144123. */
  144124. get output(): NodeMaterialConnectionPoint;
  144125. protected _buildBlock(state: NodeMaterialBuildState): this;
  144126. }
  144127. }
  144128. declare module BABYLON {
  144129. /**
  144130. * Block used to compute arc tangent of 2 values
  144131. */
  144132. export class ArcTan2Block extends NodeMaterialBlock {
  144133. /**
  144134. * Creates a new ArcTan2Block
  144135. * @param name defines the block name
  144136. */
  144137. constructor(name: string);
  144138. /**
  144139. * Gets the current class name
  144140. * @returns the class name
  144141. */
  144142. getClassName(): string;
  144143. /**
  144144. * Gets the x operand input component
  144145. */
  144146. get x(): NodeMaterialConnectionPoint;
  144147. /**
  144148. * Gets the y operand input component
  144149. */
  144150. get y(): NodeMaterialConnectionPoint;
  144151. /**
  144152. * Gets the output component
  144153. */
  144154. get output(): NodeMaterialConnectionPoint;
  144155. protected _buildBlock(state: NodeMaterialBuildState): this;
  144156. }
  144157. }
  144158. declare module BABYLON {
  144159. /**
  144160. * Block used to smooth step a value
  144161. */
  144162. export class SmoothStepBlock extends NodeMaterialBlock {
  144163. /**
  144164. * Creates a new SmoothStepBlock
  144165. * @param name defines the block name
  144166. */
  144167. constructor(name: string);
  144168. /**
  144169. * Gets the current class name
  144170. * @returns the class name
  144171. */
  144172. getClassName(): string;
  144173. /**
  144174. * Gets the value operand input component
  144175. */
  144176. get value(): NodeMaterialConnectionPoint;
  144177. /**
  144178. * Gets the first edge operand input component
  144179. */
  144180. get edge0(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the second edge operand input component
  144183. */
  144184. get edge1(): NodeMaterialConnectionPoint;
  144185. /**
  144186. * Gets the output component
  144187. */
  144188. get output(): NodeMaterialConnectionPoint;
  144189. protected _buildBlock(state: NodeMaterialBuildState): this;
  144190. }
  144191. }
  144192. declare module BABYLON {
  144193. /**
  144194. * Block used to get the reciprocal (1 / x) of a value
  144195. */
  144196. export class ReciprocalBlock extends NodeMaterialBlock {
  144197. /**
  144198. * Creates a new ReciprocalBlock
  144199. * @param name defines the block name
  144200. */
  144201. constructor(name: string);
  144202. /**
  144203. * Gets the current class name
  144204. * @returns the class name
  144205. */
  144206. getClassName(): string;
  144207. /**
  144208. * Gets the input component
  144209. */
  144210. get input(): NodeMaterialConnectionPoint;
  144211. /**
  144212. * Gets the output component
  144213. */
  144214. get output(): NodeMaterialConnectionPoint;
  144215. protected _buildBlock(state: NodeMaterialBuildState): this;
  144216. }
  144217. }
  144218. declare module BABYLON {
  144219. /**
  144220. * Block used to replace a color by another one
  144221. */
  144222. export class ReplaceColorBlock extends NodeMaterialBlock {
  144223. /**
  144224. * Creates a new ReplaceColorBlock
  144225. * @param name defines the block name
  144226. */
  144227. constructor(name: string);
  144228. /**
  144229. * Gets the current class name
  144230. * @returns the class name
  144231. */
  144232. getClassName(): string;
  144233. /**
  144234. * Gets the value input component
  144235. */
  144236. get value(): NodeMaterialConnectionPoint;
  144237. /**
  144238. * Gets the reference input component
  144239. */
  144240. get reference(): NodeMaterialConnectionPoint;
  144241. /**
  144242. * Gets the distance input component
  144243. */
  144244. get distance(): NodeMaterialConnectionPoint;
  144245. /**
  144246. * Gets the replacement input component
  144247. */
  144248. get replacement(): NodeMaterialConnectionPoint;
  144249. /**
  144250. * Gets the output component
  144251. */
  144252. get output(): NodeMaterialConnectionPoint;
  144253. protected _buildBlock(state: NodeMaterialBuildState): this;
  144254. }
  144255. }
  144256. declare module BABYLON {
  144257. /**
  144258. * Block used to posterize a value
  144259. * @see https://en.wikipedia.org/wiki/Posterization
  144260. */
  144261. export class PosterizeBlock extends NodeMaterialBlock {
  144262. /**
  144263. * Creates a new PosterizeBlock
  144264. * @param name defines the block name
  144265. */
  144266. constructor(name: string);
  144267. /**
  144268. * Gets the current class name
  144269. * @returns the class name
  144270. */
  144271. getClassName(): string;
  144272. /**
  144273. * Gets the value input component
  144274. */
  144275. get value(): NodeMaterialConnectionPoint;
  144276. /**
  144277. * Gets the steps input component
  144278. */
  144279. get steps(): NodeMaterialConnectionPoint;
  144280. /**
  144281. * Gets the output component
  144282. */
  144283. get output(): NodeMaterialConnectionPoint;
  144284. protected _buildBlock(state: NodeMaterialBuildState): this;
  144285. }
  144286. }
  144287. declare module BABYLON {
  144288. /**
  144289. * Operations supported by the Wave block
  144290. */
  144291. export enum WaveBlockKind {
  144292. /** SawTooth */
  144293. SawTooth = 0,
  144294. /** Square */
  144295. Square = 1,
  144296. /** Triangle */
  144297. Triangle = 2
  144298. }
  144299. /**
  144300. * Block used to apply wave operation to floats
  144301. */
  144302. export class WaveBlock extends NodeMaterialBlock {
  144303. /**
  144304. * Gets or sets the kibnd of wave to be applied by the block
  144305. */
  144306. kind: WaveBlockKind;
  144307. /**
  144308. * Creates a new WaveBlock
  144309. * @param name defines the block name
  144310. */
  144311. constructor(name: string);
  144312. /**
  144313. * Gets the current class name
  144314. * @returns the class name
  144315. */
  144316. getClassName(): string;
  144317. /**
  144318. * Gets the input component
  144319. */
  144320. get input(): NodeMaterialConnectionPoint;
  144321. /**
  144322. * Gets the output component
  144323. */
  144324. get output(): NodeMaterialConnectionPoint;
  144325. protected _buildBlock(state: NodeMaterialBuildState): this;
  144326. serialize(): any;
  144327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144328. }
  144329. }
  144330. declare module BABYLON {
  144331. /**
  144332. * Class used to store a color step for the GradientBlock
  144333. */
  144334. export class GradientBlockColorStep {
  144335. private _step;
  144336. /**
  144337. * Gets value indicating which step this color is associated with (between 0 and 1)
  144338. */
  144339. get step(): number;
  144340. /**
  144341. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144342. */
  144343. set step(val: number);
  144344. private _color;
  144345. /**
  144346. * Gets the color associated with this step
  144347. */
  144348. get color(): Color3;
  144349. /**
  144350. * Sets the color associated with this step
  144351. */
  144352. set color(val: Color3);
  144353. /**
  144354. * Creates a new GradientBlockColorStep
  144355. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144356. * @param color defines the color associated with this step
  144357. */
  144358. constructor(step: number, color: Color3);
  144359. }
  144360. /**
  144361. * Block used to return a color from a gradient based on an input value between 0 and 1
  144362. */
  144363. export class GradientBlock extends NodeMaterialBlock {
  144364. /**
  144365. * Gets or sets the list of color steps
  144366. */
  144367. colorSteps: GradientBlockColorStep[];
  144368. /** Gets an observable raised when the value is changed */
  144369. onValueChangedObservable: Observable<GradientBlock>;
  144370. /** calls observable when the value is changed*/
  144371. colorStepsUpdated(): void;
  144372. /**
  144373. * Creates a new GradientBlock
  144374. * @param name defines the block name
  144375. */
  144376. constructor(name: string);
  144377. /**
  144378. * Gets the current class name
  144379. * @returns the class name
  144380. */
  144381. getClassName(): string;
  144382. /**
  144383. * Gets the gradient input component
  144384. */
  144385. get gradient(): NodeMaterialConnectionPoint;
  144386. /**
  144387. * Gets the output component
  144388. */
  144389. get output(): NodeMaterialConnectionPoint;
  144390. private _writeColorConstant;
  144391. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144392. serialize(): any;
  144393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144394. protected _dumpPropertiesCode(): string;
  144395. }
  144396. }
  144397. declare module BABYLON {
  144398. /**
  144399. * Block used to normalize lerp between 2 values
  144400. */
  144401. export class NLerpBlock extends NodeMaterialBlock {
  144402. /**
  144403. * Creates a new NLerpBlock
  144404. * @param name defines the block name
  144405. */
  144406. constructor(name: string);
  144407. /**
  144408. * Gets the current class name
  144409. * @returns the class name
  144410. */
  144411. getClassName(): string;
  144412. /**
  144413. * Gets the left operand input component
  144414. */
  144415. get left(): NodeMaterialConnectionPoint;
  144416. /**
  144417. * Gets the right operand input component
  144418. */
  144419. get right(): NodeMaterialConnectionPoint;
  144420. /**
  144421. * Gets the gradient operand input component
  144422. */
  144423. get gradient(): NodeMaterialConnectionPoint;
  144424. /**
  144425. * Gets the output component
  144426. */
  144427. get output(): NodeMaterialConnectionPoint;
  144428. protected _buildBlock(state: NodeMaterialBuildState): this;
  144429. }
  144430. }
  144431. declare module BABYLON {
  144432. /**
  144433. * block used to Generate a Worley Noise 3D Noise Pattern
  144434. */
  144435. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144436. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144437. manhattanDistance: boolean;
  144438. /**
  144439. * Creates a new WorleyNoise3DBlock
  144440. * @param name defines the block name
  144441. */
  144442. constructor(name: string);
  144443. /**
  144444. * Gets the current class name
  144445. * @returns the class name
  144446. */
  144447. getClassName(): string;
  144448. /**
  144449. * Gets the seed input component
  144450. */
  144451. get seed(): NodeMaterialConnectionPoint;
  144452. /**
  144453. * Gets the jitter input component
  144454. */
  144455. get jitter(): NodeMaterialConnectionPoint;
  144456. /**
  144457. * Gets the output component
  144458. */
  144459. get output(): NodeMaterialConnectionPoint;
  144460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144461. /**
  144462. * Exposes the properties to the UI?
  144463. */
  144464. protected _dumpPropertiesCode(): string;
  144465. /**
  144466. * Exposes the properties to the Seralize?
  144467. */
  144468. serialize(): any;
  144469. /**
  144470. * Exposes the properties to the deseralize?
  144471. */
  144472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144473. }
  144474. }
  144475. declare module BABYLON {
  144476. /**
  144477. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144478. */
  144479. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144480. /**
  144481. * Creates a new SimplexPerlin3DBlock
  144482. * @param name defines the block name
  144483. */
  144484. constructor(name: string);
  144485. /**
  144486. * Gets the current class name
  144487. * @returns the class name
  144488. */
  144489. getClassName(): string;
  144490. /**
  144491. * Gets the seed operand input component
  144492. */
  144493. get seed(): NodeMaterialConnectionPoint;
  144494. /**
  144495. * Gets the output component
  144496. */
  144497. get output(): NodeMaterialConnectionPoint;
  144498. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144499. }
  144500. }
  144501. declare module BABYLON {
  144502. /**
  144503. * Block used to blend normals
  144504. */
  144505. export class NormalBlendBlock extends NodeMaterialBlock {
  144506. /**
  144507. * Creates a new NormalBlendBlock
  144508. * @param name defines the block name
  144509. */
  144510. constructor(name: string);
  144511. /**
  144512. * Gets the current class name
  144513. * @returns the class name
  144514. */
  144515. getClassName(): string;
  144516. /**
  144517. * Gets the first input component
  144518. */
  144519. get normalMap0(): NodeMaterialConnectionPoint;
  144520. /**
  144521. * Gets the second input component
  144522. */
  144523. get normalMap1(): NodeMaterialConnectionPoint;
  144524. /**
  144525. * Gets the output component
  144526. */
  144527. get output(): NodeMaterialConnectionPoint;
  144528. protected _buildBlock(state: NodeMaterialBuildState): this;
  144529. }
  144530. }
  144531. declare module BABYLON {
  144532. /**
  144533. * Block used to rotate a 2d vector by a given angle
  144534. */
  144535. export class Rotate2dBlock extends NodeMaterialBlock {
  144536. /**
  144537. * Creates a new Rotate2dBlock
  144538. * @param name defines the block name
  144539. */
  144540. constructor(name: string);
  144541. /**
  144542. * Gets the current class name
  144543. * @returns the class name
  144544. */
  144545. getClassName(): string;
  144546. /**
  144547. * Gets the input vector
  144548. */
  144549. get input(): NodeMaterialConnectionPoint;
  144550. /**
  144551. * Gets the input angle
  144552. */
  144553. get angle(): NodeMaterialConnectionPoint;
  144554. /**
  144555. * Gets the output component
  144556. */
  144557. get output(): NodeMaterialConnectionPoint;
  144558. autoConfigure(material: NodeMaterial): void;
  144559. protected _buildBlock(state: NodeMaterialBuildState): this;
  144560. }
  144561. }
  144562. declare module BABYLON {
  144563. /**
  144564. * Block used to get the reflected vector from a direction and a normal
  144565. */
  144566. export class ReflectBlock extends NodeMaterialBlock {
  144567. /**
  144568. * Creates a new ReflectBlock
  144569. * @param name defines the block name
  144570. */
  144571. constructor(name: string);
  144572. /**
  144573. * Gets the current class name
  144574. * @returns the class name
  144575. */
  144576. getClassName(): string;
  144577. /**
  144578. * Gets the incident component
  144579. */
  144580. get incident(): NodeMaterialConnectionPoint;
  144581. /**
  144582. * Gets the normal component
  144583. */
  144584. get normal(): NodeMaterialConnectionPoint;
  144585. /**
  144586. * Gets the output component
  144587. */
  144588. get output(): NodeMaterialConnectionPoint;
  144589. protected _buildBlock(state: NodeMaterialBuildState): this;
  144590. }
  144591. }
  144592. declare module BABYLON {
  144593. /**
  144594. * Block used to get the refracted vector from a direction and a normal
  144595. */
  144596. export class RefractBlock extends NodeMaterialBlock {
  144597. /**
  144598. * Creates a new RefractBlock
  144599. * @param name defines the block name
  144600. */
  144601. constructor(name: string);
  144602. /**
  144603. * Gets the current class name
  144604. * @returns the class name
  144605. */
  144606. getClassName(): string;
  144607. /**
  144608. * Gets the incident component
  144609. */
  144610. get incident(): NodeMaterialConnectionPoint;
  144611. /**
  144612. * Gets the normal component
  144613. */
  144614. get normal(): NodeMaterialConnectionPoint;
  144615. /**
  144616. * Gets the index of refraction component
  144617. */
  144618. get ior(): NodeMaterialConnectionPoint;
  144619. /**
  144620. * Gets the output component
  144621. */
  144622. get output(): NodeMaterialConnectionPoint;
  144623. protected _buildBlock(state: NodeMaterialBuildState): this;
  144624. }
  144625. }
  144626. declare module BABYLON {
  144627. /**
  144628. * Block used to desaturate a color
  144629. */
  144630. export class DesaturateBlock extends NodeMaterialBlock {
  144631. /**
  144632. * Creates a new DesaturateBlock
  144633. * @param name defines the block name
  144634. */
  144635. constructor(name: string);
  144636. /**
  144637. * Gets the current class name
  144638. * @returns the class name
  144639. */
  144640. getClassName(): string;
  144641. /**
  144642. * Gets the color operand input component
  144643. */
  144644. get color(): NodeMaterialConnectionPoint;
  144645. /**
  144646. * Gets the level operand input component
  144647. */
  144648. get level(): NodeMaterialConnectionPoint;
  144649. /**
  144650. * Gets the output component
  144651. */
  144652. get output(): NodeMaterialConnectionPoint;
  144653. protected _buildBlock(state: NodeMaterialBuildState): this;
  144654. }
  144655. }
  144656. declare module BABYLON {
  144657. /**
  144658. * Block used to implement the ambient occlusion module of the PBR material
  144659. */
  144660. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144661. /**
  144662. * Create a new AmbientOcclusionBlock
  144663. * @param name defines the block name
  144664. */
  144665. constructor(name: string);
  144666. /**
  144667. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144668. */
  144669. useAmbientInGrayScale: boolean;
  144670. /**
  144671. * Initialize the block and prepare the context for build
  144672. * @param state defines the state that will be used for the build
  144673. */
  144674. initialize(state: NodeMaterialBuildState): void;
  144675. /**
  144676. * Gets the current class name
  144677. * @returns the class name
  144678. */
  144679. getClassName(): string;
  144680. /**
  144681. * Gets the texture input component
  144682. */
  144683. get texture(): NodeMaterialConnectionPoint;
  144684. /**
  144685. * Gets the texture intensity component
  144686. */
  144687. get intensity(): NodeMaterialConnectionPoint;
  144688. /**
  144689. * Gets the direct light intensity input component
  144690. */
  144691. get directLightIntensity(): NodeMaterialConnectionPoint;
  144692. /**
  144693. * Gets the ambient occlusion object output component
  144694. */
  144695. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144696. /**
  144697. * Gets the main code of the block (fragment side)
  144698. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144699. * @returns the shader code
  144700. */
  144701. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144703. protected _buildBlock(state: NodeMaterialBuildState): this;
  144704. protected _dumpPropertiesCode(): string;
  144705. serialize(): any;
  144706. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144707. }
  144708. }
  144709. declare module BABYLON {
  144710. /**
  144711. * Block used to implement the reflection module of the PBR material
  144712. */
  144713. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144714. /** @hidden */
  144715. _defineLODReflectionAlpha: string;
  144716. /** @hidden */
  144717. _defineLinearSpecularReflection: string;
  144718. private _vEnvironmentIrradianceName;
  144719. /** @hidden */
  144720. _vReflectionMicrosurfaceInfosName: string;
  144721. /** @hidden */
  144722. _vReflectionInfosName: string;
  144723. /** @hidden */
  144724. _vReflectionFilteringInfoName: string;
  144725. private _scene;
  144726. /**
  144727. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144728. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144729. * It's less burden on the user side in the editor part.
  144730. */
  144731. /** @hidden */
  144732. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144733. /** @hidden */
  144734. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144735. /** @hidden */
  144736. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144737. /**
  144738. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144739. * diffuse part of the IBL.
  144740. */
  144741. useSphericalHarmonics: boolean;
  144742. /**
  144743. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144744. */
  144745. forceIrradianceInFragment: boolean;
  144746. /**
  144747. * Create a new ReflectionBlock
  144748. * @param name defines the block name
  144749. */
  144750. constructor(name: string);
  144751. /**
  144752. * Gets the current class name
  144753. * @returns the class name
  144754. */
  144755. getClassName(): string;
  144756. /**
  144757. * Gets the position input component
  144758. */
  144759. get position(): NodeMaterialConnectionPoint;
  144760. /**
  144761. * Gets the world position input component
  144762. */
  144763. get worldPosition(): NodeMaterialConnectionPoint;
  144764. /**
  144765. * Gets the world normal input component
  144766. */
  144767. get worldNormal(): NodeMaterialConnectionPoint;
  144768. /**
  144769. * Gets the world input component
  144770. */
  144771. get world(): NodeMaterialConnectionPoint;
  144772. /**
  144773. * Gets the camera (or eye) position component
  144774. */
  144775. get cameraPosition(): NodeMaterialConnectionPoint;
  144776. /**
  144777. * Gets the view input component
  144778. */
  144779. get view(): NodeMaterialConnectionPoint;
  144780. /**
  144781. * Gets the color input component
  144782. */
  144783. get color(): NodeMaterialConnectionPoint;
  144784. /**
  144785. * Gets the reflection object output component
  144786. */
  144787. get reflection(): NodeMaterialConnectionPoint;
  144788. /**
  144789. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144790. */
  144791. get hasTexture(): boolean;
  144792. /**
  144793. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144794. */
  144795. get reflectionColor(): string;
  144796. protected _getTexture(): Nullable<BaseTexture>;
  144797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144799. /**
  144800. * Gets the code to inject in the vertex shader
  144801. * @param state current state of the node material building
  144802. * @returns the shader code
  144803. */
  144804. handleVertexSide(state: NodeMaterialBuildState): string;
  144805. /**
  144806. * Gets the main code of the block (fragment side)
  144807. * @param state current state of the node material building
  144808. * @param normalVarName name of the existing variable corresponding to the normal
  144809. * @returns the shader code
  144810. */
  144811. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144812. protected _buildBlock(state: NodeMaterialBuildState): this;
  144813. protected _dumpPropertiesCode(): string;
  144814. serialize(): any;
  144815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144816. }
  144817. }
  144818. declare module BABYLON {
  144819. /**
  144820. * Block used to implement the sheen module of the PBR material
  144821. */
  144822. export class SheenBlock extends NodeMaterialBlock {
  144823. /**
  144824. * Create a new SheenBlock
  144825. * @param name defines the block name
  144826. */
  144827. constructor(name: string);
  144828. /**
  144829. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144830. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144831. * making it easier to setup and tweak the effect
  144832. */
  144833. albedoScaling: boolean;
  144834. /**
  144835. * Defines if the sheen is linked to the sheen color.
  144836. */
  144837. linkSheenWithAlbedo: boolean;
  144838. /**
  144839. * Initialize the block and prepare the context for build
  144840. * @param state defines the state that will be used for the build
  144841. */
  144842. initialize(state: NodeMaterialBuildState): void;
  144843. /**
  144844. * Gets the current class name
  144845. * @returns the class name
  144846. */
  144847. getClassName(): string;
  144848. /**
  144849. * Gets the intensity input component
  144850. */
  144851. get intensity(): NodeMaterialConnectionPoint;
  144852. /**
  144853. * Gets the color input component
  144854. */
  144855. get color(): NodeMaterialConnectionPoint;
  144856. /**
  144857. * Gets the roughness input component
  144858. */
  144859. get roughness(): NodeMaterialConnectionPoint;
  144860. /**
  144861. * Gets the sheen object output component
  144862. */
  144863. get sheen(): NodeMaterialConnectionPoint;
  144864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144865. /**
  144866. * Gets the main code of the block (fragment side)
  144867. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144868. * @returns the shader code
  144869. */
  144870. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144871. protected _buildBlock(state: NodeMaterialBuildState): this;
  144872. protected _dumpPropertiesCode(): string;
  144873. serialize(): any;
  144874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144875. }
  144876. }
  144877. declare module BABYLON {
  144878. /**
  144879. * Block used to implement the reflectivity module of the PBR material
  144880. */
  144881. export class ReflectivityBlock extends NodeMaterialBlock {
  144882. private _metallicReflectanceColor;
  144883. private _metallicF0Factor;
  144884. /** @hidden */
  144885. _vMetallicReflectanceFactorsName: string;
  144886. /**
  144887. * The property below is set by the main PBR block prior to calling methods of this class.
  144888. */
  144889. /** @hidden */
  144890. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144891. /**
  144892. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144893. */
  144894. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144895. /**
  144896. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144897. */
  144898. useMetallnessFromMetallicTextureBlue: boolean;
  144899. /**
  144900. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144901. */
  144902. useRoughnessFromMetallicTextureAlpha: boolean;
  144903. /**
  144904. * Specifies if the metallic texture contains the roughness information in its green channel.
  144905. */
  144906. useRoughnessFromMetallicTextureGreen: boolean;
  144907. /**
  144908. * Create a new ReflectivityBlock
  144909. * @param name defines the block name
  144910. */
  144911. constructor(name: string);
  144912. /**
  144913. * Initialize the block and prepare the context for build
  144914. * @param state defines the state that will be used for the build
  144915. */
  144916. initialize(state: NodeMaterialBuildState): void;
  144917. /**
  144918. * Gets the current class name
  144919. * @returns the class name
  144920. */
  144921. getClassName(): string;
  144922. /**
  144923. * Gets the metallic input component
  144924. */
  144925. get metallic(): NodeMaterialConnectionPoint;
  144926. /**
  144927. * Gets the roughness input component
  144928. */
  144929. get roughness(): NodeMaterialConnectionPoint;
  144930. /**
  144931. * Gets the texture input component
  144932. */
  144933. get texture(): NodeMaterialConnectionPoint;
  144934. /**
  144935. * Gets the reflectivity object output component
  144936. */
  144937. get reflectivity(): NodeMaterialConnectionPoint;
  144938. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144939. /**
  144940. * Gets the main code of the block (fragment side)
  144941. * @param state current state of the node material building
  144942. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144943. * @returns the shader code
  144944. */
  144945. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144947. protected _buildBlock(state: NodeMaterialBuildState): this;
  144948. protected _dumpPropertiesCode(): string;
  144949. serialize(): any;
  144950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144951. }
  144952. }
  144953. declare module BABYLON {
  144954. /**
  144955. * Block used to implement the anisotropy module of the PBR material
  144956. */
  144957. export class AnisotropyBlock extends NodeMaterialBlock {
  144958. /**
  144959. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144960. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144961. * It's less burden on the user side in the editor part.
  144962. */
  144963. /** @hidden */
  144964. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144965. /** @hidden */
  144966. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144967. /**
  144968. * Create a new AnisotropyBlock
  144969. * @param name defines the block name
  144970. */
  144971. constructor(name: string);
  144972. /**
  144973. * Initialize the block and prepare the context for build
  144974. * @param state defines the state that will be used for the build
  144975. */
  144976. initialize(state: NodeMaterialBuildState): void;
  144977. /**
  144978. * Gets the current class name
  144979. * @returns the class name
  144980. */
  144981. getClassName(): string;
  144982. /**
  144983. * Gets the intensity input component
  144984. */
  144985. get intensity(): NodeMaterialConnectionPoint;
  144986. /**
  144987. * Gets the direction input component
  144988. */
  144989. get direction(): NodeMaterialConnectionPoint;
  144990. /**
  144991. * Gets the texture input component
  144992. */
  144993. get texture(): NodeMaterialConnectionPoint;
  144994. /**
  144995. * Gets the uv input component
  144996. */
  144997. get uv(): NodeMaterialConnectionPoint;
  144998. /**
  144999. * Gets the worldTangent input component
  145000. */
  145001. get worldTangent(): NodeMaterialConnectionPoint;
  145002. /**
  145003. * Gets the anisotropy object output component
  145004. */
  145005. get anisotropy(): NodeMaterialConnectionPoint;
  145006. private _generateTBNSpace;
  145007. /**
  145008. * Gets the main code of the block (fragment side)
  145009. * @param state current state of the node material building
  145010. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145011. * @returns the shader code
  145012. */
  145013. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145015. protected _buildBlock(state: NodeMaterialBuildState): this;
  145016. }
  145017. }
  145018. declare module BABYLON {
  145019. /**
  145020. * Block used to implement the clear coat module of the PBR material
  145021. */
  145022. export class ClearCoatBlock extends NodeMaterialBlock {
  145023. private _scene;
  145024. /**
  145025. * Create a new ClearCoatBlock
  145026. * @param name defines the block name
  145027. */
  145028. constructor(name: string);
  145029. /**
  145030. * Initialize the block and prepare the context for build
  145031. * @param state defines the state that will be used for the build
  145032. */
  145033. initialize(state: NodeMaterialBuildState): void;
  145034. /**
  145035. * Gets the current class name
  145036. * @returns the class name
  145037. */
  145038. getClassName(): string;
  145039. /**
  145040. * Gets the intensity input component
  145041. */
  145042. get intensity(): NodeMaterialConnectionPoint;
  145043. /**
  145044. * Gets the roughness input component
  145045. */
  145046. get roughness(): NodeMaterialConnectionPoint;
  145047. /**
  145048. * Gets the ior input component
  145049. */
  145050. get ior(): NodeMaterialConnectionPoint;
  145051. /**
  145052. * Gets the texture input component
  145053. */
  145054. get texture(): NodeMaterialConnectionPoint;
  145055. /**
  145056. * Gets the bump texture input component
  145057. */
  145058. get bumpTexture(): NodeMaterialConnectionPoint;
  145059. /**
  145060. * Gets the uv input component
  145061. */
  145062. get uv(): NodeMaterialConnectionPoint;
  145063. /**
  145064. * Gets the tint color input component
  145065. */
  145066. get tintColor(): NodeMaterialConnectionPoint;
  145067. /**
  145068. * Gets the tint "at distance" input component
  145069. */
  145070. get tintAtDistance(): NodeMaterialConnectionPoint;
  145071. /**
  145072. * Gets the tint thickness input component
  145073. */
  145074. get tintThickness(): NodeMaterialConnectionPoint;
  145075. /**
  145076. * Gets the world tangent input component
  145077. */
  145078. get worldTangent(): NodeMaterialConnectionPoint;
  145079. /**
  145080. * Gets the clear coat object output component
  145081. */
  145082. get clearcoat(): NodeMaterialConnectionPoint;
  145083. autoConfigure(material: NodeMaterial): void;
  145084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145086. private _generateTBNSpace;
  145087. /**
  145088. * Gets the main code of the block (fragment side)
  145089. * @param state current state of the node material building
  145090. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145091. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145092. * @param worldPosVarName name of the variable holding the world position
  145093. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145094. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145095. * @param worldNormalVarName name of the variable holding the world normal
  145096. * @returns the shader code
  145097. */
  145098. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145099. protected _buildBlock(state: NodeMaterialBuildState): this;
  145100. }
  145101. }
  145102. declare module BABYLON {
  145103. /**
  145104. * Block used to implement the sub surface module of the PBR material
  145105. */
  145106. export class SubSurfaceBlock extends NodeMaterialBlock {
  145107. /**
  145108. * Create a new SubSurfaceBlock
  145109. * @param name defines the block name
  145110. */
  145111. constructor(name: string);
  145112. /**
  145113. * Stores the intensity of the different subsurface effects in the thickness texture.
  145114. * * the green channel is the translucency intensity.
  145115. * * the blue channel is the scattering intensity.
  145116. * * the alpha channel is the refraction intensity.
  145117. */
  145118. useMaskFromThicknessTexture: boolean;
  145119. /**
  145120. * Initialize the block and prepare the context for build
  145121. * @param state defines the state that will be used for the build
  145122. */
  145123. initialize(state: NodeMaterialBuildState): void;
  145124. /**
  145125. * Gets the current class name
  145126. * @returns the class name
  145127. */
  145128. getClassName(): string;
  145129. /**
  145130. * Gets the min thickness input component
  145131. */
  145132. get minThickness(): NodeMaterialConnectionPoint;
  145133. /**
  145134. * Gets the max thickness input component
  145135. */
  145136. get maxThickness(): NodeMaterialConnectionPoint;
  145137. /**
  145138. * Gets the thickness texture component
  145139. */
  145140. get thicknessTexture(): NodeMaterialConnectionPoint;
  145141. /**
  145142. * Gets the tint color input component
  145143. */
  145144. get tintColor(): NodeMaterialConnectionPoint;
  145145. /**
  145146. * Gets the translucency intensity input component
  145147. */
  145148. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145149. /**
  145150. * Gets the translucency diffusion distance input component
  145151. */
  145152. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145153. /**
  145154. * Gets the refraction object parameters
  145155. */
  145156. get refraction(): NodeMaterialConnectionPoint;
  145157. /**
  145158. * Gets the sub surface object output component
  145159. */
  145160. get subsurface(): NodeMaterialConnectionPoint;
  145161. autoConfigure(material: NodeMaterial): void;
  145162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145163. /**
  145164. * Gets the main code of the block (fragment side)
  145165. * @param state current state of the node material building
  145166. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145167. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145168. * @param worldPosVarName name of the variable holding the world position
  145169. * @returns the shader code
  145170. */
  145171. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145172. protected _buildBlock(state: NodeMaterialBuildState): this;
  145173. }
  145174. }
  145175. declare module BABYLON {
  145176. /**
  145177. * Block used to implement the PBR metallic/roughness model
  145178. */
  145179. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145180. /**
  145181. * Gets or sets the light associated with this block
  145182. */
  145183. light: Nullable<Light>;
  145184. private _lightId;
  145185. private _scene;
  145186. private _environmentBRDFTexture;
  145187. private _environmentBrdfSamplerName;
  145188. private _vNormalWName;
  145189. private _invertNormalName;
  145190. /**
  145191. * Create a new ReflectionBlock
  145192. * @param name defines the block name
  145193. */
  145194. constructor(name: string);
  145195. /**
  145196. * Intensity of the direct lights e.g. the four lights available in your scene.
  145197. * This impacts both the direct diffuse and specular highlights.
  145198. */
  145199. directIntensity: number;
  145200. /**
  145201. * Intensity of the environment e.g. how much the environment will light the object
  145202. * either through harmonics for rough material or through the refelction for shiny ones.
  145203. */
  145204. environmentIntensity: number;
  145205. /**
  145206. * This is a special control allowing the reduction of the specular highlights coming from the
  145207. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145208. */
  145209. specularIntensity: number;
  145210. /**
  145211. * Defines the falloff type used in this material.
  145212. * It by default is Physical.
  145213. */
  145214. lightFalloff: number;
  145215. /**
  145216. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145217. */
  145218. useAlphaFromAlbedoTexture: boolean;
  145219. /**
  145220. * Specifies that alpha test should be used
  145221. */
  145222. useAlphaTest: boolean;
  145223. /**
  145224. * Defines the alpha limits in alpha test mode.
  145225. */
  145226. alphaTestCutoff: number;
  145227. /**
  145228. * Specifies that alpha blending should be used
  145229. */
  145230. useAlphaBlending: boolean;
  145231. /**
  145232. * Defines if the alpha value should be determined via the rgb values.
  145233. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145234. */
  145235. opacityRGB: boolean;
  145236. /**
  145237. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145238. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145239. */
  145240. useRadianceOverAlpha: boolean;
  145241. /**
  145242. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145243. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145244. */
  145245. useSpecularOverAlpha: boolean;
  145246. /**
  145247. * Enables specular anti aliasing in the PBR shader.
  145248. * It will both interacts on the Geometry for analytical and IBL lighting.
  145249. * It also prefilter the roughness map based on the bump values.
  145250. */
  145251. enableSpecularAntiAliasing: boolean;
  145252. /**
  145253. * Enables realtime filtering on the texture.
  145254. */
  145255. realTimeFiltering: boolean;
  145256. /**
  145257. * Quality switch for realtime filtering
  145258. */
  145259. realTimeFilteringQuality: number;
  145260. /**
  145261. * Defines if the material uses energy conservation.
  145262. */
  145263. useEnergyConservation: boolean;
  145264. /**
  145265. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145266. * too much the area relying on ambient texture to define their ambient occlusion.
  145267. */
  145268. useRadianceOcclusion: boolean;
  145269. /**
  145270. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145271. * makes the reflect vector face the model (under horizon).
  145272. */
  145273. useHorizonOcclusion: boolean;
  145274. /**
  145275. * If set to true, no lighting calculations will be applied.
  145276. */
  145277. unlit: boolean;
  145278. /**
  145279. * Force normal to face away from face.
  145280. */
  145281. forceNormalForward: boolean;
  145282. /**
  145283. * Defines the material debug mode.
  145284. * It helps seeing only some components of the material while troubleshooting.
  145285. */
  145286. debugMode: number;
  145287. /**
  145288. * Specify from where on screen the debug mode should start.
  145289. * The value goes from -1 (full screen) to 1 (not visible)
  145290. * It helps with side by side comparison against the final render
  145291. * This defaults to 0
  145292. */
  145293. debugLimit: number;
  145294. /**
  145295. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145296. * You can use the factor to better multiply the final value.
  145297. */
  145298. debugFactor: number;
  145299. /**
  145300. * Initialize the block and prepare the context for build
  145301. * @param state defines the state that will be used for the build
  145302. */
  145303. initialize(state: NodeMaterialBuildState): void;
  145304. /**
  145305. * Gets the current class name
  145306. * @returns the class name
  145307. */
  145308. getClassName(): string;
  145309. /**
  145310. * Gets the world position input component
  145311. */
  145312. get worldPosition(): NodeMaterialConnectionPoint;
  145313. /**
  145314. * Gets the world normal input component
  145315. */
  145316. get worldNormal(): NodeMaterialConnectionPoint;
  145317. /**
  145318. * Gets the perturbed normal input component
  145319. */
  145320. get perturbedNormal(): NodeMaterialConnectionPoint;
  145321. /**
  145322. * Gets the camera position input component
  145323. */
  145324. get cameraPosition(): NodeMaterialConnectionPoint;
  145325. /**
  145326. * Gets the base color input component
  145327. */
  145328. get baseColor(): NodeMaterialConnectionPoint;
  145329. /**
  145330. * Gets the opacity texture input component
  145331. */
  145332. get opacityTexture(): NodeMaterialConnectionPoint;
  145333. /**
  145334. * Gets the ambient color input component
  145335. */
  145336. get ambientColor(): NodeMaterialConnectionPoint;
  145337. /**
  145338. * Gets the reflectivity object parameters
  145339. */
  145340. get reflectivity(): NodeMaterialConnectionPoint;
  145341. /**
  145342. * Gets the ambient occlusion object parameters
  145343. */
  145344. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145345. /**
  145346. * Gets the reflection object parameters
  145347. */
  145348. get reflection(): NodeMaterialConnectionPoint;
  145349. /**
  145350. * Gets the sheen object parameters
  145351. */
  145352. get sheen(): NodeMaterialConnectionPoint;
  145353. /**
  145354. * Gets the clear coat object parameters
  145355. */
  145356. get clearcoat(): NodeMaterialConnectionPoint;
  145357. /**
  145358. * Gets the sub surface object parameters
  145359. */
  145360. get subsurface(): NodeMaterialConnectionPoint;
  145361. /**
  145362. * Gets the anisotropy object parameters
  145363. */
  145364. get anisotropy(): NodeMaterialConnectionPoint;
  145365. /**
  145366. * Gets the ambient output component
  145367. */
  145368. get ambient(): NodeMaterialConnectionPoint;
  145369. /**
  145370. * Gets the diffuse output component
  145371. */
  145372. get diffuse(): NodeMaterialConnectionPoint;
  145373. /**
  145374. * Gets the specular output component
  145375. */
  145376. get specular(): NodeMaterialConnectionPoint;
  145377. /**
  145378. * Gets the sheen output component
  145379. */
  145380. get sheenDir(): NodeMaterialConnectionPoint;
  145381. /**
  145382. * Gets the clear coat output component
  145383. */
  145384. get clearcoatDir(): NodeMaterialConnectionPoint;
  145385. /**
  145386. * Gets the indirect diffuse output component
  145387. */
  145388. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145389. /**
  145390. * Gets the indirect specular output component
  145391. */
  145392. get specularIndirect(): NodeMaterialConnectionPoint;
  145393. /**
  145394. * Gets the indirect sheen output component
  145395. */
  145396. get sheenIndirect(): NodeMaterialConnectionPoint;
  145397. /**
  145398. * Gets the indirect clear coat output component
  145399. */
  145400. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145401. /**
  145402. * Gets the refraction output component
  145403. */
  145404. get refraction(): NodeMaterialConnectionPoint;
  145405. /**
  145406. * Gets the global lighting output component
  145407. */
  145408. get lighting(): NodeMaterialConnectionPoint;
  145409. /**
  145410. * Gets the shadow output component
  145411. */
  145412. get shadow(): NodeMaterialConnectionPoint;
  145413. /**
  145414. * Gets the alpha output component
  145415. */
  145416. get alpha(): NodeMaterialConnectionPoint;
  145417. autoConfigure(material: NodeMaterial): void;
  145418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145419. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145421. private _injectVertexCode;
  145422. /**
  145423. * Gets the code corresponding to the albedo/opacity module
  145424. * @returns the shader code
  145425. */
  145426. getAlbedoOpacityCode(): string;
  145427. protected _buildBlock(state: NodeMaterialBuildState): this;
  145428. protected _dumpPropertiesCode(): string;
  145429. serialize(): any;
  145430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145431. }
  145432. }
  145433. declare module BABYLON {
  145434. /**
  145435. * Block used to compute value of one parameter modulo another
  145436. */
  145437. export class ModBlock extends NodeMaterialBlock {
  145438. /**
  145439. * Creates a new ModBlock
  145440. * @param name defines the block name
  145441. */
  145442. constructor(name: string);
  145443. /**
  145444. * Gets the current class name
  145445. * @returns the class name
  145446. */
  145447. getClassName(): string;
  145448. /**
  145449. * Gets the left operand input component
  145450. */
  145451. get left(): NodeMaterialConnectionPoint;
  145452. /**
  145453. * Gets the right operand input component
  145454. */
  145455. get right(): NodeMaterialConnectionPoint;
  145456. /**
  145457. * Gets the output component
  145458. */
  145459. get output(): NodeMaterialConnectionPoint;
  145460. protected _buildBlock(state: NodeMaterialBuildState): this;
  145461. }
  145462. }
  145463. declare module BABYLON {
  145464. /**
  145465. * Configuration for Draco compression
  145466. */
  145467. export interface IDracoCompressionConfiguration {
  145468. /**
  145469. * Configuration for the decoder.
  145470. */
  145471. decoder: {
  145472. /**
  145473. * The url to the WebAssembly module.
  145474. */
  145475. wasmUrl?: string;
  145476. /**
  145477. * The url to the WebAssembly binary.
  145478. */
  145479. wasmBinaryUrl?: string;
  145480. /**
  145481. * The url to the fallback JavaScript module.
  145482. */
  145483. fallbackUrl?: string;
  145484. };
  145485. }
  145486. /**
  145487. * Draco compression (https://google.github.io/draco/)
  145488. *
  145489. * This class wraps the Draco module.
  145490. *
  145491. * **Encoder**
  145492. *
  145493. * The encoder is not currently implemented.
  145494. *
  145495. * **Decoder**
  145496. *
  145497. * 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.
  145498. *
  145499. * To update the configuration, use the following code:
  145500. * ```javascript
  145501. * DracoCompression.Configuration = {
  145502. * decoder: {
  145503. * wasmUrl: "<url to the WebAssembly library>",
  145504. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145505. * fallbackUrl: "<url to the fallback JavaScript library>",
  145506. * }
  145507. * };
  145508. * ```
  145509. *
  145510. * 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.
  145511. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145512. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145513. *
  145514. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145515. * ```javascript
  145516. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145517. * ```
  145518. *
  145519. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145520. */
  145521. export class DracoCompression implements IDisposable {
  145522. private _workerPoolPromise?;
  145523. private _decoderModulePromise?;
  145524. /**
  145525. * The configuration. Defaults to the following urls:
  145526. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145527. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145528. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145529. */
  145530. static Configuration: IDracoCompressionConfiguration;
  145531. /**
  145532. * Returns true if the decoder configuration is available.
  145533. */
  145534. static get DecoderAvailable(): boolean;
  145535. /**
  145536. * Default number of workers to create when creating the draco compression object.
  145537. */
  145538. static DefaultNumWorkers: number;
  145539. private static GetDefaultNumWorkers;
  145540. private static _Default;
  145541. /**
  145542. * Default instance for the draco compression object.
  145543. */
  145544. static get Default(): DracoCompression;
  145545. /**
  145546. * Constructor
  145547. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145548. */
  145549. constructor(numWorkers?: number);
  145550. /**
  145551. * Stop all async operations and release resources.
  145552. */
  145553. dispose(): void;
  145554. /**
  145555. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145556. * @returns a promise that resolves when ready
  145557. */
  145558. whenReadyAsync(): Promise<void>;
  145559. /**
  145560. * Decode Draco compressed mesh data to vertex data.
  145561. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145562. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145563. * @returns A promise that resolves with the decoded vertex data
  145564. */
  145565. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145566. [kind: string]: number;
  145567. }): Promise<VertexData>;
  145568. }
  145569. }
  145570. declare module BABYLON {
  145571. /**
  145572. * Class for building Constructive Solid Geometry
  145573. */
  145574. export class CSG {
  145575. private polygons;
  145576. /**
  145577. * The world matrix
  145578. */
  145579. matrix: Matrix;
  145580. /**
  145581. * Stores the position
  145582. */
  145583. position: Vector3;
  145584. /**
  145585. * Stores the rotation
  145586. */
  145587. rotation: Vector3;
  145588. /**
  145589. * Stores the rotation quaternion
  145590. */
  145591. rotationQuaternion: Nullable<Quaternion>;
  145592. /**
  145593. * Stores the scaling vector
  145594. */
  145595. scaling: Vector3;
  145596. /**
  145597. * Convert the Mesh to CSG
  145598. * @param mesh The Mesh to convert to CSG
  145599. * @returns A new CSG from the Mesh
  145600. */
  145601. static FromMesh(mesh: Mesh): CSG;
  145602. /**
  145603. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145604. * @param polygons Polygons used to construct a CSG solid
  145605. */
  145606. private static FromPolygons;
  145607. /**
  145608. * Clones, or makes a deep copy, of the CSG
  145609. * @returns A new CSG
  145610. */
  145611. clone(): CSG;
  145612. /**
  145613. * Unions this CSG with another CSG
  145614. * @param csg The CSG to union against this CSG
  145615. * @returns The unioned CSG
  145616. */
  145617. union(csg: CSG): CSG;
  145618. /**
  145619. * Unions this CSG with another CSG in place
  145620. * @param csg The CSG to union against this CSG
  145621. */
  145622. unionInPlace(csg: CSG): void;
  145623. /**
  145624. * Subtracts this CSG with another CSG
  145625. * @param csg The CSG to subtract against this CSG
  145626. * @returns A new CSG
  145627. */
  145628. subtract(csg: CSG): CSG;
  145629. /**
  145630. * Subtracts this CSG with another CSG in place
  145631. * @param csg The CSG to subtact against this CSG
  145632. */
  145633. subtractInPlace(csg: CSG): void;
  145634. /**
  145635. * Intersect this CSG with another CSG
  145636. * @param csg The CSG to intersect against this CSG
  145637. * @returns A new CSG
  145638. */
  145639. intersect(csg: CSG): CSG;
  145640. /**
  145641. * Intersects this CSG with another CSG in place
  145642. * @param csg The CSG to intersect against this CSG
  145643. */
  145644. intersectInPlace(csg: CSG): void;
  145645. /**
  145646. * Return a new CSG solid with solid and empty space switched. This solid is
  145647. * not modified.
  145648. * @returns A new CSG solid with solid and empty space switched
  145649. */
  145650. inverse(): CSG;
  145651. /**
  145652. * Inverses the CSG in place
  145653. */
  145654. inverseInPlace(): void;
  145655. /**
  145656. * This is used to keep meshes transformations so they can be restored
  145657. * when we build back a Babylon Mesh
  145658. * NB : All CSG operations are performed in world coordinates
  145659. * @param csg The CSG to copy the transform attributes from
  145660. * @returns This CSG
  145661. */
  145662. copyTransformAttributes(csg: CSG): CSG;
  145663. /**
  145664. * Build Raw mesh from CSG
  145665. * Coordinates here are in world space
  145666. * @param name The name of the mesh geometry
  145667. * @param scene The Scene
  145668. * @param keepSubMeshes Specifies if the submeshes should be kept
  145669. * @returns A new Mesh
  145670. */
  145671. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145672. /**
  145673. * Build Mesh from CSG taking material and transforms into account
  145674. * @param name The name of the Mesh
  145675. * @param material The material of the Mesh
  145676. * @param scene The Scene
  145677. * @param keepSubMeshes Specifies if submeshes should be kept
  145678. * @returns The new Mesh
  145679. */
  145680. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145681. }
  145682. }
  145683. declare module BABYLON {
  145684. /**
  145685. * Class used to create a trail following a mesh
  145686. */
  145687. export class TrailMesh extends Mesh {
  145688. private _generator;
  145689. private _autoStart;
  145690. private _running;
  145691. private _diameter;
  145692. private _length;
  145693. private _sectionPolygonPointsCount;
  145694. private _sectionVectors;
  145695. private _sectionNormalVectors;
  145696. private _beforeRenderObserver;
  145697. /**
  145698. * @constructor
  145699. * @param name The value used by scene.getMeshByName() to do a lookup.
  145700. * @param generator The mesh or transform node to generate a trail.
  145701. * @param scene The scene to add this mesh to.
  145702. * @param diameter Diameter of trailing mesh. Default is 1.
  145703. * @param length Length of trailing mesh. Default is 60.
  145704. * @param autoStart Automatically start trailing mesh. Default true.
  145705. */
  145706. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145707. /**
  145708. * "TrailMesh"
  145709. * @returns "TrailMesh"
  145710. */
  145711. getClassName(): string;
  145712. private _createMesh;
  145713. /**
  145714. * Start trailing mesh.
  145715. */
  145716. start(): void;
  145717. /**
  145718. * Stop trailing mesh.
  145719. */
  145720. stop(): void;
  145721. /**
  145722. * Update trailing mesh geometry.
  145723. */
  145724. update(): void;
  145725. /**
  145726. * Returns a new TrailMesh object.
  145727. * @param name is a string, the name given to the new mesh
  145728. * @param newGenerator use new generator object for cloned trail mesh
  145729. * @returns a new mesh
  145730. */
  145731. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145732. /**
  145733. * Serializes this trail mesh
  145734. * @param serializationObject object to write serialization to
  145735. */
  145736. serialize(serializationObject: any): void;
  145737. /**
  145738. * Parses a serialized trail mesh
  145739. * @param parsedMesh the serialized mesh
  145740. * @param scene the scene to create the trail mesh in
  145741. * @returns the created trail mesh
  145742. */
  145743. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145744. }
  145745. }
  145746. declare module BABYLON {
  145747. /**
  145748. * Class containing static functions to help procedurally build meshes
  145749. */
  145750. export class TiledBoxBuilder {
  145751. /**
  145752. * Creates a box mesh
  145753. * 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)
  145754. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145758. * @param name defines the name of the mesh
  145759. * @param options defines the options used to create the mesh
  145760. * @param scene defines the hosting scene
  145761. * @returns the box mesh
  145762. */
  145763. static CreateTiledBox(name: string, options: {
  145764. pattern?: number;
  145765. width?: number;
  145766. height?: number;
  145767. depth?: number;
  145768. tileSize?: number;
  145769. tileWidth?: number;
  145770. tileHeight?: number;
  145771. alignHorizontal?: number;
  145772. alignVertical?: number;
  145773. faceUV?: Vector4[];
  145774. faceColors?: Color4[];
  145775. sideOrientation?: number;
  145776. updatable?: boolean;
  145777. }, scene?: Nullable<Scene>): Mesh;
  145778. }
  145779. }
  145780. declare module BABYLON {
  145781. /**
  145782. * Class containing static functions to help procedurally build meshes
  145783. */
  145784. export class TorusKnotBuilder {
  145785. /**
  145786. * Creates a torus knot mesh
  145787. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145788. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145789. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145790. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145794. * @param name defines the name of the mesh
  145795. * @param options defines the options used to create the mesh
  145796. * @param scene defines the hosting scene
  145797. * @returns the torus knot mesh
  145798. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145799. */
  145800. static CreateTorusKnot(name: string, options: {
  145801. radius?: number;
  145802. tube?: number;
  145803. radialSegments?: number;
  145804. tubularSegments?: number;
  145805. p?: number;
  145806. q?: number;
  145807. updatable?: boolean;
  145808. sideOrientation?: number;
  145809. frontUVs?: Vector4;
  145810. backUVs?: Vector4;
  145811. }, scene: any): Mesh;
  145812. }
  145813. }
  145814. declare module BABYLON {
  145815. /**
  145816. * Polygon
  145817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145818. */
  145819. export class Polygon {
  145820. /**
  145821. * Creates a rectangle
  145822. * @param xmin bottom X coord
  145823. * @param ymin bottom Y coord
  145824. * @param xmax top X coord
  145825. * @param ymax top Y coord
  145826. * @returns points that make the resulting rectation
  145827. */
  145828. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145829. /**
  145830. * Creates a circle
  145831. * @param radius radius of circle
  145832. * @param cx scale in x
  145833. * @param cy scale in y
  145834. * @param numberOfSides number of sides that make up the circle
  145835. * @returns points that make the resulting circle
  145836. */
  145837. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145838. /**
  145839. * Creates a polygon from input string
  145840. * @param input Input polygon data
  145841. * @returns the parsed points
  145842. */
  145843. static Parse(input: string): Vector2[];
  145844. /**
  145845. * Starts building a polygon from x and y coordinates
  145846. * @param x x coordinate
  145847. * @param y y coordinate
  145848. * @returns the started path2
  145849. */
  145850. static StartingAt(x: number, y: number): Path2;
  145851. }
  145852. /**
  145853. * Builds a polygon
  145854. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145855. */
  145856. export class PolygonMeshBuilder {
  145857. private _points;
  145858. private _outlinepoints;
  145859. private _holes;
  145860. private _name;
  145861. private _scene;
  145862. private _epoints;
  145863. private _eholes;
  145864. private _addToepoint;
  145865. /**
  145866. * Babylon reference to the earcut plugin.
  145867. */
  145868. bjsEarcut: any;
  145869. /**
  145870. * Creates a PolygonMeshBuilder
  145871. * @param name name of the builder
  145872. * @param contours Path of the polygon
  145873. * @param scene scene to add to when creating the mesh
  145874. * @param earcutInjection can be used to inject your own earcut reference
  145875. */
  145876. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145877. /**
  145878. * Adds a whole within the polygon
  145879. * @param hole Array of points defining the hole
  145880. * @returns this
  145881. */
  145882. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145883. /**
  145884. * Creates the polygon
  145885. * @param updatable If the mesh should be updatable
  145886. * @param depth The depth of the mesh created
  145887. * @returns the created mesh
  145888. */
  145889. build(updatable?: boolean, depth?: number): Mesh;
  145890. /**
  145891. * Creates the polygon
  145892. * @param depth The depth of the mesh created
  145893. * @returns the created VertexData
  145894. */
  145895. buildVertexData(depth?: number): VertexData;
  145896. /**
  145897. * Adds a side to the polygon
  145898. * @param positions points that make the polygon
  145899. * @param normals normals of the polygon
  145900. * @param uvs uvs of the polygon
  145901. * @param indices indices of the polygon
  145902. * @param bounds bounds of the polygon
  145903. * @param points points of the polygon
  145904. * @param depth depth of the polygon
  145905. * @param flip flip of the polygon
  145906. */
  145907. private addSide;
  145908. }
  145909. }
  145910. declare module BABYLON {
  145911. /**
  145912. * Class containing static functions to help procedurally build meshes
  145913. */
  145914. export class PolygonBuilder {
  145915. /**
  145916. * Creates a polygon mesh
  145917. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145918. * * 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
  145919. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145922. * * Remember you can only change the shape positions, not their number when updating a polygon
  145923. * @param name defines the name of the mesh
  145924. * @param options defines the options used to create the mesh
  145925. * @param scene defines the hosting scene
  145926. * @param earcutInjection can be used to inject your own earcut reference
  145927. * @returns the polygon mesh
  145928. */
  145929. static CreatePolygon(name: string, options: {
  145930. shape: Vector3[];
  145931. holes?: Vector3[][];
  145932. depth?: number;
  145933. faceUV?: Vector4[];
  145934. faceColors?: Color4[];
  145935. updatable?: boolean;
  145936. sideOrientation?: number;
  145937. frontUVs?: Vector4;
  145938. backUVs?: Vector4;
  145939. wrap?: boolean;
  145940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145941. /**
  145942. * Creates an extruded polygon mesh, with depth in the Y direction.
  145943. * * 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)
  145944. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145945. * @param name defines the name of the mesh
  145946. * @param options defines the options used to create the mesh
  145947. * @param scene defines the hosting scene
  145948. * @param earcutInjection can be used to inject your own earcut reference
  145949. * @returns the polygon mesh
  145950. */
  145951. static ExtrudePolygon(name: string, options: {
  145952. shape: Vector3[];
  145953. holes?: Vector3[][];
  145954. depth?: number;
  145955. faceUV?: Vector4[];
  145956. faceColors?: Color4[];
  145957. updatable?: boolean;
  145958. sideOrientation?: number;
  145959. frontUVs?: Vector4;
  145960. backUVs?: Vector4;
  145961. wrap?: boolean;
  145962. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145963. }
  145964. }
  145965. declare module BABYLON {
  145966. /**
  145967. * Class containing static functions to help procedurally build meshes
  145968. */
  145969. export class LatheBuilder {
  145970. /**
  145971. * Creates lathe mesh.
  145972. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145973. * * 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
  145974. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145975. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145976. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145977. * * 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
  145978. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145979. * * 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
  145980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145984. * @param name defines the name of the mesh
  145985. * @param options defines the options used to create the mesh
  145986. * @param scene defines the hosting scene
  145987. * @returns the lathe mesh
  145988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145989. */
  145990. static CreateLathe(name: string, options: {
  145991. shape: Vector3[];
  145992. radius?: number;
  145993. tessellation?: number;
  145994. clip?: number;
  145995. arc?: number;
  145996. closed?: boolean;
  145997. updatable?: boolean;
  145998. sideOrientation?: number;
  145999. frontUVs?: Vector4;
  146000. backUVs?: Vector4;
  146001. cap?: number;
  146002. invertUV?: boolean;
  146003. }, scene?: Nullable<Scene>): Mesh;
  146004. }
  146005. }
  146006. declare module BABYLON {
  146007. /**
  146008. * Class containing static functions to help procedurally build meshes
  146009. */
  146010. export class TiledPlaneBuilder {
  146011. /**
  146012. * Creates a tiled plane mesh
  146013. * * The parameter `pattern` will, depending on value, do nothing or
  146014. * * * flip (reflect about central vertical) alternate tiles across and up
  146015. * * * flip every tile on alternate rows
  146016. * * * rotate (180 degs) alternate tiles across and up
  146017. * * * rotate every tile on alternate rows
  146018. * * * flip and rotate alternate tiles across and up
  146019. * * * flip and rotate every tile on alternate rows
  146020. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146021. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146024. * * 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)
  146025. * * 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)
  146026. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146027. * @param name defines the name of the mesh
  146028. * @param options defines the options used to create the mesh
  146029. * @param scene defines the hosting scene
  146030. * @returns the box mesh
  146031. */
  146032. static CreateTiledPlane(name: string, options: {
  146033. pattern?: number;
  146034. tileSize?: number;
  146035. tileWidth?: number;
  146036. tileHeight?: number;
  146037. size?: number;
  146038. width?: number;
  146039. height?: number;
  146040. alignHorizontal?: number;
  146041. alignVertical?: number;
  146042. sideOrientation?: number;
  146043. frontUVs?: Vector4;
  146044. backUVs?: Vector4;
  146045. updatable?: boolean;
  146046. }, scene?: Nullable<Scene>): Mesh;
  146047. }
  146048. }
  146049. declare module BABYLON {
  146050. /**
  146051. * Class containing static functions to help procedurally build meshes
  146052. */
  146053. export class TubeBuilder {
  146054. /**
  146055. * Creates a tube mesh.
  146056. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146057. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146058. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146059. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146060. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146061. * * 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)
  146062. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146063. * * 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
  146064. * * 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
  146065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146069. * @param name defines the name of the mesh
  146070. * @param options defines the options used to create the mesh
  146071. * @param scene defines the hosting scene
  146072. * @returns the tube mesh
  146073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146074. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146075. */
  146076. static CreateTube(name: string, options: {
  146077. path: Vector3[];
  146078. radius?: number;
  146079. tessellation?: number;
  146080. radiusFunction?: {
  146081. (i: number, distance: number): number;
  146082. };
  146083. cap?: number;
  146084. arc?: number;
  146085. updatable?: boolean;
  146086. sideOrientation?: number;
  146087. frontUVs?: Vector4;
  146088. backUVs?: Vector4;
  146089. instance?: Mesh;
  146090. invertUV?: boolean;
  146091. }, scene?: Nullable<Scene>): Mesh;
  146092. }
  146093. }
  146094. declare module BABYLON {
  146095. /**
  146096. * Class containing static functions to help procedurally build meshes
  146097. */
  146098. export class IcoSphereBuilder {
  146099. /**
  146100. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146101. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146102. * * 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`)
  146103. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146104. * * 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
  146105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146108. * @param name defines the name of the mesh
  146109. * @param options defines the options used to create the mesh
  146110. * @param scene defines the hosting scene
  146111. * @returns the icosahedron mesh
  146112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146113. */
  146114. static CreateIcoSphere(name: string, options: {
  146115. radius?: number;
  146116. radiusX?: number;
  146117. radiusY?: number;
  146118. radiusZ?: number;
  146119. flat?: boolean;
  146120. subdivisions?: number;
  146121. sideOrientation?: number;
  146122. frontUVs?: Vector4;
  146123. backUVs?: Vector4;
  146124. updatable?: boolean;
  146125. }, scene?: Nullable<Scene>): Mesh;
  146126. }
  146127. }
  146128. declare module BABYLON {
  146129. /**
  146130. * Class containing static functions to help procedurally build meshes
  146131. */
  146132. export class DecalBuilder {
  146133. /**
  146134. * Creates a decal mesh.
  146135. * 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
  146136. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146137. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146138. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146139. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146140. * @param name defines the name of the mesh
  146141. * @param sourceMesh defines the mesh where the decal must be applied
  146142. * @param options defines the options used to create the mesh
  146143. * @param scene defines the hosting scene
  146144. * @returns the decal mesh
  146145. * @see https://doc.babylonjs.com/how_to/decals
  146146. */
  146147. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146148. position?: Vector3;
  146149. normal?: Vector3;
  146150. size?: Vector3;
  146151. angle?: number;
  146152. }): Mesh;
  146153. }
  146154. }
  146155. declare module BABYLON {
  146156. /**
  146157. * Class containing static functions to help procedurally build meshes
  146158. */
  146159. export class MeshBuilder {
  146160. /**
  146161. * Creates a box mesh
  146162. * * The parameter `size` sets the size (float) of each box side (default 1)
  146163. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146164. * * 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)
  146165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146169. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146170. * @param name defines the name of the mesh
  146171. * @param options defines the options used to create the mesh
  146172. * @param scene defines the hosting scene
  146173. * @returns the box mesh
  146174. */
  146175. static CreateBox(name: string, options: {
  146176. size?: number;
  146177. width?: number;
  146178. height?: number;
  146179. depth?: number;
  146180. faceUV?: Vector4[];
  146181. faceColors?: Color4[];
  146182. sideOrientation?: number;
  146183. frontUVs?: Vector4;
  146184. backUVs?: Vector4;
  146185. wrap?: boolean;
  146186. topBaseAt?: number;
  146187. bottomBaseAt?: number;
  146188. updatable?: boolean;
  146189. }, scene?: Nullable<Scene>): Mesh;
  146190. /**
  146191. * Creates a tiled box mesh
  146192. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146194. * @param name defines the name of the mesh
  146195. * @param options defines the options used to create the mesh
  146196. * @param scene defines the hosting scene
  146197. * @returns the tiled box mesh
  146198. */
  146199. static CreateTiledBox(name: string, options: {
  146200. pattern?: number;
  146201. size?: number;
  146202. width?: number;
  146203. height?: number;
  146204. depth: number;
  146205. tileSize?: number;
  146206. tileWidth?: number;
  146207. tileHeight?: number;
  146208. faceUV?: Vector4[];
  146209. faceColors?: Color4[];
  146210. alignHorizontal?: number;
  146211. alignVertical?: number;
  146212. sideOrientation?: number;
  146213. updatable?: boolean;
  146214. }, scene?: Nullable<Scene>): Mesh;
  146215. /**
  146216. * Creates a sphere mesh
  146217. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146218. * * 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`)
  146219. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146220. * * 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
  146221. * * 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)
  146222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146225. * @param name defines the name of the mesh
  146226. * @param options defines the options used to create the mesh
  146227. * @param scene defines the hosting scene
  146228. * @returns the sphere mesh
  146229. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146230. */
  146231. static CreateSphere(name: string, options: {
  146232. segments?: number;
  146233. diameter?: number;
  146234. diameterX?: number;
  146235. diameterY?: number;
  146236. diameterZ?: number;
  146237. arc?: number;
  146238. slice?: number;
  146239. sideOrientation?: number;
  146240. frontUVs?: Vector4;
  146241. backUVs?: Vector4;
  146242. updatable?: boolean;
  146243. }, scene?: Nullable<Scene>): Mesh;
  146244. /**
  146245. * Creates a plane polygonal mesh. By default, this is a disc
  146246. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146247. * * 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
  146248. * * 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
  146249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146252. * @param name defines the name of the mesh
  146253. * @param options defines the options used to create the mesh
  146254. * @param scene defines the hosting scene
  146255. * @returns the plane polygonal mesh
  146256. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146257. */
  146258. static CreateDisc(name: string, options: {
  146259. radius?: number;
  146260. tessellation?: number;
  146261. arc?: number;
  146262. updatable?: boolean;
  146263. sideOrientation?: number;
  146264. frontUVs?: Vector4;
  146265. backUVs?: Vector4;
  146266. }, scene?: Nullable<Scene>): Mesh;
  146267. /**
  146268. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146269. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146270. * * 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`)
  146271. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146272. * * 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
  146273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146276. * @param name defines the name of the mesh
  146277. * @param options defines the options used to create the mesh
  146278. * @param scene defines the hosting scene
  146279. * @returns the icosahedron mesh
  146280. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146281. */
  146282. static CreateIcoSphere(name: string, options: {
  146283. radius?: number;
  146284. radiusX?: number;
  146285. radiusY?: number;
  146286. radiusZ?: number;
  146287. flat?: boolean;
  146288. subdivisions?: number;
  146289. sideOrientation?: number;
  146290. frontUVs?: Vector4;
  146291. backUVs?: Vector4;
  146292. updatable?: boolean;
  146293. }, scene?: Nullable<Scene>): Mesh;
  146294. /**
  146295. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146296. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146297. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146298. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146299. * * 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
  146300. * * 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
  146301. * * 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
  146302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146305. * * 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
  146306. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146307. * * 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
  146308. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146310. * @param name defines the name of the mesh
  146311. * @param options defines the options used to create the mesh
  146312. * @param scene defines the hosting scene
  146313. * @returns the ribbon mesh
  146314. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146316. */
  146317. static CreateRibbon(name: string, options: {
  146318. pathArray: Vector3[][];
  146319. closeArray?: boolean;
  146320. closePath?: boolean;
  146321. offset?: number;
  146322. updatable?: boolean;
  146323. sideOrientation?: number;
  146324. frontUVs?: Vector4;
  146325. backUVs?: Vector4;
  146326. instance?: Mesh;
  146327. invertUV?: boolean;
  146328. uvs?: Vector2[];
  146329. colors?: Color4[];
  146330. }, scene?: Nullable<Scene>): Mesh;
  146331. /**
  146332. * Creates a cylinder or a cone mesh
  146333. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146334. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146335. * * 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.
  146336. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146337. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146338. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146339. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146340. * * 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).
  146341. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146342. * * 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).
  146343. * * 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
  146344. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146345. * * 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
  146346. * * 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.
  146347. * * If `enclose` is false, a ring surface is one element.
  146348. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146349. * * 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
  146350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146353. * @param name defines the name of the mesh
  146354. * @param options defines the options used to create the mesh
  146355. * @param scene defines the hosting scene
  146356. * @returns the cylinder mesh
  146357. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146358. */
  146359. static CreateCylinder(name: string, options: {
  146360. height?: number;
  146361. diameterTop?: number;
  146362. diameterBottom?: number;
  146363. diameter?: number;
  146364. tessellation?: number;
  146365. subdivisions?: number;
  146366. arc?: number;
  146367. faceColors?: Color4[];
  146368. faceUV?: Vector4[];
  146369. updatable?: boolean;
  146370. hasRings?: boolean;
  146371. enclose?: boolean;
  146372. cap?: number;
  146373. sideOrientation?: number;
  146374. frontUVs?: Vector4;
  146375. backUVs?: Vector4;
  146376. }, scene?: Nullable<Scene>): Mesh;
  146377. /**
  146378. * Creates a torus mesh
  146379. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146380. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146381. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146385. * @param name defines the name of the mesh
  146386. * @param options defines the options used to create the mesh
  146387. * @param scene defines the hosting scene
  146388. * @returns the torus mesh
  146389. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146390. */
  146391. static CreateTorus(name: string, options: {
  146392. diameter?: number;
  146393. thickness?: number;
  146394. tessellation?: number;
  146395. updatable?: boolean;
  146396. sideOrientation?: number;
  146397. frontUVs?: Vector4;
  146398. backUVs?: Vector4;
  146399. }, scene?: Nullable<Scene>): Mesh;
  146400. /**
  146401. * Creates a torus knot mesh
  146402. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146403. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146404. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146405. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146409. * @param name defines the name of the mesh
  146410. * @param options defines the options used to create the mesh
  146411. * @param scene defines the hosting scene
  146412. * @returns the torus knot mesh
  146413. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146414. */
  146415. static CreateTorusKnot(name: string, options: {
  146416. radius?: number;
  146417. tube?: number;
  146418. radialSegments?: number;
  146419. tubularSegments?: number;
  146420. p?: number;
  146421. q?: number;
  146422. updatable?: boolean;
  146423. sideOrientation?: number;
  146424. frontUVs?: Vector4;
  146425. backUVs?: Vector4;
  146426. }, scene?: Nullable<Scene>): Mesh;
  146427. /**
  146428. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146429. * * 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
  146430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146431. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146432. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146433. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146434. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146435. * * 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
  146436. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146439. * @param name defines the name of the new line system
  146440. * @param options defines the options used to create the line system
  146441. * @param scene defines the hosting scene
  146442. * @returns a new line system mesh
  146443. */
  146444. static CreateLineSystem(name: string, options: {
  146445. lines: Vector3[][];
  146446. updatable?: boolean;
  146447. instance?: Nullable<LinesMesh>;
  146448. colors?: Nullable<Color4[][]>;
  146449. useVertexAlpha?: boolean;
  146450. }, scene: Nullable<Scene>): LinesMesh;
  146451. /**
  146452. * Creates a line mesh
  146453. * 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
  146454. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146455. * * The parameter `points` is an array successive Vector3
  146456. * * 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
  146457. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146458. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146459. * * When updating an instance, remember that only point positions can change, not the number of points
  146460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146462. * @param name defines the name of the new line system
  146463. * @param options defines the options used to create the line system
  146464. * @param scene defines the hosting scene
  146465. * @returns a new line mesh
  146466. */
  146467. static CreateLines(name: string, options: {
  146468. points: Vector3[];
  146469. updatable?: boolean;
  146470. instance?: Nullable<LinesMesh>;
  146471. colors?: Color4[];
  146472. useVertexAlpha?: boolean;
  146473. }, scene?: Nullable<Scene>): LinesMesh;
  146474. /**
  146475. * Creates a dashed line mesh
  146476. * * 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
  146477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146478. * * The parameter `points` is an array successive Vector3
  146479. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146480. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146481. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146482. * * 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
  146483. * * When updating an instance, remember that only point positions can change, not the number of points
  146484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146485. * @param name defines the name of the mesh
  146486. * @param options defines the options used to create the mesh
  146487. * @param scene defines the hosting scene
  146488. * @returns the dashed line mesh
  146489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146490. */
  146491. static CreateDashedLines(name: string, options: {
  146492. points: Vector3[];
  146493. dashSize?: number;
  146494. gapSize?: number;
  146495. dashNb?: number;
  146496. updatable?: boolean;
  146497. instance?: LinesMesh;
  146498. }, scene?: Nullable<Scene>): LinesMesh;
  146499. /**
  146500. * 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.
  146501. * * 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.
  146502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146503. * * 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.
  146504. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146505. * * 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
  146506. * * 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
  146507. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146512. * @param name defines the name of the mesh
  146513. * @param options defines the options used to create the mesh
  146514. * @param scene defines the hosting scene
  146515. * @returns the extruded shape mesh
  146516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146518. */
  146519. static ExtrudeShape(name: string, options: {
  146520. shape: Vector3[];
  146521. path: Vector3[];
  146522. scale?: number;
  146523. rotation?: number;
  146524. cap?: number;
  146525. updatable?: boolean;
  146526. sideOrientation?: number;
  146527. frontUVs?: Vector4;
  146528. backUVs?: Vector4;
  146529. instance?: Mesh;
  146530. invertUV?: boolean;
  146531. }, scene?: Nullable<Scene>): Mesh;
  146532. /**
  146533. * Creates an custom extruded shape mesh.
  146534. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146535. * * 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.
  146536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146537. * * 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
  146538. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146539. * * 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
  146540. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146541. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146542. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146543. * * 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
  146544. * * 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
  146545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146550. * @param name defines the name of the mesh
  146551. * @param options defines the options used to create the mesh
  146552. * @param scene defines the hosting scene
  146553. * @returns the custom extruded shape mesh
  146554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146557. */
  146558. static ExtrudeShapeCustom(name: string, options: {
  146559. shape: Vector3[];
  146560. path: Vector3[];
  146561. scaleFunction?: any;
  146562. rotationFunction?: any;
  146563. ribbonCloseArray?: boolean;
  146564. ribbonClosePath?: boolean;
  146565. cap?: number;
  146566. updatable?: boolean;
  146567. sideOrientation?: number;
  146568. frontUVs?: Vector4;
  146569. backUVs?: Vector4;
  146570. instance?: Mesh;
  146571. invertUV?: boolean;
  146572. }, scene?: Nullable<Scene>): Mesh;
  146573. /**
  146574. * Creates lathe mesh.
  146575. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146576. * * 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
  146577. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146578. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146579. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146580. * * 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
  146581. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146582. * * 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
  146583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146587. * @param name defines the name of the mesh
  146588. * @param options defines the options used to create the mesh
  146589. * @param scene defines the hosting scene
  146590. * @returns the lathe mesh
  146591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146592. */
  146593. static CreateLathe(name: string, options: {
  146594. shape: Vector3[];
  146595. radius?: number;
  146596. tessellation?: number;
  146597. clip?: number;
  146598. arc?: number;
  146599. closed?: boolean;
  146600. updatable?: boolean;
  146601. sideOrientation?: number;
  146602. frontUVs?: Vector4;
  146603. backUVs?: Vector4;
  146604. cap?: number;
  146605. invertUV?: boolean;
  146606. }, scene?: Nullable<Scene>): Mesh;
  146607. /**
  146608. * Creates a tiled plane mesh
  146609. * * You can set a limited pattern arrangement with the tiles
  146610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146613. * @param name defines the name of the mesh
  146614. * @param options defines the options used to create the mesh
  146615. * @param scene defines the hosting scene
  146616. * @returns the plane mesh
  146617. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146618. */
  146619. static CreateTiledPlane(name: string, options: {
  146620. pattern?: number;
  146621. tileSize?: number;
  146622. tileWidth?: number;
  146623. tileHeight?: number;
  146624. size?: number;
  146625. width?: number;
  146626. height?: number;
  146627. alignHorizontal?: number;
  146628. alignVertical?: number;
  146629. sideOrientation?: number;
  146630. frontUVs?: Vector4;
  146631. backUVs?: Vector4;
  146632. updatable?: boolean;
  146633. }, scene?: Nullable<Scene>): Mesh;
  146634. /**
  146635. * Creates a plane mesh
  146636. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146637. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146638. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146642. * @param name defines the name of the mesh
  146643. * @param options defines the options used to create the mesh
  146644. * @param scene defines the hosting scene
  146645. * @returns the plane mesh
  146646. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146647. */
  146648. static CreatePlane(name: string, options: {
  146649. size?: number;
  146650. width?: number;
  146651. height?: number;
  146652. sideOrientation?: number;
  146653. frontUVs?: Vector4;
  146654. backUVs?: Vector4;
  146655. updatable?: boolean;
  146656. sourcePlane?: Plane;
  146657. }, scene?: Nullable<Scene>): Mesh;
  146658. /**
  146659. * Creates a ground mesh
  146660. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146661. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146663. * @param name defines the name of the mesh
  146664. * @param options defines the options used to create the mesh
  146665. * @param scene defines the hosting scene
  146666. * @returns the ground mesh
  146667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146668. */
  146669. static CreateGround(name: string, options: {
  146670. width?: number;
  146671. height?: number;
  146672. subdivisions?: number;
  146673. subdivisionsX?: number;
  146674. subdivisionsY?: number;
  146675. updatable?: boolean;
  146676. }, scene?: Nullable<Scene>): Mesh;
  146677. /**
  146678. * Creates a tiled ground mesh
  146679. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146680. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146681. * * 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
  146682. * * 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
  146683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146684. * @param name defines the name of the mesh
  146685. * @param options defines the options used to create the mesh
  146686. * @param scene defines the hosting scene
  146687. * @returns the tiled ground mesh
  146688. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146689. */
  146690. static CreateTiledGround(name: string, options: {
  146691. xmin: number;
  146692. zmin: number;
  146693. xmax: number;
  146694. zmax: number;
  146695. subdivisions?: {
  146696. w: number;
  146697. h: number;
  146698. };
  146699. precision?: {
  146700. w: number;
  146701. h: number;
  146702. };
  146703. updatable?: boolean;
  146704. }, scene?: Nullable<Scene>): Mesh;
  146705. /**
  146706. * Creates a ground mesh from a height map
  146707. * * The parameter `url` sets the URL of the height map image resource.
  146708. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146709. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146710. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146711. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146712. * * 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.
  146713. * * 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).
  146714. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146716. * @param name defines the name of the mesh
  146717. * @param url defines the url to the height map
  146718. * @param options defines the options used to create the mesh
  146719. * @param scene defines the hosting scene
  146720. * @returns the ground mesh
  146721. * @see https://doc.babylonjs.com/babylon101/height_map
  146722. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146723. */
  146724. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146725. width?: number;
  146726. height?: number;
  146727. subdivisions?: number;
  146728. minHeight?: number;
  146729. maxHeight?: number;
  146730. colorFilter?: Color3;
  146731. alphaFilter?: number;
  146732. updatable?: boolean;
  146733. onReady?: (mesh: GroundMesh) => void;
  146734. }, scene?: Nullable<Scene>): GroundMesh;
  146735. /**
  146736. * Creates a polygon mesh
  146737. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146738. * * 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
  146739. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146742. * * Remember you can only change the shape positions, not their number when updating a polygon
  146743. * @param name defines the name of the mesh
  146744. * @param options defines the options used to create the mesh
  146745. * @param scene defines the hosting scene
  146746. * @param earcutInjection can be used to inject your own earcut reference
  146747. * @returns the polygon mesh
  146748. */
  146749. static CreatePolygon(name: string, options: {
  146750. shape: Vector3[];
  146751. holes?: Vector3[][];
  146752. depth?: number;
  146753. faceUV?: Vector4[];
  146754. faceColors?: Color4[];
  146755. updatable?: boolean;
  146756. sideOrientation?: number;
  146757. frontUVs?: Vector4;
  146758. backUVs?: Vector4;
  146759. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146760. /**
  146761. * Creates an extruded polygon mesh, with depth in the Y direction.
  146762. * * 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)
  146763. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146764. * @param name defines the name of the mesh
  146765. * @param options defines the options used to create the mesh
  146766. * @param scene defines the hosting scene
  146767. * @param earcutInjection can be used to inject your own earcut reference
  146768. * @returns the polygon mesh
  146769. */
  146770. static ExtrudePolygon(name: string, options: {
  146771. shape: Vector3[];
  146772. holes?: Vector3[][];
  146773. depth?: number;
  146774. faceUV?: Vector4[];
  146775. faceColors?: Color4[];
  146776. updatable?: boolean;
  146777. sideOrientation?: number;
  146778. frontUVs?: Vector4;
  146779. backUVs?: Vector4;
  146780. wrap?: boolean;
  146781. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146782. /**
  146783. * Creates a tube mesh.
  146784. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146785. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146786. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146787. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146788. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146789. * * 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)
  146790. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146791. * * 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
  146792. * * 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
  146793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146795. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146797. * @param name defines the name of the mesh
  146798. * @param options defines the options used to create the mesh
  146799. * @param scene defines the hosting scene
  146800. * @returns the tube mesh
  146801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146802. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146803. */
  146804. static CreateTube(name: string, options: {
  146805. path: Vector3[];
  146806. radius?: number;
  146807. tessellation?: number;
  146808. radiusFunction?: {
  146809. (i: number, distance: number): number;
  146810. };
  146811. cap?: number;
  146812. arc?: number;
  146813. updatable?: boolean;
  146814. sideOrientation?: number;
  146815. frontUVs?: Vector4;
  146816. backUVs?: Vector4;
  146817. instance?: Mesh;
  146818. invertUV?: boolean;
  146819. }, scene?: Nullable<Scene>): Mesh;
  146820. /**
  146821. * Creates a polyhedron mesh
  146822. * * 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
  146823. * * The parameter `size` (positive float, default 1) sets the polygon size
  146824. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146825. * * 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`
  146826. * * 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
  146827. * * 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)`)
  146828. * * 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
  146829. * * 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
  146830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146833. * @param name defines the name of the mesh
  146834. * @param options defines the options used to create the mesh
  146835. * @param scene defines the hosting scene
  146836. * @returns the polyhedron mesh
  146837. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146838. */
  146839. static CreatePolyhedron(name: string, options: {
  146840. type?: number;
  146841. size?: number;
  146842. sizeX?: number;
  146843. sizeY?: number;
  146844. sizeZ?: number;
  146845. custom?: any;
  146846. faceUV?: Vector4[];
  146847. faceColors?: Color4[];
  146848. flat?: boolean;
  146849. updatable?: boolean;
  146850. sideOrientation?: number;
  146851. frontUVs?: Vector4;
  146852. backUVs?: Vector4;
  146853. }, scene?: Nullable<Scene>): Mesh;
  146854. /**
  146855. * Creates a decal mesh.
  146856. * 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
  146857. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146858. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146859. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146860. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146861. * @param name defines the name of the mesh
  146862. * @param sourceMesh defines the mesh where the decal must be applied
  146863. * @param options defines the options used to create the mesh
  146864. * @param scene defines the hosting scene
  146865. * @returns the decal mesh
  146866. * @see https://doc.babylonjs.com/how_to/decals
  146867. */
  146868. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146869. position?: Vector3;
  146870. normal?: Vector3;
  146871. size?: Vector3;
  146872. angle?: number;
  146873. }): Mesh;
  146874. /**
  146875. * Creates a Capsule Mesh
  146876. * @param name defines the name of the mesh.
  146877. * @param options the constructors options used to shape the mesh.
  146878. * @param scene defines the scene the mesh is scoped to.
  146879. * @returns the capsule mesh
  146880. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146881. */
  146882. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146883. }
  146884. }
  146885. declare module BABYLON {
  146886. /**
  146887. * A simplifier interface for future simplification implementations
  146888. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146889. */
  146890. export interface ISimplifier {
  146891. /**
  146892. * Simplification of a given mesh according to the given settings.
  146893. * Since this requires computation, it is assumed that the function runs async.
  146894. * @param settings The settings of the simplification, including quality and distance
  146895. * @param successCallback A callback that will be called after the mesh was simplified.
  146896. * @param errorCallback in case of an error, this callback will be called. optional.
  146897. */
  146898. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146899. }
  146900. /**
  146901. * Expected simplification settings.
  146902. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146903. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146904. */
  146905. export interface ISimplificationSettings {
  146906. /**
  146907. * Gets or sets the expected quality
  146908. */
  146909. quality: number;
  146910. /**
  146911. * Gets or sets the distance when this optimized version should be used
  146912. */
  146913. distance: number;
  146914. /**
  146915. * Gets an already optimized mesh
  146916. */
  146917. optimizeMesh?: boolean;
  146918. }
  146919. /**
  146920. * Class used to specify simplification options
  146921. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146922. */
  146923. export class SimplificationSettings implements ISimplificationSettings {
  146924. /** expected quality */
  146925. quality: number;
  146926. /** distance when this optimized version should be used */
  146927. distance: number;
  146928. /** already optimized mesh */
  146929. optimizeMesh?: boolean | undefined;
  146930. /**
  146931. * Creates a SimplificationSettings
  146932. * @param quality expected quality
  146933. * @param distance distance when this optimized version should be used
  146934. * @param optimizeMesh already optimized mesh
  146935. */
  146936. constructor(
  146937. /** expected quality */
  146938. quality: number,
  146939. /** distance when this optimized version should be used */
  146940. distance: number,
  146941. /** already optimized mesh */
  146942. optimizeMesh?: boolean | undefined);
  146943. }
  146944. /**
  146945. * Interface used to define a simplification task
  146946. */
  146947. export interface ISimplificationTask {
  146948. /**
  146949. * Array of settings
  146950. */
  146951. settings: Array<ISimplificationSettings>;
  146952. /**
  146953. * Simplification type
  146954. */
  146955. simplificationType: SimplificationType;
  146956. /**
  146957. * Mesh to simplify
  146958. */
  146959. mesh: Mesh;
  146960. /**
  146961. * Callback called on success
  146962. */
  146963. successCallback?: () => void;
  146964. /**
  146965. * Defines if parallel processing can be used
  146966. */
  146967. parallelProcessing: boolean;
  146968. }
  146969. /**
  146970. * Queue used to order the simplification tasks
  146971. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146972. */
  146973. export class SimplificationQueue {
  146974. private _simplificationArray;
  146975. /**
  146976. * Gets a boolean indicating that the process is still running
  146977. */
  146978. running: boolean;
  146979. /**
  146980. * Creates a new queue
  146981. */
  146982. constructor();
  146983. /**
  146984. * Adds a new simplification task
  146985. * @param task defines a task to add
  146986. */
  146987. addTask(task: ISimplificationTask): void;
  146988. /**
  146989. * Execute next task
  146990. */
  146991. executeNext(): void;
  146992. /**
  146993. * Execute a simplification task
  146994. * @param task defines the task to run
  146995. */
  146996. runSimplification(task: ISimplificationTask): void;
  146997. private getSimplifier;
  146998. }
  146999. /**
  147000. * The implemented types of simplification
  147001. * At the moment only Quadratic Error Decimation is implemented
  147002. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147003. */
  147004. export enum SimplificationType {
  147005. /** Quadratic error decimation */
  147006. QUADRATIC = 0
  147007. }
  147008. /**
  147009. * An implementation of the Quadratic Error simplification algorithm.
  147010. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147011. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147012. * @author RaananW
  147013. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147014. */
  147015. export class QuadraticErrorSimplification implements ISimplifier {
  147016. private _mesh;
  147017. private triangles;
  147018. private vertices;
  147019. private references;
  147020. private _reconstructedMesh;
  147021. /** Gets or sets the number pf sync interations */
  147022. syncIterations: number;
  147023. /** Gets or sets the aggressiveness of the simplifier */
  147024. aggressiveness: number;
  147025. /** Gets or sets the number of allowed iterations for decimation */
  147026. decimationIterations: number;
  147027. /** Gets or sets the espilon to use for bounding box computation */
  147028. boundingBoxEpsilon: number;
  147029. /**
  147030. * Creates a new QuadraticErrorSimplification
  147031. * @param _mesh defines the target mesh
  147032. */
  147033. constructor(_mesh: Mesh);
  147034. /**
  147035. * Simplification of a given mesh according to the given settings.
  147036. * Since this requires computation, it is assumed that the function runs async.
  147037. * @param settings The settings of the simplification, including quality and distance
  147038. * @param successCallback A callback that will be called after the mesh was simplified.
  147039. */
  147040. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147041. private runDecimation;
  147042. private initWithMesh;
  147043. private init;
  147044. private reconstructMesh;
  147045. private initDecimatedMesh;
  147046. private isFlipped;
  147047. private updateTriangles;
  147048. private identifyBorder;
  147049. private updateMesh;
  147050. private vertexError;
  147051. private calculateError;
  147052. }
  147053. }
  147054. declare module BABYLON {
  147055. interface Scene {
  147056. /** @hidden (Backing field) */
  147057. _simplificationQueue: SimplificationQueue;
  147058. /**
  147059. * Gets or sets the simplification queue attached to the scene
  147060. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147061. */
  147062. simplificationQueue: SimplificationQueue;
  147063. }
  147064. interface Mesh {
  147065. /**
  147066. * Simplify the mesh according to the given array of settings.
  147067. * Function will return immediately and will simplify async
  147068. * @param settings a collection of simplification settings
  147069. * @param parallelProcessing should all levels calculate parallel or one after the other
  147070. * @param simplificationType the type of simplification to run
  147071. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147072. * @returns the current mesh
  147073. */
  147074. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147075. }
  147076. /**
  147077. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147078. * created in a scene
  147079. */
  147080. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147081. /**
  147082. * The component name helpfull to identify the component in the list of scene components.
  147083. */
  147084. readonly name: string;
  147085. /**
  147086. * The scene the component belongs to.
  147087. */
  147088. scene: Scene;
  147089. /**
  147090. * Creates a new instance of the component for the given scene
  147091. * @param scene Defines the scene to register the component in
  147092. */
  147093. constructor(scene: Scene);
  147094. /**
  147095. * Registers the component in a given scene
  147096. */
  147097. register(): void;
  147098. /**
  147099. * Rebuilds the elements related to this component in case of
  147100. * context lost for instance.
  147101. */
  147102. rebuild(): void;
  147103. /**
  147104. * Disposes the component and the associated ressources
  147105. */
  147106. dispose(): void;
  147107. private _beforeCameraUpdate;
  147108. }
  147109. }
  147110. declare module BABYLON {
  147111. interface Mesh {
  147112. /**
  147113. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147114. */
  147115. thinInstanceEnablePicking: boolean;
  147116. /**
  147117. * Creates a new thin instance
  147118. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147119. * @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
  147120. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147121. */
  147122. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147123. /**
  147124. * Adds the transformation (matrix) of the current mesh as a thin instance
  147125. * @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
  147126. * @returns the thin instance index number
  147127. */
  147128. thinInstanceAddSelf(refresh: boolean): number;
  147129. /**
  147130. * Registers a custom attribute to be used with thin instances
  147131. * @param kind name of the attribute
  147132. * @param stride size in floats of the attribute
  147133. */
  147134. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147135. /**
  147136. * Sets the matrix of a thin instance
  147137. * @param index index of the thin instance
  147138. * @param matrix matrix to set
  147139. * @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
  147140. */
  147141. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147142. /**
  147143. * Sets the value of a custom attribute for a thin instance
  147144. * @param kind name of the attribute
  147145. * @param index index of the thin instance
  147146. * @param value value to set
  147147. * @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
  147148. */
  147149. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147150. /**
  147151. * 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.
  147152. */
  147153. thinInstanceCount: number;
  147154. /**
  147155. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147156. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147157. * @param buffer buffer to set
  147158. * @param stride size in floats of each value of the buffer
  147159. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147160. */
  147161. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147162. /**
  147163. * Gets the list of world matrices
  147164. * @return an array containing all the world matrices from the thin instances
  147165. */
  147166. thinInstanceGetWorldMatrices(): Matrix[];
  147167. /**
  147168. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147169. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147170. */
  147171. thinInstanceBufferUpdated(kind: string): void;
  147172. /**
  147173. * Applies a partial update to a buffer directly on the GPU
  147174. * 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
  147175. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147176. * @param data the data to set in the GPU buffer
  147177. * @param offset the offset in the GPU buffer where to update the data
  147178. */
  147179. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147180. /**
  147181. * Refreshes the bounding info, taking into account all the thin instances defined
  147182. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147183. */
  147184. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147185. /** @hidden */
  147186. _thinInstanceInitializeUserStorage(): void;
  147187. /** @hidden */
  147188. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147189. /** @hidden */
  147190. _userThinInstanceBuffersStorage: {
  147191. data: {
  147192. [key: string]: Float32Array;
  147193. };
  147194. sizes: {
  147195. [key: string]: number;
  147196. };
  147197. vertexBuffers: {
  147198. [key: string]: Nullable<VertexBuffer>;
  147199. };
  147200. strides: {
  147201. [key: string]: number;
  147202. };
  147203. };
  147204. }
  147205. }
  147206. declare module BABYLON {
  147207. /**
  147208. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147209. */
  147210. export interface INavigationEnginePlugin {
  147211. /**
  147212. * plugin name
  147213. */
  147214. name: string;
  147215. /**
  147216. * Creates a navigation mesh
  147217. * @param meshes array of all the geometry used to compute the navigatio mesh
  147218. * @param parameters bunch of parameters used to filter geometry
  147219. */
  147220. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147221. /**
  147222. * Create a navigation mesh debug mesh
  147223. * @param scene is where the mesh will be added
  147224. * @returns debug display mesh
  147225. */
  147226. createDebugNavMesh(scene: Scene): Mesh;
  147227. /**
  147228. * Get a navigation mesh constrained position, closest to the parameter position
  147229. * @param position world position
  147230. * @returns the closest point to position constrained by the navigation mesh
  147231. */
  147232. getClosestPoint(position: Vector3): Vector3;
  147233. /**
  147234. * Get a navigation mesh constrained position, closest to the parameter position
  147235. * @param position world position
  147236. * @param result output the closest point to position constrained by the navigation mesh
  147237. */
  147238. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147239. /**
  147240. * Get a navigation mesh constrained position, within a particular radius
  147241. * @param position world position
  147242. * @param maxRadius the maximum distance to the constrained world position
  147243. * @returns the closest point to position constrained by the navigation mesh
  147244. */
  147245. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147246. /**
  147247. * Get a navigation mesh constrained position, within a particular radius
  147248. * @param position world position
  147249. * @param maxRadius the maximum distance to the constrained world position
  147250. * @param result output the closest point to position constrained by the navigation mesh
  147251. */
  147252. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147253. /**
  147254. * Compute the final position from a segment made of destination-position
  147255. * @param position world position
  147256. * @param destination world position
  147257. * @returns the resulting point along the navmesh
  147258. */
  147259. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147260. /**
  147261. * Compute the final position from a segment made of destination-position
  147262. * @param position world position
  147263. * @param destination world position
  147264. * @param result output the resulting point along the navmesh
  147265. */
  147266. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147267. /**
  147268. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147269. * @param start world position
  147270. * @param end world position
  147271. * @returns array containing world position composing the path
  147272. */
  147273. computePath(start: Vector3, end: Vector3): Vector3[];
  147274. /**
  147275. * If this plugin is supported
  147276. * @returns true if plugin is supported
  147277. */
  147278. isSupported(): boolean;
  147279. /**
  147280. * Create a new Crowd so you can add agents
  147281. * @param maxAgents the maximum agent count in the crowd
  147282. * @param maxAgentRadius the maximum radius an agent can have
  147283. * @param scene to attach the crowd to
  147284. * @returns the crowd you can add agents to
  147285. */
  147286. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147287. /**
  147288. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147289. * The queries will try to find a solution within those bounds
  147290. * default is (1,1,1)
  147291. * @param extent x,y,z value that define the extent around the queries point of reference
  147292. */
  147293. setDefaultQueryExtent(extent: Vector3): void;
  147294. /**
  147295. * Get the Bounding box extent specified by setDefaultQueryExtent
  147296. * @returns the box extent values
  147297. */
  147298. getDefaultQueryExtent(): Vector3;
  147299. /**
  147300. * build the navmesh from a previously saved state using getNavmeshData
  147301. * @param data the Uint8Array returned by getNavmeshData
  147302. */
  147303. buildFromNavmeshData(data: Uint8Array): void;
  147304. /**
  147305. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147306. * @returns data the Uint8Array that can be saved and reused
  147307. */
  147308. getNavmeshData(): Uint8Array;
  147309. /**
  147310. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147311. * @param result output the box extent values
  147312. */
  147313. getDefaultQueryExtentToRef(result: Vector3): void;
  147314. /**
  147315. * Release all resources
  147316. */
  147317. dispose(): void;
  147318. }
  147319. /**
  147320. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147321. */
  147322. export interface ICrowd {
  147323. /**
  147324. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147325. * You can attach anything to that node. The node position is updated in the scene update tick.
  147326. * @param pos world position that will be constrained by the navigation mesh
  147327. * @param parameters agent parameters
  147328. * @param transform hooked to the agent that will be update by the scene
  147329. * @returns agent index
  147330. */
  147331. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147332. /**
  147333. * Returns the agent position in world space
  147334. * @param index agent index returned by addAgent
  147335. * @returns world space position
  147336. */
  147337. getAgentPosition(index: number): Vector3;
  147338. /**
  147339. * Gets the agent position result in world space
  147340. * @param index agent index returned by addAgent
  147341. * @param result output world space position
  147342. */
  147343. getAgentPositionToRef(index: number, result: Vector3): void;
  147344. /**
  147345. * Gets the agent velocity in world space
  147346. * @param index agent index returned by addAgent
  147347. * @returns world space velocity
  147348. */
  147349. getAgentVelocity(index: number): Vector3;
  147350. /**
  147351. * Gets the agent velocity result in world space
  147352. * @param index agent index returned by addAgent
  147353. * @param result output world space velocity
  147354. */
  147355. getAgentVelocityToRef(index: number, result: Vector3): void;
  147356. /**
  147357. * remove a particular agent previously created
  147358. * @param index agent index returned by addAgent
  147359. */
  147360. removeAgent(index: number): void;
  147361. /**
  147362. * get the list of all agents attached to this crowd
  147363. * @returns list of agent indices
  147364. */
  147365. getAgents(): number[];
  147366. /**
  147367. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147368. * @param deltaTime in seconds
  147369. */
  147370. update(deltaTime: number): void;
  147371. /**
  147372. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147373. * @param index agent index returned by addAgent
  147374. * @param destination targeted world position
  147375. */
  147376. agentGoto(index: number, destination: Vector3): void;
  147377. /**
  147378. * Teleport the agent to a new position
  147379. * @param index agent index returned by addAgent
  147380. * @param destination targeted world position
  147381. */
  147382. agentTeleport(index: number, destination: Vector3): void;
  147383. /**
  147384. * Update agent parameters
  147385. * @param index agent index returned by addAgent
  147386. * @param parameters agent parameters
  147387. */
  147388. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147389. /**
  147390. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147391. * The queries will try to find a solution within those bounds
  147392. * default is (1,1,1)
  147393. * @param extent x,y,z value that define the extent around the queries point of reference
  147394. */
  147395. setDefaultQueryExtent(extent: Vector3): void;
  147396. /**
  147397. * Get the Bounding box extent specified by setDefaultQueryExtent
  147398. * @returns the box extent values
  147399. */
  147400. getDefaultQueryExtent(): Vector3;
  147401. /**
  147402. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147403. * @param result output the box extent values
  147404. */
  147405. getDefaultQueryExtentToRef(result: Vector3): void;
  147406. /**
  147407. * Release all resources
  147408. */
  147409. dispose(): void;
  147410. }
  147411. /**
  147412. * Configures an agent
  147413. */
  147414. export interface IAgentParameters {
  147415. /**
  147416. * Agent radius. [Limit: >= 0]
  147417. */
  147418. radius: number;
  147419. /**
  147420. * Agent height. [Limit: > 0]
  147421. */
  147422. height: number;
  147423. /**
  147424. * Maximum allowed acceleration. [Limit: >= 0]
  147425. */
  147426. maxAcceleration: number;
  147427. /**
  147428. * Maximum allowed speed. [Limit: >= 0]
  147429. */
  147430. maxSpeed: number;
  147431. /**
  147432. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147433. */
  147434. collisionQueryRange: number;
  147435. /**
  147436. * The path visibility optimization range. [Limit: > 0]
  147437. */
  147438. pathOptimizationRange: number;
  147439. /**
  147440. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147441. */
  147442. separationWeight: number;
  147443. }
  147444. /**
  147445. * Configures the navigation mesh creation
  147446. */
  147447. export interface INavMeshParameters {
  147448. /**
  147449. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147450. */
  147451. cs: number;
  147452. /**
  147453. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147454. */
  147455. ch: number;
  147456. /**
  147457. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147458. */
  147459. walkableSlopeAngle: number;
  147460. /**
  147461. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147462. * be considered walkable. [Limit: >= 3] [Units: vx]
  147463. */
  147464. walkableHeight: number;
  147465. /**
  147466. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147467. */
  147468. walkableClimb: number;
  147469. /**
  147470. * The distance to erode/shrink the walkable area of the heightfield away from
  147471. * obstructions. [Limit: >=0] [Units: vx]
  147472. */
  147473. walkableRadius: number;
  147474. /**
  147475. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147476. */
  147477. maxEdgeLen: number;
  147478. /**
  147479. * The maximum distance a simplfied contour's border edges should deviate
  147480. * the original raw contour. [Limit: >=0] [Units: vx]
  147481. */
  147482. maxSimplificationError: number;
  147483. /**
  147484. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147485. */
  147486. minRegionArea: number;
  147487. /**
  147488. * Any regions with a span count smaller than this value will, if possible,
  147489. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147490. */
  147491. mergeRegionArea: number;
  147492. /**
  147493. * The maximum number of vertices allowed for polygons generated during the
  147494. * contour to polygon conversion process. [Limit: >= 3]
  147495. */
  147496. maxVertsPerPoly: number;
  147497. /**
  147498. * Sets the sampling distance to use when generating the detail mesh.
  147499. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147500. */
  147501. detailSampleDist: number;
  147502. /**
  147503. * The maximum distance the detail mesh surface should deviate from heightfield
  147504. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147505. */
  147506. detailSampleMaxError: number;
  147507. }
  147508. }
  147509. declare module BABYLON {
  147510. /**
  147511. * RecastJS navigation plugin
  147512. */
  147513. export class RecastJSPlugin implements INavigationEnginePlugin {
  147514. /**
  147515. * Reference to the Recast library
  147516. */
  147517. bjsRECAST: any;
  147518. /**
  147519. * plugin name
  147520. */
  147521. name: string;
  147522. /**
  147523. * the first navmesh created. We might extend this to support multiple navmeshes
  147524. */
  147525. navMesh: any;
  147526. /**
  147527. * Initializes the recastJS plugin
  147528. * @param recastInjection can be used to inject your own recast reference
  147529. */
  147530. constructor(recastInjection?: any);
  147531. /**
  147532. * Creates a navigation mesh
  147533. * @param meshes array of all the geometry used to compute the navigatio mesh
  147534. * @param parameters bunch of parameters used to filter geometry
  147535. */
  147536. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147537. /**
  147538. * Create a navigation mesh debug mesh
  147539. * @param scene is where the mesh will be added
  147540. * @returns debug display mesh
  147541. */
  147542. createDebugNavMesh(scene: Scene): Mesh;
  147543. /**
  147544. * Get a navigation mesh constrained position, closest to the parameter position
  147545. * @param position world position
  147546. * @returns the closest point to position constrained by the navigation mesh
  147547. */
  147548. getClosestPoint(position: Vector3): Vector3;
  147549. /**
  147550. * Get a navigation mesh constrained position, closest to the parameter position
  147551. * @param position world position
  147552. * @param result output the closest point to position constrained by the navigation mesh
  147553. */
  147554. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147555. /**
  147556. * Get a navigation mesh constrained position, within a particular radius
  147557. * @param position world position
  147558. * @param maxRadius the maximum distance to the constrained world position
  147559. * @returns the closest point to position constrained by the navigation mesh
  147560. */
  147561. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147562. /**
  147563. * Get a navigation mesh constrained position, within a particular radius
  147564. * @param position world position
  147565. * @param maxRadius the maximum distance to the constrained world position
  147566. * @param result output the closest point to position constrained by the navigation mesh
  147567. */
  147568. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147569. /**
  147570. * Compute the final position from a segment made of destination-position
  147571. * @param position world position
  147572. * @param destination world position
  147573. * @returns the resulting point along the navmesh
  147574. */
  147575. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147576. /**
  147577. * Compute the final position from a segment made of destination-position
  147578. * @param position world position
  147579. * @param destination world position
  147580. * @param result output the resulting point along the navmesh
  147581. */
  147582. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147583. /**
  147584. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147585. * @param start world position
  147586. * @param end world position
  147587. * @returns array containing world position composing the path
  147588. */
  147589. computePath(start: Vector3, end: Vector3): Vector3[];
  147590. /**
  147591. * Create a new Crowd so you can add agents
  147592. * @param maxAgents the maximum agent count in the crowd
  147593. * @param maxAgentRadius the maximum radius an agent can have
  147594. * @param scene to attach the crowd to
  147595. * @returns the crowd you can add agents to
  147596. */
  147597. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147598. /**
  147599. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147600. * The queries will try to find a solution within those bounds
  147601. * default is (1,1,1)
  147602. * @param extent x,y,z value that define the extent around the queries point of reference
  147603. */
  147604. setDefaultQueryExtent(extent: Vector3): void;
  147605. /**
  147606. * Get the Bounding box extent specified by setDefaultQueryExtent
  147607. * @returns the box extent values
  147608. */
  147609. getDefaultQueryExtent(): Vector3;
  147610. /**
  147611. * build the navmesh from a previously saved state using getNavmeshData
  147612. * @param data the Uint8Array returned by getNavmeshData
  147613. */
  147614. buildFromNavmeshData(data: Uint8Array): void;
  147615. /**
  147616. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147617. * @returns data the Uint8Array that can be saved and reused
  147618. */
  147619. getNavmeshData(): Uint8Array;
  147620. /**
  147621. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147622. * @param result output the box extent values
  147623. */
  147624. getDefaultQueryExtentToRef(result: Vector3): void;
  147625. /**
  147626. * Disposes
  147627. */
  147628. dispose(): void;
  147629. /**
  147630. * If this plugin is supported
  147631. * @returns true if plugin is supported
  147632. */
  147633. isSupported(): boolean;
  147634. }
  147635. /**
  147636. * Recast detour crowd implementation
  147637. */
  147638. export class RecastJSCrowd implements ICrowd {
  147639. /**
  147640. * Recast/detour plugin
  147641. */
  147642. bjsRECASTPlugin: RecastJSPlugin;
  147643. /**
  147644. * Link to the detour crowd
  147645. */
  147646. recastCrowd: any;
  147647. /**
  147648. * One transform per agent
  147649. */
  147650. transforms: TransformNode[];
  147651. /**
  147652. * All agents created
  147653. */
  147654. agents: number[];
  147655. /**
  147656. * Link to the scene is kept to unregister the crowd from the scene
  147657. */
  147658. private _scene;
  147659. /**
  147660. * Observer for crowd updates
  147661. */
  147662. private _onBeforeAnimationsObserver;
  147663. /**
  147664. * Constructor
  147665. * @param plugin recastJS plugin
  147666. * @param maxAgents the maximum agent count in the crowd
  147667. * @param maxAgentRadius the maximum radius an agent can have
  147668. * @param scene to attach the crowd to
  147669. * @returns the crowd you can add agents to
  147670. */
  147671. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147672. /**
  147673. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147674. * You can attach anything to that node. The node position is updated in the scene update tick.
  147675. * @param pos world position that will be constrained by the navigation mesh
  147676. * @param parameters agent parameters
  147677. * @param transform hooked to the agent that will be update by the scene
  147678. * @returns agent index
  147679. */
  147680. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147681. /**
  147682. * Returns the agent position in world space
  147683. * @param index agent index returned by addAgent
  147684. * @returns world space position
  147685. */
  147686. getAgentPosition(index: number): Vector3;
  147687. /**
  147688. * Returns the agent position result in world space
  147689. * @param index agent index returned by addAgent
  147690. * @param result output world space position
  147691. */
  147692. getAgentPositionToRef(index: number, result: Vector3): void;
  147693. /**
  147694. * Returns the agent velocity in world space
  147695. * @param index agent index returned by addAgent
  147696. * @returns world space velocity
  147697. */
  147698. getAgentVelocity(index: number): Vector3;
  147699. /**
  147700. * Returns the agent velocity result in world space
  147701. * @param index agent index returned by addAgent
  147702. * @param result output world space velocity
  147703. */
  147704. getAgentVelocityToRef(index: number, result: Vector3): void;
  147705. /**
  147706. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147707. * @param index agent index returned by addAgent
  147708. * @param destination targeted world position
  147709. */
  147710. agentGoto(index: number, destination: Vector3): void;
  147711. /**
  147712. * Teleport the agent to a new position
  147713. * @param index agent index returned by addAgent
  147714. * @param destination targeted world position
  147715. */
  147716. agentTeleport(index: number, destination: Vector3): void;
  147717. /**
  147718. * Update agent parameters
  147719. * @param index agent index returned by addAgent
  147720. * @param parameters agent parameters
  147721. */
  147722. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147723. /**
  147724. * remove a particular agent previously created
  147725. * @param index agent index returned by addAgent
  147726. */
  147727. removeAgent(index: number): void;
  147728. /**
  147729. * get the list of all agents attached to this crowd
  147730. * @returns list of agent indices
  147731. */
  147732. getAgents(): number[];
  147733. /**
  147734. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147735. * @param deltaTime in seconds
  147736. */
  147737. update(deltaTime: number): void;
  147738. /**
  147739. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147740. * The queries will try to find a solution within those bounds
  147741. * default is (1,1,1)
  147742. * @param extent x,y,z value that define the extent around the queries point of reference
  147743. */
  147744. setDefaultQueryExtent(extent: Vector3): void;
  147745. /**
  147746. * Get the Bounding box extent specified by setDefaultQueryExtent
  147747. * @returns the box extent values
  147748. */
  147749. getDefaultQueryExtent(): Vector3;
  147750. /**
  147751. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147752. * @param result output the box extent values
  147753. */
  147754. getDefaultQueryExtentToRef(result: Vector3): void;
  147755. /**
  147756. * Release all resources
  147757. */
  147758. dispose(): void;
  147759. }
  147760. }
  147761. declare module BABYLON {
  147762. /**
  147763. * Class used to enable access to IndexedDB
  147764. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147765. */
  147766. export class Database implements IOfflineProvider {
  147767. private _callbackManifestChecked;
  147768. private _currentSceneUrl;
  147769. private _db;
  147770. private _enableSceneOffline;
  147771. private _enableTexturesOffline;
  147772. private _manifestVersionFound;
  147773. private _mustUpdateRessources;
  147774. private _hasReachedQuota;
  147775. private _isSupported;
  147776. private _idbFactory;
  147777. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147778. private static IsUASupportingBlobStorage;
  147779. /**
  147780. * Gets a boolean indicating if Database storate is enabled (off by default)
  147781. */
  147782. static IDBStorageEnabled: boolean;
  147783. /**
  147784. * Gets a boolean indicating if scene must be saved in the database
  147785. */
  147786. get enableSceneOffline(): boolean;
  147787. /**
  147788. * Gets a boolean indicating if textures must be saved in the database
  147789. */
  147790. get enableTexturesOffline(): boolean;
  147791. /**
  147792. * Creates a new Database
  147793. * @param urlToScene defines the url to load the scene
  147794. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147795. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147796. */
  147797. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147798. private static _ParseURL;
  147799. private static _ReturnFullUrlLocation;
  147800. private _checkManifestFile;
  147801. /**
  147802. * Open the database and make it available
  147803. * @param successCallback defines the callback to call on success
  147804. * @param errorCallback defines the callback to call on error
  147805. */
  147806. open(successCallback: () => void, errorCallback: () => void): void;
  147807. /**
  147808. * Loads an image from the database
  147809. * @param url defines the url to load from
  147810. * @param image defines the target DOM image
  147811. */
  147812. loadImage(url: string, image: HTMLImageElement): void;
  147813. private _loadImageFromDBAsync;
  147814. private _saveImageIntoDBAsync;
  147815. private _checkVersionFromDB;
  147816. private _loadVersionFromDBAsync;
  147817. private _saveVersionIntoDBAsync;
  147818. /**
  147819. * Loads a file from database
  147820. * @param url defines the URL to load from
  147821. * @param sceneLoaded defines a callback to call on success
  147822. * @param progressCallBack defines a callback to call when progress changed
  147823. * @param errorCallback defines a callback to call on error
  147824. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147825. */
  147826. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147827. private _loadFileAsync;
  147828. private _saveFileAsync;
  147829. /**
  147830. * Validates if xhr data is correct
  147831. * @param xhr defines the request to validate
  147832. * @param dataType defines the expected data type
  147833. * @returns true if data is correct
  147834. */
  147835. private static _ValidateXHRData;
  147836. }
  147837. }
  147838. declare module BABYLON {
  147839. /** @hidden */
  147840. export var gpuUpdateParticlesPixelShader: {
  147841. name: string;
  147842. shader: string;
  147843. };
  147844. }
  147845. declare module BABYLON {
  147846. /** @hidden */
  147847. export var gpuUpdateParticlesVertexShader: {
  147848. name: string;
  147849. shader: string;
  147850. };
  147851. }
  147852. declare module BABYLON {
  147853. /** @hidden */
  147854. export var clipPlaneFragmentDeclaration2: {
  147855. name: string;
  147856. shader: string;
  147857. };
  147858. }
  147859. declare module BABYLON {
  147860. /** @hidden */
  147861. export var gpuRenderParticlesPixelShader: {
  147862. name: string;
  147863. shader: string;
  147864. };
  147865. }
  147866. declare module BABYLON {
  147867. /** @hidden */
  147868. export var clipPlaneVertexDeclaration2: {
  147869. name: string;
  147870. shader: string;
  147871. };
  147872. }
  147873. declare module BABYLON {
  147874. /** @hidden */
  147875. export var gpuRenderParticlesVertexShader: {
  147876. name: string;
  147877. shader: string;
  147878. };
  147879. }
  147880. declare module BABYLON {
  147881. /**
  147882. * This represents a GPU particle system in Babylon
  147883. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147884. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147885. */
  147886. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147887. /**
  147888. * The layer mask we are rendering the particles through.
  147889. */
  147890. layerMask: number;
  147891. private _capacity;
  147892. private _activeCount;
  147893. private _currentActiveCount;
  147894. private _accumulatedCount;
  147895. private _renderEffect;
  147896. private _updateEffect;
  147897. private _buffer0;
  147898. private _buffer1;
  147899. private _spriteBuffer;
  147900. private _updateVAO;
  147901. private _renderVAO;
  147902. private _targetIndex;
  147903. private _sourceBuffer;
  147904. private _targetBuffer;
  147905. private _currentRenderId;
  147906. private _started;
  147907. private _stopped;
  147908. private _timeDelta;
  147909. private _randomTexture;
  147910. private _randomTexture2;
  147911. private _attributesStrideSize;
  147912. private _updateEffectOptions;
  147913. private _randomTextureSize;
  147914. private _actualFrame;
  147915. private _customEffect;
  147916. private readonly _rawTextureWidth;
  147917. /**
  147918. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147919. */
  147920. static get IsSupported(): boolean;
  147921. /**
  147922. * An event triggered when the system is disposed.
  147923. */
  147924. onDisposeObservable: Observable<IParticleSystem>;
  147925. /**
  147926. * Gets the maximum number of particles active at the same time.
  147927. * @returns The max number of active particles.
  147928. */
  147929. getCapacity(): number;
  147930. /**
  147931. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147932. * to override the particles.
  147933. */
  147934. forceDepthWrite: boolean;
  147935. /**
  147936. * Gets or set the number of active particles
  147937. */
  147938. get activeParticleCount(): number;
  147939. set activeParticleCount(value: number);
  147940. private _preWarmDone;
  147941. /**
  147942. * Specifies if the particles are updated in emitter local space or world space.
  147943. */
  147944. isLocal: boolean;
  147945. /** Gets or sets a matrix to use to compute projection */
  147946. defaultProjectionMatrix: Matrix;
  147947. /**
  147948. * Is this system ready to be used/rendered
  147949. * @return true if the system is ready
  147950. */
  147951. isReady(): boolean;
  147952. /**
  147953. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147954. * @returns True if it has been started, otherwise false.
  147955. */
  147956. isStarted(): boolean;
  147957. /**
  147958. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147959. * @returns True if it has been stopped, otherwise false.
  147960. */
  147961. isStopped(): boolean;
  147962. /**
  147963. * Gets a boolean indicating that the system is stopping
  147964. * @returns true if the system is currently stopping
  147965. */
  147966. isStopping(): boolean;
  147967. /**
  147968. * Gets the number of particles active at the same time.
  147969. * @returns The number of active particles.
  147970. */
  147971. getActiveCount(): number;
  147972. /**
  147973. * Starts the particle system and begins to emit
  147974. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147975. */
  147976. start(delay?: number): void;
  147977. /**
  147978. * Stops the particle system.
  147979. */
  147980. stop(): void;
  147981. /**
  147982. * Remove all active particles
  147983. */
  147984. reset(): void;
  147985. /**
  147986. * Returns the string "GPUParticleSystem"
  147987. * @returns a string containing the class name
  147988. */
  147989. getClassName(): string;
  147990. /**
  147991. * Gets the custom effect used to render the particles
  147992. * @param blendMode Blend mode for which the effect should be retrieved
  147993. * @returns The effect
  147994. */
  147995. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147996. /**
  147997. * Sets the custom effect used to render the particles
  147998. * @param effect The effect to set
  147999. * @param blendMode Blend mode for which the effect should be set
  148000. */
  148001. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148002. /** @hidden */
  148003. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148004. /**
  148005. * Observable that will be called just before the particles are drawn
  148006. */
  148007. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148008. /**
  148009. * Gets the name of the particle vertex shader
  148010. */
  148011. get vertexShaderName(): string;
  148012. private _colorGradientsTexture;
  148013. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148014. /**
  148015. * Adds a new color gradient
  148016. * @param gradient defines the gradient to use (between 0 and 1)
  148017. * @param color1 defines the color to affect to the specified gradient
  148018. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148019. * @returns the current particle system
  148020. */
  148021. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148022. private _refreshColorGradient;
  148023. /** Force the system to rebuild all gradients that need to be resync */
  148024. forceRefreshGradients(): void;
  148025. /**
  148026. * Remove a specific color gradient
  148027. * @param gradient defines the gradient to remove
  148028. * @returns the current particle system
  148029. */
  148030. removeColorGradient(gradient: number): GPUParticleSystem;
  148031. private _angularSpeedGradientsTexture;
  148032. private _sizeGradientsTexture;
  148033. private _velocityGradientsTexture;
  148034. private _limitVelocityGradientsTexture;
  148035. private _dragGradientsTexture;
  148036. private _addFactorGradient;
  148037. /**
  148038. * Adds a new size gradient
  148039. * @param gradient defines the gradient to use (between 0 and 1)
  148040. * @param factor defines the size factor to affect to the specified gradient
  148041. * @returns the current particle system
  148042. */
  148043. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148044. /**
  148045. * Remove a specific size gradient
  148046. * @param gradient defines the gradient to remove
  148047. * @returns the current particle system
  148048. */
  148049. removeSizeGradient(gradient: number): GPUParticleSystem;
  148050. private _refreshFactorGradient;
  148051. /**
  148052. * Adds a new angular speed gradient
  148053. * @param gradient defines the gradient to use (between 0 and 1)
  148054. * @param factor defines the angular speed to affect to the specified gradient
  148055. * @returns the current particle system
  148056. */
  148057. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148058. /**
  148059. * Remove a specific angular speed gradient
  148060. * @param gradient defines the gradient to remove
  148061. * @returns the current particle system
  148062. */
  148063. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148064. /**
  148065. * Adds a new velocity gradient
  148066. * @param gradient defines the gradient to use (between 0 and 1)
  148067. * @param factor defines the velocity to affect to the specified gradient
  148068. * @returns the current particle system
  148069. */
  148070. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148071. /**
  148072. * Remove a specific velocity gradient
  148073. * @param gradient defines the gradient to remove
  148074. * @returns the current particle system
  148075. */
  148076. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148077. /**
  148078. * Adds a new limit velocity gradient
  148079. * @param gradient defines the gradient to use (between 0 and 1)
  148080. * @param factor defines the limit velocity value to affect to the specified gradient
  148081. * @returns the current particle system
  148082. */
  148083. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148084. /**
  148085. * Remove a specific limit velocity gradient
  148086. * @param gradient defines the gradient to remove
  148087. * @returns the current particle system
  148088. */
  148089. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148090. /**
  148091. * Adds a new drag gradient
  148092. * @param gradient defines the gradient to use (between 0 and 1)
  148093. * @param factor defines the drag value to affect to the specified gradient
  148094. * @returns the current particle system
  148095. */
  148096. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148097. /**
  148098. * Remove a specific drag gradient
  148099. * @param gradient defines the gradient to remove
  148100. * @returns the current particle system
  148101. */
  148102. removeDragGradient(gradient: number): GPUParticleSystem;
  148103. /**
  148104. * Not supported by GPUParticleSystem
  148105. * @param gradient defines the gradient to use (between 0 and 1)
  148106. * @param factor defines the emit rate value to affect to the specified gradient
  148107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148108. * @returns the current particle system
  148109. */
  148110. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148111. /**
  148112. * Not supported by GPUParticleSystem
  148113. * @param gradient defines the gradient to remove
  148114. * @returns the current particle system
  148115. */
  148116. removeEmitRateGradient(gradient: number): IParticleSystem;
  148117. /**
  148118. * Not supported by GPUParticleSystem
  148119. * @param gradient defines the gradient to use (between 0 and 1)
  148120. * @param factor defines the start size value to affect to the specified gradient
  148121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148122. * @returns the current particle system
  148123. */
  148124. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148125. /**
  148126. * Not supported by GPUParticleSystem
  148127. * @param gradient defines the gradient to remove
  148128. * @returns the current particle system
  148129. */
  148130. removeStartSizeGradient(gradient: number): IParticleSystem;
  148131. /**
  148132. * Not supported by GPUParticleSystem
  148133. * @param gradient defines the gradient to use (between 0 and 1)
  148134. * @param min defines the color remap minimal range
  148135. * @param max defines the color remap maximal range
  148136. * @returns the current particle system
  148137. */
  148138. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148139. /**
  148140. * Not supported by GPUParticleSystem
  148141. * @param gradient defines the gradient to remove
  148142. * @returns the current particle system
  148143. */
  148144. removeColorRemapGradient(): IParticleSystem;
  148145. /**
  148146. * Not supported by GPUParticleSystem
  148147. * @param gradient defines the gradient to use (between 0 and 1)
  148148. * @param min defines the alpha remap minimal range
  148149. * @param max defines the alpha remap maximal range
  148150. * @returns the current particle system
  148151. */
  148152. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148153. /**
  148154. * Not supported by GPUParticleSystem
  148155. * @param gradient defines the gradient to remove
  148156. * @returns the current particle system
  148157. */
  148158. removeAlphaRemapGradient(): IParticleSystem;
  148159. /**
  148160. * Not supported by GPUParticleSystem
  148161. * @param gradient defines the gradient to use (between 0 and 1)
  148162. * @param color defines the color to affect to the specified gradient
  148163. * @returns the current particle system
  148164. */
  148165. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148166. /**
  148167. * Not supported by GPUParticleSystem
  148168. * @param gradient defines the gradient to remove
  148169. * @returns the current particle system
  148170. */
  148171. removeRampGradient(): IParticleSystem;
  148172. /**
  148173. * Not supported by GPUParticleSystem
  148174. * @returns the list of ramp gradients
  148175. */
  148176. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148177. /**
  148178. * Not supported by GPUParticleSystem
  148179. * Gets or sets a boolean indicating that ramp gradients must be used
  148180. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148181. */
  148182. get useRampGradients(): boolean;
  148183. set useRampGradients(value: boolean);
  148184. /**
  148185. * Not supported by GPUParticleSystem
  148186. * @param gradient defines the gradient to use (between 0 and 1)
  148187. * @param factor defines the life time factor to affect to the specified gradient
  148188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148189. * @returns the current particle system
  148190. */
  148191. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148192. /**
  148193. * Not supported by GPUParticleSystem
  148194. * @param gradient defines the gradient to remove
  148195. * @returns the current particle system
  148196. */
  148197. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148198. /**
  148199. * Instantiates a GPU particle system.
  148200. * 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.
  148201. * @param name The name of the particle system
  148202. * @param options The options used to create the system
  148203. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148204. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148205. * @param customEffect a custom effect used to change the way particles are rendered by default
  148206. */
  148207. constructor(name: string, options: Partial<{
  148208. capacity: number;
  148209. randomTextureSize: number;
  148210. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148211. protected _reset(): void;
  148212. private _createUpdateVAO;
  148213. private _createRenderVAO;
  148214. private _initialize;
  148215. /** @hidden */
  148216. _recreateUpdateEffect(): void;
  148217. private _getEffect;
  148218. /**
  148219. * Fill the defines array according to the current settings of the particle system
  148220. * @param defines Array to be updated
  148221. * @param blendMode blend mode to take into account when updating the array
  148222. */
  148223. fillDefines(defines: Array<string>, blendMode?: number): void;
  148224. /**
  148225. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148226. * @param uniforms Uniforms array to fill
  148227. * @param attributes Attributes array to fill
  148228. * @param samplers Samplers array to fill
  148229. */
  148230. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148231. /** @hidden */
  148232. _recreateRenderEffect(): Effect;
  148233. /**
  148234. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148235. * @param preWarm defines if we are in the pre-warmimg phase
  148236. */
  148237. animate(preWarm?: boolean): void;
  148238. private _createFactorGradientTexture;
  148239. private _createSizeGradientTexture;
  148240. private _createAngularSpeedGradientTexture;
  148241. private _createVelocityGradientTexture;
  148242. private _createLimitVelocityGradientTexture;
  148243. private _createDragGradientTexture;
  148244. private _createColorGradientTexture;
  148245. /**
  148246. * Renders the particle system in its current state
  148247. * @param preWarm defines if the system should only update the particles but not render them
  148248. * @returns the current number of particles
  148249. */
  148250. render(preWarm?: boolean): number;
  148251. /**
  148252. * Rebuilds the particle system
  148253. */
  148254. rebuild(): void;
  148255. private _releaseBuffers;
  148256. private _releaseVAOs;
  148257. /**
  148258. * Disposes the particle system and free the associated resources
  148259. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148260. */
  148261. dispose(disposeTexture?: boolean): void;
  148262. /**
  148263. * Clones the particle system.
  148264. * @param name The name of the cloned object
  148265. * @param newEmitter The new emitter to use
  148266. * @returns the cloned particle system
  148267. */
  148268. clone(name: string, newEmitter: any): GPUParticleSystem;
  148269. /**
  148270. * Serializes the particle system to a JSON object
  148271. * @param serializeTexture defines if the texture must be serialized as well
  148272. * @returns the JSON object
  148273. */
  148274. serialize(serializeTexture?: boolean): any;
  148275. /**
  148276. * Parses a JSON object to create a GPU particle system.
  148277. * @param parsedParticleSystem The JSON object to parse
  148278. * @param sceneOrEngine The scene or the engine to create the particle system in
  148279. * @param rootUrl The root url to use to load external dependencies like texture
  148280. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148281. * @returns the parsed GPU particle system
  148282. */
  148283. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148284. }
  148285. }
  148286. declare module BABYLON {
  148287. /**
  148288. * Represents a set of particle systems working together to create a specific effect
  148289. */
  148290. export class ParticleSystemSet implements IDisposable {
  148291. /**
  148292. * Gets or sets base Assets URL
  148293. */
  148294. static BaseAssetsUrl: string;
  148295. private _emitterCreationOptions;
  148296. private _emitterNode;
  148297. /**
  148298. * Gets the particle system list
  148299. */
  148300. systems: IParticleSystem[];
  148301. /**
  148302. * Gets the emitter node used with this set
  148303. */
  148304. get emitterNode(): Nullable<TransformNode>;
  148305. /**
  148306. * Creates a new emitter mesh as a sphere
  148307. * @param options defines the options used to create the sphere
  148308. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148309. * @param scene defines the hosting scene
  148310. */
  148311. setEmitterAsSphere(options: {
  148312. diameter: number;
  148313. segments: number;
  148314. color: Color3;
  148315. }, renderingGroupId: number, scene: Scene): void;
  148316. /**
  148317. * Starts all particle systems of the set
  148318. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148319. */
  148320. start(emitter?: AbstractMesh): void;
  148321. /**
  148322. * Release all associated resources
  148323. */
  148324. dispose(): void;
  148325. /**
  148326. * Serialize the set into a JSON compatible object
  148327. * @param serializeTexture defines if the texture must be serialized as well
  148328. * @returns a JSON compatible representation of the set
  148329. */
  148330. serialize(serializeTexture?: boolean): any;
  148331. /**
  148332. * Parse a new ParticleSystemSet from a serialized source
  148333. * @param data defines a JSON compatible representation of the set
  148334. * @param scene defines the hosting scene
  148335. * @param gpu defines if we want GPU particles or CPU particles
  148336. * @returns a new ParticleSystemSet
  148337. */
  148338. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148339. }
  148340. }
  148341. declare module BABYLON {
  148342. /**
  148343. * This class is made for on one-liner static method to help creating particle system set.
  148344. */
  148345. export class ParticleHelper {
  148346. /**
  148347. * Gets or sets base Assets URL
  148348. */
  148349. static BaseAssetsUrl: string;
  148350. /** Define the Url to load snippets */
  148351. static SnippetUrl: string;
  148352. /**
  148353. * Create a default particle system that you can tweak
  148354. * @param emitter defines the emitter to use
  148355. * @param capacity defines the system capacity (default is 500 particles)
  148356. * @param scene defines the hosting scene
  148357. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148358. * @returns the new Particle system
  148359. */
  148360. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148361. /**
  148362. * This is the main static method (one-liner) of this helper to create different particle systems
  148363. * @param type This string represents the type to the particle system to create
  148364. * @param scene The scene where the particle system should live
  148365. * @param gpu If the system will use gpu
  148366. * @returns the ParticleSystemSet created
  148367. */
  148368. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148369. /**
  148370. * Static function used to export a particle system to a ParticleSystemSet variable.
  148371. * Please note that the emitter shape is not exported
  148372. * @param systems defines the particle systems to export
  148373. * @returns the created particle system set
  148374. */
  148375. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148376. /**
  148377. * Creates a particle system from a snippet saved in a remote file
  148378. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148379. * @param url defines the url to load from
  148380. * @param scene defines the hosting scene
  148381. * @param gpu If the system will use gpu
  148382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148383. * @returns a promise that will resolve to the new particle system
  148384. */
  148385. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148386. /**
  148387. * Creates a particle system from a snippet saved by the particle system editor
  148388. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148389. * @param scene defines the hosting scene
  148390. * @param gpu If the system will use gpu
  148391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148392. * @returns a promise that will resolve to the new particle system
  148393. */
  148394. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148395. }
  148396. }
  148397. declare module BABYLON {
  148398. interface Engine {
  148399. /**
  148400. * Create an effect to use with particle systems.
  148401. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148402. * the particle system for which you want to create a custom effect in the last parameter
  148403. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148404. * @param uniformsNames defines a list of attribute names
  148405. * @param samplers defines an array of string used to represent textures
  148406. * @param defines defines the string containing the defines to use to compile the shaders
  148407. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148408. * @param onCompiled defines a function to call when the effect creation is successful
  148409. * @param onError defines a function to call when the effect creation has failed
  148410. * @param particleSystem the particle system you want to create the effect for
  148411. * @returns the new Effect
  148412. */
  148413. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148414. }
  148415. interface Mesh {
  148416. /**
  148417. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148418. * @returns an array of IParticleSystem
  148419. */
  148420. getEmittedParticleSystems(): IParticleSystem[];
  148421. /**
  148422. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148423. * @returns an array of IParticleSystem
  148424. */
  148425. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148426. }
  148427. }
  148428. declare module BABYLON {
  148429. /** Defines the 4 color options */
  148430. export enum PointColor {
  148431. /** color value */
  148432. Color = 2,
  148433. /** uv value */
  148434. UV = 1,
  148435. /** random value */
  148436. Random = 0,
  148437. /** stated value */
  148438. Stated = 3
  148439. }
  148440. /**
  148441. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148442. * 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.
  148443. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148444. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148445. *
  148446. * Full documentation here : TO BE ENTERED
  148447. */
  148448. export class PointsCloudSystem implements IDisposable {
  148449. /**
  148450. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148451. * Example : var p = SPS.particles[i];
  148452. */
  148453. particles: CloudPoint[];
  148454. /**
  148455. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148456. */
  148457. nbParticles: number;
  148458. /**
  148459. * This a counter for your own usage. It's not set by any SPS functions.
  148460. */
  148461. counter: number;
  148462. /**
  148463. * The PCS name. This name is also given to the underlying mesh.
  148464. */
  148465. name: string;
  148466. /**
  148467. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148468. */
  148469. mesh: Mesh;
  148470. /**
  148471. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148472. * Please read :
  148473. */
  148474. vars: any;
  148475. /**
  148476. * @hidden
  148477. */
  148478. _size: number;
  148479. private _scene;
  148480. private _promises;
  148481. private _positions;
  148482. private _indices;
  148483. private _normals;
  148484. private _colors;
  148485. private _uvs;
  148486. private _indices32;
  148487. private _positions32;
  148488. private _colors32;
  148489. private _uvs32;
  148490. private _updatable;
  148491. private _isVisibilityBoxLocked;
  148492. private _alwaysVisible;
  148493. private _groups;
  148494. private _groupCounter;
  148495. private _computeParticleColor;
  148496. private _computeParticleTexture;
  148497. private _computeParticleRotation;
  148498. private _computeBoundingBox;
  148499. private _isReady;
  148500. /**
  148501. * Creates a PCS (Points Cloud System) object
  148502. * @param name (String) is the PCS name, this will be the underlying mesh name
  148503. * @param pointSize (number) is the size for each point
  148504. * @param scene (Scene) is the scene in which the PCS is added
  148505. * @param options defines the options of the PCS e.g.
  148506. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148507. */
  148508. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148509. updatable?: boolean;
  148510. });
  148511. /**
  148512. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148513. * If no points were added to the PCS, the returned mesh is just a single point.
  148514. * @returns a promise for the created mesh
  148515. */
  148516. buildMeshAsync(): Promise<Mesh>;
  148517. /**
  148518. * @hidden
  148519. */
  148520. private _buildMesh;
  148521. private _addParticle;
  148522. private _randomUnitVector;
  148523. private _getColorIndicesForCoord;
  148524. private _setPointsColorOrUV;
  148525. private _colorFromTexture;
  148526. private _calculateDensity;
  148527. /**
  148528. * Adds points to the PCS in random positions within a unit sphere
  148529. * @param nb (positive integer) the number of particles to be created from this model
  148530. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148531. * @returns the number of groups in the system
  148532. */
  148533. addPoints(nb: number, pointFunction?: any): number;
  148534. /**
  148535. * Adds points to the PCS from the surface of the model shape
  148536. * @param mesh is any Mesh object that will be used as a surface model for the points
  148537. * @param nb (positive integer) the number of particles to be created from this model
  148538. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148539. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148540. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148541. * @returns the number of groups in the system
  148542. */
  148543. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148544. /**
  148545. * Adds points to the PCS inside the model shape
  148546. * @param mesh is any Mesh object that will be used as a surface model for the points
  148547. * @param nb (positive integer) the number of particles to be created from this model
  148548. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148549. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148550. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148551. * @returns the number of groups in the system
  148552. */
  148553. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148554. /**
  148555. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148556. * This method calls `updateParticle()` for each particle of the SPS.
  148557. * For an animated SPS, it is usually called within the render loop.
  148558. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148559. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148560. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148561. * @returns the PCS.
  148562. */
  148563. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148564. /**
  148565. * Disposes the PCS.
  148566. */
  148567. dispose(): void;
  148568. /**
  148569. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148570. * doc :
  148571. * @returns the PCS.
  148572. */
  148573. refreshVisibleSize(): PointsCloudSystem;
  148574. /**
  148575. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148576. * @param size the size (float) of the visibility box
  148577. * note : this doesn't lock the PCS mesh bounding box.
  148578. * doc :
  148579. */
  148580. setVisibilityBox(size: number): void;
  148581. /**
  148582. * Gets whether the PCS is always visible or not
  148583. * doc :
  148584. */
  148585. get isAlwaysVisible(): boolean;
  148586. /**
  148587. * Sets the PCS as always visible or not
  148588. * doc :
  148589. */
  148590. set isAlwaysVisible(val: boolean);
  148591. /**
  148592. * Tells to `setParticles()` to compute the particle rotations or not
  148593. * Default value : false. The PCS is faster when it's set to false
  148594. * Note : particle rotations are only applied to parent particles
  148595. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148596. */
  148597. set computeParticleRotation(val: boolean);
  148598. /**
  148599. * Tells to `setParticles()` to compute the particle colors or not.
  148600. * Default value : true. The PCS is faster when it's set to false.
  148601. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148602. */
  148603. set computeParticleColor(val: boolean);
  148604. set computeParticleTexture(val: boolean);
  148605. /**
  148606. * Gets if `setParticles()` computes the particle colors or not.
  148607. * Default value : false. The PCS is faster when it's set to false.
  148608. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148609. */
  148610. get computeParticleColor(): boolean;
  148611. /**
  148612. * Gets if `setParticles()` computes the particle textures or not.
  148613. * Default value : false. The PCS is faster when it's set to false.
  148614. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148615. */
  148616. get computeParticleTexture(): boolean;
  148617. /**
  148618. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148619. */
  148620. set computeBoundingBox(val: boolean);
  148621. /**
  148622. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148623. */
  148624. get computeBoundingBox(): boolean;
  148625. /**
  148626. * This function does nothing. It may be overwritten to set all the particle first values.
  148627. * The PCS doesn't call this function, you may have to call it by your own.
  148628. * doc :
  148629. */
  148630. initParticles(): void;
  148631. /**
  148632. * This function does nothing. It may be overwritten to recycle a particle
  148633. * The PCS doesn't call this function, you can to call it
  148634. * doc :
  148635. * @param particle The particle to recycle
  148636. * @returns the recycled particle
  148637. */
  148638. recycleParticle(particle: CloudPoint): CloudPoint;
  148639. /**
  148640. * Updates a particle : this function should be overwritten by the user.
  148641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148642. * doc :
  148643. * @example : just set a particle position or velocity and recycle conditions
  148644. * @param particle The particle to update
  148645. * @returns the updated particle
  148646. */
  148647. updateParticle(particle: CloudPoint): CloudPoint;
  148648. /**
  148649. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148650. * This does nothing and may be overwritten by the user.
  148651. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148652. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148653. * @param update the boolean update value actually passed to setParticles()
  148654. */
  148655. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148656. /**
  148657. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148658. * This will be passed three parameters.
  148659. * This does nothing and may be overwritten by the user.
  148660. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148661. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148662. * @param update the boolean update value actually passed to setParticles()
  148663. */
  148664. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148665. }
  148666. }
  148667. declare module BABYLON {
  148668. /**
  148669. * Represents one particle of a points cloud system.
  148670. */
  148671. export class CloudPoint {
  148672. /**
  148673. * particle global index
  148674. */
  148675. idx: number;
  148676. /**
  148677. * The color of the particle
  148678. */
  148679. color: Nullable<Color4>;
  148680. /**
  148681. * The world space position of the particle.
  148682. */
  148683. position: Vector3;
  148684. /**
  148685. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148686. */
  148687. rotation: Vector3;
  148688. /**
  148689. * The world space rotation quaternion of the particle.
  148690. */
  148691. rotationQuaternion: Nullable<Quaternion>;
  148692. /**
  148693. * The uv of the particle.
  148694. */
  148695. uv: Nullable<Vector2>;
  148696. /**
  148697. * The current speed of the particle.
  148698. */
  148699. velocity: Vector3;
  148700. /**
  148701. * The pivot point in the particle local space.
  148702. */
  148703. pivot: Vector3;
  148704. /**
  148705. * Must the particle be translated from its pivot point in its local space ?
  148706. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148707. * Default : false
  148708. */
  148709. translateFromPivot: boolean;
  148710. /**
  148711. * Index of this particle in the global "positions" array (Internal use)
  148712. * @hidden
  148713. */
  148714. _pos: number;
  148715. /**
  148716. * @hidden Index of this particle in the global "indices" array (Internal use)
  148717. */
  148718. _ind: number;
  148719. /**
  148720. * Group this particle belongs to
  148721. */
  148722. _group: PointsGroup;
  148723. /**
  148724. * Group id of this particle
  148725. */
  148726. groupId: number;
  148727. /**
  148728. * Index of the particle in its group id (Internal use)
  148729. */
  148730. idxInGroup: number;
  148731. /**
  148732. * @hidden Particle BoundingInfo object (Internal use)
  148733. */
  148734. _boundingInfo: BoundingInfo;
  148735. /**
  148736. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148737. */
  148738. _pcs: PointsCloudSystem;
  148739. /**
  148740. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148741. */
  148742. _stillInvisible: boolean;
  148743. /**
  148744. * @hidden Last computed particle rotation matrix
  148745. */
  148746. _rotationMatrix: number[];
  148747. /**
  148748. * Parent particle Id, if any.
  148749. * Default null.
  148750. */
  148751. parentId: Nullable<number>;
  148752. /**
  148753. * @hidden Internal global position in the PCS.
  148754. */
  148755. _globalPosition: Vector3;
  148756. /**
  148757. * Creates a Point Cloud object.
  148758. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148759. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148760. * @param group (PointsGroup) is the group the particle belongs to
  148761. * @param groupId (integer) is the group identifier in the PCS.
  148762. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148763. * @param pcs defines the PCS it is associated to
  148764. */
  148765. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148766. /**
  148767. * get point size
  148768. */
  148769. get size(): Vector3;
  148770. /**
  148771. * Set point size
  148772. */
  148773. set size(scale: Vector3);
  148774. /**
  148775. * Legacy support, changed quaternion to rotationQuaternion
  148776. */
  148777. get quaternion(): Nullable<Quaternion>;
  148778. /**
  148779. * Legacy support, changed quaternion to rotationQuaternion
  148780. */
  148781. set quaternion(q: Nullable<Quaternion>);
  148782. /**
  148783. * Returns a boolean. True if the particle intersects a mesh, else false
  148784. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148785. * @param target is the object (point or mesh) what the intersection is computed against
  148786. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148787. * @returns true if it intersects
  148788. */
  148789. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148790. /**
  148791. * get the rotation matrix of the particle
  148792. * @hidden
  148793. */
  148794. getRotationMatrix(m: Matrix): void;
  148795. }
  148796. /**
  148797. * Represents a group of points in a points cloud system
  148798. * * PCS internal tool, don't use it manually.
  148799. */
  148800. export class PointsGroup {
  148801. /**
  148802. * The group id
  148803. * @hidden
  148804. */
  148805. groupID: number;
  148806. /**
  148807. * image data for group (internal use)
  148808. * @hidden
  148809. */
  148810. _groupImageData: Nullable<ArrayBufferView>;
  148811. /**
  148812. * Image Width (internal use)
  148813. * @hidden
  148814. */
  148815. _groupImgWidth: number;
  148816. /**
  148817. * Image Height (internal use)
  148818. * @hidden
  148819. */
  148820. _groupImgHeight: number;
  148821. /**
  148822. * Custom position function (internal use)
  148823. * @hidden
  148824. */
  148825. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148826. /**
  148827. * density per facet for surface points
  148828. * @hidden
  148829. */
  148830. _groupDensity: number[];
  148831. /**
  148832. * Only when points are colored by texture carries pointer to texture list array
  148833. * @hidden
  148834. */
  148835. _textureNb: number;
  148836. /**
  148837. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148838. * PCS internal tool, don't use it manually.
  148839. * @hidden
  148840. */
  148841. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148842. }
  148843. }
  148844. declare module BABYLON {
  148845. interface Scene {
  148846. /** @hidden (Backing field) */
  148847. _physicsEngine: Nullable<IPhysicsEngine>;
  148848. /** @hidden */
  148849. _physicsTimeAccumulator: number;
  148850. /**
  148851. * Gets the current physics engine
  148852. * @returns a IPhysicsEngine or null if none attached
  148853. */
  148854. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148855. /**
  148856. * Enables physics to the current scene
  148857. * @param gravity defines the scene's gravity for the physics engine
  148858. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148859. * @return a boolean indicating if the physics engine was initialized
  148860. */
  148861. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148862. /**
  148863. * Disables and disposes the physics engine associated with the scene
  148864. */
  148865. disablePhysicsEngine(): void;
  148866. /**
  148867. * Gets a boolean indicating if there is an active physics engine
  148868. * @returns a boolean indicating if there is an active physics engine
  148869. */
  148870. isPhysicsEnabled(): boolean;
  148871. /**
  148872. * Deletes a physics compound impostor
  148873. * @param compound defines the compound to delete
  148874. */
  148875. deleteCompoundImpostor(compound: any): void;
  148876. /**
  148877. * An event triggered when physic simulation is about to be run
  148878. */
  148879. onBeforePhysicsObservable: Observable<Scene>;
  148880. /**
  148881. * An event triggered when physic simulation has been done
  148882. */
  148883. onAfterPhysicsObservable: Observable<Scene>;
  148884. }
  148885. interface AbstractMesh {
  148886. /** @hidden */
  148887. _physicsImpostor: Nullable<PhysicsImpostor>;
  148888. /**
  148889. * Gets or sets impostor used for physic simulation
  148890. * @see https://doc.babylonjs.com/features/physics_engine
  148891. */
  148892. physicsImpostor: Nullable<PhysicsImpostor>;
  148893. /**
  148894. * Gets the current physics impostor
  148895. * @see https://doc.babylonjs.com/features/physics_engine
  148896. * @returns a physics impostor or null
  148897. */
  148898. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148899. /** Apply a physic impulse to the mesh
  148900. * @param force defines the force to apply
  148901. * @param contactPoint defines where to apply the force
  148902. * @returns the current mesh
  148903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148904. */
  148905. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148906. /**
  148907. * Creates a physic joint between two meshes
  148908. * @param otherMesh defines the other mesh to use
  148909. * @param pivot1 defines the pivot to use on this mesh
  148910. * @param pivot2 defines the pivot to use on the other mesh
  148911. * @param options defines additional options (can be plugin dependent)
  148912. * @returns the current mesh
  148913. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148914. */
  148915. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148916. /** @hidden */
  148917. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148918. }
  148919. /**
  148920. * Defines the physics engine scene component responsible to manage a physics engine
  148921. */
  148922. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148923. /**
  148924. * The component name helpful to identify the component in the list of scene components.
  148925. */
  148926. readonly name: string;
  148927. /**
  148928. * The scene the component belongs to.
  148929. */
  148930. scene: Scene;
  148931. /**
  148932. * Creates a new instance of the component for the given scene
  148933. * @param scene Defines the scene to register the component in
  148934. */
  148935. constructor(scene: Scene);
  148936. /**
  148937. * Registers the component in a given scene
  148938. */
  148939. register(): void;
  148940. /**
  148941. * Rebuilds the elements related to this component in case of
  148942. * context lost for instance.
  148943. */
  148944. rebuild(): void;
  148945. /**
  148946. * Disposes the component and the associated ressources
  148947. */
  148948. dispose(): void;
  148949. }
  148950. }
  148951. declare module BABYLON {
  148952. /**
  148953. * A helper for physics simulations
  148954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148955. */
  148956. export class PhysicsHelper {
  148957. private _scene;
  148958. private _physicsEngine;
  148959. /**
  148960. * Initializes the Physics helper
  148961. * @param scene Babylon.js scene
  148962. */
  148963. constructor(scene: Scene);
  148964. /**
  148965. * Applies a radial explosion impulse
  148966. * @param origin the origin of the explosion
  148967. * @param radiusOrEventOptions the radius or the options of radial explosion
  148968. * @param strength the explosion strength
  148969. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148970. * @returns A physics radial explosion event, or null
  148971. */
  148972. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148973. /**
  148974. * Applies a radial explosion force
  148975. * @param origin the origin of the explosion
  148976. * @param radiusOrEventOptions the radius or the options of radial explosion
  148977. * @param strength the explosion strength
  148978. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148979. * @returns A physics radial explosion event, or null
  148980. */
  148981. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148982. /**
  148983. * Creates a gravitational field
  148984. * @param origin the origin of the explosion
  148985. * @param radiusOrEventOptions the radius or the options of radial explosion
  148986. * @param strength the explosion strength
  148987. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148988. * @returns A physics gravitational field event, or null
  148989. */
  148990. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148991. /**
  148992. * Creates a physics updraft event
  148993. * @param origin the origin of the updraft
  148994. * @param radiusOrEventOptions the radius or the options of the updraft
  148995. * @param strength the strength of the updraft
  148996. * @param height the height of the updraft
  148997. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148998. * @returns A physics updraft event, or null
  148999. */
  149000. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149001. /**
  149002. * Creates a physics vortex event
  149003. * @param origin the of the vortex
  149004. * @param radiusOrEventOptions the radius or the options of the vortex
  149005. * @param strength the strength of the vortex
  149006. * @param height the height of the vortex
  149007. * @returns a Physics vortex event, or null
  149008. * A physics vortex event or null
  149009. */
  149010. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149011. }
  149012. /**
  149013. * Represents a physics radial explosion event
  149014. */
  149015. class PhysicsRadialExplosionEvent {
  149016. private _scene;
  149017. private _options;
  149018. private _sphere;
  149019. private _dataFetched;
  149020. /**
  149021. * Initializes a radial explosioin event
  149022. * @param _scene BabylonJS scene
  149023. * @param _options The options for the vortex event
  149024. */
  149025. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149026. /**
  149027. * Returns the data related to the radial explosion event (sphere).
  149028. * @returns The radial explosion event data
  149029. */
  149030. getData(): PhysicsRadialExplosionEventData;
  149031. /**
  149032. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149033. * @param impostor A physics imposter
  149034. * @param origin the origin of the explosion
  149035. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149036. */
  149037. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149038. /**
  149039. * Triggers affecterd impostors callbacks
  149040. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149041. */
  149042. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149043. /**
  149044. * Disposes the sphere.
  149045. * @param force Specifies if the sphere should be disposed by force
  149046. */
  149047. dispose(force?: boolean): void;
  149048. /*** Helpers ***/
  149049. private _prepareSphere;
  149050. private _intersectsWithSphere;
  149051. }
  149052. /**
  149053. * Represents a gravitational field event
  149054. */
  149055. class PhysicsGravitationalFieldEvent {
  149056. private _physicsHelper;
  149057. private _scene;
  149058. private _origin;
  149059. private _options;
  149060. private _tickCallback;
  149061. private _sphere;
  149062. private _dataFetched;
  149063. /**
  149064. * Initializes the physics gravitational field event
  149065. * @param _physicsHelper A physics helper
  149066. * @param _scene BabylonJS scene
  149067. * @param _origin The origin position of the gravitational field event
  149068. * @param _options The options for the vortex event
  149069. */
  149070. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149071. /**
  149072. * Returns the data related to the gravitational field event (sphere).
  149073. * @returns A gravitational field event
  149074. */
  149075. getData(): PhysicsGravitationalFieldEventData;
  149076. /**
  149077. * Enables the gravitational field.
  149078. */
  149079. enable(): void;
  149080. /**
  149081. * Disables the gravitational field.
  149082. */
  149083. disable(): void;
  149084. /**
  149085. * Disposes the sphere.
  149086. * @param force The force to dispose from the gravitational field event
  149087. */
  149088. dispose(force?: boolean): void;
  149089. private _tick;
  149090. }
  149091. /**
  149092. * Represents a physics updraft event
  149093. */
  149094. class PhysicsUpdraftEvent {
  149095. private _scene;
  149096. private _origin;
  149097. private _options;
  149098. private _physicsEngine;
  149099. private _originTop;
  149100. private _originDirection;
  149101. private _tickCallback;
  149102. private _cylinder;
  149103. private _cylinderPosition;
  149104. private _dataFetched;
  149105. /**
  149106. * Initializes the physics updraft event
  149107. * @param _scene BabylonJS scene
  149108. * @param _origin The origin position of the updraft
  149109. * @param _options The options for the updraft event
  149110. */
  149111. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149112. /**
  149113. * Returns the data related to the updraft event (cylinder).
  149114. * @returns A physics updraft event
  149115. */
  149116. getData(): PhysicsUpdraftEventData;
  149117. /**
  149118. * Enables the updraft.
  149119. */
  149120. enable(): void;
  149121. /**
  149122. * Disables the updraft.
  149123. */
  149124. disable(): void;
  149125. /**
  149126. * Disposes the cylinder.
  149127. * @param force Specifies if the updraft should be disposed by force
  149128. */
  149129. dispose(force?: boolean): void;
  149130. private getImpostorHitData;
  149131. private _tick;
  149132. /*** Helpers ***/
  149133. private _prepareCylinder;
  149134. private _intersectsWithCylinder;
  149135. }
  149136. /**
  149137. * Represents a physics vortex event
  149138. */
  149139. class PhysicsVortexEvent {
  149140. private _scene;
  149141. private _origin;
  149142. private _options;
  149143. private _physicsEngine;
  149144. private _originTop;
  149145. private _tickCallback;
  149146. private _cylinder;
  149147. private _cylinderPosition;
  149148. private _dataFetched;
  149149. /**
  149150. * Initializes the physics vortex event
  149151. * @param _scene The BabylonJS scene
  149152. * @param _origin The origin position of the vortex
  149153. * @param _options The options for the vortex event
  149154. */
  149155. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149156. /**
  149157. * Returns the data related to the vortex event (cylinder).
  149158. * @returns The physics vortex event data
  149159. */
  149160. getData(): PhysicsVortexEventData;
  149161. /**
  149162. * Enables the vortex.
  149163. */
  149164. enable(): void;
  149165. /**
  149166. * Disables the cortex.
  149167. */
  149168. disable(): void;
  149169. /**
  149170. * Disposes the sphere.
  149171. * @param force
  149172. */
  149173. dispose(force?: boolean): void;
  149174. private getImpostorHitData;
  149175. private _tick;
  149176. /*** Helpers ***/
  149177. private _prepareCylinder;
  149178. private _intersectsWithCylinder;
  149179. }
  149180. /**
  149181. * Options fot the radial explosion event
  149182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149183. */
  149184. export class PhysicsRadialExplosionEventOptions {
  149185. /**
  149186. * The radius of the sphere for the radial explosion.
  149187. */
  149188. radius: number;
  149189. /**
  149190. * The strenth of the explosion.
  149191. */
  149192. strength: number;
  149193. /**
  149194. * The strenght of the force in correspondence to the distance of the affected object
  149195. */
  149196. falloff: PhysicsRadialImpulseFalloff;
  149197. /**
  149198. * Sphere options for the radial explosion.
  149199. */
  149200. sphere: {
  149201. segments: number;
  149202. diameter: number;
  149203. };
  149204. /**
  149205. * Sphere options for the radial explosion.
  149206. */
  149207. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149208. }
  149209. /**
  149210. * Options fot the updraft event
  149211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149212. */
  149213. export class PhysicsUpdraftEventOptions {
  149214. /**
  149215. * The radius of the cylinder for the vortex
  149216. */
  149217. radius: number;
  149218. /**
  149219. * The strenth of the updraft.
  149220. */
  149221. strength: number;
  149222. /**
  149223. * The height of the cylinder for the updraft.
  149224. */
  149225. height: number;
  149226. /**
  149227. * The mode for the the updraft.
  149228. */
  149229. updraftMode: PhysicsUpdraftMode;
  149230. }
  149231. /**
  149232. * Options fot the vortex event
  149233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149234. */
  149235. export class PhysicsVortexEventOptions {
  149236. /**
  149237. * The radius of the cylinder for the vortex
  149238. */
  149239. radius: number;
  149240. /**
  149241. * The strenth of the vortex.
  149242. */
  149243. strength: number;
  149244. /**
  149245. * The height of the cylinder for the vortex.
  149246. */
  149247. height: number;
  149248. /**
  149249. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149250. */
  149251. centripetalForceThreshold: number;
  149252. /**
  149253. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149254. */
  149255. centripetalForceMultiplier: number;
  149256. /**
  149257. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149258. */
  149259. centrifugalForceMultiplier: number;
  149260. /**
  149261. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149262. */
  149263. updraftForceMultiplier: number;
  149264. }
  149265. /**
  149266. * The strenght of the force in correspondence to the distance of the affected object
  149267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149268. */
  149269. export enum PhysicsRadialImpulseFalloff {
  149270. /** Defines that impulse is constant in strength across it's whole radius */
  149271. Constant = 0,
  149272. /** Defines that impulse gets weaker if it's further from the origin */
  149273. Linear = 1
  149274. }
  149275. /**
  149276. * The strength of the force in correspondence to the distance of the affected object
  149277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149278. */
  149279. export enum PhysicsUpdraftMode {
  149280. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149281. Center = 0,
  149282. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149283. Perpendicular = 1
  149284. }
  149285. /**
  149286. * Interface for a physics hit data
  149287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149288. */
  149289. export interface PhysicsHitData {
  149290. /**
  149291. * The force applied at the contact point
  149292. */
  149293. force: Vector3;
  149294. /**
  149295. * The contact point
  149296. */
  149297. contactPoint: Vector3;
  149298. /**
  149299. * The distance from the origin to the contact point
  149300. */
  149301. distanceFromOrigin: number;
  149302. }
  149303. /**
  149304. * Interface for radial explosion event data
  149305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149306. */
  149307. export interface PhysicsRadialExplosionEventData {
  149308. /**
  149309. * A sphere used for the radial explosion event
  149310. */
  149311. sphere: Mesh;
  149312. }
  149313. /**
  149314. * Interface for gravitational field event data
  149315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149316. */
  149317. export interface PhysicsGravitationalFieldEventData {
  149318. /**
  149319. * A sphere mesh used for the gravitational field event
  149320. */
  149321. sphere: Mesh;
  149322. }
  149323. /**
  149324. * Interface for updraft event data
  149325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149326. */
  149327. export interface PhysicsUpdraftEventData {
  149328. /**
  149329. * A cylinder used for the updraft event
  149330. */
  149331. cylinder: Mesh;
  149332. }
  149333. /**
  149334. * Interface for vortex event data
  149335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149336. */
  149337. export interface PhysicsVortexEventData {
  149338. /**
  149339. * A cylinder used for the vortex event
  149340. */
  149341. cylinder: Mesh;
  149342. }
  149343. /**
  149344. * Interface for an affected physics impostor
  149345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149346. */
  149347. export interface PhysicsAffectedImpostorWithData {
  149348. /**
  149349. * The impostor affected by the effect
  149350. */
  149351. impostor: PhysicsImpostor;
  149352. /**
  149353. * The data about the hit/horce from the explosion
  149354. */
  149355. hitData: PhysicsHitData;
  149356. }
  149357. }
  149358. declare module BABYLON {
  149359. /** @hidden */
  149360. export var blackAndWhitePixelShader: {
  149361. name: string;
  149362. shader: string;
  149363. };
  149364. }
  149365. declare module BABYLON {
  149366. /**
  149367. * Post process used to render in black and white
  149368. */
  149369. export class BlackAndWhitePostProcess extends PostProcess {
  149370. /**
  149371. * Linear about to convert he result to black and white (default: 1)
  149372. */
  149373. degree: number;
  149374. /**
  149375. * Gets a string identifying the name of the class
  149376. * @returns "BlackAndWhitePostProcess" string
  149377. */
  149378. getClassName(): string;
  149379. /**
  149380. * Creates a black and white post process
  149381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149382. * @param name The name of the effect.
  149383. * @param options The required width/height ratio to downsize to before computing the render pass.
  149384. * @param camera The camera to apply the render pass to.
  149385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149386. * @param engine The engine which the post process will be applied. (default: current engine)
  149387. * @param reusable If the post process can be reused on the same frame. (default: false)
  149388. */
  149389. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149390. /** @hidden */
  149391. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149392. }
  149393. }
  149394. declare module BABYLON {
  149395. /**
  149396. * This represents a set of one or more post processes in Babylon.
  149397. * A post process can be used to apply a shader to a texture after it is rendered.
  149398. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149399. */
  149400. export class PostProcessRenderEffect {
  149401. private _postProcesses;
  149402. private _getPostProcesses;
  149403. private _singleInstance;
  149404. private _cameras;
  149405. private _indicesForCamera;
  149406. /**
  149407. * Name of the effect
  149408. * @hidden
  149409. */
  149410. _name: string;
  149411. /**
  149412. * Instantiates a post process render effect.
  149413. * A post process can be used to apply a shader to a texture after it is rendered.
  149414. * @param engine The engine the effect is tied to
  149415. * @param name The name of the effect
  149416. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149417. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149418. */
  149419. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149420. /**
  149421. * Checks if all the post processes in the effect are supported.
  149422. */
  149423. get isSupported(): boolean;
  149424. /**
  149425. * Updates the current state of the effect
  149426. * @hidden
  149427. */
  149428. _update(): void;
  149429. /**
  149430. * Attaches the effect on cameras
  149431. * @param cameras The camera to attach to.
  149432. * @hidden
  149433. */
  149434. _attachCameras(cameras: Camera): void;
  149435. /**
  149436. * Attaches the effect on cameras
  149437. * @param cameras The camera to attach to.
  149438. * @hidden
  149439. */
  149440. _attachCameras(cameras: Camera[]): void;
  149441. /**
  149442. * Detaches the effect on cameras
  149443. * @param cameras The camera to detatch from.
  149444. * @hidden
  149445. */
  149446. _detachCameras(cameras: Camera): void;
  149447. /**
  149448. * Detatches the effect on cameras
  149449. * @param cameras The camera to detatch from.
  149450. * @hidden
  149451. */
  149452. _detachCameras(cameras: Camera[]): void;
  149453. /**
  149454. * Enables the effect on given cameras
  149455. * @param cameras The camera to enable.
  149456. * @hidden
  149457. */
  149458. _enable(cameras: Camera): void;
  149459. /**
  149460. * Enables the effect on given cameras
  149461. * @param cameras The camera to enable.
  149462. * @hidden
  149463. */
  149464. _enable(cameras: Nullable<Camera[]>): void;
  149465. /**
  149466. * Disables the effect on the given cameras
  149467. * @param cameras The camera to disable.
  149468. * @hidden
  149469. */
  149470. _disable(cameras: Camera): void;
  149471. /**
  149472. * Disables the effect on the given cameras
  149473. * @param cameras The camera to disable.
  149474. * @hidden
  149475. */
  149476. _disable(cameras: Nullable<Camera[]>): void;
  149477. /**
  149478. * Gets a list of the post processes contained in the effect.
  149479. * @param camera The camera to get the post processes on.
  149480. * @returns The list of the post processes in the effect.
  149481. */
  149482. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149483. }
  149484. }
  149485. declare module BABYLON {
  149486. /** @hidden */
  149487. export var extractHighlightsPixelShader: {
  149488. name: string;
  149489. shader: string;
  149490. };
  149491. }
  149492. declare module BABYLON {
  149493. /**
  149494. * 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.
  149495. */
  149496. export class ExtractHighlightsPostProcess extends PostProcess {
  149497. /**
  149498. * The luminance threshold, pixels below this value will be set to black.
  149499. */
  149500. threshold: number;
  149501. /** @hidden */
  149502. _exposure: number;
  149503. /**
  149504. * Post process which has the input texture to be used when performing highlight extraction
  149505. * @hidden
  149506. */
  149507. _inputPostProcess: Nullable<PostProcess>;
  149508. /**
  149509. * Gets a string identifying the name of the class
  149510. * @returns "ExtractHighlightsPostProcess" string
  149511. */
  149512. getClassName(): string;
  149513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149514. }
  149515. }
  149516. declare module BABYLON {
  149517. /** @hidden */
  149518. export var bloomMergePixelShader: {
  149519. name: string;
  149520. shader: string;
  149521. };
  149522. }
  149523. declare module BABYLON {
  149524. /**
  149525. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149526. */
  149527. export class BloomMergePostProcess extends PostProcess {
  149528. /** Weight of the bloom to be added to the original input. */
  149529. weight: number;
  149530. /**
  149531. * Gets a string identifying the name of the class
  149532. * @returns "BloomMergePostProcess" string
  149533. */
  149534. getClassName(): string;
  149535. /**
  149536. * Creates a new instance of @see BloomMergePostProcess
  149537. * @param name The name of the effect.
  149538. * @param originalFromInput Post process which's input will be used for the merge.
  149539. * @param blurred Blurred highlights post process which's output will be used.
  149540. * @param weight Weight of the bloom to be added to the original input.
  149541. * @param options The required width/height ratio to downsize to before computing the render pass.
  149542. * @param camera The camera to apply the render pass to.
  149543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149544. * @param engine The engine which the post process will be applied. (default: current engine)
  149545. * @param reusable If the post process can be reused on the same frame. (default: false)
  149546. * @param textureType Type of textures used when performing the post process. (default: 0)
  149547. * @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)
  149548. */
  149549. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149550. /** Weight of the bloom to be added to the original input. */
  149551. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149552. }
  149553. }
  149554. declare module BABYLON {
  149555. /**
  149556. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149557. */
  149558. export class BloomEffect extends PostProcessRenderEffect {
  149559. private bloomScale;
  149560. /**
  149561. * @hidden Internal
  149562. */
  149563. _effects: Array<PostProcess>;
  149564. /**
  149565. * @hidden Internal
  149566. */
  149567. _downscale: ExtractHighlightsPostProcess;
  149568. private _blurX;
  149569. private _blurY;
  149570. private _merge;
  149571. /**
  149572. * The luminance threshold to find bright areas of the image to bloom.
  149573. */
  149574. get threshold(): number;
  149575. set threshold(value: number);
  149576. /**
  149577. * The strength of the bloom.
  149578. */
  149579. get weight(): number;
  149580. set weight(value: number);
  149581. /**
  149582. * Specifies the size of the bloom blur kernel, relative to the final output size
  149583. */
  149584. get kernel(): number;
  149585. set kernel(value: number);
  149586. /**
  149587. * Creates a new instance of @see BloomEffect
  149588. * @param scene The scene the effect belongs to.
  149589. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149590. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149591. * @param bloomWeight The the strength of bloom.
  149592. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149593. * @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)
  149594. */
  149595. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149596. /**
  149597. * Disposes each of the internal effects for a given camera.
  149598. * @param camera The camera to dispose the effect on.
  149599. */
  149600. disposeEffects(camera: Camera): void;
  149601. /**
  149602. * @hidden Internal
  149603. */
  149604. _updateEffects(): void;
  149605. /**
  149606. * Internal
  149607. * @returns if all the contained post processes are ready.
  149608. * @hidden
  149609. */
  149610. _isReady(): boolean;
  149611. }
  149612. }
  149613. declare module BABYLON {
  149614. /** @hidden */
  149615. export var chromaticAberrationPixelShader: {
  149616. name: string;
  149617. shader: string;
  149618. };
  149619. }
  149620. declare module BABYLON {
  149621. /**
  149622. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149623. */
  149624. export class ChromaticAberrationPostProcess extends PostProcess {
  149625. /**
  149626. * The amount of seperation of rgb channels (default: 30)
  149627. */
  149628. aberrationAmount: number;
  149629. /**
  149630. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149631. */
  149632. radialIntensity: number;
  149633. /**
  149634. * 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))
  149635. */
  149636. direction: Vector2;
  149637. /**
  149638. * 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))
  149639. */
  149640. centerPosition: Vector2;
  149641. /** The width of the screen to apply the effect on */
  149642. screenWidth: number;
  149643. /** The height of the screen to apply the effect on */
  149644. screenHeight: number;
  149645. /**
  149646. * Gets a string identifying the name of the class
  149647. * @returns "ChromaticAberrationPostProcess" string
  149648. */
  149649. getClassName(): string;
  149650. /**
  149651. * Creates a new instance ChromaticAberrationPostProcess
  149652. * @param name The name of the effect.
  149653. * @param screenWidth The width of the screen to apply the effect on.
  149654. * @param screenHeight The height of the screen to apply the effect on.
  149655. * @param options The required width/height ratio to downsize to before computing the render pass.
  149656. * @param camera The camera to apply the render pass to.
  149657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149658. * @param engine The engine which the post process will be applied. (default: current engine)
  149659. * @param reusable If the post process can be reused on the same frame. (default: false)
  149660. * @param textureType Type of textures used when performing the post process. (default: 0)
  149661. * @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)
  149662. */
  149663. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149664. /** @hidden */
  149665. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149666. }
  149667. }
  149668. declare module BABYLON {
  149669. /** @hidden */
  149670. export var circleOfConfusionPixelShader: {
  149671. name: string;
  149672. shader: string;
  149673. };
  149674. }
  149675. declare module BABYLON {
  149676. /**
  149677. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149678. */
  149679. export class CircleOfConfusionPostProcess extends PostProcess {
  149680. /**
  149681. * 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.
  149682. */
  149683. lensSize: number;
  149684. /**
  149685. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149686. */
  149687. fStop: number;
  149688. /**
  149689. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149690. */
  149691. focusDistance: number;
  149692. /**
  149693. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149694. */
  149695. focalLength: number;
  149696. /**
  149697. * Gets a string identifying the name of the class
  149698. * @returns "CircleOfConfusionPostProcess" string
  149699. */
  149700. getClassName(): string;
  149701. private _depthTexture;
  149702. /**
  149703. * Creates a new instance CircleOfConfusionPostProcess
  149704. * @param name The name of the effect.
  149705. * @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.
  149706. * @param options The required width/height ratio to downsize to before computing the render pass.
  149707. * @param camera The camera to apply the render pass to.
  149708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149709. * @param engine The engine which the post process will be applied. (default: current engine)
  149710. * @param reusable If the post process can be reused on the same frame. (default: false)
  149711. * @param textureType Type of textures used when performing the post process. (default: 0)
  149712. * @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)
  149713. */
  149714. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149715. /**
  149716. * 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.
  149717. */
  149718. set depthTexture(value: RenderTargetTexture);
  149719. }
  149720. }
  149721. declare module BABYLON {
  149722. /** @hidden */
  149723. export var colorCorrectionPixelShader: {
  149724. name: string;
  149725. shader: string;
  149726. };
  149727. }
  149728. declare module BABYLON {
  149729. /**
  149730. *
  149731. * This post-process allows the modification of rendered colors by using
  149732. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149733. *
  149734. * The object needs to be provided an url to a texture containing the color
  149735. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149736. * Use an image editing software to tweak the LUT to match your needs.
  149737. *
  149738. * For an example of a color LUT, see here:
  149739. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149740. * For explanations on color grading, see here:
  149741. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149742. *
  149743. */
  149744. export class ColorCorrectionPostProcess extends PostProcess {
  149745. private _colorTableTexture;
  149746. /**
  149747. * Gets the color table url used to create the LUT texture
  149748. */
  149749. colorTableUrl: string;
  149750. /**
  149751. * Gets a string identifying the name of the class
  149752. * @returns "ColorCorrectionPostProcess" string
  149753. */
  149754. getClassName(): string;
  149755. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149756. /** @hidden */
  149757. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149758. }
  149759. }
  149760. declare module BABYLON {
  149761. /** @hidden */
  149762. export var convolutionPixelShader: {
  149763. name: string;
  149764. shader: string;
  149765. };
  149766. }
  149767. declare module BABYLON {
  149768. /**
  149769. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149770. * input texture to perform effects such as edge detection or sharpening
  149771. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149772. */
  149773. export class ConvolutionPostProcess extends PostProcess {
  149774. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149775. kernel: number[];
  149776. /**
  149777. * Gets a string identifying the name of the class
  149778. * @returns "ConvolutionPostProcess" string
  149779. */
  149780. getClassName(): string;
  149781. /**
  149782. * Creates a new instance ConvolutionPostProcess
  149783. * @param name The name of the effect.
  149784. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149785. * @param options The required width/height ratio to downsize to before computing the render pass.
  149786. * @param camera The camera to apply the render pass to.
  149787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149788. * @param engine The engine which the post process will be applied. (default: current engine)
  149789. * @param reusable If the post process can be reused on the same frame. (default: false)
  149790. * @param textureType Type of textures used when performing the post process. (default: 0)
  149791. */
  149792. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149793. /** @hidden */
  149794. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149795. /**
  149796. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149797. */
  149798. static EdgeDetect0Kernel: number[];
  149799. /**
  149800. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149801. */
  149802. static EdgeDetect1Kernel: number[];
  149803. /**
  149804. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149805. */
  149806. static EdgeDetect2Kernel: number[];
  149807. /**
  149808. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149809. */
  149810. static SharpenKernel: number[];
  149811. /**
  149812. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149813. */
  149814. static EmbossKernel: number[];
  149815. /**
  149816. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149817. */
  149818. static GaussianKernel: number[];
  149819. }
  149820. }
  149821. declare module BABYLON {
  149822. /**
  149823. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149824. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149825. * based on samples that have a large difference in distance than the center pixel.
  149826. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149827. */
  149828. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149829. /**
  149830. * The direction the blur should be applied
  149831. */
  149832. direction: Vector2;
  149833. /**
  149834. * Gets a string identifying the name of the class
  149835. * @returns "DepthOfFieldBlurPostProcess" string
  149836. */
  149837. getClassName(): string;
  149838. /**
  149839. * Creates a new instance CircleOfConfusionPostProcess
  149840. * @param name The name of the effect.
  149841. * @param scene The scene the effect belongs to.
  149842. * @param direction The direction the blur should be applied.
  149843. * @param kernel The size of the kernel used to blur.
  149844. * @param options The required width/height ratio to downsize to before computing the render pass.
  149845. * @param camera The camera to apply the render pass to.
  149846. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149847. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149849. * @param engine The engine which the post process will be applied. (default: current engine)
  149850. * @param reusable If the post process can be reused on the same frame. (default: false)
  149851. * @param textureType Type of textures used when performing the post process. (default: 0)
  149852. * @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)
  149853. */
  149854. 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);
  149855. }
  149856. }
  149857. declare module BABYLON {
  149858. /** @hidden */
  149859. export var depthOfFieldMergePixelShader: {
  149860. name: string;
  149861. shader: string;
  149862. };
  149863. }
  149864. declare module BABYLON {
  149865. /**
  149866. * Options to be set when merging outputs from the default pipeline.
  149867. */
  149868. export class DepthOfFieldMergePostProcessOptions {
  149869. /**
  149870. * The original image to merge on top of
  149871. */
  149872. originalFromInput: PostProcess;
  149873. /**
  149874. * Parameters to perform the merge of the depth of field effect
  149875. */
  149876. depthOfField?: {
  149877. circleOfConfusion: PostProcess;
  149878. blurSteps: Array<PostProcess>;
  149879. };
  149880. /**
  149881. * Parameters to perform the merge of bloom effect
  149882. */
  149883. bloom?: {
  149884. blurred: PostProcess;
  149885. weight: number;
  149886. };
  149887. }
  149888. /**
  149889. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149890. */
  149891. export class DepthOfFieldMergePostProcess extends PostProcess {
  149892. private blurSteps;
  149893. /**
  149894. * Gets a string identifying the name of the class
  149895. * @returns "DepthOfFieldMergePostProcess" string
  149896. */
  149897. getClassName(): string;
  149898. /**
  149899. * Creates a new instance of DepthOfFieldMergePostProcess
  149900. * @param name The name of the effect.
  149901. * @param originalFromInput Post process which's input will be used for the merge.
  149902. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149903. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149904. * @param options The required width/height ratio to downsize to before computing the render pass.
  149905. * @param camera The camera to apply the render pass to.
  149906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149907. * @param engine The engine which the post process will be applied. (default: current engine)
  149908. * @param reusable If the post process can be reused on the same frame. (default: false)
  149909. * @param textureType Type of textures used when performing the post process. (default: 0)
  149910. * @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)
  149911. */
  149912. 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);
  149913. /**
  149914. * Updates the effect with the current post process compile time values and recompiles the shader.
  149915. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149916. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149917. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149918. * @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
  149919. * @param onCompiled Called when the shader has been compiled.
  149920. * @param onError Called if there is an error when compiling a shader.
  149921. */
  149922. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149923. }
  149924. }
  149925. declare module BABYLON {
  149926. /**
  149927. * Specifies the level of max blur that should be applied when using the depth of field effect
  149928. */
  149929. export enum DepthOfFieldEffectBlurLevel {
  149930. /**
  149931. * Subtle blur
  149932. */
  149933. Low = 0,
  149934. /**
  149935. * Medium blur
  149936. */
  149937. Medium = 1,
  149938. /**
  149939. * Large blur
  149940. */
  149941. High = 2
  149942. }
  149943. /**
  149944. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149945. */
  149946. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149947. private _circleOfConfusion;
  149948. /**
  149949. * @hidden Internal, blurs from high to low
  149950. */
  149951. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149952. private _depthOfFieldBlurY;
  149953. private _dofMerge;
  149954. /**
  149955. * @hidden Internal post processes in depth of field effect
  149956. */
  149957. _effects: Array<PostProcess>;
  149958. /**
  149959. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149960. */
  149961. set focalLength(value: number);
  149962. get focalLength(): number;
  149963. /**
  149964. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149965. */
  149966. set fStop(value: number);
  149967. get fStop(): number;
  149968. /**
  149969. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149970. */
  149971. set focusDistance(value: number);
  149972. get focusDistance(): number;
  149973. /**
  149974. * 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.
  149975. */
  149976. set lensSize(value: number);
  149977. get lensSize(): number;
  149978. /**
  149979. * Creates a new instance DepthOfFieldEffect
  149980. * @param scene The scene the effect belongs to.
  149981. * @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.
  149982. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149983. * @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)
  149984. */
  149985. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149986. /**
  149987. * Get the current class name of the current effet
  149988. * @returns "DepthOfFieldEffect"
  149989. */
  149990. getClassName(): string;
  149991. /**
  149992. * 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.
  149993. */
  149994. set depthTexture(value: RenderTargetTexture);
  149995. /**
  149996. * Disposes each of the internal effects for a given camera.
  149997. * @param camera The camera to dispose the effect on.
  149998. */
  149999. disposeEffects(camera: Camera): void;
  150000. /**
  150001. * @hidden Internal
  150002. */
  150003. _updateEffects(): void;
  150004. /**
  150005. * Internal
  150006. * @returns if all the contained post processes are ready.
  150007. * @hidden
  150008. */
  150009. _isReady(): boolean;
  150010. }
  150011. }
  150012. declare module BABYLON {
  150013. /** @hidden */
  150014. export var displayPassPixelShader: {
  150015. name: string;
  150016. shader: string;
  150017. };
  150018. }
  150019. declare module BABYLON {
  150020. /**
  150021. * DisplayPassPostProcess which produces an output the same as it's input
  150022. */
  150023. export class DisplayPassPostProcess extends PostProcess {
  150024. /**
  150025. * Gets a string identifying the name of the class
  150026. * @returns "DisplayPassPostProcess" string
  150027. */
  150028. getClassName(): string;
  150029. /**
  150030. * Creates the DisplayPassPostProcess
  150031. * @param name The name of the effect.
  150032. * @param options The required width/height ratio to downsize to before computing the render pass.
  150033. * @param camera The camera to apply the render pass to.
  150034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150035. * @param engine The engine which the post process will be applied. (default: current engine)
  150036. * @param reusable If the post process can be reused on the same frame. (default: false)
  150037. */
  150038. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150039. /** @hidden */
  150040. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150041. }
  150042. }
  150043. declare module BABYLON {
  150044. /** @hidden */
  150045. export var filterPixelShader: {
  150046. name: string;
  150047. shader: string;
  150048. };
  150049. }
  150050. declare module BABYLON {
  150051. /**
  150052. * Applies a kernel filter to the image
  150053. */
  150054. export class FilterPostProcess extends PostProcess {
  150055. /** The matrix to be applied to the image */
  150056. kernelMatrix: Matrix;
  150057. /**
  150058. * Gets a string identifying the name of the class
  150059. * @returns "FilterPostProcess" string
  150060. */
  150061. getClassName(): string;
  150062. /**
  150063. *
  150064. * @param name The name of the effect.
  150065. * @param kernelMatrix The matrix to be applied to the image
  150066. * @param options The required width/height ratio to downsize to before computing the render pass.
  150067. * @param camera The camera to apply the render pass to.
  150068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150069. * @param engine The engine which the post process will be applied. (default: current engine)
  150070. * @param reusable If the post process can be reused on the same frame. (default: false)
  150071. */
  150072. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150073. /** @hidden */
  150074. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150075. }
  150076. }
  150077. declare module BABYLON {
  150078. /** @hidden */
  150079. export var fxaaPixelShader: {
  150080. name: string;
  150081. shader: string;
  150082. };
  150083. }
  150084. declare module BABYLON {
  150085. /** @hidden */
  150086. export var fxaaVertexShader: {
  150087. name: string;
  150088. shader: string;
  150089. };
  150090. }
  150091. declare module BABYLON {
  150092. /**
  150093. * Fxaa post process
  150094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150095. */
  150096. export class FxaaPostProcess extends PostProcess {
  150097. /**
  150098. * Gets a string identifying the name of the class
  150099. * @returns "FxaaPostProcess" string
  150100. */
  150101. getClassName(): string;
  150102. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150103. private _getDefines;
  150104. /** @hidden */
  150105. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150106. }
  150107. }
  150108. declare module BABYLON {
  150109. /** @hidden */
  150110. export var grainPixelShader: {
  150111. name: string;
  150112. shader: string;
  150113. };
  150114. }
  150115. declare module BABYLON {
  150116. /**
  150117. * The GrainPostProcess adds noise to the image at mid luminance levels
  150118. */
  150119. export class GrainPostProcess extends PostProcess {
  150120. /**
  150121. * The intensity of the grain added (default: 30)
  150122. */
  150123. intensity: number;
  150124. /**
  150125. * If the grain should be randomized on every frame
  150126. */
  150127. animated: boolean;
  150128. /**
  150129. * Gets a string identifying the name of the class
  150130. * @returns "GrainPostProcess" string
  150131. */
  150132. getClassName(): string;
  150133. /**
  150134. * Creates a new instance of @see GrainPostProcess
  150135. * @param name The name of the effect.
  150136. * @param options The required width/height ratio to downsize to before computing the render pass.
  150137. * @param camera The camera to apply the render pass to.
  150138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150139. * @param engine The engine which the post process will be applied. (default: current engine)
  150140. * @param reusable If the post process can be reused on the same frame. (default: false)
  150141. * @param textureType Type of textures used when performing the post process. (default: 0)
  150142. * @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)
  150143. */
  150144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150145. /** @hidden */
  150146. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150147. }
  150148. }
  150149. declare module BABYLON {
  150150. /** @hidden */
  150151. export var highlightsPixelShader: {
  150152. name: string;
  150153. shader: string;
  150154. };
  150155. }
  150156. declare module BABYLON {
  150157. /**
  150158. * Extracts highlights from the image
  150159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150160. */
  150161. export class HighlightsPostProcess extends PostProcess {
  150162. /**
  150163. * Gets a string identifying the name of the class
  150164. * @returns "HighlightsPostProcess" string
  150165. */
  150166. getClassName(): string;
  150167. /**
  150168. * Extracts highlights from the image
  150169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150170. * @param name The name of the effect.
  150171. * @param options The required width/height ratio to downsize to before computing the render pass.
  150172. * @param camera The camera to apply the render pass to.
  150173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150174. * @param engine The engine which the post process will be applied. (default: current engine)
  150175. * @param reusable If the post process can be reused on the same frame. (default: false)
  150176. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150177. */
  150178. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150179. }
  150180. }
  150181. declare module BABYLON {
  150182. /** @hidden */
  150183. export var mrtFragmentDeclaration: {
  150184. name: string;
  150185. shader: string;
  150186. };
  150187. }
  150188. declare module BABYLON {
  150189. /** @hidden */
  150190. export var geometryPixelShader: {
  150191. name: string;
  150192. shader: string;
  150193. };
  150194. }
  150195. declare module BABYLON {
  150196. /** @hidden */
  150197. export var geometryVertexShader: {
  150198. name: string;
  150199. shader: string;
  150200. };
  150201. }
  150202. declare module BABYLON {
  150203. /** @hidden */
  150204. interface ISavedTransformationMatrix {
  150205. world: Matrix;
  150206. viewProjection: Matrix;
  150207. }
  150208. /**
  150209. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150210. */
  150211. export class GeometryBufferRenderer {
  150212. /**
  150213. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150214. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150215. */
  150216. static readonly POSITION_TEXTURE_TYPE: number;
  150217. /**
  150218. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150219. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150220. */
  150221. static readonly VELOCITY_TEXTURE_TYPE: number;
  150222. /**
  150223. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150224. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150225. */
  150226. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150227. /**
  150228. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150229. * in order to compute objects velocities when enableVelocity is set to "true"
  150230. * @hidden
  150231. */
  150232. _previousTransformationMatrices: {
  150233. [index: number]: ISavedTransformationMatrix;
  150234. };
  150235. /**
  150236. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150237. * in order to compute objects velocities when enableVelocity is set to "true"
  150238. * @hidden
  150239. */
  150240. _previousBonesTransformationMatrices: {
  150241. [index: number]: Float32Array;
  150242. };
  150243. /**
  150244. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150245. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150246. */
  150247. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150248. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150249. renderTransparentMeshes: boolean;
  150250. private _scene;
  150251. private _resizeObserver;
  150252. private _multiRenderTarget;
  150253. private _ratio;
  150254. private _enablePosition;
  150255. private _enableVelocity;
  150256. private _enableReflectivity;
  150257. private _positionIndex;
  150258. private _velocityIndex;
  150259. private _reflectivityIndex;
  150260. protected _effect: Effect;
  150261. protected _cachedDefines: string;
  150262. /**
  150263. * Set the render list (meshes to be rendered) used in the G buffer.
  150264. */
  150265. set renderList(meshes: Mesh[]);
  150266. /**
  150267. * Gets wether or not G buffer are supported by the running hardware.
  150268. * This requires draw buffer supports
  150269. */
  150270. get isSupported(): boolean;
  150271. /**
  150272. * Returns the index of the given texture type in the G-Buffer textures array
  150273. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150274. * @returns the index of the given texture type in the G-Buffer textures array
  150275. */
  150276. getTextureIndex(textureType: number): number;
  150277. /**
  150278. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150279. */
  150280. get enablePosition(): boolean;
  150281. /**
  150282. * Sets whether or not objects positions are enabled for the G buffer.
  150283. */
  150284. set enablePosition(enable: boolean);
  150285. /**
  150286. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150287. */
  150288. get enableVelocity(): boolean;
  150289. /**
  150290. * Sets wether or not objects velocities are enabled for the G buffer.
  150291. */
  150292. set enableVelocity(enable: boolean);
  150293. /**
  150294. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150295. */
  150296. get enableReflectivity(): boolean;
  150297. /**
  150298. * Sets wether or not objects roughness are enabled for the G buffer.
  150299. */
  150300. set enableReflectivity(enable: boolean);
  150301. /**
  150302. * Gets the scene associated with the buffer.
  150303. */
  150304. get scene(): Scene;
  150305. /**
  150306. * Gets the ratio used by the buffer during its creation.
  150307. * How big is the buffer related to the main canvas.
  150308. */
  150309. get ratio(): number;
  150310. /** @hidden */
  150311. static _SceneComponentInitialization: (scene: Scene) => void;
  150312. /**
  150313. * Creates a new G Buffer for the scene
  150314. * @param scene The scene the buffer belongs to
  150315. * @param ratio How big is the buffer related to the main canvas.
  150316. */
  150317. constructor(scene: Scene, ratio?: number);
  150318. /**
  150319. * Checks wether everything is ready to render a submesh to the G buffer.
  150320. * @param subMesh the submesh to check readiness for
  150321. * @param useInstances is the mesh drawn using instance or not
  150322. * @returns true if ready otherwise false
  150323. */
  150324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150325. /**
  150326. * Gets the current underlying G Buffer.
  150327. * @returns the buffer
  150328. */
  150329. getGBuffer(): MultiRenderTarget;
  150330. /**
  150331. * Gets the number of samples used to render the buffer (anti aliasing).
  150332. */
  150333. get samples(): number;
  150334. /**
  150335. * Sets the number of samples used to render the buffer (anti aliasing).
  150336. */
  150337. set samples(value: number);
  150338. /**
  150339. * Disposes the renderer and frees up associated resources.
  150340. */
  150341. dispose(): void;
  150342. protected _createRenderTargets(): void;
  150343. private _copyBonesTransformationMatrices;
  150344. }
  150345. }
  150346. declare module BABYLON {
  150347. interface Scene {
  150348. /** @hidden (Backing field) */
  150349. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150350. /**
  150351. * Gets or Sets the current geometry buffer associated to the scene.
  150352. */
  150353. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150354. /**
  150355. * Enables a GeometryBufferRender and associates it with the scene
  150356. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150357. * @returns the GeometryBufferRenderer
  150358. */
  150359. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150360. /**
  150361. * Disables the GeometryBufferRender associated with the scene
  150362. */
  150363. disableGeometryBufferRenderer(): void;
  150364. }
  150365. /**
  150366. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150367. * in several rendering techniques.
  150368. */
  150369. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150370. /**
  150371. * The component name helpful to identify the component in the list of scene components.
  150372. */
  150373. readonly name: string;
  150374. /**
  150375. * The scene the component belongs to.
  150376. */
  150377. scene: Scene;
  150378. /**
  150379. * Creates a new instance of the component for the given scene
  150380. * @param scene Defines the scene to register the component in
  150381. */
  150382. constructor(scene: Scene);
  150383. /**
  150384. * Registers the component in a given scene
  150385. */
  150386. register(): void;
  150387. /**
  150388. * Rebuilds the elements related to this component in case of
  150389. * context lost for instance.
  150390. */
  150391. rebuild(): void;
  150392. /**
  150393. * Disposes the component and the associated ressources
  150394. */
  150395. dispose(): void;
  150396. private _gatherRenderTargets;
  150397. }
  150398. }
  150399. declare module BABYLON {
  150400. /** @hidden */
  150401. export var motionBlurPixelShader: {
  150402. name: string;
  150403. shader: string;
  150404. };
  150405. }
  150406. declare module BABYLON {
  150407. /**
  150408. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150409. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150410. * As an example, all you have to do is to create the post-process:
  150411. * var mb = new BABYLON.MotionBlurPostProcess(
  150412. * 'mb', // The name of the effect.
  150413. * scene, // The scene containing the objects to blur according to their velocity.
  150414. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150415. * camera // The camera to apply the render pass to.
  150416. * );
  150417. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150418. */
  150419. export class MotionBlurPostProcess extends PostProcess {
  150420. /**
  150421. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150422. */
  150423. motionStrength: number;
  150424. /**
  150425. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150426. */
  150427. get motionBlurSamples(): number;
  150428. /**
  150429. * Sets the number of iterations to be used for motion blur quality
  150430. */
  150431. set motionBlurSamples(samples: number);
  150432. private _motionBlurSamples;
  150433. private _geometryBufferRenderer;
  150434. /**
  150435. * Gets a string identifying the name of the class
  150436. * @returns "MotionBlurPostProcess" string
  150437. */
  150438. getClassName(): string;
  150439. /**
  150440. * Creates a new instance MotionBlurPostProcess
  150441. * @param name The name of the effect.
  150442. * @param scene The scene containing the objects to blur according to their velocity.
  150443. * @param options The required width/height ratio to downsize to before computing the render pass.
  150444. * @param camera The camera to apply the render pass to.
  150445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150446. * @param engine The engine which the post process will be applied. (default: current engine)
  150447. * @param reusable If the post process can be reused on the same frame. (default: false)
  150448. * @param textureType Type of textures used when performing the post process. (default: 0)
  150449. * @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)
  150450. */
  150451. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150452. /**
  150453. * Excludes the given skinned mesh from computing bones velocities.
  150454. * 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.
  150455. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150456. */
  150457. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150458. /**
  150459. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150460. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150461. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150462. */
  150463. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150464. /**
  150465. * Disposes the post process.
  150466. * @param camera The camera to dispose the post process on.
  150467. */
  150468. dispose(camera?: Camera): void;
  150469. /** @hidden */
  150470. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150471. }
  150472. }
  150473. declare module BABYLON {
  150474. /** @hidden */
  150475. export var refractionPixelShader: {
  150476. name: string;
  150477. shader: string;
  150478. };
  150479. }
  150480. declare module BABYLON {
  150481. /**
  150482. * Post process which applies a refractin texture
  150483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150484. */
  150485. export class RefractionPostProcess extends PostProcess {
  150486. private _refTexture;
  150487. private _ownRefractionTexture;
  150488. /** the base color of the refraction (used to taint the rendering) */
  150489. color: Color3;
  150490. /** simulated refraction depth */
  150491. depth: number;
  150492. /** the coefficient of the base color (0 to remove base color tainting) */
  150493. colorLevel: number;
  150494. /** Gets the url used to load the refraction texture */
  150495. refractionTextureUrl: string;
  150496. /**
  150497. * Gets or sets the refraction texture
  150498. * Please note that you are responsible for disposing the texture if you set it manually
  150499. */
  150500. get refractionTexture(): Texture;
  150501. set refractionTexture(value: Texture);
  150502. /**
  150503. * Gets a string identifying the name of the class
  150504. * @returns "RefractionPostProcess" string
  150505. */
  150506. getClassName(): string;
  150507. /**
  150508. * Initializes the RefractionPostProcess
  150509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150510. * @param name The name of the effect.
  150511. * @param refractionTextureUrl Url of the refraction texture to use
  150512. * @param color the base color of the refraction (used to taint the rendering)
  150513. * @param depth simulated refraction depth
  150514. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150515. * @param camera The camera to apply the render pass to.
  150516. * @param options The required width/height ratio to downsize to before computing the render pass.
  150517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150518. * @param engine The engine which the post process will be applied. (default: current engine)
  150519. * @param reusable If the post process can be reused on the same frame. (default: false)
  150520. */
  150521. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150522. /**
  150523. * Disposes of the post process
  150524. * @param camera Camera to dispose post process on
  150525. */
  150526. dispose(camera: Camera): void;
  150527. /** @hidden */
  150528. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150529. }
  150530. }
  150531. declare module BABYLON {
  150532. /** @hidden */
  150533. export var sharpenPixelShader: {
  150534. name: string;
  150535. shader: string;
  150536. };
  150537. }
  150538. declare module BABYLON {
  150539. /**
  150540. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150541. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150542. */
  150543. export class SharpenPostProcess extends PostProcess {
  150544. /**
  150545. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150546. */
  150547. colorAmount: number;
  150548. /**
  150549. * How much sharpness should be applied (default: 0.3)
  150550. */
  150551. edgeAmount: number;
  150552. /**
  150553. * Gets a string identifying the name of the class
  150554. * @returns "SharpenPostProcess" string
  150555. */
  150556. getClassName(): string;
  150557. /**
  150558. * Creates a new instance ConvolutionPostProcess
  150559. * @param name The name of the effect.
  150560. * @param options The required width/height ratio to downsize to before computing the render pass.
  150561. * @param camera The camera to apply the render pass to.
  150562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150563. * @param engine The engine which the post process will be applied. (default: current engine)
  150564. * @param reusable If the post process can be reused on the same frame. (default: false)
  150565. * @param textureType Type of textures used when performing the post process. (default: 0)
  150566. * @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)
  150567. */
  150568. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150569. /** @hidden */
  150570. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150571. }
  150572. }
  150573. declare module BABYLON {
  150574. /**
  150575. * PostProcessRenderPipeline
  150576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150577. */
  150578. export class PostProcessRenderPipeline {
  150579. private engine;
  150580. private _renderEffects;
  150581. private _renderEffectsForIsolatedPass;
  150582. /**
  150583. * List of inspectable custom properties (used by the Inspector)
  150584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150585. */
  150586. inspectableCustomProperties: IInspectable[];
  150587. /**
  150588. * @hidden
  150589. */
  150590. protected _cameras: Camera[];
  150591. /** @hidden */
  150592. _name: string;
  150593. /**
  150594. * Gets pipeline name
  150595. */
  150596. get name(): string;
  150597. /** Gets the list of attached cameras */
  150598. get cameras(): Camera[];
  150599. /**
  150600. * Initializes a PostProcessRenderPipeline
  150601. * @param engine engine to add the pipeline to
  150602. * @param name name of the pipeline
  150603. */
  150604. constructor(engine: Engine, name: string);
  150605. /**
  150606. * Gets the class name
  150607. * @returns "PostProcessRenderPipeline"
  150608. */
  150609. getClassName(): string;
  150610. /**
  150611. * If all the render effects in the pipeline are supported
  150612. */
  150613. get isSupported(): boolean;
  150614. /**
  150615. * Adds an effect to the pipeline
  150616. * @param renderEffect the effect to add
  150617. */
  150618. addEffect(renderEffect: PostProcessRenderEffect): void;
  150619. /** @hidden */
  150620. _rebuild(): void;
  150621. /** @hidden */
  150622. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150623. /** @hidden */
  150624. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150625. /** @hidden */
  150626. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150627. /** @hidden */
  150628. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150629. /** @hidden */
  150630. _attachCameras(cameras: Camera, unique: boolean): void;
  150631. /** @hidden */
  150632. _attachCameras(cameras: Camera[], unique: boolean): void;
  150633. /** @hidden */
  150634. _detachCameras(cameras: Camera): void;
  150635. /** @hidden */
  150636. _detachCameras(cameras: Nullable<Camera[]>): void;
  150637. /** @hidden */
  150638. _update(): void;
  150639. /** @hidden */
  150640. _reset(): void;
  150641. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150642. /**
  150643. * Sets the required values to the prepass renderer.
  150644. * @param prePassRenderer defines the prepass renderer to setup.
  150645. * @returns true if the pre pass is needed.
  150646. */
  150647. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150648. /**
  150649. * Disposes of the pipeline
  150650. */
  150651. dispose(): void;
  150652. }
  150653. }
  150654. declare module BABYLON {
  150655. /**
  150656. * PostProcessRenderPipelineManager class
  150657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150658. */
  150659. export class PostProcessRenderPipelineManager {
  150660. private _renderPipelines;
  150661. /**
  150662. * Initializes a PostProcessRenderPipelineManager
  150663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150664. */
  150665. constructor();
  150666. /**
  150667. * Gets the list of supported render pipelines
  150668. */
  150669. get supportedPipelines(): PostProcessRenderPipeline[];
  150670. /**
  150671. * Adds a pipeline to the manager
  150672. * @param renderPipeline The pipeline to add
  150673. */
  150674. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150675. /**
  150676. * Attaches a camera to the pipeline
  150677. * @param renderPipelineName The name of the pipeline to attach to
  150678. * @param cameras the camera to attach
  150679. * @param unique if the camera can be attached multiple times to the pipeline
  150680. */
  150681. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150682. /**
  150683. * Detaches a camera from the pipeline
  150684. * @param renderPipelineName The name of the pipeline to detach from
  150685. * @param cameras the camera to detach
  150686. */
  150687. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150688. /**
  150689. * Enables an effect by name on a pipeline
  150690. * @param renderPipelineName the name of the pipeline to enable the effect in
  150691. * @param renderEffectName the name of the effect to enable
  150692. * @param cameras the cameras that the effect should be enabled on
  150693. */
  150694. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150695. /**
  150696. * Disables an effect by name on a pipeline
  150697. * @param renderPipelineName the name of the pipeline to disable the effect in
  150698. * @param renderEffectName the name of the effect to disable
  150699. * @param cameras the cameras that the effect should be disabled on
  150700. */
  150701. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150702. /**
  150703. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150704. */
  150705. update(): void;
  150706. /** @hidden */
  150707. _rebuild(): void;
  150708. /**
  150709. * Disposes of the manager and pipelines
  150710. */
  150711. dispose(): void;
  150712. }
  150713. }
  150714. declare module BABYLON {
  150715. interface Scene {
  150716. /** @hidden (Backing field) */
  150717. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150718. /**
  150719. * Gets the postprocess render pipeline manager
  150720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150721. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150722. */
  150723. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150724. }
  150725. /**
  150726. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150727. */
  150728. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150729. /**
  150730. * The component name helpfull to identify the component in the list of scene components.
  150731. */
  150732. readonly name: string;
  150733. /**
  150734. * The scene the component belongs to.
  150735. */
  150736. scene: Scene;
  150737. /**
  150738. * Creates a new instance of the component for the given scene
  150739. * @param scene Defines the scene to register the component in
  150740. */
  150741. constructor(scene: Scene);
  150742. /**
  150743. * Registers the component in a given scene
  150744. */
  150745. register(): void;
  150746. /**
  150747. * Rebuilds the elements related to this component in case of
  150748. * context lost for instance.
  150749. */
  150750. rebuild(): void;
  150751. /**
  150752. * Disposes the component and the associated ressources
  150753. */
  150754. dispose(): void;
  150755. private _gatherRenderTargets;
  150756. }
  150757. }
  150758. declare module BABYLON {
  150759. /**
  150760. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150761. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150762. */
  150763. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150764. private _scene;
  150765. private _camerasToBeAttached;
  150766. /**
  150767. * ID of the sharpen post process,
  150768. */
  150769. private readonly SharpenPostProcessId;
  150770. /**
  150771. * @ignore
  150772. * ID of the image processing post process;
  150773. */
  150774. readonly ImageProcessingPostProcessId: string;
  150775. /**
  150776. * @ignore
  150777. * ID of the Fast Approximate Anti-Aliasing post process;
  150778. */
  150779. readonly FxaaPostProcessId: string;
  150780. /**
  150781. * ID of the chromatic aberration post process,
  150782. */
  150783. private readonly ChromaticAberrationPostProcessId;
  150784. /**
  150785. * ID of the grain post process
  150786. */
  150787. private readonly GrainPostProcessId;
  150788. /**
  150789. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150790. */
  150791. sharpen: SharpenPostProcess;
  150792. private _sharpenEffect;
  150793. private bloom;
  150794. /**
  150795. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150796. */
  150797. depthOfField: DepthOfFieldEffect;
  150798. /**
  150799. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150800. */
  150801. fxaa: FxaaPostProcess;
  150802. /**
  150803. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150804. */
  150805. imageProcessing: ImageProcessingPostProcess;
  150806. /**
  150807. * Chromatic aberration post process which will shift rgb colors in the image
  150808. */
  150809. chromaticAberration: ChromaticAberrationPostProcess;
  150810. private _chromaticAberrationEffect;
  150811. /**
  150812. * Grain post process which add noise to the image
  150813. */
  150814. grain: GrainPostProcess;
  150815. private _grainEffect;
  150816. /**
  150817. * Glow post process which adds a glow to emissive areas of the image
  150818. */
  150819. private _glowLayer;
  150820. /**
  150821. * Animations which can be used to tweak settings over a period of time
  150822. */
  150823. animations: Animation[];
  150824. private _imageProcessingConfigurationObserver;
  150825. private _sharpenEnabled;
  150826. private _bloomEnabled;
  150827. private _depthOfFieldEnabled;
  150828. private _depthOfFieldBlurLevel;
  150829. private _fxaaEnabled;
  150830. private _imageProcessingEnabled;
  150831. private _defaultPipelineTextureType;
  150832. private _bloomScale;
  150833. private _chromaticAberrationEnabled;
  150834. private _grainEnabled;
  150835. private _buildAllowed;
  150836. /**
  150837. * Gets active scene
  150838. */
  150839. get scene(): Scene;
  150840. /**
  150841. * Enable or disable the sharpen process from the pipeline
  150842. */
  150843. set sharpenEnabled(enabled: boolean);
  150844. get sharpenEnabled(): boolean;
  150845. private _resizeObserver;
  150846. private _hardwareScaleLevel;
  150847. private _bloomKernel;
  150848. /**
  150849. * Specifies the size of the bloom blur kernel, relative to the final output size
  150850. */
  150851. get bloomKernel(): number;
  150852. set bloomKernel(value: number);
  150853. /**
  150854. * Specifies the weight of the bloom in the final rendering
  150855. */
  150856. private _bloomWeight;
  150857. /**
  150858. * Specifies the luma threshold for the area that will be blurred by the bloom
  150859. */
  150860. private _bloomThreshold;
  150861. private _hdr;
  150862. /**
  150863. * The strength of the bloom.
  150864. */
  150865. set bloomWeight(value: number);
  150866. get bloomWeight(): number;
  150867. /**
  150868. * The strength of the bloom.
  150869. */
  150870. set bloomThreshold(value: number);
  150871. get bloomThreshold(): number;
  150872. /**
  150873. * The scale of the bloom, lower value will provide better performance.
  150874. */
  150875. set bloomScale(value: number);
  150876. get bloomScale(): number;
  150877. /**
  150878. * Enable or disable the bloom from the pipeline
  150879. */
  150880. set bloomEnabled(enabled: boolean);
  150881. get bloomEnabled(): boolean;
  150882. private _rebuildBloom;
  150883. /**
  150884. * If the depth of field is enabled.
  150885. */
  150886. get depthOfFieldEnabled(): boolean;
  150887. set depthOfFieldEnabled(enabled: boolean);
  150888. /**
  150889. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150890. */
  150891. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150892. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150893. /**
  150894. * If the anti aliasing is enabled.
  150895. */
  150896. set fxaaEnabled(enabled: boolean);
  150897. get fxaaEnabled(): boolean;
  150898. private _samples;
  150899. /**
  150900. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150901. */
  150902. set samples(sampleCount: number);
  150903. get samples(): number;
  150904. /**
  150905. * If image processing is enabled.
  150906. */
  150907. set imageProcessingEnabled(enabled: boolean);
  150908. get imageProcessingEnabled(): boolean;
  150909. /**
  150910. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150911. */
  150912. set glowLayerEnabled(enabled: boolean);
  150913. get glowLayerEnabled(): boolean;
  150914. /**
  150915. * Gets the glow layer (or null if not defined)
  150916. */
  150917. get glowLayer(): Nullable<GlowLayer>;
  150918. /**
  150919. * Enable or disable the chromaticAberration process from the pipeline
  150920. */
  150921. set chromaticAberrationEnabled(enabled: boolean);
  150922. get chromaticAberrationEnabled(): boolean;
  150923. /**
  150924. * Enable or disable the grain process from the pipeline
  150925. */
  150926. set grainEnabled(enabled: boolean);
  150927. get grainEnabled(): boolean;
  150928. /**
  150929. * @constructor
  150930. * @param name - The rendering pipeline name (default: "")
  150931. * @param hdr - If high dynamic range textures should be used (default: true)
  150932. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150933. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150934. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150935. */
  150936. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150937. /**
  150938. * Get the class name
  150939. * @returns "DefaultRenderingPipeline"
  150940. */
  150941. getClassName(): string;
  150942. /**
  150943. * Force the compilation of the entire pipeline.
  150944. */
  150945. prepare(): void;
  150946. private _hasCleared;
  150947. private _prevPostProcess;
  150948. private _prevPrevPostProcess;
  150949. private _setAutoClearAndTextureSharing;
  150950. private _depthOfFieldSceneObserver;
  150951. private _buildPipeline;
  150952. private _disposePostProcesses;
  150953. /**
  150954. * Adds a camera to the pipeline
  150955. * @param camera the camera to be added
  150956. */
  150957. addCamera(camera: Camera): void;
  150958. /**
  150959. * Removes a camera from the pipeline
  150960. * @param camera the camera to remove
  150961. */
  150962. removeCamera(camera: Camera): void;
  150963. /**
  150964. * Dispose of the pipeline and stop all post processes
  150965. */
  150966. dispose(): void;
  150967. /**
  150968. * Serialize the rendering pipeline (Used when exporting)
  150969. * @returns the serialized object
  150970. */
  150971. serialize(): any;
  150972. /**
  150973. * Parse the serialized pipeline
  150974. * @param source Source pipeline.
  150975. * @param scene The scene to load the pipeline to.
  150976. * @param rootUrl The URL of the serialized pipeline.
  150977. * @returns An instantiated pipeline from the serialized object.
  150978. */
  150979. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150980. }
  150981. }
  150982. declare module BABYLON {
  150983. /** @hidden */
  150984. export var lensHighlightsPixelShader: {
  150985. name: string;
  150986. shader: string;
  150987. };
  150988. }
  150989. declare module BABYLON {
  150990. /** @hidden */
  150991. export var depthOfFieldPixelShader: {
  150992. name: string;
  150993. shader: string;
  150994. };
  150995. }
  150996. declare module BABYLON {
  150997. /**
  150998. * BABYLON.JS Chromatic Aberration GLSL Shader
  150999. * Author: Olivier Guyot
  151000. * Separates very slightly R, G and B colors on the edges of the screen
  151001. * Inspired by Francois Tarlier & Martins Upitis
  151002. */
  151003. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151004. /**
  151005. * @ignore
  151006. * The chromatic aberration PostProcess id in the pipeline
  151007. */
  151008. LensChromaticAberrationEffect: string;
  151009. /**
  151010. * @ignore
  151011. * The highlights enhancing PostProcess id in the pipeline
  151012. */
  151013. HighlightsEnhancingEffect: string;
  151014. /**
  151015. * @ignore
  151016. * The depth-of-field PostProcess id in the pipeline
  151017. */
  151018. LensDepthOfFieldEffect: string;
  151019. private _scene;
  151020. private _depthTexture;
  151021. private _grainTexture;
  151022. private _chromaticAberrationPostProcess;
  151023. private _highlightsPostProcess;
  151024. private _depthOfFieldPostProcess;
  151025. private _edgeBlur;
  151026. private _grainAmount;
  151027. private _chromaticAberration;
  151028. private _distortion;
  151029. private _highlightsGain;
  151030. private _highlightsThreshold;
  151031. private _dofDistance;
  151032. private _dofAperture;
  151033. private _dofDarken;
  151034. private _dofPentagon;
  151035. private _blurNoise;
  151036. /**
  151037. * @constructor
  151038. *
  151039. * Effect parameters are as follow:
  151040. * {
  151041. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151042. * edge_blur: number; // from 0 to x (1 for realism)
  151043. * distortion: number; // from 0 to x (1 for realism)
  151044. * grain_amount: number; // from 0 to 1
  151045. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151046. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151047. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151048. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151049. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151050. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151051. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151052. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151053. * }
  151054. * Note: if an effect parameter is unset, effect is disabled
  151055. *
  151056. * @param name The rendering pipeline name
  151057. * @param parameters - An object containing all parameters (see above)
  151058. * @param scene The scene linked to this pipeline
  151059. * @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)
  151060. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151061. */
  151062. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151063. /**
  151064. * Get the class name
  151065. * @returns "LensRenderingPipeline"
  151066. */
  151067. getClassName(): string;
  151068. /**
  151069. * Gets associated scene
  151070. */
  151071. get scene(): Scene;
  151072. /**
  151073. * Gets or sets the edge blur
  151074. */
  151075. get edgeBlur(): number;
  151076. set edgeBlur(value: number);
  151077. /**
  151078. * Gets or sets the grain amount
  151079. */
  151080. get grainAmount(): number;
  151081. set grainAmount(value: number);
  151082. /**
  151083. * Gets or sets the chromatic aberration amount
  151084. */
  151085. get chromaticAberration(): number;
  151086. set chromaticAberration(value: number);
  151087. /**
  151088. * Gets or sets the depth of field aperture
  151089. */
  151090. get dofAperture(): number;
  151091. set dofAperture(value: number);
  151092. /**
  151093. * Gets or sets the edge distortion
  151094. */
  151095. get edgeDistortion(): number;
  151096. set edgeDistortion(value: number);
  151097. /**
  151098. * Gets or sets the depth of field distortion
  151099. */
  151100. get dofDistortion(): number;
  151101. set dofDistortion(value: number);
  151102. /**
  151103. * Gets or sets the darken out of focus amount
  151104. */
  151105. get darkenOutOfFocus(): number;
  151106. set darkenOutOfFocus(value: number);
  151107. /**
  151108. * Gets or sets a boolean indicating if blur noise is enabled
  151109. */
  151110. get blurNoise(): boolean;
  151111. set blurNoise(value: boolean);
  151112. /**
  151113. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151114. */
  151115. get pentagonBokeh(): boolean;
  151116. set pentagonBokeh(value: boolean);
  151117. /**
  151118. * Gets or sets the highlight grain amount
  151119. */
  151120. get highlightsGain(): number;
  151121. set highlightsGain(value: number);
  151122. /**
  151123. * Gets or sets the highlight threshold
  151124. */
  151125. get highlightsThreshold(): number;
  151126. set highlightsThreshold(value: number);
  151127. /**
  151128. * Sets the amount of blur at the edges
  151129. * @param amount blur amount
  151130. */
  151131. setEdgeBlur(amount: number): void;
  151132. /**
  151133. * Sets edge blur to 0
  151134. */
  151135. disableEdgeBlur(): void;
  151136. /**
  151137. * Sets the amout of grain
  151138. * @param amount Amount of grain
  151139. */
  151140. setGrainAmount(amount: number): void;
  151141. /**
  151142. * Set grain amount to 0
  151143. */
  151144. disableGrain(): void;
  151145. /**
  151146. * Sets the chromatic aberration amount
  151147. * @param amount amount of chromatic aberration
  151148. */
  151149. setChromaticAberration(amount: number): void;
  151150. /**
  151151. * Sets chromatic aberration amount to 0
  151152. */
  151153. disableChromaticAberration(): void;
  151154. /**
  151155. * Sets the EdgeDistortion amount
  151156. * @param amount amount of EdgeDistortion
  151157. */
  151158. setEdgeDistortion(amount: number): void;
  151159. /**
  151160. * Sets edge distortion to 0
  151161. */
  151162. disableEdgeDistortion(): void;
  151163. /**
  151164. * Sets the FocusDistance amount
  151165. * @param amount amount of FocusDistance
  151166. */
  151167. setFocusDistance(amount: number): void;
  151168. /**
  151169. * Disables depth of field
  151170. */
  151171. disableDepthOfField(): void;
  151172. /**
  151173. * Sets the Aperture amount
  151174. * @param amount amount of Aperture
  151175. */
  151176. setAperture(amount: number): void;
  151177. /**
  151178. * Sets the DarkenOutOfFocus amount
  151179. * @param amount amount of DarkenOutOfFocus
  151180. */
  151181. setDarkenOutOfFocus(amount: number): void;
  151182. private _pentagonBokehIsEnabled;
  151183. /**
  151184. * Creates a pentagon bokeh effect
  151185. */
  151186. enablePentagonBokeh(): void;
  151187. /**
  151188. * Disables the pentagon bokeh effect
  151189. */
  151190. disablePentagonBokeh(): void;
  151191. /**
  151192. * Enables noise blur
  151193. */
  151194. enableNoiseBlur(): void;
  151195. /**
  151196. * Disables noise blur
  151197. */
  151198. disableNoiseBlur(): void;
  151199. /**
  151200. * Sets the HighlightsGain amount
  151201. * @param amount amount of HighlightsGain
  151202. */
  151203. setHighlightsGain(amount: number): void;
  151204. /**
  151205. * Sets the HighlightsThreshold amount
  151206. * @param amount amount of HighlightsThreshold
  151207. */
  151208. setHighlightsThreshold(amount: number): void;
  151209. /**
  151210. * Disables highlights
  151211. */
  151212. disableHighlights(): void;
  151213. /**
  151214. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151215. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151216. */
  151217. dispose(disableDepthRender?: boolean): void;
  151218. private _createChromaticAberrationPostProcess;
  151219. private _createHighlightsPostProcess;
  151220. private _createDepthOfFieldPostProcess;
  151221. private _createGrainTexture;
  151222. }
  151223. }
  151224. declare module BABYLON {
  151225. /**
  151226. * Contains all parameters needed for the prepass to perform
  151227. * screen space subsurface scattering
  151228. */
  151229. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151230. /**
  151231. * Is subsurface enabled
  151232. */
  151233. enabled: boolean;
  151234. /**
  151235. * Name of the configuration
  151236. */
  151237. name: string;
  151238. /**
  151239. * Textures that should be present in the MRT for this effect to work
  151240. */
  151241. readonly texturesRequired: number[];
  151242. /**
  151243. * Builds a ssao2 configuration object
  151244. * @param scene The scene
  151245. */
  151246. constructor();
  151247. /**
  151248. * Disposes the configuration
  151249. */
  151250. dispose(): void;
  151251. }
  151252. }
  151253. declare module BABYLON {
  151254. /** @hidden */
  151255. export var ssao2PixelShader: {
  151256. name: string;
  151257. shader: string;
  151258. };
  151259. }
  151260. declare module BABYLON {
  151261. /** @hidden */
  151262. export var ssaoCombinePixelShader: {
  151263. name: string;
  151264. shader: string;
  151265. };
  151266. }
  151267. declare module BABYLON {
  151268. /**
  151269. * Render pipeline to produce ssao effect
  151270. */
  151271. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151272. /**
  151273. * @ignore
  151274. * The PassPostProcess id in the pipeline that contains the original scene color
  151275. */
  151276. SSAOOriginalSceneColorEffect: string;
  151277. /**
  151278. * @ignore
  151279. * The SSAO PostProcess id in the pipeline
  151280. */
  151281. SSAORenderEffect: string;
  151282. /**
  151283. * @ignore
  151284. * The horizontal blur PostProcess id in the pipeline
  151285. */
  151286. SSAOBlurHRenderEffect: string;
  151287. /**
  151288. * @ignore
  151289. * The vertical blur PostProcess id in the pipeline
  151290. */
  151291. SSAOBlurVRenderEffect: string;
  151292. /**
  151293. * @ignore
  151294. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151295. */
  151296. SSAOCombineRenderEffect: string;
  151297. /**
  151298. * The output strength of the SSAO post-process. Default value is 1.0.
  151299. */
  151300. totalStrength: number;
  151301. /**
  151302. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151303. */
  151304. maxZ: number;
  151305. /**
  151306. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151307. */
  151308. minZAspect: number;
  151309. private _samples;
  151310. /**
  151311. * Number of samples used for the SSAO calculations. Default value is 8
  151312. */
  151313. set samples(n: number);
  151314. get samples(): number;
  151315. private _textureSamples;
  151316. /**
  151317. * Number of samples to use for antialiasing
  151318. */
  151319. set textureSamples(n: number);
  151320. get textureSamples(): number;
  151321. /**
  151322. * Force rendering the geometry through geometry buffer
  151323. */
  151324. private _forceGeometryBuffer;
  151325. /**
  151326. * Ratio object used for SSAO ratio and blur ratio
  151327. */
  151328. private _ratio;
  151329. /**
  151330. * Dynamically generated sphere sampler.
  151331. */
  151332. private _sampleSphere;
  151333. private _ssao2PrePassConfiguration;
  151334. /**
  151335. * Blur filter offsets
  151336. */
  151337. private _samplerOffsets;
  151338. private _expensiveBlur;
  151339. /**
  151340. * If bilateral blur should be used
  151341. */
  151342. set expensiveBlur(b: boolean);
  151343. get expensiveBlur(): boolean;
  151344. /**
  151345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151346. */
  151347. radius: number;
  151348. /**
  151349. * The base color of the SSAO post-process
  151350. * The final result is "base + ssao" between [0, 1]
  151351. */
  151352. base: number;
  151353. /**
  151354. * Support test.
  151355. */
  151356. static get IsSupported(): boolean;
  151357. private _scene;
  151358. private _randomTexture;
  151359. private _originalColorPostProcess;
  151360. private _ssaoPostProcess;
  151361. private _blurHPostProcess;
  151362. private _blurVPostProcess;
  151363. private _ssaoCombinePostProcess;
  151364. private _prePassRenderer;
  151365. /**
  151366. * Gets active scene
  151367. */
  151368. get scene(): Scene;
  151369. /**
  151370. * @constructor
  151371. * @param name The rendering pipeline name
  151372. * @param scene The scene linked to this pipeline
  151373. * @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 }
  151374. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151375. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151376. */
  151377. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151378. /**
  151379. * Get the class name
  151380. * @returns "SSAO2RenderingPipeline"
  151381. */
  151382. getClassName(): string;
  151383. /**
  151384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151385. */
  151386. dispose(disableGeometryBufferRenderer?: boolean): void;
  151387. private _createBlurPostProcess;
  151388. /** @hidden */
  151389. _rebuild(): void;
  151390. private _bits;
  151391. private _radicalInverse_VdC;
  151392. private _hammersley;
  151393. private _hemisphereSample_uniform;
  151394. private _generateHemisphere;
  151395. private _getDefinesForSSAO;
  151396. private _createSSAOPostProcess;
  151397. private _createSSAOCombinePostProcess;
  151398. private _createRandomTexture;
  151399. /**
  151400. * Serialize the rendering pipeline (Used when exporting)
  151401. * @returns the serialized object
  151402. */
  151403. serialize(): any;
  151404. /**
  151405. * Parse the serialized pipeline
  151406. * @param source Source pipeline.
  151407. * @param scene The scene to load the pipeline to.
  151408. * @param rootUrl The URL of the serialized pipeline.
  151409. * @returns An instantiated pipeline from the serialized object.
  151410. */
  151411. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151412. /**
  151413. * Sets the required values to the prepass renderer.
  151414. * @param prePassRenderer defines the prepass renderer to setup
  151415. * @returns true if the pre pass is needed.
  151416. */
  151417. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151418. }
  151419. }
  151420. declare module BABYLON {
  151421. /** @hidden */
  151422. export var ssaoPixelShader: {
  151423. name: string;
  151424. shader: string;
  151425. };
  151426. }
  151427. declare module BABYLON {
  151428. /**
  151429. * Render pipeline to produce ssao effect
  151430. */
  151431. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151432. /**
  151433. * @ignore
  151434. * The PassPostProcess id in the pipeline that contains the original scene color
  151435. */
  151436. SSAOOriginalSceneColorEffect: string;
  151437. /**
  151438. * @ignore
  151439. * The SSAO PostProcess id in the pipeline
  151440. */
  151441. SSAORenderEffect: string;
  151442. /**
  151443. * @ignore
  151444. * The horizontal blur PostProcess id in the pipeline
  151445. */
  151446. SSAOBlurHRenderEffect: string;
  151447. /**
  151448. * @ignore
  151449. * The vertical blur PostProcess id in the pipeline
  151450. */
  151451. SSAOBlurVRenderEffect: string;
  151452. /**
  151453. * @ignore
  151454. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151455. */
  151456. SSAOCombineRenderEffect: string;
  151457. /**
  151458. * The output strength of the SSAO post-process. Default value is 1.0.
  151459. */
  151460. totalStrength: number;
  151461. /**
  151462. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151463. */
  151464. radius: number;
  151465. /**
  151466. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151467. * Must not be equal to fallOff and superior to fallOff.
  151468. * Default value is 0.0075
  151469. */
  151470. area: number;
  151471. /**
  151472. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151473. * Must not be equal to area and inferior to area.
  151474. * Default value is 0.000001
  151475. */
  151476. fallOff: number;
  151477. /**
  151478. * The base color of the SSAO post-process
  151479. * The final result is "base + ssao" between [0, 1]
  151480. */
  151481. base: number;
  151482. private _scene;
  151483. private _depthTexture;
  151484. private _randomTexture;
  151485. private _originalColorPostProcess;
  151486. private _ssaoPostProcess;
  151487. private _blurHPostProcess;
  151488. private _blurVPostProcess;
  151489. private _ssaoCombinePostProcess;
  151490. private _firstUpdate;
  151491. /**
  151492. * Gets active scene
  151493. */
  151494. get scene(): Scene;
  151495. /**
  151496. * @constructor
  151497. * @param name - The rendering pipeline name
  151498. * @param scene - The scene linked to this pipeline
  151499. * @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 }
  151500. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151501. */
  151502. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151503. /**
  151504. * Get the class name
  151505. * @returns "SSAORenderingPipeline"
  151506. */
  151507. getClassName(): string;
  151508. /**
  151509. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151510. */
  151511. dispose(disableDepthRender?: boolean): void;
  151512. private _createBlurPostProcess;
  151513. /** @hidden */
  151514. _rebuild(): void;
  151515. private _createSSAOPostProcess;
  151516. private _createSSAOCombinePostProcess;
  151517. private _createRandomTexture;
  151518. }
  151519. }
  151520. declare module BABYLON {
  151521. /** @hidden */
  151522. export var screenSpaceReflectionPixelShader: {
  151523. name: string;
  151524. shader: string;
  151525. };
  151526. }
  151527. declare module BABYLON {
  151528. /**
  151529. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151530. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151531. */
  151532. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151533. /**
  151534. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151535. */
  151536. threshold: number;
  151537. /**
  151538. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151539. */
  151540. strength: number;
  151541. /**
  151542. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151543. */
  151544. reflectionSpecularFalloffExponent: number;
  151545. /**
  151546. * 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]
  151547. */
  151548. step: number;
  151549. /**
  151550. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151551. */
  151552. roughnessFactor: number;
  151553. private _geometryBufferRenderer;
  151554. private _enableSmoothReflections;
  151555. private _reflectionSamples;
  151556. private _smoothSteps;
  151557. /**
  151558. * Gets a string identifying the name of the class
  151559. * @returns "ScreenSpaceReflectionPostProcess" string
  151560. */
  151561. getClassName(): string;
  151562. /**
  151563. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151564. * @param name The name of the effect.
  151565. * @param scene The scene containing the objects to calculate reflections.
  151566. * @param options The required width/height ratio to downsize to before computing the render pass.
  151567. * @param camera The camera to apply the render pass to.
  151568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151569. * @param engine The engine which the post process will be applied. (default: current engine)
  151570. * @param reusable If the post process can be reused on the same frame. (default: false)
  151571. * @param textureType Type of textures used when performing the post process. (default: 0)
  151572. * @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)
  151573. */
  151574. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151575. /**
  151576. * Gets wether or not smoothing reflections is enabled.
  151577. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151578. */
  151579. get enableSmoothReflections(): boolean;
  151580. /**
  151581. * Sets wether or not smoothing reflections is enabled.
  151582. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151583. */
  151584. set enableSmoothReflections(enabled: boolean);
  151585. /**
  151586. * Gets the number of samples taken while computing reflections. More samples count is high,
  151587. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151588. */
  151589. get reflectionSamples(): number;
  151590. /**
  151591. * Sets the number of samples taken while computing reflections. More samples count is high,
  151592. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151593. */
  151594. set reflectionSamples(samples: number);
  151595. /**
  151596. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151597. * more the post-process will require GPU power and can generate a drop in FPS.
  151598. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151599. */
  151600. get smoothSteps(): number;
  151601. set smoothSteps(steps: number);
  151602. private _updateEffectDefines;
  151603. /** @hidden */
  151604. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151605. }
  151606. }
  151607. declare module BABYLON {
  151608. /** @hidden */
  151609. export var standardPixelShader: {
  151610. name: string;
  151611. shader: string;
  151612. };
  151613. }
  151614. declare module BABYLON {
  151615. /**
  151616. * Standard rendering pipeline
  151617. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151618. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151619. */
  151620. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151621. /**
  151622. * Public members
  151623. */
  151624. /**
  151625. * Post-process which contains the original scene color before the pipeline applies all the effects
  151626. */
  151627. originalPostProcess: Nullable<PostProcess>;
  151628. /**
  151629. * Post-process used to down scale an image x4
  151630. */
  151631. downSampleX4PostProcess: Nullable<PostProcess>;
  151632. /**
  151633. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151634. */
  151635. brightPassPostProcess: Nullable<PostProcess>;
  151636. /**
  151637. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151638. */
  151639. blurHPostProcesses: PostProcess[];
  151640. /**
  151641. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151642. */
  151643. blurVPostProcesses: PostProcess[];
  151644. /**
  151645. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151646. */
  151647. textureAdderPostProcess: Nullable<PostProcess>;
  151648. /**
  151649. * Post-process used to create volumetric lighting effect
  151650. */
  151651. volumetricLightPostProcess: Nullable<PostProcess>;
  151652. /**
  151653. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151654. */
  151655. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151656. /**
  151657. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151658. */
  151659. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151660. /**
  151661. * Post-process used to merge the volumetric light effect and the real scene color
  151662. */
  151663. volumetricLightMergePostProces: Nullable<PostProcess>;
  151664. /**
  151665. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151666. */
  151667. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151668. /**
  151669. * Base post-process used to calculate the average luminance of the final image for HDR
  151670. */
  151671. luminancePostProcess: Nullable<PostProcess>;
  151672. /**
  151673. * Post-processes used to create down sample post-processes in order to get
  151674. * the average luminance of the final image for HDR
  151675. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151676. */
  151677. luminanceDownSamplePostProcesses: PostProcess[];
  151678. /**
  151679. * Post-process used to create a HDR effect (light adaptation)
  151680. */
  151681. hdrPostProcess: Nullable<PostProcess>;
  151682. /**
  151683. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151684. */
  151685. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151686. /**
  151687. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151688. */
  151689. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151690. /**
  151691. * Post-process used to merge the final HDR post-process and the real scene color
  151692. */
  151693. hdrFinalPostProcess: Nullable<PostProcess>;
  151694. /**
  151695. * Post-process used to create a lens flare effect
  151696. */
  151697. lensFlarePostProcess: Nullable<PostProcess>;
  151698. /**
  151699. * Post-process that merges the result of the lens flare post-process and the real scene color
  151700. */
  151701. lensFlareComposePostProcess: Nullable<PostProcess>;
  151702. /**
  151703. * Post-process used to create a motion blur effect
  151704. */
  151705. motionBlurPostProcess: Nullable<PostProcess>;
  151706. /**
  151707. * Post-process used to create a depth of field effect
  151708. */
  151709. depthOfFieldPostProcess: Nullable<PostProcess>;
  151710. /**
  151711. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151712. */
  151713. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151714. /**
  151715. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151716. */
  151717. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151718. /**
  151719. * Represents the brightness threshold in order to configure the illuminated surfaces
  151720. */
  151721. brightThreshold: number;
  151722. /**
  151723. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151724. */
  151725. blurWidth: number;
  151726. /**
  151727. * Sets if the blur for highlighted surfaces must be only horizontal
  151728. */
  151729. horizontalBlur: boolean;
  151730. /**
  151731. * Gets the overall exposure used by the pipeline
  151732. */
  151733. get exposure(): number;
  151734. /**
  151735. * Sets the overall exposure used by the pipeline
  151736. */
  151737. set exposure(value: number);
  151738. /**
  151739. * Texture used typically to simulate "dirty" on camera lens
  151740. */
  151741. lensTexture: Nullable<Texture>;
  151742. /**
  151743. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151744. */
  151745. volumetricLightCoefficient: number;
  151746. /**
  151747. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151748. */
  151749. volumetricLightPower: number;
  151750. /**
  151751. * Used the set the blur intensity to smooth the volumetric lights
  151752. */
  151753. volumetricLightBlurScale: number;
  151754. /**
  151755. * Light (spot or directional) used to generate the volumetric lights rays
  151756. * The source light must have a shadow generate so the pipeline can get its
  151757. * depth map
  151758. */
  151759. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151760. /**
  151761. * For eye adaptation, represents the minimum luminance the eye can see
  151762. */
  151763. hdrMinimumLuminance: number;
  151764. /**
  151765. * For eye adaptation, represents the decrease luminance speed
  151766. */
  151767. hdrDecreaseRate: number;
  151768. /**
  151769. * For eye adaptation, represents the increase luminance speed
  151770. */
  151771. hdrIncreaseRate: number;
  151772. /**
  151773. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151774. */
  151775. get hdrAutoExposure(): boolean;
  151776. /**
  151777. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151778. */
  151779. set hdrAutoExposure(value: boolean);
  151780. /**
  151781. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151782. */
  151783. lensColorTexture: Nullable<Texture>;
  151784. /**
  151785. * The overall strengh for the lens flare effect
  151786. */
  151787. lensFlareStrength: number;
  151788. /**
  151789. * Dispersion coefficient for lens flare ghosts
  151790. */
  151791. lensFlareGhostDispersal: number;
  151792. /**
  151793. * Main lens flare halo width
  151794. */
  151795. lensFlareHaloWidth: number;
  151796. /**
  151797. * Based on the lens distortion effect, defines how much the lens flare result
  151798. * is distorted
  151799. */
  151800. lensFlareDistortionStrength: number;
  151801. /**
  151802. * Configures the blur intensity used for for lens flare (halo)
  151803. */
  151804. lensFlareBlurWidth: number;
  151805. /**
  151806. * Lens star texture must be used to simulate rays on the flares and is available
  151807. * in the documentation
  151808. */
  151809. lensStarTexture: Nullable<Texture>;
  151810. /**
  151811. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151812. * flare effect by taking account of the dirt texture
  151813. */
  151814. lensFlareDirtTexture: Nullable<Texture>;
  151815. /**
  151816. * Represents the focal length for the depth of field effect
  151817. */
  151818. depthOfFieldDistance: number;
  151819. /**
  151820. * Represents the blur intensity for the blurred part of the depth of field effect
  151821. */
  151822. depthOfFieldBlurWidth: number;
  151823. /**
  151824. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151825. */
  151826. get motionStrength(): number;
  151827. /**
  151828. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151829. */
  151830. set motionStrength(strength: number);
  151831. /**
  151832. * Gets wether or not the motion blur post-process is object based or screen based.
  151833. */
  151834. get objectBasedMotionBlur(): boolean;
  151835. /**
  151836. * Sets wether or not the motion blur post-process should be object based or screen based
  151837. */
  151838. set objectBasedMotionBlur(value: boolean);
  151839. /**
  151840. * List of animations for the pipeline (IAnimatable implementation)
  151841. */
  151842. animations: Animation[];
  151843. /**
  151844. * Private members
  151845. */
  151846. private _scene;
  151847. private _currentDepthOfFieldSource;
  151848. private _basePostProcess;
  151849. private _fixedExposure;
  151850. private _currentExposure;
  151851. private _hdrAutoExposure;
  151852. private _hdrCurrentLuminance;
  151853. private _motionStrength;
  151854. private _isObjectBasedMotionBlur;
  151855. private _floatTextureType;
  151856. private _camerasToBeAttached;
  151857. private _ratio;
  151858. private _bloomEnabled;
  151859. private _depthOfFieldEnabled;
  151860. private _vlsEnabled;
  151861. private _lensFlareEnabled;
  151862. private _hdrEnabled;
  151863. private _motionBlurEnabled;
  151864. private _fxaaEnabled;
  151865. private _screenSpaceReflectionsEnabled;
  151866. private _motionBlurSamples;
  151867. private _volumetricLightStepsCount;
  151868. private _samples;
  151869. /**
  151870. * @ignore
  151871. * Specifies if the bloom pipeline is enabled
  151872. */
  151873. get BloomEnabled(): boolean;
  151874. set BloomEnabled(enabled: boolean);
  151875. /**
  151876. * @ignore
  151877. * Specifies if the depth of field pipeline is enabed
  151878. */
  151879. get DepthOfFieldEnabled(): boolean;
  151880. set DepthOfFieldEnabled(enabled: boolean);
  151881. /**
  151882. * @ignore
  151883. * Specifies if the lens flare pipeline is enabed
  151884. */
  151885. get LensFlareEnabled(): boolean;
  151886. set LensFlareEnabled(enabled: boolean);
  151887. /**
  151888. * @ignore
  151889. * Specifies if the HDR pipeline is enabled
  151890. */
  151891. get HDREnabled(): boolean;
  151892. set HDREnabled(enabled: boolean);
  151893. /**
  151894. * @ignore
  151895. * Specifies if the volumetric lights scattering effect is enabled
  151896. */
  151897. get VLSEnabled(): boolean;
  151898. set VLSEnabled(enabled: boolean);
  151899. /**
  151900. * @ignore
  151901. * Specifies if the motion blur effect is enabled
  151902. */
  151903. get MotionBlurEnabled(): boolean;
  151904. set MotionBlurEnabled(enabled: boolean);
  151905. /**
  151906. * Specifies if anti-aliasing is enabled
  151907. */
  151908. get fxaaEnabled(): boolean;
  151909. set fxaaEnabled(enabled: boolean);
  151910. /**
  151911. * Specifies if screen space reflections are enabled.
  151912. */
  151913. get screenSpaceReflectionsEnabled(): boolean;
  151914. set screenSpaceReflectionsEnabled(enabled: boolean);
  151915. /**
  151916. * Specifies the number of steps used to calculate the volumetric lights
  151917. * Typically in interval [50, 200]
  151918. */
  151919. get volumetricLightStepsCount(): number;
  151920. set volumetricLightStepsCount(count: number);
  151921. /**
  151922. * Specifies the number of samples used for the motion blur effect
  151923. * Typically in interval [16, 64]
  151924. */
  151925. get motionBlurSamples(): number;
  151926. set motionBlurSamples(samples: number);
  151927. /**
  151928. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151929. */
  151930. get samples(): number;
  151931. set samples(sampleCount: number);
  151932. /**
  151933. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151934. * @constructor
  151935. * @param name The rendering pipeline name
  151936. * @param scene The scene linked to this pipeline
  151937. * @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)
  151938. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151939. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151940. */
  151941. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151942. private _buildPipeline;
  151943. private _createDownSampleX4PostProcess;
  151944. private _createBrightPassPostProcess;
  151945. private _createBlurPostProcesses;
  151946. private _createTextureAdderPostProcess;
  151947. private _createVolumetricLightPostProcess;
  151948. private _createLuminancePostProcesses;
  151949. private _createHdrPostProcess;
  151950. private _createLensFlarePostProcess;
  151951. private _createDepthOfFieldPostProcess;
  151952. private _createMotionBlurPostProcess;
  151953. private _getDepthTexture;
  151954. private _disposePostProcesses;
  151955. /**
  151956. * Dispose of the pipeline and stop all post processes
  151957. */
  151958. dispose(): void;
  151959. /**
  151960. * Serialize the rendering pipeline (Used when exporting)
  151961. * @returns the serialized object
  151962. */
  151963. serialize(): any;
  151964. /**
  151965. * Parse the serialized pipeline
  151966. * @param source Source pipeline.
  151967. * @param scene The scene to load the pipeline to.
  151968. * @param rootUrl The URL of the serialized pipeline.
  151969. * @returns An instantiated pipeline from the serialized object.
  151970. */
  151971. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151972. /**
  151973. * Luminance steps
  151974. */
  151975. static LuminanceSteps: number;
  151976. }
  151977. }
  151978. declare module BABYLON {
  151979. /** @hidden */
  151980. export var stereoscopicInterlacePixelShader: {
  151981. name: string;
  151982. shader: string;
  151983. };
  151984. }
  151985. declare module BABYLON {
  151986. /**
  151987. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151988. */
  151989. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151990. private _stepSize;
  151991. private _passedProcess;
  151992. /**
  151993. * Gets a string identifying the name of the class
  151994. * @returns "StereoscopicInterlacePostProcessI" string
  151995. */
  151996. getClassName(): string;
  151997. /**
  151998. * Initializes a StereoscopicInterlacePostProcessI
  151999. * @param name The name of the effect.
  152000. * @param rigCameras The rig cameras to be appled to the post process
  152001. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152002. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152004. * @param engine The engine which the post process will be applied. (default: current engine)
  152005. * @param reusable If the post process can be reused on the same frame. (default: false)
  152006. */
  152007. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152008. }
  152009. /**
  152010. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152011. */
  152012. export class StereoscopicInterlacePostProcess extends PostProcess {
  152013. private _stepSize;
  152014. private _passedProcess;
  152015. /**
  152016. * Gets a string identifying the name of the class
  152017. * @returns "StereoscopicInterlacePostProcess" string
  152018. */
  152019. getClassName(): string;
  152020. /**
  152021. * Initializes a StereoscopicInterlacePostProcess
  152022. * @param name The name of the effect.
  152023. * @param rigCameras The rig cameras to be appled to the post process
  152024. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152026. * @param engine The engine which the post process will be applied. (default: current engine)
  152027. * @param reusable If the post process can be reused on the same frame. (default: false)
  152028. */
  152029. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152030. }
  152031. }
  152032. declare module BABYLON {
  152033. /** @hidden */
  152034. export var tonemapPixelShader: {
  152035. name: string;
  152036. shader: string;
  152037. };
  152038. }
  152039. declare module BABYLON {
  152040. /** Defines operator used for tonemapping */
  152041. export enum TonemappingOperator {
  152042. /** Hable */
  152043. Hable = 0,
  152044. /** Reinhard */
  152045. Reinhard = 1,
  152046. /** HejiDawson */
  152047. HejiDawson = 2,
  152048. /** Photographic */
  152049. Photographic = 3
  152050. }
  152051. /**
  152052. * Defines a post process to apply tone mapping
  152053. */
  152054. export class TonemapPostProcess extends PostProcess {
  152055. private _operator;
  152056. /** Defines the required exposure adjustement */
  152057. exposureAdjustment: number;
  152058. /**
  152059. * Gets a string identifying the name of the class
  152060. * @returns "TonemapPostProcess" string
  152061. */
  152062. getClassName(): string;
  152063. /**
  152064. * Creates a new TonemapPostProcess
  152065. * @param name defines the name of the postprocess
  152066. * @param _operator defines the operator to use
  152067. * @param exposureAdjustment defines the required exposure adjustement
  152068. * @param camera defines the camera to use (can be null)
  152069. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152070. * @param engine defines the hosting engine (can be ignore if camera is set)
  152071. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152072. */
  152073. constructor(name: string, _operator: TonemappingOperator,
  152074. /** Defines the required exposure adjustement */
  152075. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152076. }
  152077. }
  152078. declare module BABYLON {
  152079. /** @hidden */
  152080. export var volumetricLightScatteringPixelShader: {
  152081. name: string;
  152082. shader: string;
  152083. };
  152084. }
  152085. declare module BABYLON {
  152086. /** @hidden */
  152087. export var volumetricLightScatteringPassVertexShader: {
  152088. name: string;
  152089. shader: string;
  152090. };
  152091. }
  152092. declare module BABYLON {
  152093. /** @hidden */
  152094. export var volumetricLightScatteringPassPixelShader: {
  152095. name: string;
  152096. shader: string;
  152097. };
  152098. }
  152099. declare module BABYLON {
  152100. /**
  152101. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152102. */
  152103. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152104. private _volumetricLightScatteringPass;
  152105. private _volumetricLightScatteringRTT;
  152106. private _viewPort;
  152107. private _screenCoordinates;
  152108. private _cachedDefines;
  152109. /**
  152110. * If not undefined, the mesh position is computed from the attached node position
  152111. */
  152112. attachedNode: {
  152113. position: Vector3;
  152114. };
  152115. /**
  152116. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152117. */
  152118. customMeshPosition: Vector3;
  152119. /**
  152120. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152121. */
  152122. useCustomMeshPosition: boolean;
  152123. /**
  152124. * If the post-process should inverse the light scattering direction
  152125. */
  152126. invert: boolean;
  152127. /**
  152128. * The internal mesh used by the post-process
  152129. */
  152130. mesh: Mesh;
  152131. /**
  152132. * @hidden
  152133. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152134. */
  152135. get useDiffuseColor(): boolean;
  152136. set useDiffuseColor(useDiffuseColor: boolean);
  152137. /**
  152138. * Array containing the excluded meshes not rendered in the internal pass
  152139. */
  152140. excludedMeshes: AbstractMesh[];
  152141. /**
  152142. * Controls the overall intensity of the post-process
  152143. */
  152144. exposure: number;
  152145. /**
  152146. * Dissipates each sample's contribution in range [0, 1]
  152147. */
  152148. decay: number;
  152149. /**
  152150. * Controls the overall intensity of each sample
  152151. */
  152152. weight: number;
  152153. /**
  152154. * Controls the density of each sample
  152155. */
  152156. density: number;
  152157. /**
  152158. * @constructor
  152159. * @param name The post-process name
  152160. * @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)
  152161. * @param camera The camera that the post-process will be attached to
  152162. * @param mesh The mesh used to create the light scattering
  152163. * @param samples The post-process quality, default 100
  152164. * @param samplingModeThe post-process filtering mode
  152165. * @param engine The babylon engine
  152166. * @param reusable If the post-process is reusable
  152167. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152168. */
  152169. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152170. /**
  152171. * Returns the string "VolumetricLightScatteringPostProcess"
  152172. * @returns "VolumetricLightScatteringPostProcess"
  152173. */
  152174. getClassName(): string;
  152175. private _isReady;
  152176. /**
  152177. * Sets the new light position for light scattering effect
  152178. * @param position The new custom light position
  152179. */
  152180. setCustomMeshPosition(position: Vector3): void;
  152181. /**
  152182. * Returns the light position for light scattering effect
  152183. * @return Vector3 The custom light position
  152184. */
  152185. getCustomMeshPosition(): Vector3;
  152186. /**
  152187. * Disposes the internal assets and detaches the post-process from the camera
  152188. */
  152189. dispose(camera: Camera): void;
  152190. /**
  152191. * Returns the render target texture used by the post-process
  152192. * @return the render target texture used by the post-process
  152193. */
  152194. getPass(): RenderTargetTexture;
  152195. private _meshExcluded;
  152196. private _createPass;
  152197. private _updateMeshScreenCoordinates;
  152198. /**
  152199. * Creates a default mesh for the Volumeric Light Scattering post-process
  152200. * @param name The mesh name
  152201. * @param scene The scene where to create the mesh
  152202. * @return the default mesh
  152203. */
  152204. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152205. }
  152206. }
  152207. declare module BABYLON {
  152208. /** @hidden */
  152209. export var screenSpaceCurvaturePixelShader: {
  152210. name: string;
  152211. shader: string;
  152212. };
  152213. }
  152214. declare module BABYLON {
  152215. /**
  152216. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152217. */
  152218. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152219. /**
  152220. * Defines how much ridge the curvature effect displays.
  152221. */
  152222. ridge: number;
  152223. /**
  152224. * Defines how much valley the curvature effect displays.
  152225. */
  152226. valley: number;
  152227. private _geometryBufferRenderer;
  152228. /**
  152229. * Gets a string identifying the name of the class
  152230. * @returns "ScreenSpaceCurvaturePostProcess" string
  152231. */
  152232. getClassName(): string;
  152233. /**
  152234. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152235. * @param name The name of the effect.
  152236. * @param scene The scene containing the objects to blur according to their velocity.
  152237. * @param options The required width/height ratio to downsize to before computing the render pass.
  152238. * @param camera The camera to apply the render pass to.
  152239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152240. * @param engine The engine which the post process will be applied. (default: current engine)
  152241. * @param reusable If the post process can be reused on the same frame. (default: false)
  152242. * @param textureType Type of textures used when performing the post process. (default: 0)
  152243. * @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)
  152244. */
  152245. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152246. /**
  152247. * Support test.
  152248. */
  152249. static get IsSupported(): boolean;
  152250. /** @hidden */
  152251. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152252. }
  152253. }
  152254. declare module BABYLON {
  152255. interface Scene {
  152256. /** @hidden (Backing field) */
  152257. _boundingBoxRenderer: BoundingBoxRenderer;
  152258. /** @hidden (Backing field) */
  152259. _forceShowBoundingBoxes: boolean;
  152260. /**
  152261. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152262. */
  152263. forceShowBoundingBoxes: boolean;
  152264. /**
  152265. * Gets the bounding box renderer associated with the scene
  152266. * @returns a BoundingBoxRenderer
  152267. */
  152268. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152269. }
  152270. interface AbstractMesh {
  152271. /** @hidden (Backing field) */
  152272. _showBoundingBox: boolean;
  152273. /**
  152274. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152275. */
  152276. showBoundingBox: boolean;
  152277. }
  152278. /**
  152279. * Component responsible of rendering the bounding box of the meshes in a scene.
  152280. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152281. */
  152282. export class BoundingBoxRenderer implements ISceneComponent {
  152283. /**
  152284. * The component name helpfull to identify the component in the list of scene components.
  152285. */
  152286. readonly name: string;
  152287. /**
  152288. * The scene the component belongs to.
  152289. */
  152290. scene: Scene;
  152291. /**
  152292. * Color of the bounding box lines placed in front of an object
  152293. */
  152294. frontColor: Color3;
  152295. /**
  152296. * Color of the bounding box lines placed behind an object
  152297. */
  152298. backColor: Color3;
  152299. /**
  152300. * Defines if the renderer should show the back lines or not
  152301. */
  152302. showBackLines: boolean;
  152303. /**
  152304. * Observable raised before rendering a bounding box
  152305. */
  152306. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152307. /**
  152308. * Observable raised after rendering a bounding box
  152309. */
  152310. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152311. /**
  152312. * @hidden
  152313. */
  152314. renderList: SmartArray<BoundingBox>;
  152315. private _colorShader;
  152316. private _vertexBuffers;
  152317. private _indexBuffer;
  152318. private _fillIndexBuffer;
  152319. private _fillIndexData;
  152320. /**
  152321. * Instantiates a new bounding box renderer in a scene.
  152322. * @param scene the scene the renderer renders in
  152323. */
  152324. constructor(scene: Scene);
  152325. /**
  152326. * Registers the component in a given scene
  152327. */
  152328. register(): void;
  152329. private _evaluateSubMesh;
  152330. private _activeMesh;
  152331. private _prepareRessources;
  152332. private _createIndexBuffer;
  152333. /**
  152334. * Rebuilds the elements related to this component in case of
  152335. * context lost for instance.
  152336. */
  152337. rebuild(): void;
  152338. /**
  152339. * @hidden
  152340. */
  152341. reset(): void;
  152342. /**
  152343. * Render the bounding boxes of a specific rendering group
  152344. * @param renderingGroupId defines the rendering group to render
  152345. */
  152346. render(renderingGroupId: number): void;
  152347. /**
  152348. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152349. * @param mesh Define the mesh to render the occlusion bounding box for
  152350. */
  152351. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152352. /**
  152353. * Dispose and release the resources attached to this renderer.
  152354. */
  152355. dispose(): void;
  152356. }
  152357. }
  152358. declare module BABYLON {
  152359. interface Scene {
  152360. /** @hidden (Backing field) */
  152361. _depthRenderer: {
  152362. [id: string]: DepthRenderer;
  152363. };
  152364. /**
  152365. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152366. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152367. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152368. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152369. * @returns the created depth renderer
  152370. */
  152371. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152372. /**
  152373. * Disables a depth renderer for a given camera
  152374. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152375. */
  152376. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152377. }
  152378. /**
  152379. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152380. * in several rendering techniques.
  152381. */
  152382. export class DepthRendererSceneComponent implements ISceneComponent {
  152383. /**
  152384. * The component name helpfull to identify the component in the list of scene components.
  152385. */
  152386. readonly name: string;
  152387. /**
  152388. * The scene the component belongs to.
  152389. */
  152390. scene: Scene;
  152391. /**
  152392. * Creates a new instance of the component for the given scene
  152393. * @param scene Defines the scene to register the component in
  152394. */
  152395. constructor(scene: Scene);
  152396. /**
  152397. * Registers the component in a given scene
  152398. */
  152399. register(): void;
  152400. /**
  152401. * Rebuilds the elements related to this component in case of
  152402. * context lost for instance.
  152403. */
  152404. rebuild(): void;
  152405. /**
  152406. * Disposes the component and the associated ressources
  152407. */
  152408. dispose(): void;
  152409. private _gatherRenderTargets;
  152410. private _gatherActiveCameraRenderTargets;
  152411. }
  152412. }
  152413. declare module BABYLON {
  152414. interface AbstractScene {
  152415. /** @hidden (Backing field) */
  152416. _prePassRenderer: Nullable<PrePassRenderer>;
  152417. /**
  152418. * Gets or Sets the current prepass renderer associated to the scene.
  152419. */
  152420. prePassRenderer: Nullable<PrePassRenderer>;
  152421. /**
  152422. * Enables the prepass and associates it with the scene
  152423. * @returns the PrePassRenderer
  152424. */
  152425. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152426. /**
  152427. * Disables the prepass associated with the scene
  152428. */
  152429. disablePrePassRenderer(): void;
  152430. }
  152431. /**
  152432. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152433. * in several rendering techniques.
  152434. */
  152435. export class PrePassRendererSceneComponent implements ISceneComponent {
  152436. /**
  152437. * The component name helpful to identify the component in the list of scene components.
  152438. */
  152439. readonly name: string;
  152440. /**
  152441. * The scene the component belongs to.
  152442. */
  152443. scene: Scene;
  152444. /**
  152445. * Creates a new instance of the component for the given scene
  152446. * @param scene Defines the scene to register the component in
  152447. */
  152448. constructor(scene: Scene);
  152449. /**
  152450. * Registers the component in a given scene
  152451. */
  152452. register(): void;
  152453. private _beforeCameraDraw;
  152454. private _afterCameraDraw;
  152455. private _beforeClearStage;
  152456. /**
  152457. * Rebuilds the elements related to this component in case of
  152458. * context lost for instance.
  152459. */
  152460. rebuild(): void;
  152461. /**
  152462. * Disposes the component and the associated ressources
  152463. */
  152464. dispose(): void;
  152465. }
  152466. }
  152467. declare module BABYLON {
  152468. /** @hidden */
  152469. export var fibonacci: {
  152470. name: string;
  152471. shader: string;
  152472. };
  152473. }
  152474. declare module BABYLON {
  152475. /** @hidden */
  152476. export var diffusionProfile: {
  152477. name: string;
  152478. shader: string;
  152479. };
  152480. }
  152481. declare module BABYLON {
  152482. /** @hidden */
  152483. export var subSurfaceScatteringPixelShader: {
  152484. name: string;
  152485. shader: string;
  152486. };
  152487. }
  152488. declare module BABYLON {
  152489. /**
  152490. * Sub surface scattering post process
  152491. */
  152492. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152493. /**
  152494. * Gets a string identifying the name of the class
  152495. * @returns "SubSurfaceScatteringPostProcess" string
  152496. */
  152497. getClassName(): string;
  152498. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152499. }
  152500. }
  152501. declare module BABYLON {
  152502. /**
  152503. * Contains all parameters needed for the prepass to perform
  152504. * screen space subsurface scattering
  152505. */
  152506. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152507. /** @hidden */
  152508. static _SceneComponentInitialization: (scene: Scene) => void;
  152509. private _ssDiffusionS;
  152510. private _ssFilterRadii;
  152511. private _ssDiffusionD;
  152512. /**
  152513. * Post process to attach for screen space subsurface scattering
  152514. */
  152515. postProcess: SubSurfaceScatteringPostProcess;
  152516. /**
  152517. * Diffusion profile color for subsurface scattering
  152518. */
  152519. get ssDiffusionS(): number[];
  152520. /**
  152521. * Diffusion profile max color channel value for subsurface scattering
  152522. */
  152523. get ssDiffusionD(): number[];
  152524. /**
  152525. * Diffusion profile filter radius for subsurface scattering
  152526. */
  152527. get ssFilterRadii(): number[];
  152528. /**
  152529. * Is subsurface enabled
  152530. */
  152531. enabled: boolean;
  152532. /**
  152533. * Name of the configuration
  152534. */
  152535. name: string;
  152536. /**
  152537. * Diffusion profile colors for subsurface scattering
  152538. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152539. * See ...
  152540. * Note that you can only store up to 5 of them
  152541. */
  152542. ssDiffusionProfileColors: Color3[];
  152543. /**
  152544. * Defines the ratio real world => scene units.
  152545. * Used for subsurface scattering
  152546. */
  152547. metersPerUnit: number;
  152548. /**
  152549. * Textures that should be present in the MRT for this effect to work
  152550. */
  152551. readonly texturesRequired: number[];
  152552. private _scene;
  152553. /**
  152554. * Builds a subsurface configuration object
  152555. * @param scene The scene
  152556. */
  152557. constructor(scene: Scene);
  152558. /**
  152559. * Adds a new diffusion profile.
  152560. * Useful for more realistic subsurface scattering on diverse materials.
  152561. * @param color The color of the diffusion profile. Should be the average color of the material.
  152562. * @return The index of the diffusion profile for the material subsurface configuration
  152563. */
  152564. addDiffusionProfile(color: Color3): number;
  152565. /**
  152566. * Creates the sss post process
  152567. * @return The created post process
  152568. */
  152569. createPostProcess(): SubSurfaceScatteringPostProcess;
  152570. /**
  152571. * Deletes all diffusion profiles.
  152572. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152573. */
  152574. clearAllDiffusionProfiles(): void;
  152575. /**
  152576. * Disposes this object
  152577. */
  152578. dispose(): void;
  152579. /**
  152580. * @hidden
  152581. * https://zero-radiance.github.io/post/sampling-diffusion/
  152582. *
  152583. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152584. * ------------------------------------------------------------------------------------
  152585. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152586. * PDF[r, phi, s] = r * R[r, phi, s]
  152587. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152588. * ------------------------------------------------------------------------------------
  152589. * We importance sample the color channel with the widest scattering distance.
  152590. */
  152591. getDiffusionProfileParameters(color: Color3): number;
  152592. /**
  152593. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152594. * 'u' is the random number (the value of the CDF): [0, 1).
  152595. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152596. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152597. */
  152598. private _sampleBurleyDiffusionProfile;
  152599. }
  152600. }
  152601. declare module BABYLON {
  152602. interface AbstractScene {
  152603. /** @hidden (Backing field) */
  152604. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152605. /**
  152606. * Gets or Sets the current prepass renderer associated to the scene.
  152607. */
  152608. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152609. /**
  152610. * Enables the subsurface effect for prepass
  152611. * @returns the SubSurfaceConfiguration
  152612. */
  152613. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152614. /**
  152615. * Disables the subsurface effect for prepass
  152616. */
  152617. disableSubSurfaceForPrePass(): void;
  152618. }
  152619. /**
  152620. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152621. * in several rendering techniques.
  152622. */
  152623. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152624. /**
  152625. * The component name helpful to identify the component in the list of scene components.
  152626. */
  152627. readonly name: string;
  152628. /**
  152629. * The scene the component belongs to.
  152630. */
  152631. scene: Scene;
  152632. /**
  152633. * Creates a new instance of the component for the given scene
  152634. * @param scene Defines the scene to register the component in
  152635. */
  152636. constructor(scene: Scene);
  152637. /**
  152638. * Registers the component in a given scene
  152639. */
  152640. register(): void;
  152641. /**
  152642. * Serializes the component data to the specified json object
  152643. * @param serializationObject The object to serialize to
  152644. */
  152645. serialize(serializationObject: any): void;
  152646. /**
  152647. * Adds all the elements from the container to the scene
  152648. * @param container the container holding the elements
  152649. */
  152650. addFromContainer(container: AbstractScene): void;
  152651. /**
  152652. * Removes all the elements in the container from the scene
  152653. * @param container contains the elements to remove
  152654. * @param dispose if the removed element should be disposed (default: false)
  152655. */
  152656. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152657. /**
  152658. * Rebuilds the elements related to this component in case of
  152659. * context lost for instance.
  152660. */
  152661. rebuild(): void;
  152662. /**
  152663. * Disposes the component and the associated ressources
  152664. */
  152665. dispose(): void;
  152666. }
  152667. }
  152668. declare module BABYLON {
  152669. /** @hidden */
  152670. export var outlinePixelShader: {
  152671. name: string;
  152672. shader: string;
  152673. };
  152674. }
  152675. declare module BABYLON {
  152676. /** @hidden */
  152677. export var outlineVertexShader: {
  152678. name: string;
  152679. shader: string;
  152680. };
  152681. }
  152682. declare module BABYLON {
  152683. interface Scene {
  152684. /** @hidden */
  152685. _outlineRenderer: OutlineRenderer;
  152686. /**
  152687. * Gets the outline renderer associated with the scene
  152688. * @returns a OutlineRenderer
  152689. */
  152690. getOutlineRenderer(): OutlineRenderer;
  152691. }
  152692. interface AbstractMesh {
  152693. /** @hidden (Backing field) */
  152694. _renderOutline: boolean;
  152695. /**
  152696. * Gets or sets a boolean indicating if the outline must be rendered as well
  152697. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152698. */
  152699. renderOutline: boolean;
  152700. /** @hidden (Backing field) */
  152701. _renderOverlay: boolean;
  152702. /**
  152703. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152704. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152705. */
  152706. renderOverlay: boolean;
  152707. }
  152708. /**
  152709. * This class is responsible to draw bothe outline/overlay of meshes.
  152710. * It should not be used directly but through the available method on mesh.
  152711. */
  152712. export class OutlineRenderer implements ISceneComponent {
  152713. /**
  152714. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152715. */
  152716. private static _StencilReference;
  152717. /**
  152718. * The name of the component. Each component must have a unique name.
  152719. */
  152720. name: string;
  152721. /**
  152722. * The scene the component belongs to.
  152723. */
  152724. scene: Scene;
  152725. /**
  152726. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152727. */
  152728. zOffset: number;
  152729. private _engine;
  152730. private _effect;
  152731. private _cachedDefines;
  152732. private _savedDepthWrite;
  152733. /**
  152734. * Instantiates a new outline renderer. (There could be only one per scene).
  152735. * @param scene Defines the scene it belongs to
  152736. */
  152737. constructor(scene: Scene);
  152738. /**
  152739. * Register the component to one instance of a scene.
  152740. */
  152741. register(): void;
  152742. /**
  152743. * Rebuilds the elements related to this component in case of
  152744. * context lost for instance.
  152745. */
  152746. rebuild(): void;
  152747. /**
  152748. * Disposes the component and the associated ressources.
  152749. */
  152750. dispose(): void;
  152751. /**
  152752. * Renders the outline in the canvas.
  152753. * @param subMesh Defines the sumesh to render
  152754. * @param batch Defines the batch of meshes in case of instances
  152755. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152756. */
  152757. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152758. /**
  152759. * Returns whether or not the outline renderer is ready for a given submesh.
  152760. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152761. * @param subMesh Defines the submesh to check readyness for
  152762. * @param useInstances Defines wheter wee are trying to render instances or not
  152763. * @returns true if ready otherwise false
  152764. */
  152765. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152766. private _beforeRenderingMesh;
  152767. private _afterRenderingMesh;
  152768. }
  152769. }
  152770. declare module BABYLON {
  152771. /**
  152772. * Defines the basic options interface of a Sprite Frame Source Size.
  152773. */
  152774. export interface ISpriteJSONSpriteSourceSize {
  152775. /**
  152776. * number of the original width of the Frame
  152777. */
  152778. w: number;
  152779. /**
  152780. * number of the original height of the Frame
  152781. */
  152782. h: number;
  152783. }
  152784. /**
  152785. * Defines the basic options interface of a Sprite Frame Data.
  152786. */
  152787. export interface ISpriteJSONSpriteFrameData {
  152788. /**
  152789. * number of the x offset of the Frame
  152790. */
  152791. x: number;
  152792. /**
  152793. * number of the y offset of the Frame
  152794. */
  152795. y: number;
  152796. /**
  152797. * number of the width of the Frame
  152798. */
  152799. w: number;
  152800. /**
  152801. * number of the height of the Frame
  152802. */
  152803. h: number;
  152804. }
  152805. /**
  152806. * Defines the basic options interface of a JSON Sprite.
  152807. */
  152808. export interface ISpriteJSONSprite {
  152809. /**
  152810. * string name of the Frame
  152811. */
  152812. filename: string;
  152813. /**
  152814. * ISpriteJSONSpriteFrame basic object of the frame data
  152815. */
  152816. frame: ISpriteJSONSpriteFrameData;
  152817. /**
  152818. * boolean to flag is the frame was rotated.
  152819. */
  152820. rotated: boolean;
  152821. /**
  152822. * boolean to flag is the frame was trimmed.
  152823. */
  152824. trimmed: boolean;
  152825. /**
  152826. * ISpriteJSONSpriteFrame basic object of the source data
  152827. */
  152828. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152829. /**
  152830. * ISpriteJSONSpriteFrame basic object of the source data
  152831. */
  152832. sourceSize: ISpriteJSONSpriteSourceSize;
  152833. }
  152834. /**
  152835. * Defines the basic options interface of a JSON atlas.
  152836. */
  152837. export interface ISpriteJSONAtlas {
  152838. /**
  152839. * Array of objects that contain the frame data.
  152840. */
  152841. frames: Array<ISpriteJSONSprite>;
  152842. /**
  152843. * object basic object containing the sprite meta data.
  152844. */
  152845. meta?: object;
  152846. }
  152847. }
  152848. declare module BABYLON {
  152849. /** @hidden */
  152850. export var spriteMapPixelShader: {
  152851. name: string;
  152852. shader: string;
  152853. };
  152854. }
  152855. declare module BABYLON {
  152856. /** @hidden */
  152857. export var spriteMapVertexShader: {
  152858. name: string;
  152859. shader: string;
  152860. };
  152861. }
  152862. declare module BABYLON {
  152863. /**
  152864. * Defines the basic options interface of a SpriteMap
  152865. */
  152866. export interface ISpriteMapOptions {
  152867. /**
  152868. * Vector2 of the number of cells in the grid.
  152869. */
  152870. stageSize?: Vector2;
  152871. /**
  152872. * Vector2 of the size of the output plane in World Units.
  152873. */
  152874. outputSize?: Vector2;
  152875. /**
  152876. * Vector3 of the position of the output plane in World Units.
  152877. */
  152878. outputPosition?: Vector3;
  152879. /**
  152880. * Vector3 of the rotation of the output plane.
  152881. */
  152882. outputRotation?: Vector3;
  152883. /**
  152884. * number of layers that the system will reserve in resources.
  152885. */
  152886. layerCount?: number;
  152887. /**
  152888. * number of max animation frames a single cell will reserve in resources.
  152889. */
  152890. maxAnimationFrames?: number;
  152891. /**
  152892. * number cell index of the base tile when the system compiles.
  152893. */
  152894. baseTile?: number;
  152895. /**
  152896. * boolean flip the sprite after its been repositioned by the framing data.
  152897. */
  152898. flipU?: boolean;
  152899. /**
  152900. * Vector3 scalar of the global RGB values of the SpriteMap.
  152901. */
  152902. colorMultiply?: Vector3;
  152903. }
  152904. /**
  152905. * Defines the IDisposable interface in order to be cleanable from resources.
  152906. */
  152907. export interface ISpriteMap extends IDisposable {
  152908. /**
  152909. * String name of the SpriteMap.
  152910. */
  152911. name: string;
  152912. /**
  152913. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152914. */
  152915. atlasJSON: ISpriteJSONAtlas;
  152916. /**
  152917. * Texture of the SpriteMap.
  152918. */
  152919. spriteSheet: Texture;
  152920. /**
  152921. * The parameters to initialize the SpriteMap with.
  152922. */
  152923. options: ISpriteMapOptions;
  152924. }
  152925. /**
  152926. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152927. */
  152928. export class SpriteMap implements ISpriteMap {
  152929. /** The Name of the spriteMap */
  152930. name: string;
  152931. /** The JSON file with the frame and meta data */
  152932. atlasJSON: ISpriteJSONAtlas;
  152933. /** The systems Sprite Sheet Texture */
  152934. spriteSheet: Texture;
  152935. /** Arguments passed with the Constructor */
  152936. options: ISpriteMapOptions;
  152937. /** Public Sprite Storage array, parsed from atlasJSON */
  152938. sprites: Array<ISpriteJSONSprite>;
  152939. /** Returns the Number of Sprites in the System */
  152940. get spriteCount(): number;
  152941. /** Returns the Position of Output Plane*/
  152942. get position(): Vector3;
  152943. /** Returns the Position of Output Plane*/
  152944. set position(v: Vector3);
  152945. /** Returns the Rotation of Output Plane*/
  152946. get rotation(): Vector3;
  152947. /** Returns the Rotation of Output Plane*/
  152948. set rotation(v: Vector3);
  152949. /** Sets the AnimationMap*/
  152950. get animationMap(): RawTexture;
  152951. /** Sets the AnimationMap*/
  152952. set animationMap(v: RawTexture);
  152953. /** Scene that the SpriteMap was created in */
  152954. private _scene;
  152955. /** Texture Buffer of Float32 that holds tile frame data*/
  152956. private _frameMap;
  152957. /** Texture Buffers of Float32 that holds tileMap data*/
  152958. private _tileMaps;
  152959. /** Texture Buffer of Float32 that holds Animation Data*/
  152960. private _animationMap;
  152961. /** Custom ShaderMaterial Central to the System*/
  152962. private _material;
  152963. /** Custom ShaderMaterial Central to the System*/
  152964. private _output;
  152965. /** Systems Time Ticker*/
  152966. private _time;
  152967. /**
  152968. * Creates a new SpriteMap
  152969. * @param name defines the SpriteMaps Name
  152970. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152971. * @param spriteSheet is the Texture that the Sprites are on.
  152972. * @param options a basic deployment configuration
  152973. * @param scene The Scene that the map is deployed on
  152974. */
  152975. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152976. /**
  152977. * Returns tileID location
  152978. * @returns Vector2 the cell position ID
  152979. */
  152980. getTileID(): Vector2;
  152981. /**
  152982. * Gets the UV location of the mouse over the SpriteMap.
  152983. * @returns Vector2 the UV position of the mouse interaction
  152984. */
  152985. getMousePosition(): Vector2;
  152986. /**
  152987. * Creates the "frame" texture Buffer
  152988. * -------------------------------------
  152989. * Structure of frames
  152990. * "filename": "Falling-Water-2.png",
  152991. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152992. * "rotated": true,
  152993. * "trimmed": true,
  152994. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152995. * "sourceSize": {"w":32,"h":32}
  152996. * @returns RawTexture of the frameMap
  152997. */
  152998. private _createFrameBuffer;
  152999. /**
  153000. * Creates the tileMap texture Buffer
  153001. * @param buffer normally and array of numbers, or a false to generate from scratch
  153002. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153003. * @returns RawTexture of the tileMap
  153004. */
  153005. private _createTileBuffer;
  153006. /**
  153007. * Modifies the data of the tileMaps
  153008. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153009. * @param pos is the iVector2 Coordinates of the Tile
  153010. * @param tile The SpriteIndex of the new Tile
  153011. */
  153012. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153013. /**
  153014. * Creates the animationMap texture Buffer
  153015. * @param buffer normally and array of numbers, or a false to generate from scratch
  153016. * @returns RawTexture of the animationMap
  153017. */
  153018. private _createTileAnimationBuffer;
  153019. /**
  153020. * Modifies the data of the animationMap
  153021. * @param cellID is the Index of the Sprite
  153022. * @param _frame is the target Animation frame
  153023. * @param toCell is the Target Index of the next frame of the animation
  153024. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153025. * @param speed is a global scalar of the time variable on the map.
  153026. */
  153027. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153028. /**
  153029. * Exports the .tilemaps file
  153030. */
  153031. saveTileMaps(): void;
  153032. /**
  153033. * Imports the .tilemaps file
  153034. * @param url of the .tilemaps file
  153035. */
  153036. loadTileMaps(url: string): void;
  153037. /**
  153038. * Release associated resources
  153039. */
  153040. dispose(): void;
  153041. }
  153042. }
  153043. declare module BABYLON {
  153044. /**
  153045. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153046. * @see https://doc.babylonjs.com/babylon101/sprites
  153047. */
  153048. export class SpritePackedManager extends SpriteManager {
  153049. /** defines the packed manager's name */
  153050. name: string;
  153051. /**
  153052. * Creates a new sprite manager from a packed sprite sheet
  153053. * @param name defines the manager's name
  153054. * @param imgUrl defines the sprite sheet url
  153055. * @param capacity defines the maximum allowed number of sprites
  153056. * @param scene defines the hosting scene
  153057. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153058. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153059. * @param samplingMode defines the smapling mode to use with spritesheet
  153060. * @param fromPacked set to true; do not alter
  153061. */
  153062. constructor(
  153063. /** defines the packed manager's name */
  153064. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153065. }
  153066. }
  153067. declare module BABYLON {
  153068. /**
  153069. * Defines the list of states available for a task inside a AssetsManager
  153070. */
  153071. export enum AssetTaskState {
  153072. /**
  153073. * Initialization
  153074. */
  153075. INIT = 0,
  153076. /**
  153077. * Running
  153078. */
  153079. RUNNING = 1,
  153080. /**
  153081. * Done
  153082. */
  153083. DONE = 2,
  153084. /**
  153085. * Error
  153086. */
  153087. ERROR = 3
  153088. }
  153089. /**
  153090. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153091. */
  153092. export abstract class AbstractAssetTask {
  153093. /**
  153094. * Task name
  153095. */ name: string;
  153096. /**
  153097. * Callback called when the task is successful
  153098. */
  153099. onSuccess: (task: any) => void;
  153100. /**
  153101. * Callback called when the task is not successful
  153102. */
  153103. onError: (task: any, message?: string, exception?: any) => void;
  153104. /**
  153105. * Creates a new AssetsManager
  153106. * @param name defines the name of the task
  153107. */
  153108. constructor(
  153109. /**
  153110. * Task name
  153111. */ name: string);
  153112. private _isCompleted;
  153113. private _taskState;
  153114. private _errorObject;
  153115. /**
  153116. * Get if the task is completed
  153117. */
  153118. get isCompleted(): boolean;
  153119. /**
  153120. * Gets the current state of the task
  153121. */
  153122. get taskState(): AssetTaskState;
  153123. /**
  153124. * Gets the current error object (if task is in error)
  153125. */
  153126. get errorObject(): {
  153127. message?: string;
  153128. exception?: any;
  153129. };
  153130. /**
  153131. * Internal only
  153132. * @hidden
  153133. */
  153134. _setErrorObject(message?: string, exception?: any): void;
  153135. /**
  153136. * Execute the current task
  153137. * @param scene defines the scene where you want your assets to be loaded
  153138. * @param onSuccess is a callback called when the task is successfully executed
  153139. * @param onError is a callback called if an error occurs
  153140. */
  153141. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153142. /**
  153143. * Execute the current task
  153144. * @param scene defines the scene where you want your assets to be loaded
  153145. * @param onSuccess is a callback called when the task is successfully executed
  153146. * @param onError is a callback called if an error occurs
  153147. */
  153148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153149. /**
  153150. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153151. * This can be used with failed tasks that have the reason for failure fixed.
  153152. */
  153153. reset(): void;
  153154. private onErrorCallback;
  153155. private onDoneCallback;
  153156. }
  153157. /**
  153158. * Define the interface used by progress events raised during assets loading
  153159. */
  153160. export interface IAssetsProgressEvent {
  153161. /**
  153162. * Defines the number of remaining tasks to process
  153163. */
  153164. remainingCount: number;
  153165. /**
  153166. * Defines the total number of tasks
  153167. */
  153168. totalCount: number;
  153169. /**
  153170. * Defines the task that was just processed
  153171. */
  153172. task: AbstractAssetTask;
  153173. }
  153174. /**
  153175. * Class used to share progress information about assets loading
  153176. */
  153177. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153178. /**
  153179. * Defines the number of remaining tasks to process
  153180. */
  153181. remainingCount: number;
  153182. /**
  153183. * Defines the total number of tasks
  153184. */
  153185. totalCount: number;
  153186. /**
  153187. * Defines the task that was just processed
  153188. */
  153189. task: AbstractAssetTask;
  153190. /**
  153191. * Creates a AssetsProgressEvent
  153192. * @param remainingCount defines the number of remaining tasks to process
  153193. * @param totalCount defines the total number of tasks
  153194. * @param task defines the task that was just processed
  153195. */
  153196. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153197. }
  153198. /**
  153199. * Define a task used by AssetsManager to load assets into a container
  153200. */
  153201. export class ContainerAssetTask extends AbstractAssetTask {
  153202. /**
  153203. * Defines the name of the task
  153204. */
  153205. name: string;
  153206. /**
  153207. * Defines the list of mesh's names you want to load
  153208. */
  153209. meshesNames: any;
  153210. /**
  153211. * Defines the root url to use as a base to load your meshes and associated resources
  153212. */
  153213. rootUrl: string;
  153214. /**
  153215. * Defines the filename or File of the scene to load from
  153216. */
  153217. sceneFilename: string | File;
  153218. /**
  153219. * Get the loaded asset container
  153220. */
  153221. loadedContainer: AssetContainer;
  153222. /**
  153223. * Gets the list of loaded meshes
  153224. */
  153225. loadedMeshes: Array<AbstractMesh>;
  153226. /**
  153227. * Gets the list of loaded particle systems
  153228. */
  153229. loadedParticleSystems: Array<IParticleSystem>;
  153230. /**
  153231. * Gets the list of loaded skeletons
  153232. */
  153233. loadedSkeletons: Array<Skeleton>;
  153234. /**
  153235. * Gets the list of loaded animation groups
  153236. */
  153237. loadedAnimationGroups: Array<AnimationGroup>;
  153238. /**
  153239. * Callback called when the task is successful
  153240. */
  153241. onSuccess: (task: ContainerAssetTask) => void;
  153242. /**
  153243. * Callback called when the task is successful
  153244. */
  153245. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153246. /**
  153247. * Creates a new ContainerAssetTask
  153248. * @param name defines the name of the task
  153249. * @param meshesNames defines the list of mesh's names you want to load
  153250. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153251. * @param sceneFilename defines the filename or File of the scene to load from
  153252. */
  153253. constructor(
  153254. /**
  153255. * Defines the name of the task
  153256. */
  153257. name: string,
  153258. /**
  153259. * Defines the list of mesh's names you want to load
  153260. */
  153261. meshesNames: any,
  153262. /**
  153263. * Defines the root url to use as a base to load your meshes and associated resources
  153264. */
  153265. rootUrl: string,
  153266. /**
  153267. * Defines the filename or File of the scene to load from
  153268. */
  153269. sceneFilename: string | File);
  153270. /**
  153271. * Execute the current task
  153272. * @param scene defines the scene where you want your assets to be loaded
  153273. * @param onSuccess is a callback called when the task is successfully executed
  153274. * @param onError is a callback called if an error occurs
  153275. */
  153276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153277. }
  153278. /**
  153279. * Define a task used by AssetsManager to load meshes
  153280. */
  153281. export class MeshAssetTask extends AbstractAssetTask {
  153282. /**
  153283. * Defines the name of the task
  153284. */
  153285. name: string;
  153286. /**
  153287. * Defines the list of mesh's names you want to load
  153288. */
  153289. meshesNames: any;
  153290. /**
  153291. * Defines the root url to use as a base to load your meshes and associated resources
  153292. */
  153293. rootUrl: string;
  153294. /**
  153295. * Defines the filename or File of the scene to load from
  153296. */
  153297. sceneFilename: string | File;
  153298. /**
  153299. * Gets the list of loaded meshes
  153300. */
  153301. loadedMeshes: Array<AbstractMesh>;
  153302. /**
  153303. * Gets the list of loaded particle systems
  153304. */
  153305. loadedParticleSystems: Array<IParticleSystem>;
  153306. /**
  153307. * Gets the list of loaded skeletons
  153308. */
  153309. loadedSkeletons: Array<Skeleton>;
  153310. /**
  153311. * Gets the list of loaded animation groups
  153312. */
  153313. loadedAnimationGroups: Array<AnimationGroup>;
  153314. /**
  153315. * Callback called when the task is successful
  153316. */
  153317. onSuccess: (task: MeshAssetTask) => void;
  153318. /**
  153319. * Callback called when the task is successful
  153320. */
  153321. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153322. /**
  153323. * Creates a new MeshAssetTask
  153324. * @param name defines the name of the task
  153325. * @param meshesNames defines the list of mesh's names you want to load
  153326. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153327. * @param sceneFilename defines the filename or File of the scene to load from
  153328. */
  153329. constructor(
  153330. /**
  153331. * Defines the name of the task
  153332. */
  153333. name: string,
  153334. /**
  153335. * Defines the list of mesh's names you want to load
  153336. */
  153337. meshesNames: any,
  153338. /**
  153339. * Defines the root url to use as a base to load your meshes and associated resources
  153340. */
  153341. rootUrl: string,
  153342. /**
  153343. * Defines the filename or File of the scene to load from
  153344. */
  153345. sceneFilename: string | File);
  153346. /**
  153347. * Execute the current task
  153348. * @param scene defines the scene where you want your assets to be loaded
  153349. * @param onSuccess is a callback called when the task is successfully executed
  153350. * @param onError is a callback called if an error occurs
  153351. */
  153352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153353. }
  153354. /**
  153355. * Define a task used by AssetsManager to load text content
  153356. */
  153357. export class TextFileAssetTask extends AbstractAssetTask {
  153358. /**
  153359. * Defines the name of the task
  153360. */
  153361. name: string;
  153362. /**
  153363. * Defines the location of the file to load
  153364. */
  153365. url: string;
  153366. /**
  153367. * Gets the loaded text string
  153368. */
  153369. text: string;
  153370. /**
  153371. * Callback called when the task is successful
  153372. */
  153373. onSuccess: (task: TextFileAssetTask) => void;
  153374. /**
  153375. * Callback called when the task is successful
  153376. */
  153377. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153378. /**
  153379. * Creates a new TextFileAssetTask object
  153380. * @param name defines the name of the task
  153381. * @param url defines the location of the file to load
  153382. */
  153383. constructor(
  153384. /**
  153385. * Defines the name of the task
  153386. */
  153387. name: string,
  153388. /**
  153389. * Defines the location of the file to load
  153390. */
  153391. url: string);
  153392. /**
  153393. * Execute the current task
  153394. * @param scene defines the scene where you want your assets to be loaded
  153395. * @param onSuccess is a callback called when the task is successfully executed
  153396. * @param onError is a callback called if an error occurs
  153397. */
  153398. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153399. }
  153400. /**
  153401. * Define a task used by AssetsManager to load binary data
  153402. */
  153403. export class BinaryFileAssetTask extends AbstractAssetTask {
  153404. /**
  153405. * Defines the name of the task
  153406. */
  153407. name: string;
  153408. /**
  153409. * Defines the location of the file to load
  153410. */
  153411. url: string;
  153412. /**
  153413. * Gets the lodaded data (as an array buffer)
  153414. */
  153415. data: ArrayBuffer;
  153416. /**
  153417. * Callback called when the task is successful
  153418. */
  153419. onSuccess: (task: BinaryFileAssetTask) => void;
  153420. /**
  153421. * Callback called when the task is successful
  153422. */
  153423. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153424. /**
  153425. * Creates a new BinaryFileAssetTask object
  153426. * @param name defines the name of the new task
  153427. * @param url defines the location of the file to load
  153428. */
  153429. constructor(
  153430. /**
  153431. * Defines the name of the task
  153432. */
  153433. name: string,
  153434. /**
  153435. * Defines the location of the file to load
  153436. */
  153437. url: string);
  153438. /**
  153439. * Execute the current task
  153440. * @param scene defines the scene where you want your assets to be loaded
  153441. * @param onSuccess is a callback called when the task is successfully executed
  153442. * @param onError is a callback called if an error occurs
  153443. */
  153444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153445. }
  153446. /**
  153447. * Define a task used by AssetsManager to load images
  153448. */
  153449. export class ImageAssetTask extends AbstractAssetTask {
  153450. /**
  153451. * Defines the name of the task
  153452. */
  153453. name: string;
  153454. /**
  153455. * Defines the location of the image to load
  153456. */
  153457. url: string;
  153458. /**
  153459. * Gets the loaded images
  153460. */
  153461. image: HTMLImageElement;
  153462. /**
  153463. * Callback called when the task is successful
  153464. */
  153465. onSuccess: (task: ImageAssetTask) => void;
  153466. /**
  153467. * Callback called when the task is successful
  153468. */
  153469. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153470. /**
  153471. * Creates a new ImageAssetTask
  153472. * @param name defines the name of the task
  153473. * @param url defines the location of the image to load
  153474. */
  153475. constructor(
  153476. /**
  153477. * Defines the name of the task
  153478. */
  153479. name: string,
  153480. /**
  153481. * Defines the location of the image to load
  153482. */
  153483. url: string);
  153484. /**
  153485. * Execute the current task
  153486. * @param scene defines the scene where you want your assets to be loaded
  153487. * @param onSuccess is a callback called when the task is successfully executed
  153488. * @param onError is a callback called if an error occurs
  153489. */
  153490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153491. }
  153492. /**
  153493. * Defines the interface used by texture loading tasks
  153494. */
  153495. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153496. /**
  153497. * Gets the loaded texture
  153498. */
  153499. texture: TEX;
  153500. }
  153501. /**
  153502. * Define a task used by AssetsManager to load 2D textures
  153503. */
  153504. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153505. /**
  153506. * Defines the name of the task
  153507. */
  153508. name: string;
  153509. /**
  153510. * Defines the location of the file to load
  153511. */
  153512. url: string;
  153513. /**
  153514. * Defines if mipmap should not be generated (default is false)
  153515. */
  153516. noMipmap?: boolean | undefined;
  153517. /**
  153518. * Defines if texture must be inverted on Y axis (default is true)
  153519. */
  153520. invertY: boolean;
  153521. /**
  153522. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153523. */
  153524. samplingMode: number;
  153525. /**
  153526. * Gets the loaded texture
  153527. */
  153528. texture: Texture;
  153529. /**
  153530. * Callback called when the task is successful
  153531. */
  153532. onSuccess: (task: TextureAssetTask) => void;
  153533. /**
  153534. * Callback called when the task is successful
  153535. */
  153536. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153537. /**
  153538. * Creates a new TextureAssetTask object
  153539. * @param name defines the name of the task
  153540. * @param url defines the location of the file to load
  153541. * @param noMipmap defines if mipmap should not be generated (default is false)
  153542. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153543. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153544. */
  153545. constructor(
  153546. /**
  153547. * Defines the name of the task
  153548. */
  153549. name: string,
  153550. /**
  153551. * Defines the location of the file to load
  153552. */
  153553. url: string,
  153554. /**
  153555. * Defines if mipmap should not be generated (default is false)
  153556. */
  153557. noMipmap?: boolean | undefined,
  153558. /**
  153559. * Defines if texture must be inverted on Y axis (default is true)
  153560. */
  153561. invertY?: boolean,
  153562. /**
  153563. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153564. */
  153565. samplingMode?: number);
  153566. /**
  153567. * Execute the current task
  153568. * @param scene defines the scene where you want your assets to be loaded
  153569. * @param onSuccess is a callback called when the task is successfully executed
  153570. * @param onError is a callback called if an error occurs
  153571. */
  153572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153573. }
  153574. /**
  153575. * Define a task used by AssetsManager to load cube textures
  153576. */
  153577. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153578. /**
  153579. * Defines the name of the task
  153580. */
  153581. name: string;
  153582. /**
  153583. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153584. */
  153585. url: string;
  153586. /**
  153587. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153588. */
  153589. extensions?: string[] | undefined;
  153590. /**
  153591. * Defines if mipmaps should not be generated (default is false)
  153592. */
  153593. noMipmap?: boolean | undefined;
  153594. /**
  153595. * Defines the explicit list of files (undefined by default)
  153596. */
  153597. files?: string[] | undefined;
  153598. /**
  153599. * Gets the loaded texture
  153600. */
  153601. texture: CubeTexture;
  153602. /**
  153603. * Callback called when the task is successful
  153604. */
  153605. onSuccess: (task: CubeTextureAssetTask) => void;
  153606. /**
  153607. * Callback called when the task is successful
  153608. */
  153609. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153610. /**
  153611. * Creates a new CubeTextureAssetTask
  153612. * @param name defines the name of the task
  153613. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153614. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153616. * @param files defines the explicit list of files (undefined by default)
  153617. */
  153618. constructor(
  153619. /**
  153620. * Defines the name of the task
  153621. */
  153622. name: string,
  153623. /**
  153624. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153625. */
  153626. url: string,
  153627. /**
  153628. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153629. */
  153630. extensions?: string[] | undefined,
  153631. /**
  153632. * Defines if mipmaps should not be generated (default is false)
  153633. */
  153634. noMipmap?: boolean | undefined,
  153635. /**
  153636. * Defines the explicit list of files (undefined by default)
  153637. */
  153638. files?: string[] | undefined);
  153639. /**
  153640. * Execute the current task
  153641. * @param scene defines the scene where you want your assets to be loaded
  153642. * @param onSuccess is a callback called when the task is successfully executed
  153643. * @param onError is a callback called if an error occurs
  153644. */
  153645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153646. }
  153647. /**
  153648. * Define a task used by AssetsManager to load HDR cube textures
  153649. */
  153650. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153651. /**
  153652. * Defines the name of the task
  153653. */
  153654. name: string;
  153655. /**
  153656. * Defines the location of the file to load
  153657. */
  153658. url: string;
  153659. /**
  153660. * Defines the desired size (the more it increases the longer the generation will be)
  153661. */
  153662. size: number;
  153663. /**
  153664. * Defines if mipmaps should not be generated (default is false)
  153665. */
  153666. noMipmap: boolean;
  153667. /**
  153668. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153669. */
  153670. generateHarmonics: boolean;
  153671. /**
  153672. * 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)
  153673. */
  153674. gammaSpace: boolean;
  153675. /**
  153676. * Internal Use Only
  153677. */
  153678. reserved: boolean;
  153679. /**
  153680. * Gets the loaded texture
  153681. */
  153682. texture: HDRCubeTexture;
  153683. /**
  153684. * Callback called when the task is successful
  153685. */
  153686. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153687. /**
  153688. * Callback called when the task is successful
  153689. */
  153690. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153691. /**
  153692. * Creates a new HDRCubeTextureAssetTask object
  153693. * @param name defines the name of the task
  153694. * @param url defines the location of the file to load
  153695. * @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.
  153696. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153697. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153698. * @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)
  153699. * @param reserved Internal use only
  153700. */
  153701. constructor(
  153702. /**
  153703. * Defines the name of the task
  153704. */
  153705. name: string,
  153706. /**
  153707. * Defines the location of the file to load
  153708. */
  153709. url: string,
  153710. /**
  153711. * Defines the desired size (the more it increases the longer the generation will be)
  153712. */
  153713. size: number,
  153714. /**
  153715. * Defines if mipmaps should not be generated (default is false)
  153716. */
  153717. noMipmap?: boolean,
  153718. /**
  153719. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153720. */
  153721. generateHarmonics?: boolean,
  153722. /**
  153723. * 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)
  153724. */
  153725. gammaSpace?: boolean,
  153726. /**
  153727. * Internal Use Only
  153728. */
  153729. reserved?: boolean);
  153730. /**
  153731. * Execute the current task
  153732. * @param scene defines the scene where you want your assets to be loaded
  153733. * @param onSuccess is a callback called when the task is successfully executed
  153734. * @param onError is a callback called if an error occurs
  153735. */
  153736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153737. }
  153738. /**
  153739. * Define a task used by AssetsManager to load Equirectangular cube textures
  153740. */
  153741. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153742. /**
  153743. * Defines the name of the task
  153744. */
  153745. name: string;
  153746. /**
  153747. * Defines the location of the file to load
  153748. */
  153749. url: string;
  153750. /**
  153751. * Defines the desired size (the more it increases the longer the generation will be)
  153752. */
  153753. size: number;
  153754. /**
  153755. * Defines if mipmaps should not be generated (default is false)
  153756. */
  153757. noMipmap: boolean;
  153758. /**
  153759. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153760. * but the standard material would require them in Gamma space) (default is true)
  153761. */
  153762. gammaSpace: boolean;
  153763. /**
  153764. * Gets the loaded texture
  153765. */
  153766. texture: EquiRectangularCubeTexture;
  153767. /**
  153768. * Callback called when the task is successful
  153769. */
  153770. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153771. /**
  153772. * Callback called when the task is successful
  153773. */
  153774. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153775. /**
  153776. * Creates a new EquiRectangularCubeTextureAssetTask object
  153777. * @param name defines the name of the task
  153778. * @param url defines the location of the file to load
  153779. * @param size defines the desired size (the more it increases the longer the generation will be)
  153780. * If the size is omitted this implies you are using a preprocessed cubemap.
  153781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153782. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153783. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153784. * (default is true)
  153785. */
  153786. constructor(
  153787. /**
  153788. * Defines the name of the task
  153789. */
  153790. name: string,
  153791. /**
  153792. * Defines the location of the file to load
  153793. */
  153794. url: string,
  153795. /**
  153796. * Defines the desired size (the more it increases the longer the generation will be)
  153797. */
  153798. size: number,
  153799. /**
  153800. * Defines if mipmaps should not be generated (default is false)
  153801. */
  153802. noMipmap?: boolean,
  153803. /**
  153804. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153805. * but the standard material would require them in Gamma space) (default is true)
  153806. */
  153807. gammaSpace?: boolean);
  153808. /**
  153809. * Execute the current task
  153810. * @param scene defines the scene where you want your assets to be loaded
  153811. * @param onSuccess is a callback called when the task is successfully executed
  153812. * @param onError is a callback called if an error occurs
  153813. */
  153814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153815. }
  153816. /**
  153817. * This class can be used to easily import assets into a scene
  153818. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153819. */
  153820. export class AssetsManager {
  153821. private _scene;
  153822. private _isLoading;
  153823. protected _tasks: AbstractAssetTask[];
  153824. protected _waitingTasksCount: number;
  153825. protected _totalTasksCount: number;
  153826. /**
  153827. * Callback called when all tasks are processed
  153828. */
  153829. onFinish: (tasks: AbstractAssetTask[]) => void;
  153830. /**
  153831. * Callback called when a task is successful
  153832. */
  153833. onTaskSuccess: (task: AbstractAssetTask) => void;
  153834. /**
  153835. * Callback called when a task had an error
  153836. */
  153837. onTaskError: (task: AbstractAssetTask) => void;
  153838. /**
  153839. * Callback called when a task is done (whatever the result is)
  153840. */
  153841. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153842. /**
  153843. * Observable called when all tasks are processed
  153844. */
  153845. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153846. /**
  153847. * Observable called when a task had an error
  153848. */
  153849. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153850. /**
  153851. * Observable called when all tasks were executed
  153852. */
  153853. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153854. /**
  153855. * Observable called when a task is done (whatever the result is)
  153856. */
  153857. onProgressObservable: Observable<IAssetsProgressEvent>;
  153858. /**
  153859. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153860. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153861. */
  153862. useDefaultLoadingScreen: boolean;
  153863. /**
  153864. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153865. * when all assets have been downloaded.
  153866. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153867. */
  153868. autoHideLoadingUI: boolean;
  153869. /**
  153870. * Creates a new AssetsManager
  153871. * @param scene defines the scene to work on
  153872. */
  153873. constructor(scene: Scene);
  153874. /**
  153875. * Add a ContainerAssetTask to the list of active tasks
  153876. * @param taskName defines the name of the new task
  153877. * @param meshesNames defines the name of meshes to load
  153878. * @param rootUrl defines the root url to use to locate files
  153879. * @param sceneFilename defines the filename of the scene file
  153880. * @returns a new ContainerAssetTask object
  153881. */
  153882. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153883. /**
  153884. * Add a MeshAssetTask to the list of active tasks
  153885. * @param taskName defines the name of the new task
  153886. * @param meshesNames defines the name of meshes to load
  153887. * @param rootUrl defines the root url to use to locate files
  153888. * @param sceneFilename defines the filename of the scene file
  153889. * @returns a new MeshAssetTask object
  153890. */
  153891. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153892. /**
  153893. * Add a TextFileAssetTask to the list of active tasks
  153894. * @param taskName defines the name of the new task
  153895. * @param url defines the url of the file to load
  153896. * @returns a new TextFileAssetTask object
  153897. */
  153898. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153899. /**
  153900. * Add a BinaryFileAssetTask to the list of active tasks
  153901. * @param taskName defines the name of the new task
  153902. * @param url defines the url of the file to load
  153903. * @returns a new BinaryFileAssetTask object
  153904. */
  153905. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153906. /**
  153907. * Add a ImageAssetTask to the list of active tasks
  153908. * @param taskName defines the name of the new task
  153909. * @param url defines the url of the file to load
  153910. * @returns a new ImageAssetTask object
  153911. */
  153912. addImageTask(taskName: string, url: string): ImageAssetTask;
  153913. /**
  153914. * Add a TextureAssetTask to the list of active tasks
  153915. * @param taskName defines the name of the new task
  153916. * @param url defines the url of the file to load
  153917. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153918. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153919. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153920. * @returns a new TextureAssetTask object
  153921. */
  153922. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153923. /**
  153924. * Add a CubeTextureAssetTask to the list of active tasks
  153925. * @param taskName defines the name of the new task
  153926. * @param url defines the url of the file to load
  153927. * @param extensions defines the extension to use to load the cube map (can be null)
  153928. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153929. * @param files defines the list of files to load (can be null)
  153930. * @returns a new CubeTextureAssetTask object
  153931. */
  153932. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153933. /**
  153934. *
  153935. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153936. * @param taskName defines the name of the new task
  153937. * @param url defines the url of the file to load
  153938. * @param size defines the size you want for the cubemap (can be null)
  153939. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153940. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153941. * @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)
  153942. * @param reserved Internal use only
  153943. * @returns a new HDRCubeTextureAssetTask object
  153944. */
  153945. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153946. /**
  153947. *
  153948. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153949. * @param taskName defines the name of the new task
  153950. * @param url defines the url of the file to load
  153951. * @param size defines the size you want for the cubemap (can be null)
  153952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153953. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153954. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153955. * @returns a new EquiRectangularCubeTextureAssetTask object
  153956. */
  153957. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153958. /**
  153959. * Remove a task from the assets manager.
  153960. * @param task the task to remove
  153961. */
  153962. removeTask(task: AbstractAssetTask): void;
  153963. private _decreaseWaitingTasksCount;
  153964. private _runTask;
  153965. /**
  153966. * Reset the AssetsManager and remove all tasks
  153967. * @return the current instance of the AssetsManager
  153968. */
  153969. reset(): AssetsManager;
  153970. /**
  153971. * Start the loading process
  153972. * @return the current instance of the AssetsManager
  153973. */
  153974. load(): AssetsManager;
  153975. /**
  153976. * Start the loading process as an async operation
  153977. * @return a promise returning the list of failed tasks
  153978. */
  153979. loadAsync(): Promise<void>;
  153980. }
  153981. }
  153982. declare module BABYLON {
  153983. /**
  153984. * Wrapper class for promise with external resolve and reject.
  153985. */
  153986. export class Deferred<T> {
  153987. /**
  153988. * The promise associated with this deferred object.
  153989. */
  153990. readonly promise: Promise<T>;
  153991. private _resolve;
  153992. private _reject;
  153993. /**
  153994. * The resolve method of the promise associated with this deferred object.
  153995. */
  153996. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153997. /**
  153998. * The reject method of the promise associated with this deferred object.
  153999. */
  154000. get reject(): (reason?: any) => void;
  154001. /**
  154002. * Constructor for this deferred object.
  154003. */
  154004. constructor();
  154005. }
  154006. }
  154007. declare module BABYLON {
  154008. /**
  154009. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154010. */
  154011. export class MeshExploder {
  154012. private _centerMesh;
  154013. private _meshes;
  154014. private _meshesOrigins;
  154015. private _toCenterVectors;
  154016. private _scaledDirection;
  154017. private _newPosition;
  154018. private _centerPosition;
  154019. /**
  154020. * Explodes meshes from a center mesh.
  154021. * @param meshes The meshes to explode.
  154022. * @param centerMesh The mesh to be center of explosion.
  154023. */
  154024. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154025. private _setCenterMesh;
  154026. /**
  154027. * Get class name
  154028. * @returns "MeshExploder"
  154029. */
  154030. getClassName(): string;
  154031. /**
  154032. * "Exploded meshes"
  154033. * @returns Array of meshes with the centerMesh at index 0.
  154034. */
  154035. getMeshes(): Array<Mesh>;
  154036. /**
  154037. * Explodes meshes giving a specific direction
  154038. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154039. */
  154040. explode(direction?: number): void;
  154041. }
  154042. }
  154043. declare module BABYLON {
  154044. /**
  154045. * Class used to help managing file picking and drag'n'drop
  154046. */
  154047. export class FilesInput {
  154048. /**
  154049. * List of files ready to be loaded
  154050. */
  154051. static get FilesToLoad(): {
  154052. [key: string]: File;
  154053. };
  154054. /**
  154055. * Callback called when a file is processed
  154056. */
  154057. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154058. private _engine;
  154059. private _currentScene;
  154060. private _sceneLoadedCallback;
  154061. private _progressCallback;
  154062. private _additionalRenderLoopLogicCallback;
  154063. private _textureLoadingCallback;
  154064. private _startingProcessingFilesCallback;
  154065. private _onReloadCallback;
  154066. private _errorCallback;
  154067. private _elementToMonitor;
  154068. private _sceneFileToLoad;
  154069. private _filesToLoad;
  154070. /**
  154071. * Creates a new FilesInput
  154072. * @param engine defines the rendering engine
  154073. * @param scene defines the hosting scene
  154074. * @param sceneLoadedCallback callback called when scene is loaded
  154075. * @param progressCallback callback called to track progress
  154076. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154077. * @param textureLoadingCallback callback called when a texture is loading
  154078. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154079. * @param onReloadCallback callback called when a reload is requested
  154080. * @param errorCallback callback call if an error occurs
  154081. */
  154082. 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>);
  154083. private _dragEnterHandler;
  154084. private _dragOverHandler;
  154085. private _dropHandler;
  154086. /**
  154087. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154088. * @param elementToMonitor defines the DOM element to track
  154089. */
  154090. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154091. /** Gets the current list of files to load */
  154092. get filesToLoad(): File[];
  154093. /**
  154094. * Release all associated resources
  154095. */
  154096. dispose(): void;
  154097. private renderFunction;
  154098. private drag;
  154099. private drop;
  154100. private _traverseFolder;
  154101. private _processFiles;
  154102. /**
  154103. * Load files from a drop event
  154104. * @param event defines the drop event to use as source
  154105. */
  154106. loadFiles(event: any): void;
  154107. private _processReload;
  154108. /**
  154109. * Reload the current scene from the loaded files
  154110. */
  154111. reload(): void;
  154112. }
  154113. }
  154114. declare module BABYLON {
  154115. /**
  154116. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154117. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154118. */
  154119. export class SceneOptimization {
  154120. /**
  154121. * Defines the priority of this optimization (0 by default which means first in the list)
  154122. */
  154123. priority: number;
  154124. /**
  154125. * Gets a string describing the action executed by the current optimization
  154126. * @returns description string
  154127. */
  154128. getDescription(): string;
  154129. /**
  154130. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154131. * @param scene defines the current scene where to apply this optimization
  154132. * @param optimizer defines the current optimizer
  154133. * @returns true if everything that can be done was applied
  154134. */
  154135. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154136. /**
  154137. * Creates the SceneOptimization object
  154138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154139. * @param desc defines the description associated with the optimization
  154140. */
  154141. constructor(
  154142. /**
  154143. * Defines the priority of this optimization (0 by default which means first in the list)
  154144. */
  154145. priority?: number);
  154146. }
  154147. /**
  154148. * Defines an optimization used to reduce the size of render target textures
  154149. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154150. */
  154151. export class TextureOptimization extends SceneOptimization {
  154152. /**
  154153. * Defines the priority of this optimization (0 by default which means first in the list)
  154154. */
  154155. priority: number;
  154156. /**
  154157. * 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
  154158. */
  154159. maximumSize: number;
  154160. /**
  154161. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154162. */
  154163. step: number;
  154164. /**
  154165. * Gets a string describing the action executed by the current optimization
  154166. * @returns description string
  154167. */
  154168. getDescription(): string;
  154169. /**
  154170. * Creates the TextureOptimization object
  154171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154172. * @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
  154173. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154174. */
  154175. constructor(
  154176. /**
  154177. * Defines the priority of this optimization (0 by default which means first in the list)
  154178. */
  154179. priority?: number,
  154180. /**
  154181. * 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
  154182. */
  154183. maximumSize?: number,
  154184. /**
  154185. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154186. */
  154187. step?: number);
  154188. /**
  154189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154190. * @param scene defines the current scene where to apply this optimization
  154191. * @param optimizer defines the current optimizer
  154192. * @returns true if everything that can be done was applied
  154193. */
  154194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154195. }
  154196. /**
  154197. * Defines an optimization used to increase or decrease the rendering resolution
  154198. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154199. */
  154200. export class HardwareScalingOptimization extends SceneOptimization {
  154201. /**
  154202. * Defines the priority of this optimization (0 by default which means first in the list)
  154203. */
  154204. priority: number;
  154205. /**
  154206. * Defines the maximum scale to use (2 by default)
  154207. */
  154208. maximumScale: number;
  154209. /**
  154210. * Defines the step to use between two passes (0.5 by default)
  154211. */
  154212. step: number;
  154213. private _currentScale;
  154214. private _directionOffset;
  154215. /**
  154216. * Gets a string describing the action executed by the current optimization
  154217. * @return description string
  154218. */
  154219. getDescription(): string;
  154220. /**
  154221. * Creates the HardwareScalingOptimization object
  154222. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154223. * @param maximumScale defines the maximum scale to use (2 by default)
  154224. * @param step defines the step to use between two passes (0.5 by default)
  154225. */
  154226. constructor(
  154227. /**
  154228. * Defines the priority of this optimization (0 by default which means first in the list)
  154229. */
  154230. priority?: number,
  154231. /**
  154232. * Defines the maximum scale to use (2 by default)
  154233. */
  154234. maximumScale?: number,
  154235. /**
  154236. * Defines the step to use between two passes (0.5 by default)
  154237. */
  154238. step?: number);
  154239. /**
  154240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154241. * @param scene defines the current scene where to apply this optimization
  154242. * @param optimizer defines the current optimizer
  154243. * @returns true if everything that can be done was applied
  154244. */
  154245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154246. }
  154247. /**
  154248. * Defines an optimization used to remove shadows
  154249. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154250. */
  154251. export class ShadowsOptimization extends SceneOptimization {
  154252. /**
  154253. * Gets a string describing the action executed by the current optimization
  154254. * @return description string
  154255. */
  154256. getDescription(): string;
  154257. /**
  154258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154259. * @param scene defines the current scene where to apply this optimization
  154260. * @param optimizer defines the current optimizer
  154261. * @returns true if everything that can be done was applied
  154262. */
  154263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154264. }
  154265. /**
  154266. * Defines an optimization used to turn post-processes off
  154267. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154268. */
  154269. export class PostProcessesOptimization extends SceneOptimization {
  154270. /**
  154271. * Gets a string describing the action executed by the current optimization
  154272. * @return description string
  154273. */
  154274. getDescription(): string;
  154275. /**
  154276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154277. * @param scene defines the current scene where to apply this optimization
  154278. * @param optimizer defines the current optimizer
  154279. * @returns true if everything that can be done was applied
  154280. */
  154281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154282. }
  154283. /**
  154284. * Defines an optimization used to turn lens flares off
  154285. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154286. */
  154287. export class LensFlaresOptimization extends SceneOptimization {
  154288. /**
  154289. * Gets a string describing the action executed by the current optimization
  154290. * @return description string
  154291. */
  154292. getDescription(): string;
  154293. /**
  154294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154295. * @param scene defines the current scene where to apply this optimization
  154296. * @param optimizer defines the current optimizer
  154297. * @returns true if everything that can be done was applied
  154298. */
  154299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154300. }
  154301. /**
  154302. * Defines an optimization based on user defined callback.
  154303. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154304. */
  154305. export class CustomOptimization extends SceneOptimization {
  154306. /**
  154307. * Callback called to apply the custom optimization.
  154308. */
  154309. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154310. /**
  154311. * Callback called to get custom description
  154312. */
  154313. onGetDescription: () => string;
  154314. /**
  154315. * Gets a string describing the action executed by the current optimization
  154316. * @returns description string
  154317. */
  154318. getDescription(): string;
  154319. /**
  154320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154321. * @param scene defines the current scene where to apply this optimization
  154322. * @param optimizer defines the current optimizer
  154323. * @returns true if everything that can be done was applied
  154324. */
  154325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154326. }
  154327. /**
  154328. * Defines an optimization used to turn particles off
  154329. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154330. */
  154331. export class ParticlesOptimization extends SceneOptimization {
  154332. /**
  154333. * Gets a string describing the action executed by the current optimization
  154334. * @return description string
  154335. */
  154336. getDescription(): string;
  154337. /**
  154338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154339. * @param scene defines the current scene where to apply this optimization
  154340. * @param optimizer defines the current optimizer
  154341. * @returns true if everything that can be done was applied
  154342. */
  154343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154344. }
  154345. /**
  154346. * Defines an optimization used to turn render targets off
  154347. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154348. */
  154349. export class RenderTargetsOptimization extends SceneOptimization {
  154350. /**
  154351. * Gets a string describing the action executed by the current optimization
  154352. * @return description string
  154353. */
  154354. getDescription(): string;
  154355. /**
  154356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154357. * @param scene defines the current scene where to apply this optimization
  154358. * @param optimizer defines the current optimizer
  154359. * @returns true if everything that can be done was applied
  154360. */
  154361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154362. }
  154363. /**
  154364. * Defines an optimization used to merge meshes with compatible materials
  154365. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154366. */
  154367. export class MergeMeshesOptimization extends SceneOptimization {
  154368. private static _UpdateSelectionTree;
  154369. /**
  154370. * Gets or sets a boolean which defines if optimization octree has to be updated
  154371. */
  154372. static get UpdateSelectionTree(): boolean;
  154373. /**
  154374. * Gets or sets a boolean which defines if optimization octree has to be updated
  154375. */
  154376. static set UpdateSelectionTree(value: boolean);
  154377. /**
  154378. * Gets a string describing the action executed by the current optimization
  154379. * @return description string
  154380. */
  154381. getDescription(): string;
  154382. private _canBeMerged;
  154383. /**
  154384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154385. * @param scene defines the current scene where to apply this optimization
  154386. * @param optimizer defines the current optimizer
  154387. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154388. * @returns true if everything that can be done was applied
  154389. */
  154390. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154391. }
  154392. /**
  154393. * Defines a list of options used by SceneOptimizer
  154394. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154395. */
  154396. export class SceneOptimizerOptions {
  154397. /**
  154398. * Defines the target frame rate to reach (60 by default)
  154399. */
  154400. targetFrameRate: number;
  154401. /**
  154402. * Defines the interval between two checkes (2000ms by default)
  154403. */
  154404. trackerDuration: number;
  154405. /**
  154406. * Gets the list of optimizations to apply
  154407. */
  154408. optimizations: SceneOptimization[];
  154409. /**
  154410. * Creates a new list of options used by SceneOptimizer
  154411. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154412. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154413. */
  154414. constructor(
  154415. /**
  154416. * Defines the target frame rate to reach (60 by default)
  154417. */
  154418. targetFrameRate?: number,
  154419. /**
  154420. * Defines the interval between two checkes (2000ms by default)
  154421. */
  154422. trackerDuration?: number);
  154423. /**
  154424. * Add a new optimization
  154425. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154426. * @returns the current SceneOptimizerOptions
  154427. */
  154428. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154429. /**
  154430. * Add a new custom optimization
  154431. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154432. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154434. * @returns the current SceneOptimizerOptions
  154435. */
  154436. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154437. /**
  154438. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154439. * @param targetFrameRate defines the target frame rate (60 by default)
  154440. * @returns a SceneOptimizerOptions object
  154441. */
  154442. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154443. /**
  154444. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154445. * @param targetFrameRate defines the target frame rate (60 by default)
  154446. * @returns a SceneOptimizerOptions object
  154447. */
  154448. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154449. /**
  154450. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154451. * @param targetFrameRate defines the target frame rate (60 by default)
  154452. * @returns a SceneOptimizerOptions object
  154453. */
  154454. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154455. }
  154456. /**
  154457. * Class used to run optimizations in order to reach a target frame rate
  154458. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154459. */
  154460. export class SceneOptimizer implements IDisposable {
  154461. private _isRunning;
  154462. private _options;
  154463. private _scene;
  154464. private _currentPriorityLevel;
  154465. private _targetFrameRate;
  154466. private _trackerDuration;
  154467. private _currentFrameRate;
  154468. private _sceneDisposeObserver;
  154469. private _improvementMode;
  154470. /**
  154471. * Defines an observable called when the optimizer reaches the target frame rate
  154472. */
  154473. onSuccessObservable: Observable<SceneOptimizer>;
  154474. /**
  154475. * Defines an observable called when the optimizer enables an optimization
  154476. */
  154477. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154478. /**
  154479. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154480. */
  154481. onFailureObservable: Observable<SceneOptimizer>;
  154482. /**
  154483. * Gets a boolean indicating if the optimizer is in improvement mode
  154484. */
  154485. get isInImprovementMode(): boolean;
  154486. /**
  154487. * Gets the current priority level (0 at start)
  154488. */
  154489. get currentPriorityLevel(): number;
  154490. /**
  154491. * Gets the current frame rate checked by the SceneOptimizer
  154492. */
  154493. get currentFrameRate(): number;
  154494. /**
  154495. * Gets or sets the current target frame rate (60 by default)
  154496. */
  154497. get targetFrameRate(): number;
  154498. /**
  154499. * Gets or sets the current target frame rate (60 by default)
  154500. */
  154501. set targetFrameRate(value: number);
  154502. /**
  154503. * Gets or sets the current interval between two checks (every 2000ms by default)
  154504. */
  154505. get trackerDuration(): number;
  154506. /**
  154507. * Gets or sets the current interval between two checks (every 2000ms by default)
  154508. */
  154509. set trackerDuration(value: number);
  154510. /**
  154511. * Gets the list of active optimizations
  154512. */
  154513. get optimizations(): SceneOptimization[];
  154514. /**
  154515. * Creates a new SceneOptimizer
  154516. * @param scene defines the scene to work on
  154517. * @param options defines the options to use with the SceneOptimizer
  154518. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154519. * @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)
  154520. */
  154521. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154522. /**
  154523. * Stops the current optimizer
  154524. */
  154525. stop(): void;
  154526. /**
  154527. * Reset the optimizer to initial step (current priority level = 0)
  154528. */
  154529. reset(): void;
  154530. /**
  154531. * Start the optimizer. By default it will try to reach a specific framerate
  154532. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154533. */
  154534. start(): void;
  154535. private _checkCurrentState;
  154536. /**
  154537. * Release all resources
  154538. */
  154539. dispose(): void;
  154540. /**
  154541. * Helper function to create a SceneOptimizer with one single line of code
  154542. * @param scene defines the scene to work on
  154543. * @param options defines the options to use with the SceneOptimizer
  154544. * @param onSuccess defines a callback to call on success
  154545. * @param onFailure defines a callback to call on failure
  154546. * @returns the new SceneOptimizer object
  154547. */
  154548. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154549. }
  154550. }
  154551. declare module BABYLON {
  154552. /**
  154553. * Class used to serialize a scene into a string
  154554. */
  154555. export class SceneSerializer {
  154556. /**
  154557. * Clear cache used by a previous serialization
  154558. */
  154559. static ClearCache(): void;
  154560. /**
  154561. * Serialize a scene into a JSON compatible object
  154562. * @param scene defines the scene to serialize
  154563. * @returns a JSON compatible object
  154564. */
  154565. static Serialize(scene: Scene): any;
  154566. /**
  154567. * Serialize a mesh into a JSON compatible object
  154568. * @param toSerialize defines the mesh to serialize
  154569. * @param withParents defines if parents must be serialized as well
  154570. * @param withChildren defines if children must be serialized as well
  154571. * @returns a JSON compatible object
  154572. */
  154573. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154574. }
  154575. }
  154576. declare module BABYLON {
  154577. /**
  154578. * Class used to host texture specific utilities
  154579. */
  154580. export class TextureTools {
  154581. /**
  154582. * Uses the GPU to create a copy texture rescaled at a given size
  154583. * @param texture Texture to copy from
  154584. * @param width defines the desired width
  154585. * @param height defines the desired height
  154586. * @param useBilinearMode defines if bilinear mode has to be used
  154587. * @return the generated texture
  154588. */
  154589. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154590. }
  154591. }
  154592. declare module BABYLON {
  154593. /**
  154594. * This represents the different options available for the video capture.
  154595. */
  154596. export interface VideoRecorderOptions {
  154597. /** Defines the mime type of the video. */
  154598. mimeType: string;
  154599. /** Defines the FPS the video should be recorded at. */
  154600. fps: number;
  154601. /** Defines the chunk size for the recording data. */
  154602. recordChunckSize: number;
  154603. /** The audio tracks to attach to the recording. */
  154604. audioTracks?: MediaStreamTrack[];
  154605. }
  154606. /**
  154607. * This can help with recording videos from BabylonJS.
  154608. * This is based on the available WebRTC functionalities of the browser.
  154609. *
  154610. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154611. */
  154612. export class VideoRecorder {
  154613. private static readonly _defaultOptions;
  154614. /**
  154615. * Returns whether or not the VideoRecorder is available in your browser.
  154616. * @param engine Defines the Babylon Engine.
  154617. * @returns true if supported otherwise false.
  154618. */
  154619. static IsSupported(engine: Engine): boolean;
  154620. private readonly _options;
  154621. private _canvas;
  154622. private _mediaRecorder;
  154623. private _recordedChunks;
  154624. private _fileName;
  154625. private _resolve;
  154626. private _reject;
  154627. /**
  154628. * True when a recording is already in progress.
  154629. */
  154630. get isRecording(): boolean;
  154631. /**
  154632. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154633. * @param engine Defines the BabylonJS Engine you wish to record.
  154634. * @param options Defines options that can be used to customize the capture.
  154635. */
  154636. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154637. /**
  154638. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154639. */
  154640. stopRecording(): void;
  154641. /**
  154642. * Starts recording the canvas for a max duration specified in parameters.
  154643. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154644. * If null no automatic download will start and you can rely on the promise to get the data back.
  154645. * @param maxDuration Defines the maximum recording time in seconds.
  154646. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154647. * @return A promise callback at the end of the recording with the video data in Blob.
  154648. */
  154649. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154650. /**
  154651. * Releases internal resources used during the recording.
  154652. */
  154653. dispose(): void;
  154654. private _handleDataAvailable;
  154655. private _handleError;
  154656. private _handleStop;
  154657. }
  154658. }
  154659. declare module BABYLON {
  154660. /**
  154661. * Class containing a set of static utilities functions for screenshots
  154662. */
  154663. export class ScreenshotTools {
  154664. /**
  154665. * Captures a screenshot of the current rendering
  154666. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154667. * @param engine defines the rendering engine
  154668. * @param camera defines the source camera
  154669. * @param size This parameter can be set to a single number or to an object with the
  154670. * following (optional) properties: precision, width, height. If a single number is passed,
  154671. * it will be used for both width and height. If an object is passed, the screenshot size
  154672. * will be derived from the parameters. The precision property is a multiplier allowing
  154673. * rendering at a higher or lower resolution
  154674. * @param successCallback defines the callback receives a single parameter which contains the
  154675. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154676. * src parameter of an <img> to display it
  154677. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154678. * Check your browser for supported MIME types
  154679. */
  154680. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154681. /**
  154682. * Captures a screenshot of the current rendering
  154683. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154684. * @param engine defines the rendering engine
  154685. * @param camera defines the source camera
  154686. * @param size This parameter can be set to a single number or to an object with the
  154687. * following (optional) properties: precision, width, height. If a single number is passed,
  154688. * it will be used for both width and height. If an object is passed, the screenshot size
  154689. * will be derived from the parameters. The precision property is a multiplier allowing
  154690. * rendering at a higher or lower resolution
  154691. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154692. * Check your browser for supported MIME types
  154693. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154694. * to the src parameter of an <img> to display it
  154695. */
  154696. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154697. /**
  154698. * Generates an image screenshot from the specified camera.
  154699. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154700. * @param engine The engine to use for rendering
  154701. * @param camera The camera to use for rendering
  154702. * @param size This parameter can be set to a single number or to an object with the
  154703. * following (optional) properties: precision, width, height. If a single number is passed,
  154704. * it will be used for both width and height. If an object is passed, the screenshot size
  154705. * will be derived from the parameters. The precision property is a multiplier allowing
  154706. * rendering at a higher or lower resolution
  154707. * @param successCallback The callback receives a single parameter which contains the
  154708. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154709. * src parameter of an <img> to display it
  154710. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154711. * Check your browser for supported MIME types
  154712. * @param samples Texture samples (default: 1)
  154713. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154714. * @param fileName A name for for the downloaded file.
  154715. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154716. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154717. */
  154718. 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;
  154719. /**
  154720. * Generates an image screenshot from the specified camera.
  154721. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154722. * @param engine The engine to use for rendering
  154723. * @param camera The camera to use for rendering
  154724. * @param size This parameter can be set to a single number or to an object with the
  154725. * following (optional) properties: precision, width, height. If a single number is passed,
  154726. * it will be used for both width and height. If an object is passed, the screenshot size
  154727. * will be derived from the parameters. The precision property is a multiplier allowing
  154728. * rendering at a higher or lower resolution
  154729. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154730. * Check your browser for supported MIME types
  154731. * @param samples Texture samples (default: 1)
  154732. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154733. * @param fileName A name for for the downloaded file.
  154734. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154735. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154736. * to the src parameter of an <img> to display it
  154737. */
  154738. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154739. /**
  154740. * Gets height and width for screenshot size
  154741. * @private
  154742. */
  154743. private static _getScreenshotSize;
  154744. }
  154745. }
  154746. declare module BABYLON {
  154747. /**
  154748. * Interface for a data buffer
  154749. */
  154750. export interface IDataBuffer {
  154751. /**
  154752. * Reads bytes from the data buffer.
  154753. * @param byteOffset The byte offset to read
  154754. * @param byteLength The byte length to read
  154755. * @returns A promise that resolves when the bytes are read
  154756. */
  154757. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154758. /**
  154759. * The byte length of the buffer.
  154760. */
  154761. readonly byteLength: number;
  154762. }
  154763. /**
  154764. * Utility class for reading from a data buffer
  154765. */
  154766. export class DataReader {
  154767. /**
  154768. * The data buffer associated with this data reader.
  154769. */
  154770. readonly buffer: IDataBuffer;
  154771. /**
  154772. * The current byte offset from the beginning of the data buffer.
  154773. */
  154774. byteOffset: number;
  154775. private _dataView;
  154776. private _dataByteOffset;
  154777. /**
  154778. * Constructor
  154779. * @param buffer The buffer to read
  154780. */
  154781. constructor(buffer: IDataBuffer);
  154782. /**
  154783. * Loads the given byte length.
  154784. * @param byteLength The byte length to load
  154785. * @returns A promise that resolves when the load is complete
  154786. */
  154787. loadAsync(byteLength: number): Promise<void>;
  154788. /**
  154789. * Read a unsigned 32-bit integer from the currently loaded data range.
  154790. * @returns The 32-bit integer read
  154791. */
  154792. readUint32(): number;
  154793. /**
  154794. * Read a byte array from the currently loaded data range.
  154795. * @param byteLength The byte length to read
  154796. * @returns The byte array read
  154797. */
  154798. readUint8Array(byteLength: number): Uint8Array;
  154799. /**
  154800. * Read a string from the currently loaded data range.
  154801. * @param byteLength The byte length to read
  154802. * @returns The string read
  154803. */
  154804. readString(byteLength: number): string;
  154805. /**
  154806. * Skips the given byte length the currently loaded data range.
  154807. * @param byteLength The byte length to skip
  154808. */
  154809. skipBytes(byteLength: number): void;
  154810. }
  154811. }
  154812. declare module BABYLON {
  154813. /**
  154814. * Class for storing data to local storage if available or in-memory storage otherwise
  154815. */
  154816. export class DataStorage {
  154817. private static _Storage;
  154818. private static _GetStorage;
  154819. /**
  154820. * Reads a string from the data storage
  154821. * @param key The key to read
  154822. * @param defaultValue The value if the key doesn't exist
  154823. * @returns The string value
  154824. */
  154825. static ReadString(key: string, defaultValue: string): string;
  154826. /**
  154827. * Writes a string to the data storage
  154828. * @param key The key to write
  154829. * @param value The value to write
  154830. */
  154831. static WriteString(key: string, value: string): void;
  154832. /**
  154833. * Reads a boolean from the data storage
  154834. * @param key The key to read
  154835. * @param defaultValue The value if the key doesn't exist
  154836. * @returns The boolean value
  154837. */
  154838. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154839. /**
  154840. * Writes a boolean to the data storage
  154841. * @param key The key to write
  154842. * @param value The value to write
  154843. */
  154844. static WriteBoolean(key: string, value: boolean): void;
  154845. /**
  154846. * Reads a number from the data storage
  154847. * @param key The key to read
  154848. * @param defaultValue The value if the key doesn't exist
  154849. * @returns The number value
  154850. */
  154851. static ReadNumber(key: string, defaultValue: number): number;
  154852. /**
  154853. * Writes a number to the data storage
  154854. * @param key The key to write
  154855. * @param value The value to write
  154856. */
  154857. static WriteNumber(key: string, value: number): void;
  154858. }
  154859. }
  154860. declare module BABYLON {
  154861. /**
  154862. * Class used to record delta files between 2 scene states
  154863. */
  154864. export class SceneRecorder {
  154865. private _trackedScene;
  154866. private _savedJSON;
  154867. /**
  154868. * Track a given scene. This means the current scene state will be considered the original state
  154869. * @param scene defines the scene to track
  154870. */
  154871. track(scene: Scene): void;
  154872. /**
  154873. * Get the delta between current state and original state
  154874. * @returns a string containing the delta
  154875. */
  154876. getDelta(): any;
  154877. private _compareArray;
  154878. private _compareObjects;
  154879. private _compareCollections;
  154880. private static GetShadowGeneratorById;
  154881. /**
  154882. * Apply a given delta to a given scene
  154883. * @param deltaJSON defines the JSON containing the delta
  154884. * @param scene defines the scene to apply the delta to
  154885. */
  154886. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154887. private static _ApplyPropertiesToEntity;
  154888. private static _ApplyDeltaForEntity;
  154889. }
  154890. }
  154891. declare module BABYLON {
  154892. /**
  154893. * A 3D trajectory consisting of an order list of vectors describing a
  154894. * path of motion through 3D space.
  154895. */
  154896. export class Trajectory {
  154897. private _points;
  154898. private readonly _segmentLength;
  154899. /**
  154900. * Serialize to JSON.
  154901. * @returns serialized JSON string
  154902. */
  154903. serialize(): string;
  154904. /**
  154905. * Deserialize from JSON.
  154906. * @param json serialized JSON string
  154907. * @returns deserialized Trajectory
  154908. */
  154909. static Deserialize(json: string): Trajectory;
  154910. /**
  154911. * Create a new empty Trajectory.
  154912. * @param segmentLength radius of discretization for Trajectory points
  154913. */
  154914. constructor(segmentLength?: number);
  154915. /**
  154916. * Get the length of the Trajectory.
  154917. * @returns length of the Trajectory
  154918. */
  154919. getLength(): number;
  154920. /**
  154921. * Append a new point to the Trajectory.
  154922. * NOTE: This implementation has many allocations.
  154923. * @param point point to append to the Trajectory
  154924. */
  154925. add(point: DeepImmutable<Vector3>): void;
  154926. /**
  154927. * Create a new Trajectory with a segment length chosen to make it
  154928. * probable that the new Trajectory will have a specified number of
  154929. * segments. This operation is imprecise.
  154930. * @param targetResolution number of segments desired
  154931. * @returns new Trajectory with approximately the requested number of segments
  154932. */
  154933. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154934. /**
  154935. * Convert Trajectory segments into tokenized representation. This
  154936. * representation is an array of numbers where each nth number is the
  154937. * index of the token which is most similar to the nth segment of the
  154938. * Trajectory.
  154939. * @param tokens list of vectors which serve as discrete tokens
  154940. * @returns list of indices of most similar token per segment
  154941. */
  154942. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154943. private static _forwardDir;
  154944. private static _inverseFromVec;
  154945. private static _upDir;
  154946. private static _fromToVec;
  154947. private static _lookMatrix;
  154948. /**
  154949. * Transform the rotation (i.e., direction) of a segment to isolate
  154950. * the relative transformation represented by the segment. This operation
  154951. * may or may not succeed due to singularities in the equations that define
  154952. * motion relativity in this context.
  154953. * @param priorVec the origin of the prior segment
  154954. * @param fromVec the origin of the current segment
  154955. * @param toVec the destination of the current segment
  154956. * @param result reference to output variable
  154957. * @returns whether or not transformation was successful
  154958. */
  154959. private static _transformSegmentDirToRef;
  154960. private static _bestMatch;
  154961. private static _score;
  154962. private static _bestScore;
  154963. /**
  154964. * Determine which token vector is most similar to the
  154965. * segment vector.
  154966. * @param segment segment vector
  154967. * @param tokens token vector list
  154968. * @returns index of the most similar token to the segment
  154969. */
  154970. private static _tokenizeSegment;
  154971. }
  154972. /**
  154973. * Class representing a set of known, named trajectories to which Trajectories can be
  154974. * added and using which Trajectories can be recognized.
  154975. */
  154976. export class TrajectoryClassifier {
  154977. private _maximumAllowableMatchCost;
  154978. private _vector3Alphabet;
  154979. private _levenshteinAlphabet;
  154980. private _nameToDescribedTrajectory;
  154981. /**
  154982. * Serialize to JSON.
  154983. * @returns JSON serialization
  154984. */
  154985. serialize(): string;
  154986. /**
  154987. * Deserialize from JSON.
  154988. * @param json JSON serialization
  154989. * @returns deserialized TrajectorySet
  154990. */
  154991. static Deserialize(json: string): TrajectoryClassifier;
  154992. /**
  154993. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  154994. * VERY naive, need to be generating these things from known
  154995. * sets. Better version later, probably eliminating this one.
  154996. * @returns auto-generated TrajectorySet
  154997. */
  154998. static Generate(): TrajectoryClassifier;
  154999. private constructor();
  155000. /**
  155001. * Add a new Trajectory to the set with a given name.
  155002. * @param trajectory new Trajectory to be added
  155003. * @param classification name to which to add the Trajectory
  155004. */
  155005. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155006. /**
  155007. * Remove a known named trajectory and all Trajectories associated with it.
  155008. * @param classification name to remove
  155009. * @returns whether anything was removed
  155010. */
  155011. deleteClassification(classification: string): boolean;
  155012. /**
  155013. * Attempt to recognize a Trajectory from among all the classifications
  155014. * already known to the classifier.
  155015. * @param trajectory Trajectory to be recognized
  155016. * @returns classification of Trajectory if recognized, null otherwise
  155017. */
  155018. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155019. }
  155020. }
  155021. declare module BABYLON {
  155022. /**
  155023. * An interface for all Hit test features
  155024. */
  155025. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155026. /**
  155027. * Triggered when new babylon (transformed) hit test results are available
  155028. */
  155029. onHitTestResultObservable: Observable<T[]>;
  155030. }
  155031. /**
  155032. * Options used for hit testing
  155033. */
  155034. export interface IWebXRLegacyHitTestOptions {
  155035. /**
  155036. * Only test when user interacted with the scene. Default - hit test every frame
  155037. */
  155038. testOnPointerDownOnly?: boolean;
  155039. /**
  155040. * The node to use to transform the local results to world coordinates
  155041. */
  155042. worldParentNode?: TransformNode;
  155043. }
  155044. /**
  155045. * Interface defining the babylon result of raycasting/hit-test
  155046. */
  155047. export interface IWebXRLegacyHitResult {
  155048. /**
  155049. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155050. */
  155051. transformationMatrix: Matrix;
  155052. /**
  155053. * The native hit test result
  155054. */
  155055. xrHitResult: XRHitResult | XRHitTestResult;
  155056. }
  155057. /**
  155058. * The currently-working hit-test module.
  155059. * Hit test (or Ray-casting) is used to interact with the real world.
  155060. * For further information read here - https://github.com/immersive-web/hit-test
  155061. */
  155062. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155063. /**
  155064. * options to use when constructing this feature
  155065. */
  155066. readonly options: IWebXRLegacyHitTestOptions;
  155067. private _direction;
  155068. private _mat;
  155069. private _onSelectEnabled;
  155070. private _origin;
  155071. /**
  155072. * The module's name
  155073. */
  155074. static readonly Name: string;
  155075. /**
  155076. * The (Babylon) version of this module.
  155077. * This is an integer representing the implementation version.
  155078. * This number does not correspond to the WebXR specs version
  155079. */
  155080. static readonly Version: number;
  155081. /**
  155082. * Populated with the last native XR Hit Results
  155083. */
  155084. lastNativeXRHitResults: XRHitResult[];
  155085. /**
  155086. * Triggered when new babylon (transformed) hit test results are available
  155087. */
  155088. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155089. /**
  155090. * Creates a new instance of the (legacy version) hit test feature
  155091. * @param _xrSessionManager an instance of WebXRSessionManager
  155092. * @param options options to use when constructing this feature
  155093. */
  155094. constructor(_xrSessionManager: WebXRSessionManager,
  155095. /**
  155096. * options to use when constructing this feature
  155097. */
  155098. options?: IWebXRLegacyHitTestOptions);
  155099. /**
  155100. * execute a hit test with an XR Ray
  155101. *
  155102. * @param xrSession a native xrSession that will execute this hit test
  155103. * @param xrRay the ray (position and direction) to use for ray-casting
  155104. * @param referenceSpace native XR reference space to use for the hit-test
  155105. * @param filter filter function that will filter the results
  155106. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155107. */
  155108. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155109. /**
  155110. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155111. * @param event the (select) event to use to select with
  155112. * @param referenceSpace the reference space to use for this hit test
  155113. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155114. */
  155115. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155116. /**
  155117. * attach this feature
  155118. * Will usually be called by the features manager
  155119. *
  155120. * @returns true if successful.
  155121. */
  155122. attach(): boolean;
  155123. /**
  155124. * detach this feature.
  155125. * Will usually be called by the features manager
  155126. *
  155127. * @returns true if successful.
  155128. */
  155129. detach(): boolean;
  155130. /**
  155131. * Dispose this feature and all of the resources attached
  155132. */
  155133. dispose(): void;
  155134. protected _onXRFrame(frame: XRFrame): void;
  155135. private _onHitTestResults;
  155136. private _onSelect;
  155137. }
  155138. }
  155139. declare module BABYLON {
  155140. /**
  155141. * Options used for hit testing (version 2)
  155142. */
  155143. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155144. /**
  155145. * Do not create a permanent hit test. Will usually be used when only
  155146. * transient inputs are needed.
  155147. */
  155148. disablePermanentHitTest?: boolean;
  155149. /**
  155150. * Enable transient (for example touch-based) hit test inspections
  155151. */
  155152. enableTransientHitTest?: boolean;
  155153. /**
  155154. * Offset ray for the permanent hit test
  155155. */
  155156. offsetRay?: Vector3;
  155157. /**
  155158. * Offset ray for the transient hit test
  155159. */
  155160. transientOffsetRay?: Vector3;
  155161. /**
  155162. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155163. */
  155164. useReferenceSpace?: boolean;
  155165. /**
  155166. * Override the default entity type(s) of the hit-test result
  155167. */
  155168. entityTypes?: XRHitTestTrackableType[];
  155169. }
  155170. /**
  155171. * Interface defining the babylon result of hit-test
  155172. */
  155173. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155174. /**
  155175. * The input source that generated this hit test (if transient)
  155176. */
  155177. inputSource?: XRInputSource;
  155178. /**
  155179. * Is this a transient hit test
  155180. */
  155181. isTransient?: boolean;
  155182. /**
  155183. * Position of the hit test result
  155184. */
  155185. position: Vector3;
  155186. /**
  155187. * Rotation of the hit test result
  155188. */
  155189. rotationQuaternion: Quaternion;
  155190. /**
  155191. * The native hit test result
  155192. */
  155193. xrHitResult: XRHitTestResult;
  155194. }
  155195. /**
  155196. * The currently-working hit-test module.
  155197. * Hit test (or Ray-casting) is used to interact with the real world.
  155198. * For further information read here - https://github.com/immersive-web/hit-test
  155199. *
  155200. * Tested on chrome (mobile) 80.
  155201. */
  155202. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155203. /**
  155204. * options to use when constructing this feature
  155205. */
  155206. readonly options: IWebXRHitTestOptions;
  155207. private _tmpMat;
  155208. private _tmpPos;
  155209. private _tmpQuat;
  155210. private _transientXrHitTestSource;
  155211. private _xrHitTestSource;
  155212. private initHitTestSource;
  155213. /**
  155214. * The module's name
  155215. */
  155216. static readonly Name: string;
  155217. /**
  155218. * The (Babylon) version of this module.
  155219. * This is an integer representing the implementation version.
  155220. * This number does not correspond to the WebXR specs version
  155221. */
  155222. static readonly Version: number;
  155223. /**
  155224. * When set to true, each hit test will have its own position/rotation objects
  155225. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155226. * the developers will clone them or copy them as they see fit.
  155227. */
  155228. autoCloneTransformation: boolean;
  155229. /**
  155230. * Triggered when new babylon (transformed) hit test results are available
  155231. * Note - this will be called when results come back from the device. It can be an empty array!!
  155232. */
  155233. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155234. /**
  155235. * Use this to temporarily pause hit test checks.
  155236. */
  155237. paused: boolean;
  155238. /**
  155239. * Creates a new instance of the hit test feature
  155240. * @param _xrSessionManager an instance of WebXRSessionManager
  155241. * @param options options to use when constructing this feature
  155242. */
  155243. constructor(_xrSessionManager: WebXRSessionManager,
  155244. /**
  155245. * options to use when constructing this feature
  155246. */
  155247. options?: IWebXRHitTestOptions);
  155248. /**
  155249. * attach this feature
  155250. * Will usually be called by the features manager
  155251. *
  155252. * @returns true if successful.
  155253. */
  155254. attach(): boolean;
  155255. /**
  155256. * detach this feature.
  155257. * Will usually be called by the features manager
  155258. *
  155259. * @returns true if successful.
  155260. */
  155261. detach(): boolean;
  155262. /**
  155263. * Dispose this feature and all of the resources attached
  155264. */
  155265. dispose(): void;
  155266. protected _onXRFrame(frame: XRFrame): void;
  155267. private _processWebXRHitTestResult;
  155268. }
  155269. }
  155270. declare module BABYLON {
  155271. /**
  155272. * Configuration options of the anchor system
  155273. */
  155274. export interface IWebXRAnchorSystemOptions {
  155275. /**
  155276. * a node that will be used to convert local to world coordinates
  155277. */
  155278. worldParentNode?: TransformNode;
  155279. /**
  155280. * If set to true a reference of the created anchors will be kept until the next session starts
  155281. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155282. */
  155283. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155284. }
  155285. /**
  155286. * A babylon container for an XR Anchor
  155287. */
  155288. export interface IWebXRAnchor {
  155289. /**
  155290. * A babylon-assigned ID for this anchor
  155291. */
  155292. id: number;
  155293. /**
  155294. * Transformation matrix to apply to an object attached to this anchor
  155295. */
  155296. transformationMatrix: Matrix;
  155297. /**
  155298. * The native anchor object
  155299. */
  155300. xrAnchor: XRAnchor;
  155301. /**
  155302. * if defined, this object will be constantly updated by the anchor's position and rotation
  155303. */
  155304. attachedNode?: TransformNode;
  155305. }
  155306. /**
  155307. * An implementation of the anchor system for WebXR.
  155308. * For further information see https://github.com/immersive-web/anchors/
  155309. */
  155310. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155311. private _options;
  155312. private _lastFrameDetected;
  155313. private _trackedAnchors;
  155314. private _referenceSpaceForFrameAnchors;
  155315. private _futureAnchors;
  155316. /**
  155317. * The module's name
  155318. */
  155319. static readonly Name: string;
  155320. /**
  155321. * The (Babylon) version of this module.
  155322. * This is an integer representing the implementation version.
  155323. * This number does not correspond to the WebXR specs version
  155324. */
  155325. static readonly Version: number;
  155326. /**
  155327. * Observers registered here will be executed when a new anchor was added to the session
  155328. */
  155329. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155330. /**
  155331. * Observers registered here will be executed when an anchor was removed from the session
  155332. */
  155333. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155334. /**
  155335. * Observers registered here will be executed when an existing anchor updates
  155336. * This can execute N times every frame
  155337. */
  155338. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155339. /**
  155340. * Set the reference space to use for anchor creation, when not using a hit test.
  155341. * Will default to the session's reference space if not defined
  155342. */
  155343. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155344. /**
  155345. * constructs a new anchor system
  155346. * @param _xrSessionManager an instance of WebXRSessionManager
  155347. * @param _options configuration object for this feature
  155348. */
  155349. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155350. private _tmpVector;
  155351. private _tmpQuaternion;
  155352. private _populateTmpTransformation;
  155353. /**
  155354. * Create a new anchor point using a hit test result at a specific point in the scene
  155355. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155356. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155357. *
  155358. * @param hitTestResult The hit test result to use for this anchor creation
  155359. * @param position an optional position offset for this anchor
  155360. * @param rotationQuaternion an optional rotation offset for this anchor
  155361. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155362. */
  155363. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155364. /**
  155365. * Add a new anchor at a specific position and rotation
  155366. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155367. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155368. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155369. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155370. *
  155371. * @param position the position in which to add an anchor
  155372. * @param rotationQuaternion an optional rotation for the anchor transformation
  155373. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155374. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155375. */
  155376. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155377. /**
  155378. * detach this feature.
  155379. * Will usually be called by the features manager
  155380. *
  155381. * @returns true if successful.
  155382. */
  155383. detach(): boolean;
  155384. /**
  155385. * Dispose this feature and all of the resources attached
  155386. */
  155387. dispose(): void;
  155388. protected _onXRFrame(frame: XRFrame): void;
  155389. /**
  155390. * avoiding using Array.find for global support.
  155391. * @param xrAnchor the plane to find in the array
  155392. */
  155393. private _findIndexInAnchorArray;
  155394. private _updateAnchorWithXRFrame;
  155395. private _createAnchorAtTransformation;
  155396. }
  155397. }
  155398. declare module BABYLON {
  155399. /**
  155400. * Options used in the plane detector module
  155401. */
  155402. export interface IWebXRPlaneDetectorOptions {
  155403. /**
  155404. * The node to use to transform the local results to world coordinates
  155405. */
  155406. worldParentNode?: TransformNode;
  155407. /**
  155408. * If set to true a reference of the created planes will be kept until the next session starts
  155409. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155410. */
  155411. doNotRemovePlanesOnSessionEnded?: boolean;
  155412. }
  155413. /**
  155414. * A babylon interface for a WebXR plane.
  155415. * A Plane is actually a polygon, built from N points in space
  155416. *
  155417. * Supported in chrome 79, not supported in canary 81 ATM
  155418. */
  155419. export interface IWebXRPlane {
  155420. /**
  155421. * a babylon-assigned ID for this polygon
  155422. */
  155423. id: number;
  155424. /**
  155425. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155426. */
  155427. polygonDefinition: Array<Vector3>;
  155428. /**
  155429. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155430. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155431. */
  155432. transformationMatrix: Matrix;
  155433. /**
  155434. * the native xr-plane object
  155435. */
  155436. xrPlane: XRPlane;
  155437. }
  155438. /**
  155439. * The plane detector is used to detect planes in the real world when in AR
  155440. * For more information see https://github.com/immersive-web/real-world-geometry/
  155441. */
  155442. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155443. private _options;
  155444. private _detectedPlanes;
  155445. private _enabled;
  155446. private _lastFrameDetected;
  155447. /**
  155448. * The module's name
  155449. */
  155450. static readonly Name: string;
  155451. /**
  155452. * The (Babylon) version of this module.
  155453. * This is an integer representing the implementation version.
  155454. * This number does not correspond to the WebXR specs version
  155455. */
  155456. static readonly Version: number;
  155457. /**
  155458. * Observers registered here will be executed when a new plane was added to the session
  155459. */
  155460. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155461. /**
  155462. * Observers registered here will be executed when a plane is no longer detected in the session
  155463. */
  155464. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155465. /**
  155466. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155467. * This can execute N times every frame
  155468. */
  155469. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155470. /**
  155471. * construct a new Plane Detector
  155472. * @param _xrSessionManager an instance of xr Session manager
  155473. * @param _options configuration to use when constructing this feature
  155474. */
  155475. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155476. /**
  155477. * detach this feature.
  155478. * Will usually be called by the features manager
  155479. *
  155480. * @returns true if successful.
  155481. */
  155482. detach(): boolean;
  155483. /**
  155484. * Dispose this feature and all of the resources attached
  155485. */
  155486. dispose(): void;
  155487. protected _onXRFrame(frame: XRFrame): void;
  155488. private _init;
  155489. private _updatePlaneWithXRPlane;
  155490. /**
  155491. * avoiding using Array.find for global support.
  155492. * @param xrPlane the plane to find in the array
  155493. */
  155494. private findIndexInPlaneArray;
  155495. }
  155496. }
  155497. declare module BABYLON {
  155498. /**
  155499. * Options interface for the background remover plugin
  155500. */
  155501. export interface IWebXRBackgroundRemoverOptions {
  155502. /**
  155503. * Further background meshes to disable when entering AR
  155504. */
  155505. backgroundMeshes?: AbstractMesh[];
  155506. /**
  155507. * flags to configure the removal of the environment helper.
  155508. * If not set, the entire background will be removed. If set, flags should be set as well.
  155509. */
  155510. environmentHelperRemovalFlags?: {
  155511. /**
  155512. * Should the skybox be removed (default false)
  155513. */
  155514. skyBox?: boolean;
  155515. /**
  155516. * Should the ground be removed (default false)
  155517. */
  155518. ground?: boolean;
  155519. };
  155520. /**
  155521. * don't disable the environment helper
  155522. */
  155523. ignoreEnvironmentHelper?: boolean;
  155524. }
  155525. /**
  155526. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155527. */
  155528. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155529. /**
  155530. * read-only options to be used in this module
  155531. */
  155532. readonly options: IWebXRBackgroundRemoverOptions;
  155533. /**
  155534. * The module's name
  155535. */
  155536. static readonly Name: string;
  155537. /**
  155538. * The (Babylon) version of this module.
  155539. * This is an integer representing the implementation version.
  155540. * This number does not correspond to the WebXR specs version
  155541. */
  155542. static readonly Version: number;
  155543. /**
  155544. * registered observers will be triggered when the background state changes
  155545. */
  155546. onBackgroundStateChangedObservable: Observable<boolean>;
  155547. /**
  155548. * constructs a new background remover module
  155549. * @param _xrSessionManager the session manager for this module
  155550. * @param options read-only options to be used in this module
  155551. */
  155552. constructor(_xrSessionManager: WebXRSessionManager,
  155553. /**
  155554. * read-only options to be used in this module
  155555. */
  155556. options?: IWebXRBackgroundRemoverOptions);
  155557. /**
  155558. * attach this feature
  155559. * Will usually be called by the features manager
  155560. *
  155561. * @returns true if successful.
  155562. */
  155563. attach(): boolean;
  155564. /**
  155565. * detach this feature.
  155566. * Will usually be called by the features manager
  155567. *
  155568. * @returns true if successful.
  155569. */
  155570. detach(): boolean;
  155571. /**
  155572. * Dispose this feature and all of the resources attached
  155573. */
  155574. dispose(): void;
  155575. protected _onXRFrame(_xrFrame: XRFrame): void;
  155576. private _setBackgroundState;
  155577. }
  155578. }
  155579. declare module BABYLON {
  155580. /**
  155581. * Options for the controller physics feature
  155582. */
  155583. export class IWebXRControllerPhysicsOptions {
  155584. /**
  155585. * Should the headset get its own impostor
  155586. */
  155587. enableHeadsetImpostor?: boolean;
  155588. /**
  155589. * Optional parameters for the headset impostor
  155590. */
  155591. headsetImpostorParams?: {
  155592. /**
  155593. * The type of impostor to create. Default is sphere
  155594. */
  155595. impostorType: number;
  155596. /**
  155597. * the size of the impostor. Defaults to 10cm
  155598. */
  155599. impostorSize?: number | {
  155600. width: number;
  155601. height: number;
  155602. depth: number;
  155603. };
  155604. /**
  155605. * Friction definitions
  155606. */
  155607. friction?: number;
  155608. /**
  155609. * Restitution
  155610. */
  155611. restitution?: number;
  155612. };
  155613. /**
  155614. * The physics properties of the future impostors
  155615. */
  155616. physicsProperties?: {
  155617. /**
  155618. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155619. * Note that this requires a physics engine that supports mesh impostors!
  155620. */
  155621. useControllerMesh?: boolean;
  155622. /**
  155623. * The type of impostor to create. Default is sphere
  155624. */
  155625. impostorType?: number;
  155626. /**
  155627. * the size of the impostor. Defaults to 10cm
  155628. */
  155629. impostorSize?: number | {
  155630. width: number;
  155631. height: number;
  155632. depth: number;
  155633. };
  155634. /**
  155635. * Friction definitions
  155636. */
  155637. friction?: number;
  155638. /**
  155639. * Restitution
  155640. */
  155641. restitution?: number;
  155642. };
  155643. /**
  155644. * the xr input to use with this pointer selection
  155645. */
  155646. xrInput: WebXRInput;
  155647. }
  155648. /**
  155649. * Add physics impostor to your webxr controllers,
  155650. * including naive calculation of their linear and angular velocity
  155651. */
  155652. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155653. private readonly _options;
  155654. private _attachController;
  155655. private _controllers;
  155656. private _debugMode;
  155657. private _delta;
  155658. private _headsetImpostor?;
  155659. private _headsetMesh?;
  155660. private _lastTimestamp;
  155661. private _tmpQuaternion;
  155662. private _tmpVector;
  155663. /**
  155664. * The module's name
  155665. */
  155666. static readonly Name: string;
  155667. /**
  155668. * The (Babylon) version of this module.
  155669. * This is an integer representing the implementation version.
  155670. * This number does not correspond to the webxr specs version
  155671. */
  155672. static readonly Version: number;
  155673. /**
  155674. * Construct a new Controller Physics Feature
  155675. * @param _xrSessionManager the corresponding xr session manager
  155676. * @param _options options to create this feature with
  155677. */
  155678. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155679. /**
  155680. * @hidden
  155681. * enable debugging - will show console outputs and the impostor mesh
  155682. */
  155683. _enablePhysicsDebug(): void;
  155684. /**
  155685. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155686. * @param xrController the controller to add
  155687. */
  155688. addController(xrController: WebXRInputSource): void;
  155689. /**
  155690. * attach this feature
  155691. * Will usually be called by the features manager
  155692. *
  155693. * @returns true if successful.
  155694. */
  155695. attach(): boolean;
  155696. /**
  155697. * detach this feature.
  155698. * Will usually be called by the features manager
  155699. *
  155700. * @returns true if successful.
  155701. */
  155702. detach(): boolean;
  155703. /**
  155704. * Get the headset impostor, if enabled
  155705. * @returns the impostor
  155706. */
  155707. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155708. /**
  155709. * Get the physics impostor of a specific controller.
  155710. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155711. * @param controller the controller or the controller id of which to get the impostor
  155712. * @returns the impostor or null
  155713. */
  155714. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155715. /**
  155716. * Update the physics properties provided in the constructor
  155717. * @param newProperties the new properties object
  155718. */
  155719. setPhysicsProperties(newProperties: {
  155720. impostorType?: number;
  155721. impostorSize?: number | {
  155722. width: number;
  155723. height: number;
  155724. depth: number;
  155725. };
  155726. friction?: number;
  155727. restitution?: number;
  155728. }): void;
  155729. protected _onXRFrame(_xrFrame: any): void;
  155730. private _detachController;
  155731. }
  155732. }
  155733. declare module BABYLON {
  155734. /**
  155735. * A babylon interface for a "WebXR" feature point.
  155736. * Represents the position and confidence value of a given feature point.
  155737. */
  155738. export interface IWebXRFeaturePoint {
  155739. /**
  155740. * Represents the position of the feature point in world space.
  155741. */
  155742. position: Vector3;
  155743. /**
  155744. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155745. */
  155746. confidenceValue: number;
  155747. }
  155748. /**
  155749. * The feature point system is used to detect feature points from real world geometry.
  155750. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155751. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155752. */
  155753. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155754. private _enabled;
  155755. private _featurePointCloud;
  155756. /**
  155757. * The module's name
  155758. */
  155759. static readonly Name: string;
  155760. /**
  155761. * The (Babylon) version of this module.
  155762. * This is an integer representing the implementation version.
  155763. * This number does not correspond to the WebXR specs version
  155764. */
  155765. static readonly Version: number;
  155766. /**
  155767. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155768. * Will notify the observers about which feature points have been added.
  155769. */
  155770. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155771. /**
  155772. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155773. * Will notify the observers about which feature points have been updated.
  155774. */
  155775. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155776. /**
  155777. * The current feature point cloud maintained across frames.
  155778. */
  155779. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155780. /**
  155781. * construct the feature point system
  155782. * @param _xrSessionManager an instance of xr Session manager
  155783. */
  155784. constructor(_xrSessionManager: WebXRSessionManager);
  155785. /**
  155786. * Detach this feature.
  155787. * Will usually be called by the features manager
  155788. *
  155789. * @returns true if successful.
  155790. */
  155791. detach(): boolean;
  155792. /**
  155793. * Dispose this feature and all of the resources attached
  155794. */
  155795. dispose(): void;
  155796. /**
  155797. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155798. */
  155799. protected _onXRFrame(frame: XRFrame): void;
  155800. /**
  155801. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155802. */
  155803. private _init;
  155804. }
  155805. }
  155806. declare module BABYLON {
  155807. /**
  155808. * Configuration interface for the hand tracking feature
  155809. */
  155810. export interface IWebXRHandTrackingOptions {
  155811. /**
  155812. * The xrInput that will be used as source for new hands
  155813. */
  155814. xrInput: WebXRInput;
  155815. /**
  155816. * Configuration object for the joint meshes
  155817. */
  155818. jointMeshes?: {
  155819. /**
  155820. * Should the meshes created be invisible (defaults to false)
  155821. */
  155822. invisible?: boolean;
  155823. /**
  155824. * A source mesh to be used to create instances. Defaults to a sphere.
  155825. * This mesh will be the source for all other (25) meshes.
  155826. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155827. */
  155828. sourceMesh?: Mesh;
  155829. /**
  155830. * Should the source mesh stay visible. Defaults to false
  155831. */
  155832. keepOriginalVisible?: boolean;
  155833. /**
  155834. * Scale factor for all instances (defaults to 2)
  155835. */
  155836. scaleFactor?: number;
  155837. /**
  155838. * Should each instance have its own physics impostor
  155839. */
  155840. enablePhysics?: boolean;
  155841. /**
  155842. * If enabled, override default physics properties
  155843. */
  155844. physicsProps?: {
  155845. friction?: number;
  155846. restitution?: number;
  155847. impostorType?: number;
  155848. };
  155849. /**
  155850. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155851. */
  155852. handMesh?: AbstractMesh;
  155853. };
  155854. }
  155855. /**
  155856. * Parts of the hands divided to writs and finger names
  155857. */
  155858. export const enum HandPart {
  155859. /**
  155860. * HandPart - Wrist
  155861. */
  155862. WRIST = "wrist",
  155863. /**
  155864. * HandPart - The THumb
  155865. */
  155866. THUMB = "thumb",
  155867. /**
  155868. * HandPart - Index finger
  155869. */
  155870. INDEX = "index",
  155871. /**
  155872. * HandPart - Middle finger
  155873. */
  155874. MIDDLE = "middle",
  155875. /**
  155876. * HandPart - Ring finger
  155877. */
  155878. RING = "ring",
  155879. /**
  155880. * HandPart - Little finger
  155881. */
  155882. LITTLE = "little"
  155883. }
  155884. /**
  155885. * Representing a single hand (with its corresponding native XRHand object)
  155886. */
  155887. export class WebXRHand implements IDisposable {
  155888. /** the controller to which the hand correlates */
  155889. readonly xrController: WebXRInputSource;
  155890. /** the meshes to be used to track the hand joints */
  155891. readonly trackedMeshes: AbstractMesh[];
  155892. /**
  155893. * Hand-parts definition (key is HandPart)
  155894. */
  155895. handPartsDefinition: {
  155896. [key: string]: number[];
  155897. };
  155898. /**
  155899. * Populate the HandPartsDefinition object.
  155900. * This is called as a side effect since certain browsers don't have XRHand defined.
  155901. */
  155902. private generateHandPartsDefinition;
  155903. /**
  155904. * Construct a new hand object
  155905. * @param xrController the controller to which the hand correlates
  155906. * @param trackedMeshes the meshes to be used to track the hand joints
  155907. */
  155908. constructor(
  155909. /** the controller to which the hand correlates */
  155910. xrController: WebXRInputSource,
  155911. /** the meshes to be used to track the hand joints */
  155912. trackedMeshes: AbstractMesh[]);
  155913. /**
  155914. * Update this hand from the latest xr frame
  155915. * @param xrFrame xrFrame to update from
  155916. * @param referenceSpace The current viewer reference space
  155917. * @param scaleFactor optional scale factor for the meshes
  155918. */
  155919. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155920. /**
  155921. * Get meshes of part of the hand
  155922. * @param part the part of hand to get
  155923. * @returns An array of meshes that correlate to the hand part requested
  155924. */
  155925. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155926. /**
  155927. * Dispose this Hand object
  155928. */
  155929. dispose(): void;
  155930. }
  155931. /**
  155932. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155933. */
  155934. export class WebXRHandTracking extends WebXRAbstractFeature {
  155935. /**
  155936. * options to use when constructing this feature
  155937. */
  155938. readonly options: IWebXRHandTrackingOptions;
  155939. private static _idCounter;
  155940. /**
  155941. * The module's name
  155942. */
  155943. static readonly Name: string;
  155944. /**
  155945. * The (Babylon) version of this module.
  155946. * This is an integer representing the implementation version.
  155947. * This number does not correspond to the WebXR specs version
  155948. */
  155949. static readonly Version: number;
  155950. /**
  155951. * This observable will notify registered observers when a new hand object was added and initialized
  155952. */
  155953. onHandAddedObservable: Observable<WebXRHand>;
  155954. /**
  155955. * This observable will notify its observers right before the hand object is disposed
  155956. */
  155957. onHandRemovedObservable: Observable<WebXRHand>;
  155958. private _hands;
  155959. /**
  155960. * Creates a new instance of the hit test feature
  155961. * @param _xrSessionManager an instance of WebXRSessionManager
  155962. * @param options options to use when constructing this feature
  155963. */
  155964. constructor(_xrSessionManager: WebXRSessionManager,
  155965. /**
  155966. * options to use when constructing this feature
  155967. */
  155968. options: IWebXRHandTrackingOptions);
  155969. /**
  155970. * Check if the needed objects are defined.
  155971. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155972. */
  155973. isCompatible(): boolean;
  155974. /**
  155975. * attach this feature
  155976. * Will usually be called by the features manager
  155977. *
  155978. * @returns true if successful.
  155979. */
  155980. attach(): boolean;
  155981. /**
  155982. * detach this feature.
  155983. * Will usually be called by the features manager
  155984. *
  155985. * @returns true if successful.
  155986. */
  155987. detach(): boolean;
  155988. /**
  155989. * Dispose this feature and all of the resources attached
  155990. */
  155991. dispose(): void;
  155992. /**
  155993. * Get the hand object according to the controller id
  155994. * @param controllerId the controller id to which we want to get the hand
  155995. * @returns null if not found or the WebXRHand object if found
  155996. */
  155997. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155998. /**
  155999. * Get a hand object according to the requested handedness
  156000. * @param handedness the handedness to request
  156001. * @returns null if not found or the WebXRHand object if found
  156002. */
  156003. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156004. protected _onXRFrame(_xrFrame: XRFrame): void;
  156005. private _attachHand;
  156006. private _detachHand;
  156007. }
  156008. }
  156009. declare module BABYLON {
  156010. /**
  156011. * The motion controller class for all microsoft mixed reality controllers
  156012. */
  156013. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156014. protected readonly _mapping: {
  156015. defaultButton: {
  156016. valueNodeName: string;
  156017. unpressedNodeName: string;
  156018. pressedNodeName: string;
  156019. };
  156020. defaultAxis: {
  156021. valueNodeName: string;
  156022. minNodeName: string;
  156023. maxNodeName: string;
  156024. };
  156025. buttons: {
  156026. "xr-standard-trigger": {
  156027. rootNodeName: string;
  156028. componentProperty: string;
  156029. states: string[];
  156030. };
  156031. "xr-standard-squeeze": {
  156032. rootNodeName: string;
  156033. componentProperty: string;
  156034. states: string[];
  156035. };
  156036. "xr-standard-touchpad": {
  156037. rootNodeName: string;
  156038. labelAnchorNodeName: string;
  156039. touchPointNodeName: string;
  156040. };
  156041. "xr-standard-thumbstick": {
  156042. rootNodeName: string;
  156043. componentProperty: string;
  156044. states: string[];
  156045. };
  156046. };
  156047. axes: {
  156048. "xr-standard-touchpad": {
  156049. "x-axis": {
  156050. rootNodeName: string;
  156051. };
  156052. "y-axis": {
  156053. rootNodeName: string;
  156054. };
  156055. };
  156056. "xr-standard-thumbstick": {
  156057. "x-axis": {
  156058. rootNodeName: string;
  156059. };
  156060. "y-axis": {
  156061. rootNodeName: string;
  156062. };
  156063. };
  156064. };
  156065. };
  156066. /**
  156067. * The base url used to load the left and right controller models
  156068. */
  156069. static MODEL_BASE_URL: string;
  156070. /**
  156071. * The name of the left controller model file
  156072. */
  156073. static MODEL_LEFT_FILENAME: string;
  156074. /**
  156075. * The name of the right controller model file
  156076. */
  156077. static MODEL_RIGHT_FILENAME: string;
  156078. profileId: string;
  156079. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156080. protected _getFilenameAndPath(): {
  156081. filename: string;
  156082. path: string;
  156083. };
  156084. protected _getModelLoadingConstraints(): boolean;
  156085. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156086. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156087. protected _updateModel(): void;
  156088. }
  156089. }
  156090. declare module BABYLON {
  156091. /**
  156092. * The motion controller class for oculus touch (quest, rift).
  156093. * This class supports legacy mapping as well the standard xr mapping
  156094. */
  156095. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156096. private _forceLegacyControllers;
  156097. private _modelRootNode;
  156098. /**
  156099. * The base url used to load the left and right controller models
  156100. */
  156101. static MODEL_BASE_URL: string;
  156102. /**
  156103. * The name of the left controller model file
  156104. */
  156105. static MODEL_LEFT_FILENAME: string;
  156106. /**
  156107. * The name of the right controller model file
  156108. */
  156109. static MODEL_RIGHT_FILENAME: string;
  156110. /**
  156111. * Base Url for the Quest controller model.
  156112. */
  156113. static QUEST_MODEL_BASE_URL: string;
  156114. profileId: string;
  156115. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156116. protected _getFilenameAndPath(): {
  156117. filename: string;
  156118. path: string;
  156119. };
  156120. protected _getModelLoadingConstraints(): boolean;
  156121. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156122. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156123. protected _updateModel(): void;
  156124. /**
  156125. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156126. * between the touch and touch 2.
  156127. */
  156128. private _isQuest;
  156129. }
  156130. }
  156131. declare module BABYLON {
  156132. /**
  156133. * The motion controller class for the standard HTC-Vive controllers
  156134. */
  156135. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156136. private _modelRootNode;
  156137. /**
  156138. * The base url used to load the left and right controller models
  156139. */
  156140. static MODEL_BASE_URL: string;
  156141. /**
  156142. * File name for the controller model.
  156143. */
  156144. static MODEL_FILENAME: string;
  156145. profileId: string;
  156146. /**
  156147. * Create a new Vive motion controller object
  156148. * @param scene the scene to use to create this controller
  156149. * @param gamepadObject the corresponding gamepad object
  156150. * @param handedness the handedness of the controller
  156151. */
  156152. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156153. protected _getFilenameAndPath(): {
  156154. filename: string;
  156155. path: string;
  156156. };
  156157. protected _getModelLoadingConstraints(): boolean;
  156158. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156159. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156160. protected _updateModel(): void;
  156161. }
  156162. }
  156163. declare module BABYLON {
  156164. /**
  156165. * A cursor which tracks a point on a path
  156166. */
  156167. export class PathCursor {
  156168. private path;
  156169. /**
  156170. * Stores path cursor callbacks for when an onchange event is triggered
  156171. */
  156172. private _onchange;
  156173. /**
  156174. * The value of the path cursor
  156175. */
  156176. value: number;
  156177. /**
  156178. * The animation array of the path cursor
  156179. */
  156180. animations: Animation[];
  156181. /**
  156182. * Initializes the path cursor
  156183. * @param path The path to track
  156184. */
  156185. constructor(path: Path2);
  156186. /**
  156187. * Gets the cursor point on the path
  156188. * @returns A point on the path cursor at the cursor location
  156189. */
  156190. getPoint(): Vector3;
  156191. /**
  156192. * Moves the cursor ahead by the step amount
  156193. * @param step The amount to move the cursor forward
  156194. * @returns This path cursor
  156195. */
  156196. moveAhead(step?: number): PathCursor;
  156197. /**
  156198. * Moves the cursor behind by the step amount
  156199. * @param step The amount to move the cursor back
  156200. * @returns This path cursor
  156201. */
  156202. moveBack(step?: number): PathCursor;
  156203. /**
  156204. * Moves the cursor by the step amount
  156205. * If the step amount is greater than one, an exception is thrown
  156206. * @param step The amount to move the cursor
  156207. * @returns This path cursor
  156208. */
  156209. move(step: number): PathCursor;
  156210. /**
  156211. * Ensures that the value is limited between zero and one
  156212. * @returns This path cursor
  156213. */
  156214. private ensureLimits;
  156215. /**
  156216. * Runs onchange callbacks on change (used by the animation engine)
  156217. * @returns This path cursor
  156218. */
  156219. private raiseOnChange;
  156220. /**
  156221. * Executes a function on change
  156222. * @param f A path cursor onchange callback
  156223. * @returns This path cursor
  156224. */
  156225. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156226. }
  156227. }
  156228. declare module BABYLON {
  156229. /** @hidden */
  156230. export var blurPixelShader: {
  156231. name: string;
  156232. shader: string;
  156233. };
  156234. }
  156235. declare module BABYLON {
  156236. /** @hidden */
  156237. export var pointCloudVertexDeclaration: {
  156238. name: string;
  156239. shader: string;
  156240. };
  156241. }
  156242. // Mixins
  156243. interface Window {
  156244. mozIndexedDB: IDBFactory;
  156245. webkitIndexedDB: IDBFactory;
  156246. msIndexedDB: IDBFactory;
  156247. webkitURL: typeof URL;
  156248. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156249. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156250. WebGLRenderingContext: WebGLRenderingContext;
  156251. MSGesture: MSGesture;
  156252. CANNON: any;
  156253. AudioContext: AudioContext;
  156254. webkitAudioContext: AudioContext;
  156255. PointerEvent: any;
  156256. Math: Math;
  156257. Uint8Array: Uint8ArrayConstructor;
  156258. Float32Array: Float32ArrayConstructor;
  156259. mozURL: typeof URL;
  156260. msURL: typeof URL;
  156261. VRFrameData: any; // WebVR, from specs 1.1
  156262. DracoDecoderModule: any;
  156263. setImmediate(handler: (...args: any[]) => void): number;
  156264. }
  156265. interface HTMLCanvasElement {
  156266. requestPointerLock(): void;
  156267. msRequestPointerLock?(): void;
  156268. mozRequestPointerLock?(): void;
  156269. webkitRequestPointerLock?(): void;
  156270. /** Track wether a record is in progress */
  156271. isRecording: boolean;
  156272. /** Capture Stream method defined by some browsers */
  156273. captureStream(fps?: number): MediaStream;
  156274. }
  156275. interface CanvasRenderingContext2D {
  156276. msImageSmoothingEnabled: boolean;
  156277. }
  156278. interface MouseEvent {
  156279. mozMovementX: number;
  156280. mozMovementY: number;
  156281. webkitMovementX: number;
  156282. webkitMovementY: number;
  156283. msMovementX: number;
  156284. msMovementY: number;
  156285. }
  156286. interface Navigator {
  156287. mozGetVRDevices: (any: any) => any;
  156288. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156289. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156290. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156291. webkitGetGamepads(): Gamepad[];
  156292. msGetGamepads(): Gamepad[];
  156293. webkitGamepads(): Gamepad[];
  156294. }
  156295. interface HTMLVideoElement {
  156296. mozSrcObject: any;
  156297. }
  156298. interface Math {
  156299. fround(x: number): number;
  156300. imul(a: number, b: number): number;
  156301. }
  156302. interface WebGLRenderingContext {
  156303. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156304. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156305. vertexAttribDivisor(index: number, divisor: number): void;
  156306. createVertexArray(): any;
  156307. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156308. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156309. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156310. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156311. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156312. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156313. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156314. // Queries
  156315. createQuery(): WebGLQuery;
  156316. deleteQuery(query: WebGLQuery): void;
  156317. beginQuery(target: number, query: WebGLQuery): void;
  156318. endQuery(target: number): void;
  156319. getQueryParameter(query: WebGLQuery, pname: number): any;
  156320. getQuery(target: number, pname: number): any;
  156321. MAX_SAMPLES: number;
  156322. RGBA8: number;
  156323. READ_FRAMEBUFFER: number;
  156324. DRAW_FRAMEBUFFER: number;
  156325. UNIFORM_BUFFER: number;
  156326. HALF_FLOAT_OES: number;
  156327. RGBA16F: number;
  156328. RGBA32F: number;
  156329. R32F: number;
  156330. RG32F: number;
  156331. RGB32F: number;
  156332. R16F: number;
  156333. RG16F: number;
  156334. RGB16F: number;
  156335. RED: number;
  156336. RG: number;
  156337. R8: number;
  156338. RG8: number;
  156339. UNSIGNED_INT_24_8: number;
  156340. DEPTH24_STENCIL8: number;
  156341. MIN: number;
  156342. MAX: number;
  156343. /* Multiple Render Targets */
  156344. drawBuffers(buffers: number[]): void;
  156345. readBuffer(src: number): void;
  156346. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156347. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156348. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156349. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156350. // Occlusion Query
  156351. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156352. ANY_SAMPLES_PASSED: number;
  156353. QUERY_RESULT_AVAILABLE: number;
  156354. QUERY_RESULT: number;
  156355. }
  156356. interface WebGLProgram {
  156357. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156358. }
  156359. interface EXT_disjoint_timer_query {
  156360. QUERY_COUNTER_BITS_EXT: number;
  156361. TIME_ELAPSED_EXT: number;
  156362. TIMESTAMP_EXT: number;
  156363. GPU_DISJOINT_EXT: number;
  156364. QUERY_RESULT_EXT: number;
  156365. QUERY_RESULT_AVAILABLE_EXT: number;
  156366. queryCounterEXT(query: WebGLQuery, target: number): void;
  156367. createQueryEXT(): WebGLQuery;
  156368. beginQueryEXT(target: number, query: WebGLQuery): void;
  156369. endQueryEXT(target: number): void;
  156370. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156371. deleteQueryEXT(query: WebGLQuery): void;
  156372. }
  156373. interface WebGLUniformLocation {
  156374. _currentState: any;
  156375. }
  156376. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156377. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156378. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156379. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156380. interface WebGLRenderingContext {
  156381. readonly RASTERIZER_DISCARD: number;
  156382. readonly DEPTH_COMPONENT24: number;
  156383. readonly TEXTURE_3D: number;
  156384. readonly TEXTURE_2D_ARRAY: number;
  156385. readonly TEXTURE_COMPARE_FUNC: number;
  156386. readonly TEXTURE_COMPARE_MODE: number;
  156387. readonly COMPARE_REF_TO_TEXTURE: number;
  156388. readonly TEXTURE_WRAP_R: number;
  156389. readonly HALF_FLOAT: number;
  156390. readonly RGB8: number;
  156391. readonly RED_INTEGER: number;
  156392. readonly RG_INTEGER: number;
  156393. readonly RGB_INTEGER: number;
  156394. readonly RGBA_INTEGER: number;
  156395. readonly R8_SNORM: number;
  156396. readonly RG8_SNORM: number;
  156397. readonly RGB8_SNORM: number;
  156398. readonly RGBA8_SNORM: number;
  156399. readonly R8I: number;
  156400. readonly RG8I: number;
  156401. readonly RGB8I: number;
  156402. readonly RGBA8I: number;
  156403. readonly R8UI: number;
  156404. readonly RG8UI: number;
  156405. readonly RGB8UI: number;
  156406. readonly RGBA8UI: number;
  156407. readonly R16I: number;
  156408. readonly RG16I: number;
  156409. readonly RGB16I: number;
  156410. readonly RGBA16I: number;
  156411. readonly R16UI: number;
  156412. readonly RG16UI: number;
  156413. readonly RGB16UI: number;
  156414. readonly RGBA16UI: number;
  156415. readonly R32I: number;
  156416. readonly RG32I: number;
  156417. readonly RGB32I: number;
  156418. readonly RGBA32I: number;
  156419. readonly R32UI: number;
  156420. readonly RG32UI: number;
  156421. readonly RGB32UI: number;
  156422. readonly RGBA32UI: number;
  156423. readonly RGB10_A2UI: number;
  156424. readonly R11F_G11F_B10F: number;
  156425. readonly RGB9_E5: number;
  156426. readonly RGB10_A2: number;
  156427. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156428. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156429. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156430. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156431. readonly DEPTH_COMPONENT32F: number;
  156432. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156433. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156434. 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;
  156435. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156436. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156437. readonly TRANSFORM_FEEDBACK: number;
  156438. readonly INTERLEAVED_ATTRIBS: number;
  156439. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156440. createTransformFeedback(): WebGLTransformFeedback;
  156441. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156442. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156443. beginTransformFeedback(primitiveMode: number): void;
  156444. endTransformFeedback(): void;
  156445. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156446. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156447. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156448. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156449. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156450. }
  156451. interface ImageBitmap {
  156452. readonly width: number;
  156453. readonly height: number;
  156454. close(): void;
  156455. }
  156456. interface WebGLQuery extends WebGLObject {
  156457. }
  156458. declare var WebGLQuery: {
  156459. prototype: WebGLQuery;
  156460. new(): WebGLQuery;
  156461. };
  156462. interface WebGLSampler extends WebGLObject {
  156463. }
  156464. declare var WebGLSampler: {
  156465. prototype: WebGLSampler;
  156466. new(): WebGLSampler;
  156467. };
  156468. interface WebGLSync extends WebGLObject {
  156469. }
  156470. declare var WebGLSync: {
  156471. prototype: WebGLSync;
  156472. new(): WebGLSync;
  156473. };
  156474. interface WebGLTransformFeedback extends WebGLObject {
  156475. }
  156476. declare var WebGLTransformFeedback: {
  156477. prototype: WebGLTransformFeedback;
  156478. new(): WebGLTransformFeedback;
  156479. };
  156480. interface WebGLVertexArrayObject extends WebGLObject {
  156481. }
  156482. declare var WebGLVertexArrayObject: {
  156483. prototype: WebGLVertexArrayObject;
  156484. new(): WebGLVertexArrayObject;
  156485. };
  156486. // Type definitions for WebVR API
  156487. // Project: https://w3c.github.io/webvr/
  156488. // Definitions by: six a <https://github.com/lostfictions>
  156489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156490. interface VRDisplay extends EventTarget {
  156491. /**
  156492. * Dictionary of capabilities describing the VRDisplay.
  156493. */
  156494. readonly capabilities: VRDisplayCapabilities;
  156495. /**
  156496. * z-depth defining the far plane of the eye view frustum
  156497. * enables mapping of values in the render target depth
  156498. * attachment to scene coordinates. Initially set to 10000.0.
  156499. */
  156500. depthFar: number;
  156501. /**
  156502. * z-depth defining the near plane of the eye view frustum
  156503. * enables mapping of values in the render target depth
  156504. * attachment to scene coordinates. Initially set to 0.01.
  156505. */
  156506. depthNear: number;
  156507. /**
  156508. * An identifier for this distinct VRDisplay. Used as an
  156509. * association point in the Gamepad API.
  156510. */
  156511. readonly displayId: number;
  156512. /**
  156513. * A display name, a user-readable name identifying it.
  156514. */
  156515. readonly displayName: string;
  156516. readonly isConnected: boolean;
  156517. readonly isPresenting: boolean;
  156518. /**
  156519. * If this VRDisplay supports room-scale experiences, the optional
  156520. * stage attribute contains details on the room-scale parameters.
  156521. */
  156522. readonly stageParameters: VRStageParameters | null;
  156523. /**
  156524. * Passing the value returned by `requestAnimationFrame` to
  156525. * `cancelAnimationFrame` will unregister the callback.
  156526. * @param handle Define the hanle of the request to cancel
  156527. */
  156528. cancelAnimationFrame(handle: number): void;
  156529. /**
  156530. * Stops presenting to the VRDisplay.
  156531. * @returns a promise to know when it stopped
  156532. */
  156533. exitPresent(): Promise<void>;
  156534. /**
  156535. * Return the current VREyeParameters for the given eye.
  156536. * @param whichEye Define the eye we want the parameter for
  156537. * @returns the eye parameters
  156538. */
  156539. getEyeParameters(whichEye: string): VREyeParameters;
  156540. /**
  156541. * Populates the passed VRFrameData with the information required to render
  156542. * the current frame.
  156543. * @param frameData Define the data structure to populate
  156544. * @returns true if ok otherwise false
  156545. */
  156546. getFrameData(frameData: VRFrameData): boolean;
  156547. /**
  156548. * Get the layers currently being presented.
  156549. * @returns the list of VR layers
  156550. */
  156551. getLayers(): VRLayer[];
  156552. /**
  156553. * Return a VRPose containing the future predicted pose of the VRDisplay
  156554. * when the current frame will be presented. The value returned will not
  156555. * change until JavaScript has returned control to the browser.
  156556. *
  156557. * The VRPose will contain the position, orientation, velocity,
  156558. * and acceleration of each of these properties.
  156559. * @returns the pose object
  156560. */
  156561. getPose(): VRPose;
  156562. /**
  156563. * Return the current instantaneous pose of the VRDisplay, with no
  156564. * prediction applied.
  156565. * @returns the current instantaneous pose
  156566. */
  156567. getImmediatePose(): VRPose;
  156568. /**
  156569. * The callback passed to `requestAnimationFrame` will be called
  156570. * any time a new frame should be rendered. When the VRDisplay is
  156571. * presenting the callback will be called at the native refresh
  156572. * rate of the HMD. When not presenting this function acts
  156573. * identically to how window.requestAnimationFrame acts. Content should
  156574. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156575. * asynchronously from other displays and at differing refresh rates.
  156576. * @param callback Define the eaction to run next frame
  156577. * @returns the request handle it
  156578. */
  156579. requestAnimationFrame(callback: FrameRequestCallback): number;
  156580. /**
  156581. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156582. * Repeat calls while already presenting will update the VRLayers being displayed.
  156583. * @param layers Define the list of layer to present
  156584. * @returns a promise to know when the request has been fulfilled
  156585. */
  156586. requestPresent(layers: VRLayer[]): Promise<void>;
  156587. /**
  156588. * Reset the pose for this display, treating its current position and
  156589. * orientation as the "origin/zero" values. VRPose.position,
  156590. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156591. * updated when calling resetPose(). This should be called in only
  156592. * sitting-space experiences.
  156593. */
  156594. resetPose(): void;
  156595. /**
  156596. * The VRLayer provided to the VRDisplay will be captured and presented
  156597. * in the HMD. Calling this function has the same effect on the source
  156598. * canvas as any other operation that uses its source image, and canvases
  156599. * created without preserveDrawingBuffer set to true will be cleared.
  156600. * @param pose Define the pose to submit
  156601. */
  156602. submitFrame(pose?: VRPose): void;
  156603. }
  156604. declare var VRDisplay: {
  156605. prototype: VRDisplay;
  156606. new(): VRDisplay;
  156607. };
  156608. interface VRLayer {
  156609. leftBounds?: number[] | Float32Array | null;
  156610. rightBounds?: number[] | Float32Array | null;
  156611. source?: HTMLCanvasElement | null;
  156612. }
  156613. interface VRDisplayCapabilities {
  156614. readonly canPresent: boolean;
  156615. readonly hasExternalDisplay: boolean;
  156616. readonly hasOrientation: boolean;
  156617. readonly hasPosition: boolean;
  156618. readonly maxLayers: number;
  156619. }
  156620. interface VREyeParameters {
  156621. /** @deprecated */
  156622. readonly fieldOfView: VRFieldOfView;
  156623. readonly offset: Float32Array;
  156624. readonly renderHeight: number;
  156625. readonly renderWidth: number;
  156626. }
  156627. interface VRFieldOfView {
  156628. readonly downDegrees: number;
  156629. readonly leftDegrees: number;
  156630. readonly rightDegrees: number;
  156631. readonly upDegrees: number;
  156632. }
  156633. interface VRFrameData {
  156634. readonly leftProjectionMatrix: Float32Array;
  156635. readonly leftViewMatrix: Float32Array;
  156636. readonly pose: VRPose;
  156637. readonly rightProjectionMatrix: Float32Array;
  156638. readonly rightViewMatrix: Float32Array;
  156639. readonly timestamp: number;
  156640. }
  156641. interface VRPose {
  156642. readonly angularAcceleration: Float32Array | null;
  156643. readonly angularVelocity: Float32Array | null;
  156644. readonly linearAcceleration: Float32Array | null;
  156645. readonly linearVelocity: Float32Array | null;
  156646. readonly orientation: Float32Array | null;
  156647. readonly position: Float32Array | null;
  156648. readonly timestamp: number;
  156649. }
  156650. interface VRStageParameters {
  156651. sittingToStandingTransform?: Float32Array;
  156652. sizeX?: number;
  156653. sizeY?: number;
  156654. }
  156655. interface Navigator {
  156656. getVRDisplays(): Promise<VRDisplay[]>;
  156657. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156658. }
  156659. interface Window {
  156660. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156661. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156662. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156663. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156664. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156665. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156666. }
  156667. interface Gamepad {
  156668. readonly displayId: number;
  156669. }
  156670. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156671. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156672. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156673. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156674. type XRHandedness = "none" | "left" | "right";
  156675. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156676. type XREye = "none" | "left" | "right";
  156677. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156678. interface XRSpace extends EventTarget {}
  156679. interface XRRenderState {
  156680. depthNear?: number;
  156681. depthFar?: number;
  156682. inlineVerticalFieldOfView?: number;
  156683. baseLayer?: XRWebGLLayer;
  156684. }
  156685. interface XRInputSource {
  156686. handedness: XRHandedness;
  156687. targetRayMode: XRTargetRayMode;
  156688. targetRaySpace: XRSpace;
  156689. gripSpace: XRSpace | undefined;
  156690. gamepad: Gamepad | undefined;
  156691. profiles: Array<string>;
  156692. hand: XRHand | undefined;
  156693. }
  156694. interface XRSessionInit {
  156695. optionalFeatures?: string[];
  156696. requiredFeatures?: string[];
  156697. }
  156698. interface XRSession {
  156699. addEventListener: Function;
  156700. removeEventListener: Function;
  156701. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156702. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156703. requestAnimationFrame: Function;
  156704. end(): Promise<void>;
  156705. renderState: XRRenderState;
  156706. inputSources: Array<XRInputSource>;
  156707. // hit test
  156708. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156709. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156710. // legacy AR hit test
  156711. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156712. // legacy plane detection
  156713. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156714. }
  156715. interface XRReferenceSpace extends XRSpace {
  156716. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156717. onreset: any;
  156718. }
  156719. type XRPlaneSet = Set<XRPlane>;
  156720. type XRAnchorSet = Set<XRAnchor>;
  156721. interface XRFrame {
  156722. session: XRSession;
  156723. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156724. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156725. // AR
  156726. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156727. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156728. // Anchors
  156729. trackedAnchors?: XRAnchorSet;
  156730. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156731. // Planes
  156732. worldInformation: {
  156733. detectedPlanes?: XRPlaneSet;
  156734. };
  156735. // Hand tracking
  156736. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156737. }
  156738. interface XRViewerPose extends XRPose {
  156739. views: Array<XRView>;
  156740. }
  156741. interface XRPose {
  156742. transform: XRRigidTransform;
  156743. emulatedPosition: boolean;
  156744. }
  156745. interface XRWebGLLayerOptions {
  156746. antialias?: boolean;
  156747. depth?: boolean;
  156748. stencil?: boolean;
  156749. alpha?: boolean;
  156750. multiview?: boolean;
  156751. framebufferScaleFactor?: number;
  156752. }
  156753. declare var XRWebGLLayer: {
  156754. prototype: XRWebGLLayer;
  156755. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156756. };
  156757. interface XRWebGLLayer {
  156758. framebuffer: WebGLFramebuffer;
  156759. framebufferWidth: number;
  156760. framebufferHeight: number;
  156761. getViewport: Function;
  156762. }
  156763. declare class XRRigidTransform {
  156764. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156765. position: DOMPointReadOnly;
  156766. orientation: DOMPointReadOnly;
  156767. matrix: Float32Array;
  156768. inverse: XRRigidTransform;
  156769. }
  156770. interface XRView {
  156771. eye: XREye;
  156772. projectionMatrix: Float32Array;
  156773. transform: XRRigidTransform;
  156774. }
  156775. interface XRInputSourceChangeEvent {
  156776. session: XRSession;
  156777. removed: Array<XRInputSource>;
  156778. added: Array<XRInputSource>;
  156779. }
  156780. interface XRInputSourceEvent extends Event {
  156781. readonly frame: XRFrame;
  156782. readonly inputSource: XRInputSource;
  156783. }
  156784. // Experimental(er) features
  156785. declare class XRRay {
  156786. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156787. origin: DOMPointReadOnly;
  156788. direction: DOMPointReadOnly;
  156789. matrix: Float32Array;
  156790. }
  156791. declare enum XRHitTestTrackableType {
  156792. "point",
  156793. "plane",
  156794. "mesh",
  156795. }
  156796. interface XRHitResult {
  156797. hitMatrix: Float32Array;
  156798. }
  156799. interface XRTransientInputHitTestResult {
  156800. readonly inputSource: XRInputSource;
  156801. readonly results: Array<XRHitTestResult>;
  156802. }
  156803. interface XRHitTestResult {
  156804. getPose(baseSpace: XRSpace): XRPose | undefined;
  156805. // When anchor system is enabled
  156806. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156807. }
  156808. interface XRHitTestSource {
  156809. cancel(): void;
  156810. }
  156811. interface XRTransientInputHitTestSource {
  156812. cancel(): void;
  156813. }
  156814. interface XRHitTestOptionsInit {
  156815. space: XRSpace;
  156816. entityTypes?: Array<XRHitTestTrackableType>;
  156817. offsetRay?: XRRay;
  156818. }
  156819. interface XRTransientInputHitTestOptionsInit {
  156820. profile: string;
  156821. entityTypes?: Array<XRHitTestTrackableType>;
  156822. offsetRay?: XRRay;
  156823. }
  156824. interface XRAnchor {
  156825. anchorSpace: XRSpace;
  156826. delete(): void;
  156827. }
  156828. interface XRPlane {
  156829. orientation: "Horizontal" | "Vertical";
  156830. planeSpace: XRSpace;
  156831. polygon: Array<DOMPointReadOnly>;
  156832. lastChangedTime: number;
  156833. }
  156834. interface XRJointSpace extends XRSpace {}
  156835. interface XRJointPose extends XRPose {
  156836. radius: number | undefined;
  156837. }
  156838. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156839. readonly length: number;
  156840. [index: number]: XRJointSpace;
  156841. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156842. readonly WRIST: number;
  156843. readonly THUMB_METACARPAL: number;
  156844. readonly THUMB_PHALANX_PROXIMAL: number;
  156845. readonly THUMB_PHALANX_DISTAL: number;
  156846. readonly THUMB_PHALANX_TIP: number;
  156847. readonly INDEX_METACARPAL: number;
  156848. readonly INDEX_PHALANX_PROXIMAL: number;
  156849. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156850. readonly INDEX_PHALANX_DISTAL: number;
  156851. readonly INDEX_PHALANX_TIP: number;
  156852. readonly MIDDLE_METACARPAL: number;
  156853. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156854. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156855. readonly MIDDLE_PHALANX_DISTAL: number;
  156856. readonly MIDDLE_PHALANX_TIP: number;
  156857. readonly RING_METACARPAL: number;
  156858. readonly RING_PHALANX_PROXIMAL: number;
  156859. readonly RING_PHALANX_INTERMEDIATE: number;
  156860. readonly RING_PHALANX_DISTAL: number;
  156861. readonly RING_PHALANX_TIP: number;
  156862. readonly LITTLE_METACARPAL: number;
  156863. readonly LITTLE_PHALANX_PROXIMAL: number;
  156864. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156865. readonly LITTLE_PHALANX_DISTAL: number;
  156866. readonly LITTLE_PHALANX_TIP: number;
  156867. }
  156868. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156869. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156870. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156871. interface XRSession {
  156872. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156873. }
  156874. interface XRFrame {
  156875. featurePointCloud? : Array<number>;
  156876. }